From d134b4f70b0802b9e4566a4d78ae13831ab09e04 Mon Sep 17 00:00:00 2001 From: Jack Conradson Date: Thu, 1 Oct 2020 08:35:21 -0700 Subject: [PATCH] Make location final in IRNode (#63078) This change makes Location a final member of IRNode as opposed to possibly changing it. This ensures that all ir nodes have a Location for error information upon creation that cannot be updated so each node can be tracked as where it came from originally. --- .../painless/ir/ArgumentsNode.java | 6 + .../painless/ir/BinaryImplNode.java | 5 + .../painless/ir/BinaryMathNode.java | 11 +- .../elasticsearch/painless/ir/BinaryNode.java | 8 +- .../elasticsearch/painless/ir/BlockNode.java | 5 + .../painless/ir/BooleanNode.java | 7 +- .../elasticsearch/painless/ir/BreakNode.java | 5 + .../elasticsearch/painless/ir/CastNode.java | 7 +- .../elasticsearch/painless/ir/CatchNode.java | 7 +- .../elasticsearch/painless/ir/ClassNode.java | 7 +- .../painless/ir/ComparisonNode.java | 7 +- .../painless/ir/ConditionNode.java | 6 + .../painless/ir/ConditionalNode.java | 7 +- .../painless/ir/ConstantNode.java | 5 + .../painless/ir/ContinueNode.java | 5 + .../painless/ir/DeclarationBlockNode.java | 5 + .../painless/ir/DeclarationNode.java | 7 +- .../ir/DefInterfaceReferenceNode.java | 7 +- .../painless/ir/DoWhileLoopNode.java | 9 +- .../elasticsearch/painless/ir/DupNode.java | 5 + .../elasticsearch/painless/ir/ElvisNode.java | 7 +- .../painless/ir/ExpressionNode.java | 5 + .../elasticsearch/painless/ir/FieldNode.java | 5 + .../painless/ir/FlipArrayIndexNode.java | 5 + .../painless/ir/FlipCollectionIndexNode.java | 5 + .../painless/ir/FlipDefIndexNode.java | 5 + .../painless/ir/ForEachLoopNode.java | 5 + .../painless/ir/ForEachSubArrayNode.java | 9 +- .../painless/ir/ForEachSubIterableNode.java | 9 +- .../painless/ir/ForLoopNode.java | 9 +- .../painless/ir/FunctionNode.java | 5 + .../org/elasticsearch/painless/ir/IRNode.java | 18 +- .../elasticsearch/painless/ir/IfElseNode.java | 7 +- .../org/elasticsearch/painless/ir/IfNode.java | 7 +- .../painless/ir/InstanceofNode.java | 5 + .../painless/ir/InvokeCallDefNode.java | 7 +- .../painless/ir/InvokeCallMemberNode.java | 7 +- .../painless/ir/InvokeCallNode.java | 7 +- .../painless/ir/ListInitializationNode.java | 7 +- .../painless/ir/LoadBraceDefNode.java | 7 +- .../painless/ir/LoadBraceNode.java | 7 +- .../painless/ir/LoadDotArrayLengthNode.java | 7 +- .../painless/ir/LoadDotDefNode.java | 7 +- .../painless/ir/LoadDotNode.java | 7 +- .../painless/ir/LoadDotShortcutNode.java | 7 +- .../painless/ir/LoadFieldMemberNode.java | 7 +- .../painless/ir/LoadListShortcutNode.java | 7 +- .../painless/ir/LoadMapShortcutNode.java | 7 +- .../painless/ir/LoadVariableNode.java | 5 + .../elasticsearch/painless/ir/LoopNode.java | 6 + .../painless/ir/MapInitializationNode.java | 7 +- .../painless/ir/NewArrayNode.java | 7 +- .../painless/ir/NewObjectNode.java | 7 +- .../elasticsearch/painless/ir/NullNode.java | 5 + .../painless/ir/NullSafeSubNode.java | 7 +- .../painless/ir/ReferenceNode.java | 6 + .../elasticsearch/painless/ir/ReturnNode.java | 7 +- .../painless/ir/StatementExpressionNode.java | 7 +- .../painless/ir/StatementNode.java | 5 + .../elasticsearch/painless/ir/StaticNode.java | 5 + .../painless/ir/StoreBraceDefNode.java | 7 +- .../painless/ir/StoreBraceNode.java | 7 +- .../painless/ir/StoreDotDefNode.java | 7 +- .../painless/ir/StoreDotNode.java | 7 +- .../painless/ir/StoreDotShortcutNode.java | 7 +- .../painless/ir/StoreFieldMemberNode.java | 7 +- .../painless/ir/StoreListShortcutNode.java | 7 +- .../painless/ir/StoreMapShortcutNode.java | 7 +- .../elasticsearch/painless/ir/StoreNode.java | 5 + .../painless/ir/StoreVariableNode.java | 5 + .../painless/ir/StringConcatenationNode.java | 7 +- .../elasticsearch/painless/ir/ThrowNode.java | 7 +- .../elasticsearch/painless/ir/TryNode.java | 7 +- .../ir/TypedCaptureReferenceNode.java | 7 +- .../ir/TypedInterfaceReferenceNode.java | 7 +- .../painless/ir/UnaryMathNode.java | 7 +- .../elasticsearch/painless/ir/UnaryNode.java | 6 + .../painless/ir/WhileLoopNode.java | 9 +- ...faultConstantFoldingOptimizationPhase.java | 14 +- .../phase/DefaultUserTreeToIRTreePhase.java | 373 ++++++------------ .../phase/PainlessUserTreeToIRTreePhase.java | 135 +++---- 81 files changed, 631 insertions(+), 416 deletions(-) diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ArgumentsNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ArgumentsNode.java index f29d498b36e..e944e7ef1ac 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ArgumentsNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ArgumentsNode.java @@ -19,6 +19,8 @@ package org.elasticsearch.painless.ir; +import org.elasticsearch.painless.Location; + import java.util.ArrayList; import java.util.List; @@ -38,4 +40,8 @@ public abstract class ArgumentsNode extends ExpressionNode { /* ---- end tree structure ---- */ + public ArgumentsNode(Location location) { + super(location); + } + } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BinaryImplNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BinaryImplNode.java index 21286f8ef4e..88797329cb7 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BinaryImplNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BinaryImplNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -41,6 +42,10 @@ public class BinaryImplNode extends BinaryNode { /* ---- end visitor ---- */ + public BinaryImplNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getLeftNode().write(classWriter, methodWriter, writeScope); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BinaryMathNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BinaryMathNode.java index 5ee31c6a703..441752e78e0 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BinaryMathNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BinaryMathNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.Operation; import org.elasticsearch.painless.WriterConstants; @@ -95,9 +96,13 @@ public class BinaryMathNode extends BinaryNode { /* ---- end visitor ---- */ + public BinaryMathNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); if (operation == Operation.FIND || operation == Operation.MATCH) { getRightNode().write(classWriter, methodWriter, writeScope); @@ -117,10 +122,10 @@ public class BinaryMathNode extends BinaryNode { getRightNode().write(classWriter, methodWriter, writeScope); if (binaryType == def.class || (shiftType != null && shiftType == def.class)) { - methodWriter.writeDynamicBinaryInstruction(location, + methodWriter.writeDynamicBinaryInstruction(getLocation(), getExpressionType(), getLeftNode().getExpressionType(), getRightNode().getExpressionType(), operation, flags); } else { - methodWriter.writeBinaryInstruction(location, getExpressionType(), operation); + methodWriter.writeBinaryInstruction(getLocation(), getExpressionType(), operation); } } } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BinaryNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BinaryNode.java index c09582c2102..c0fd3ac5650 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BinaryNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BinaryNode.java @@ -19,6 +19,8 @@ package org.elasticsearch.painless.ir; +import org.elasticsearch.painless.Location; + public abstract class BinaryNode extends ExpressionNode { /* ---- begin tree structure ---- */ @@ -42,6 +44,10 @@ public abstract class BinaryNode extends ExpressionNode { return rightNode; } - /* ---- end tree structure, begin visitor ---- */ + /* ---- end tree structure ---- */ + + public BinaryNode(Location location) { + super(location); + } } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BlockNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BlockNode.java index 07e39176a1f..428a5f1c1a8 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BlockNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BlockNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -69,6 +70,10 @@ public class BlockNode extends StatementNode { /* ---- end visitor ---- */ + public BlockNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { for (StatementNode statementNode : statementNodes) { diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BooleanNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BooleanNode.java index d51395b9ab6..89300083744 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BooleanNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BooleanNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.Operation; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -56,9 +57,13 @@ public class BooleanNode extends BinaryNode { /* ---- end visitor ---- */ + public BooleanNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); if (operation == Operation.AND) { Label fals = new Label(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BreakNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BreakNode.java index 0c4d03ae950..7b211817d4e 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BreakNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/BreakNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -40,6 +41,10 @@ public class BreakNode extends StatementNode { /* ---- end visitor ---- */ + public BreakNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { methodWriter.goTo(breakLabel); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/CastNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/CastNode.java index 65350313d1a..5806c75de57 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/CastNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/CastNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessCast; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -53,10 +54,14 @@ public class CastNode extends UnaryNode { /* ---- end visitor ---- */ + public CastNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.writeCast(cast); } } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/CatchNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/CatchNode.java index fbcf9cac273..54c95e6e114 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/CatchNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/CatchNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -79,9 +80,13 @@ public class CatchNode extends StatementNode { Label end = null; Label exception = null; + public CatchNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); Variable variable = writeScope.defineVariable(exceptionType, symbol); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ClassNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ClassNode.java index 44c61282218..8dacee8534f 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ClassNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ClassNode.java @@ -107,9 +107,10 @@ public class ClassNode extends IRNode { /* ---- end visitor ---- */ - public ClassNode() { - clinitBlockNode = new BlockNode(); - clinitBlockNode.setLocation(new Location("internal$clinit$blocknode", 0)); + public ClassNode(Location location) { + super(location); + + clinitBlockNode = new BlockNode(new Location("internal$clinit$blocknode", 0)); clinitBlockNode.setAllEscape(true); } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ComparisonNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ComparisonNode.java index 105b7a6ef94..3729000c816 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ComparisonNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ComparisonNode.java @@ -21,6 +21,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; import org.elasticsearch.painless.DefBootstrap; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.Operation; import org.elasticsearch.painless.lookup.PainlessLookupUtility; @@ -75,9 +76,13 @@ public class ComparisonNode extends BinaryNode { /* ---- end visitor ---- */ + public ComparisonNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); getLeftNode().write(classWriter, methodWriter, writeScope); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConditionNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConditionNode.java index 8efeac594fe..829d44334b1 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConditionNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConditionNode.java @@ -19,6 +19,8 @@ package org.elasticsearch.painless.ir; +import org.elasticsearch.painless.Location; + public abstract class ConditionNode extends StatementNode { /* ---- begin tree structure ---- */ @@ -44,4 +46,8 @@ public abstract class ConditionNode extends StatementNode { /* ---- end tree structure ---- */ + public ConditionNode(Location location) { + super(location); + } + } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConditionalNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConditionalNode.java index 94efe9041e3..ccc73c8970b 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConditionalNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConditionalNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -56,9 +57,13 @@ public class ConditionalNode extends BinaryNode { /* ---- end visitor ---- */ + public ConditionalNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); Label fals = new Label(); Label end = new Label(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConstantNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConstantNode.java index c2b157fdef2..122ade69e0a 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConstantNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ConstantNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -52,6 +53,10 @@ public class ConstantNode extends ExpressionNode { /* ---- end visitor ---- */ + public ConstantNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { if (constant instanceof String) methodWriter.push((String)constant); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ContinueNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ContinueNode.java index fe4c6788c01..ab7cd1c0118 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ContinueNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ContinueNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -40,6 +41,10 @@ public class ContinueNode extends StatementNode { /* ---- end visitor ---- */ + public ContinueNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { methodWriter.goTo(continueLabel); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DeclarationBlockNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DeclarationBlockNode.java index b630f47d5a7..bd554e7d2cf 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DeclarationBlockNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DeclarationBlockNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -57,6 +58,10 @@ public class DeclarationBlockNode extends StatementNode { /* ---- end visitor ---- */ + public DeclarationBlockNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { for (DeclarationNode declarationNode : declarationNodes) { diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DeclarationNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DeclarationNode.java index 366f7c3401b..d60fe62fe97 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DeclarationNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DeclarationNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessLookupUtility; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -82,9 +83,13 @@ public class DeclarationNode extends StatementNode { /* ---- end visitor ---- */ + public DeclarationNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); Variable variable = writeScope.defineVariable(declarationType, name); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DefInterfaceReferenceNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DefInterfaceReferenceNode.java index 81932a3fe6a..c28103293aa 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DefInterfaceReferenceNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DefInterfaceReferenceNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -53,9 +54,13 @@ public class DefInterfaceReferenceNode extends ReferenceNode { /* ---- end visitor ---- */ + public DefInterfaceReferenceNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); // place holder for functional interface receiver // which is resolved and replace at runtime diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DoWhileLoopNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DoWhileLoopNode.java index e50a483ef46..9335f403453 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DoWhileLoopNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DoWhileLoopNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -47,9 +48,13 @@ public class DoWhileLoopNode extends LoopNode { /* ---- end visitor ---- */ + public DoWhileLoopNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); writeScope = writeScope.newScope(); @@ -73,7 +78,7 @@ public class DoWhileLoopNode extends LoopNode { Variable loop = writeScope.getInternalVariable("loop"); if (loop != null) { - methodWriter.writeLoopCounter(loop.getSlot(), location); + methodWriter.writeLoopCounter(loop.getSlot(), getLocation()); } methodWriter.goTo(start); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DupNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DupNode.java index 0058fd908be..34de12f9fe5 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DupNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/DupNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -61,6 +62,10 @@ public class DupNode extends UnaryNode { /* ---- end visitor ---- */ + public DupNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ElvisNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ElvisNode.java index 8ae73f513ce..1946fdaf7ca 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ElvisNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ElvisNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -42,9 +43,13 @@ public class ElvisNode extends BinaryNode { /* ---- end visitor ---- */ + public ElvisNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); Label end = new Label(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ExpressionNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ExpressionNode.java index 418b5afc391..cf70697dbbd 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ExpressionNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ExpressionNode.java @@ -19,6 +19,7 @@ package org.elasticsearch.painless.ir; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.lookup.PainlessLookupUtility; public abstract class ExpressionNode extends IRNode { @@ -41,4 +42,8 @@ public abstract class ExpressionNode extends IRNode { /* ---- end node data ---- */ + public ExpressionNode(Location location) { + super(location); + } + } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FieldNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FieldNode.java index 971a57ee25a..f50410beb1d 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FieldNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FieldNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessLookupUtility; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -76,6 +77,10 @@ public class FieldNode extends IRNode { /* ---- end visitor ---- */ + public FieldNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { classWriter.getClassVisitor().visitField( diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FlipArrayIndexNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FlipArrayIndexNode.java index e99187317b1..b97294f70f7 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FlipArrayIndexNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FlipArrayIndexNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -42,6 +43,10 @@ public class FlipArrayIndexNode extends UnaryNode { /* ---- end visitor ---- */ + public FlipArrayIndexNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FlipCollectionIndexNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FlipCollectionIndexNode.java index fa713b9c4e6..ad311e5c660 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FlipCollectionIndexNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FlipCollectionIndexNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.WriterConstants; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -43,6 +44,10 @@ public class FlipCollectionIndexNode extends UnaryNode { /* ---- end visitor ---- */ + public FlipCollectionIndexNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FlipDefIndexNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FlipDefIndexNode.java index 01c2febffb8..ae84de8401e 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FlipDefIndexNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FlipDefIndexNode.java @@ -21,6 +21,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; import org.elasticsearch.painless.DefBootstrap; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.def; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -43,6 +44,10 @@ public class FlipDefIndexNode extends UnaryNode { /* ---- end visitor ---- */ + public FlipDefIndexNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { methodWriter.dup(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForEachLoopNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForEachLoopNode.java index 261e30f4169..551fc333706 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForEachLoopNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForEachLoopNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -52,6 +53,10 @@ public class ForEachLoopNode extends StatementNode { /* ---- end visitor ---- */ + public ForEachLoopNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { writeScope = writeScope.newScope(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForEachSubArrayNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForEachSubArrayNode.java index 431ea061e8e..a4e48f2e06c 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForEachSubArrayNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForEachSubArrayNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessCast; import org.elasticsearch.painless.lookup.PainlessLookupUtility; @@ -137,9 +138,13 @@ public class ForEachSubArrayNode extends LoopNode { /* ---- end visitor ---- */ + public ForEachSubArrayNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); Variable variable = writeScope.defineVariable(variableType, variableName); Variable array = writeScope.defineInternalVariable(arrayType, arrayName); @@ -170,7 +175,7 @@ public class ForEachSubArrayNode extends LoopNode { Variable loop = writeScope.getInternalVariable("loop"); if (loop != null) { - methodWriter.writeLoopCounter(loop.getSlot(), location); + methodWriter.writeLoopCounter(loop.getSlot(), getLocation()); } getBlockNode().continueLabel = begin; diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForEachSubIterableNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForEachSubIterableNode.java index 371a51c2f18..e9a4579600d 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForEachSubIterableNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForEachSubIterableNode.java @@ -21,6 +21,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; import org.elasticsearch.painless.DefBootstrap; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessCast; import org.elasticsearch.painless.lookup.PainlessMethod; @@ -113,9 +114,13 @@ public class ForEachSubIterableNode extends LoopNode { /* ---- end visitor ---- */ + public ForEachSubIterableNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); Variable variable = writeScope.defineVariable(variableType, variableName); Variable iterator = writeScope.defineInternalVariable(iteratorType, iteratorName); @@ -149,7 +154,7 @@ public class ForEachSubIterableNode extends LoopNode { Variable loop = writeScope.getInternalVariable("loop"); if (loop != null) { - methodWriter.writeLoopCounter(loop.getSlot(), location); + methodWriter.writeLoopCounter(loop.getSlot(), getLocation()); } getBlockNode().continueLabel = begin; diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForLoopNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForLoopNode.java index e641be38ea7..32087ae1197 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForLoopNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ForLoopNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -78,9 +79,13 @@ public class ForLoopNode extends LoopNode { /* ---- end visitor ---- */ + public ForLoopNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); writeScope = writeScope.newScope(); @@ -107,7 +112,7 @@ public class ForLoopNode extends LoopNode { Variable loop = writeScope.getInternalVariable("loop"); if (loop != null) { - methodWriter.writeLoopCounter(loop.getSlot(), location); + methodWriter.writeLoopCounter(loop.getSlot(), getLocation()); } boolean allEscape = false; diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FunctionNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FunctionNode.java index 8f913492061..be27ebae7ff 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FunctionNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/FunctionNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -134,6 +135,10 @@ public class FunctionNode extends IRNode { /* ---- end visitor ---- */ + public FunctionNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { int access = Opcodes.ACC_PUBLIC; diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/IRNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/IRNode.java index cbc805011ae..c677701536d 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/IRNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/IRNode.java @@ -29,11 +29,7 @@ public abstract class IRNode { /* ---- begin node data ---- */ - protected Location location; - - public void setLocation(Location location) { - this.location = location; - } + private final Location location; public Location getLocation() { return location; @@ -41,17 +37,15 @@ public abstract class IRNode { /* ---- end node data, begin visitor ---- */ - /** - * Callback to visit an ir tree node. - */ public abstract void visit(IRTreeVisitor irTreeVisitor, Scope scope); - - /** - * Visits all child ir tree nodes for this ir tree node. - */ public abstract void visitChildren(IRTreeVisitor irTreeVisitor, Scope scope); /* ---- end visitor ---- */ + public IRNode(Location location) { + this.location = location; + } + protected abstract void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope); + } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/IfElseNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/IfElseNode.java index 11e3e97404d..7daf9c9f38c 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/IfElseNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/IfElseNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -56,9 +57,13 @@ public class IfElseNode extends ConditionNode { /* ---- end visitor ---- */ + public IfElseNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); Label fals = new Label(); Label end = new Label(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/IfNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/IfNode.java index 638c29dd0f2..e9e7dd7f67b 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/IfNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/IfNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -43,9 +44,13 @@ public class IfNode extends ConditionNode { /* ---- end visitor ---- */ + public IfNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); Label fals = new Label(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InstanceofNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InstanceofNode.java index 701cd2ca2ef..0fee7e85a2d 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InstanceofNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InstanceofNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessLookupUtility; import org.elasticsearch.painless.lookup.def; @@ -58,6 +59,10 @@ public class InstanceofNode extends UnaryNode { /* ---- end visitor ---- */ + public InstanceofNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InvokeCallDefNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InvokeCallDefNode.java index 33e9c1c0ef4..f454b2c448d 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InvokeCallDefNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InvokeCallDefNode.java @@ -21,6 +21,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; import org.elasticsearch.painless.DefBootstrap; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -61,12 +62,16 @@ public class InvokeCallDefNode extends ArgumentsNode { /* ---- end visitor ---- */ + public InvokeCallDefNode(Location location) { + super(location); + } + /** * Writes an invokedynamic instruction for a call with an unknown receiver type. */ @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); // its possible to have unknown functional interfaces // as arguments that require captures; the set of diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InvokeCallMemberNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InvokeCallMemberNode.java index dbd1f577101..a1240264973 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InvokeCallMemberNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InvokeCallMemberNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessClassBinding; import org.elasticsearch.painless.lookup.PainlessInstanceBinding; @@ -108,9 +109,13 @@ public class InvokeCallMemberNode extends ArgumentsNode { /* ---- end visitor ---- */ + public InvokeCallMemberNode(Location location) { + super(location); + } + @Override public void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); if (localFunction != null) { if (localFunction.isStatic() == false) { diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InvokeCallNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InvokeCallNode.java index 2b4aefb70e1..53102211a79 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InvokeCallNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/InvokeCallNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessMethod; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -64,9 +65,13 @@ public class InvokeCallNode extends ArgumentsNode { /* ---- end visitor ---- */ + public InvokeCallNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); if (box.isPrimitive()) { methodWriter.box(MethodWriter.getType(box)); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ListInitializationNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ListInitializationNode.java index 29acc8f7a9a..52aa75f723a 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ListInitializationNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ListInitializationNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessConstructor; import org.elasticsearch.painless.lookup.PainlessMethod; @@ -67,9 +68,13 @@ public class ListInitializationNode extends ArgumentsNode { /* ---- end visitor ---- */ + public ListInitializationNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.newInstance(MethodWriter.getType(getExpressionType())); methodWriter.dup(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadBraceDefNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadBraceDefNode.java index 17713341eb8..9cc78d986bc 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadBraceDefNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadBraceDefNode.java @@ -21,6 +21,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; import org.elasticsearch.painless.DefBootstrap; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessLookupUtility; import org.elasticsearch.painless.lookup.def; @@ -58,9 +59,13 @@ public class LoadBraceDefNode extends ExpressionNode { /* ---- end visitor ---- */ + public LoadBraceDefNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); Type methodType = Type.getMethodType( MethodWriter.getType(getExpressionType()), MethodWriter.getType(def.class), diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadBraceNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadBraceNode.java index 798bf798d6b..77824481838 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadBraceNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadBraceNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -40,9 +41,13 @@ public class LoadBraceNode extends ExpressionNode { /* ---- end visitor ---- */ + public LoadBraceNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.arrayLoad(MethodWriter.getType(getExpressionType())); } } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotArrayLengthNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotArrayLengthNode.java index 153c2d523d5..e48c6002ccf 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotArrayLengthNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotArrayLengthNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -40,9 +41,13 @@ public class LoadDotArrayLengthNode extends ExpressionNode { /* ---- end visitor ---- */ + public LoadDotArrayLengthNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.arrayLength(); } } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotDefNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotDefNode.java index a737d0d7d70..2bfab4e581a 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotDefNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotDefNode.java @@ -21,6 +21,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; import org.elasticsearch.painless.DefBootstrap; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.def; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -55,9 +56,13 @@ public class LoadDotDefNode extends ExpressionNode { /* ---- end visitor ---- */ + public LoadDotDefNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); Type methodType = Type.getMethodType( MethodWriter.getType(getExpressionType()), MethodWriter.getType(def.class)); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotNode.java index 4189a633353..ad81a0d5f0d 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessField; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -54,9 +55,13 @@ public class LoadDotNode extends ExpressionNode { /* ---- end visitor ---- */ + public LoadDotNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); if (java.lang.reflect.Modifier.isStatic(field.javaField.getModifiers())) { methodWriter.getStatic(Type.getType( diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotShortcutNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotShortcutNode.java index 90104a72886..37f4e2e3ed9 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotShortcutNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadDotShortcutNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessMethod; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -53,9 +54,13 @@ public class LoadDotShortcutNode extends ExpressionNode { /* ---- end visitor ---- */ + public LoadDotShortcutNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.invokeMethodCall(getter); if (!getter.returnType.equals(getter.javaMethod.getReturnType())) { diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadFieldMemberNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadFieldMemberNode.java index 214b0ae62ef..267b3336545 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadFieldMemberNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadFieldMemberNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -67,9 +68,13 @@ public class LoadFieldMemberNode extends ExpressionNode { /* ---- end visitor ---- */ + public LoadFieldMemberNode(Location location) { + super(location); + } + @Override public void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); if (isStatic) { methodWriter.getStatic(CLASS_TYPE, name, MethodWriter.getType(getExpressionType())); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadListShortcutNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadListShortcutNode.java index e03218d4da7..33f3031064e 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadListShortcutNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadListShortcutNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessMethod; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -53,9 +54,13 @@ public class LoadListShortcutNode extends ExpressionNode { /* ---- end visitor ---- */ + public LoadListShortcutNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.invokeMethodCall(getter); if (getter.returnType == getter.javaMethod.getReturnType()) { diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadMapShortcutNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadMapShortcutNode.java index dbefb60527b..b8b5214da5c 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadMapShortcutNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadMapShortcutNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessMethod; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -53,9 +54,13 @@ public class LoadMapShortcutNode extends ExpressionNode { /* ---- end visitor ---- */ + public LoadMapShortcutNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.invokeMethodCall(getter); if (getter.returnType != getter.javaMethod.getReturnType()) { diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadVariableNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadVariableNode.java index c79042d70ae..e3610f6f8d4 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadVariableNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoadVariableNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -54,6 +55,10 @@ public class LoadVariableNode extends ExpressionNode { /* ---- end visitor ---- */ + public LoadVariableNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { Variable variable = writeScope.getVariable(name); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoopNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoopNode.java index 7822917009b..0ce4d9d6d6e 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoopNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/LoopNode.java @@ -19,6 +19,8 @@ package org.elasticsearch.painless.ir; +import org.elasticsearch.painless.Location; + public abstract class LoopNode extends ConditionNode { /* ---- begin node data ---- */ @@ -35,4 +37,8 @@ public abstract class LoopNode extends ConditionNode { /* ---- end node data ---- */ + public LoopNode(Location location) { + super(location); + } + } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/MapInitializationNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/MapInitializationNode.java index 56cc2fca3ad..3bdd2f24b41 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/MapInitializationNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/MapInitializationNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessConstructor; import org.elasticsearch.painless.lookup.PainlessMethod; @@ -104,9 +105,13 @@ public class MapInitializationNode extends ExpressionNode { /* ---- end visitor ---- */ + public MapInitializationNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.newInstance(MethodWriter.getType(getExpressionType())); methodWriter.dup(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NewArrayNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NewArrayNode.java index 64c5bc85f17..5e001f8e784 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NewArrayNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NewArrayNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -54,9 +55,13 @@ public class NewArrayNode extends ArgumentsNode { /* ---- end visitor ---- */ + public NewArrayNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); if (initialize) { methodWriter.push(getArgumentNodes().size()); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NewObjectNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NewObjectNode.java index 8868ce04d02..cad999a19ff 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NewObjectNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NewObjectNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessConstructor; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -66,9 +67,13 @@ public class NewObjectNode extends ArgumentsNode { /* ---- end visitor ---- */ + public NewObjectNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.newInstance(MethodWriter.getType(getExpressionType())); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NullNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NullNode.java index 026be8bd61b..71f9233717b 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NullNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NullNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -41,6 +42,10 @@ public class NullNode extends ExpressionNode { /* ---- end visitor ---- */ + public NullNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { methodWriter.visitInsn(Opcodes.ACONST_NULL); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NullSafeSubNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NullSafeSubNode.java index 1139bfd0441..a1c09e282b5 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NullSafeSubNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/NullSafeSubNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -41,9 +42,13 @@ public class NullSafeSubNode extends UnaryNode { /* ---- end visitor ---- */ + public NullSafeSubNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); Label end = new Label(); methodWriter.dup(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ReferenceNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ReferenceNode.java index 931d6328998..dc4b4862836 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ReferenceNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ReferenceNode.java @@ -19,6 +19,8 @@ package org.elasticsearch.painless.ir; +import org.elasticsearch.painless.Location; + import java.util.ArrayList; import java.util.List; @@ -38,4 +40,8 @@ public abstract class ReferenceNode extends ExpressionNode { /* ---- end node data ---- */ + public ReferenceNode(Location location) { + super(location); + } + } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ReturnNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ReturnNode.java index d6941a9eddc..45a2d681673 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ReturnNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ReturnNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -54,9 +55,13 @@ public class ReturnNode extends StatementNode { /* ---- end visitor ---- */ + public ReturnNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); if (expressionNode != null) { expressionNode.write(classWriter, methodWriter, writeScope); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StatementExpressionNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StatementExpressionNode.java index 4b18b51b3db..c34804fc92c 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StatementExpressionNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StatementExpressionNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -52,9 +53,13 @@ public class StatementExpressionNode extends StatementNode { /* ---- end visitor ---- */ + public StatementExpressionNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); expressionNode.write(classWriter, methodWriter, writeScope); methodWriter.writePop(MethodWriter.getType(expressionNode.getExpressionType()).getSize()); } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StatementNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StatementNode.java index d2f7ec65832..7937415fc05 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StatementNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StatementNode.java @@ -19,6 +19,7 @@ package org.elasticsearch.painless.ir; +import org.elasticsearch.painless.Location; import org.objectweb.asm.Label; public abstract class StatementNode extends IRNode { @@ -26,4 +27,8 @@ public abstract class StatementNode extends IRNode { protected Label continueLabel = null; protected Label breakLabel = null; + public StatementNode(Location location) { + super(location); + } + } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StaticNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StaticNode.java index 327a52276b4..73213e2881b 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StaticNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StaticNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -40,6 +41,10 @@ public class StaticNode extends ExpressionNode { /* ---- end visitor ---- */ + public StaticNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { // do nothing diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreBraceDefNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreBraceDefNode.java index d82ba2edf8e..2130b950d39 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreBraceDefNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreBraceDefNode.java @@ -21,6 +21,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; import org.elasticsearch.painless.DefBootstrap; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessLookupUtility; import org.elasticsearch.painless.lookup.def; @@ -60,11 +61,15 @@ public class StoreBraceDefNode extends StoreNode { /* ---- end visitor ---- */ + public StoreBraceDefNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); Type methodType = Type.getMethodType( MethodWriter.getType(void.class), MethodWriter.getType(def.class), diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreBraceNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreBraceNode.java index fd603ee1092..b58d0c8ddfa 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreBraceNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreBraceNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -40,11 +41,15 @@ public class StoreBraceNode extends StoreNode { /* ---- end visitor ---- */ + public StoreBraceNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.arrayStore(MethodWriter.getType(getStoreType())); } } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreDotDefNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreDotDefNode.java index 99f203317ab..3d81f83c1bd 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreDotDefNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreDotDefNode.java @@ -21,6 +21,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; import org.elasticsearch.painless.DefBootstrap; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.def; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -55,11 +56,15 @@ public class StoreDotDefNode extends StoreNode { /* ---- end visitor ---- */ + public StoreDotDefNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); Type methodType = Type.getMethodType( MethodWriter.getType(void.class), MethodWriter.getType(def.class), diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreDotNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreDotNode.java index 61898078372..a64ac878a91 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreDotNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreDotNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessField; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -54,11 +55,15 @@ public class StoreDotNode extends StoreNode { /* ---- end visitor ---- */ + public StoreDotNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); if (java.lang.reflect.Modifier.isStatic(field.javaField.getModifiers())) { methodWriter.putStatic(Type.getType( diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreDotShortcutNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreDotShortcutNode.java index 1eb67b5f23e..cf59ad33e78 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreDotShortcutNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreDotShortcutNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessMethod; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -53,11 +54,15 @@ public class StoreDotShortcutNode extends StoreNode { /* ---- end visitor ---- */ + public StoreDotShortcutNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.invokeMethodCall(setter); methodWriter.writePop(MethodWriter.getType(setter.returnType).getSize()); } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreFieldMemberNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreFieldMemberNode.java index cd46a589865..4b22c4abf16 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreFieldMemberNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreFieldMemberNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -68,6 +69,10 @@ public class StoreFieldMemberNode extends StoreNode { /* ---- end visitor ---- */ + public StoreFieldMemberNode(Location location) { + super(location); + } + @Override public void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { if (isStatic == false) { @@ -76,7 +81,7 @@ public class StoreFieldMemberNode extends StoreNode { getChildNode().write(classWriter, methodWriter, writeScope); - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); if (isStatic) { methodWriter.putStatic(CLASS_TYPE, name, MethodWriter.getType(getStoreType())); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreListShortcutNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreListShortcutNode.java index a5c2cda8074..d4f5a03aed6 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreListShortcutNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreListShortcutNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessMethod; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -53,11 +54,15 @@ public class StoreListShortcutNode extends StoreNode { /* ---- end visitor ---- */ + public StoreListShortcutNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.invokeMethodCall(setter); methodWriter.writePop(MethodWriter.getType(setter.returnType).getSize()); } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreMapShortcutNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreMapShortcutNode.java index 9bb4f56590e..c7c63f67050 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreMapShortcutNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreMapShortcutNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.lookup.PainlessMethod; import org.elasticsearch.painless.phase.IRTreeVisitor; @@ -53,11 +54,15 @@ public class StoreMapShortcutNode extends StoreNode { /* ---- end visitor ---- */ + public StoreMapShortcutNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.invokeMethodCall(setter); methodWriter.writePop(MethodWriter.getType(setter.returnType).getSize()); } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreNode.java index 9f2b2006528..c4dd2b995f9 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreNode.java @@ -19,6 +19,7 @@ package org.elasticsearch.painless.ir; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.lookup.PainlessLookupUtility; public abstract class StoreNode extends UnaryNode { @@ -41,4 +42,8 @@ public abstract class StoreNode extends UnaryNode { /* ---- end node data ---- */ + public StoreNode(Location location) { + super(location); + } + } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreVariableNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreVariableNode.java index 4d2996efb63..8f8dd345c4f 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreVariableNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StoreVariableNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -54,6 +55,10 @@ public class StoreVariableNode extends StoreNode { /* ---- end visitor ---- */ + public StoreVariableNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { getChildNode().write(classWriter, methodWriter, writeScope); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StringConcatenationNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StringConcatenationNode.java index b1b71266a1e..a8e20ba236e 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StringConcatenationNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/StringConcatenationNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -40,9 +41,13 @@ public class StringConcatenationNode extends ArgumentsNode { /* ---- end visitor ---- */ + public StringConcatenationNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); methodWriter.writeNewStrings(); for (ExpressionNode argumentNode : getArgumentNodes()) { diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ThrowNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ThrowNode.java index 6d3c1724740..ac3ae087604 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ThrowNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/ThrowNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -52,9 +53,13 @@ public class ThrowNode extends StatementNode { /* ---- end visitor ---- */ + public ThrowNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); expressionNode.write(classWriter, methodWriter, writeScope); methodWriter.throwException(); } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/TryNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/TryNode.java index 7c25bb45af5..22b88e28b5c 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/TryNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/TryNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -69,9 +70,13 @@ public class TryNode extends StatementNode { /* ---- end visitor ---- */ + public TryNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); Label begin = new Label(); Label end = new Label(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/TypedCaptureReferenceNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/TypedCaptureReferenceNode.java index f8bd87729db..813b0740c70 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/TypedCaptureReferenceNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/TypedCaptureReferenceNode.java @@ -21,6 +21,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; import org.elasticsearch.painless.DefBootstrap; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -56,9 +57,13 @@ public class TypedCaptureReferenceNode extends ReferenceNode { /* ---- end visitor ---- */ + public TypedCaptureReferenceNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); Variable captured = writeScope.getVariable(getCaptures().get(0)); methodWriter.visitVarInsn(captured.getAsmType().getOpcode(Opcodes.ILOAD), captured.getSlot()); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/TypedInterfaceReferenceNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/TypedInterfaceReferenceNode.java index 6793e317490..b4abf274562 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/TypedInterfaceReferenceNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/TypedInterfaceReferenceNode.java @@ -21,6 +21,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; import org.elasticsearch.painless.FunctionRef; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -54,9 +55,13 @@ public class TypedInterfaceReferenceNode extends ReferenceNode { /* ---- end visitor ---- */ + public TypedInterfaceReferenceNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); for (String capture : getCaptures()) { WriteScope.Variable variable = writeScope.getVariable(capture); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/UnaryMathNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/UnaryMathNode.java index b82c25cb120..f015ed2aaa2 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/UnaryMathNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/UnaryMathNode.java @@ -21,6 +21,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; import org.elasticsearch.painless.DefBootstrap; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.Operation; import org.elasticsearch.painless.lookup.PainlessLookupUtility; @@ -90,9 +91,13 @@ public class UnaryMathNode extends UnaryNode { /* ---- end visitor ---- */ + public UnaryMathNode(Location location) { + super(location); + } + @Override public void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeDebugInfo(location); + methodWriter.writeDebugInfo(getLocation()); if (operation == Operation.NOT) { Label fals = new Label(); diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/UnaryNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/UnaryNode.java index 1fca6e0e6a7..061f62d51a3 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/UnaryNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/UnaryNode.java @@ -19,6 +19,8 @@ package org.elasticsearch.painless.ir; +import org.elasticsearch.painless.Location; + public abstract class UnaryNode extends ExpressionNode { /* ---- begin tree structure ---- */ @@ -35,4 +37,8 @@ public abstract class UnaryNode extends ExpressionNode { /* ---- end tree structure ---- */ + public UnaryNode(Location location) { + super(location); + } + } diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/WhileLoopNode.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/WhileLoopNode.java index a08fa5eb1ac..0f5c349d2fc 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/WhileLoopNode.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/ir/WhileLoopNode.java @@ -20,6 +20,7 @@ package org.elasticsearch.painless.ir; import org.elasticsearch.painless.ClassWriter; +import org.elasticsearch.painless.Location; import org.elasticsearch.painless.MethodWriter; import org.elasticsearch.painless.phase.IRTreeVisitor; import org.elasticsearch.painless.symbol.WriteScope; @@ -49,9 +50,13 @@ public class WhileLoopNode extends LoopNode { /* ---- end visitor ---- */ + public WhileLoopNode(Location location) { + super(location); + } + @Override protected void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope) { - methodWriter.writeStatementOffset(location); + methodWriter.writeStatementOffset(getLocation()); writeScope = writeScope.newScope(); @@ -68,7 +73,7 @@ public class WhileLoopNode extends LoopNode { Variable loop = writeScope.getInternalVariable("loop"); if (loop != null) { - methodWriter.writeLoopCounter(loop.getSlot(), location); + methodWriter.writeLoopCounter(loop.getSlot(), getLocation()); } if (getBlockNode() != null) { diff --git a/modules/lang-painless/src/main/java/org/elasticsearch/painless/phase/DefaultConstantFoldingOptimizationPhase.java b/modules/lang-painless/src/main/java/org/elasticsearch/painless/phase/DefaultConstantFoldingOptimizationPhase.java index 3a3deda7eee..9f29e7dd35a 100644 --- a/modules/lang-painless/src/main/java/org/elasticsearch/painless/phase/DefaultConstantFoldingOptimizationPhase.java +++ b/modules/lang-painless/src/main/java/org/elasticsearch/painless/phase/DefaultConstantFoldingOptimizationPhase.java @@ -448,7 +448,7 @@ public class DefaultConstantFoldingOptimizationPhase extends IRTreeBaseVisitor valueType = scriptScope.getDecoration(userBinaryNode, ValueType.class).getValueType(); if (operation == Operation.ADD && valueType == String.class) { - StringConcatenationNode stringConcatenationNode = new StringConcatenationNode(); + StringConcatenationNode stringConcatenationNode = new StringConcatenationNode(userBinaryNode.getLocation()); stringConcatenationNode.addArgumentNode((ExpressionNode)visit(userBinaryNode.getLeftNode(), scriptScope)); stringConcatenationNode.addArgumentNode((ExpressionNode)visit(userBinaryNode.getRightNode(), scriptScope)); irExpressionNode = stringConcatenationNode; @@ -989,7 +937,7 @@ public class DefaultUserTreeToIRTreePhase implements UserTreeVisitor shiftType = scriptScope.hasDecoration(userBinaryNode, ShiftType.class) ? scriptScope.getDecoration(userBinaryNode, ShiftType.class).getShiftType() : null; - BinaryMathNode irBinaryMathNode = new BinaryMathNode(); + BinaryMathNode irBinaryMathNode = new BinaryMathNode(userBinaryNode.getLocation()); irBinaryMathNode.setBinaryType(scriptScope.getDecoration(userBinaryNode, BinaryType.class).getBinaryType()); irBinaryMathNode.setShiftType(shiftType); @@ -1004,15 +952,13 @@ public class DefaultUserTreeToIRTreePhase implements UserTreeVisitor captures = scriptScope.getDecoration(userLambdaNode, CapturesDecoration.class).getCaptures(); @@ -1380,22 +1299,21 @@ public class DefaultUserTreeToIRTreePhase implements UserTreeVisitor returnType = scriptScope.getDecoration(userNewArrayFunctionRefNode, ReturnType.class).getReturnType(); - LoadVariableNode irLoadVariableNode = new LoadVariableNode(); - irLoadVariableNode.setLocation(userNewArrayFunctionRefNode.getLocation()); + LoadVariableNode irLoadVariableNode = new LoadVariableNode(userNewArrayFunctionRefNode.getLocation()); irLoadVariableNode.setExpressionType(int.class); irLoadVariableNode.setName("size"); - NewArrayNode irNewArrayNode = new NewArrayNode(); - irNewArrayNode.setLocation(userNewArrayFunctionRefNode.getLocation()); + NewArrayNode irNewArrayNode = new NewArrayNode(userNewArrayFunctionRefNode.getLocation()); irNewArrayNode.setExpressionType(returnType); irNewArrayNode.setInitialize(false); irNewArrayNode.addArgumentNode(irLoadVariableNode); - ReturnNode irReturnNode = new ReturnNode(); - irReturnNode.setLocation(userNewArrayFunctionRefNode.getLocation()); + ReturnNode irReturnNode = new ReturnNode(userNewArrayFunctionRefNode.getLocation()); irReturnNode.setExpressionNode(irNewArrayNode); - BlockNode irBlockNode = new BlockNode(); + BlockNode irBlockNode = new BlockNode(userNewArrayFunctionRefNode.getLocation()); irBlockNode.setAllEscape(true); irBlockNode.addStatementNode(irReturnNode); - FunctionNode irFunctionNode = new FunctionNode(); + FunctionNode irFunctionNode = new FunctionNode(userNewArrayFunctionRefNode.getLocation()); irFunctionNode.setMaxLoopCounter(0); irFunctionNode.setName(scriptScope.getDecoration(userNewArrayFunctionRefNode, MethodNameDecoration.class).getMethodName()); irFunctionNode.setReturnType(returnType); @@ -1456,7 +1372,6 @@ public class DefaultUserTreeToIRTreePhase implements UserTreeVisitor staticType = scriptScope.getDecoration(userSymbolNode, StaticType.class).getStaticType(); - StaticNode staticNode = new StaticNode(); - staticNode.setLocation(userSymbolNode.getLocation()); + StaticNode staticNode = new StaticNode(userSymbolNode.getLocation()); staticNode.setExpressionType(staticType); irExpressionNode = staticNode; } else if (scriptScope.hasDecoration(userSymbolNode, ValueType.class)) { @@ -1488,8 +1402,7 @@ public class DefaultUserTreeToIRTreePhase implements UserTreeVisitor staticType = scriptScope.getDecoration(userDotNode, StaticType.class).getStaticType(); - StaticNode staticNode = new StaticNode(); - staticNode.setLocation(userDotNode.getLocation()); + StaticNode staticNode = new StaticNode(userDotNode.getLocation()); staticNode.setExpressionType(staticType); irExpressionNode = staticNode; } else { @@ -1543,16 +1454,14 @@ public class DefaultUserTreeToIRTreePhase implements UserTreeVisitor indexType = scriptScope.getDecoration(userBraceNode.getIndexNode(), ValueType.class).getValueType(); - FlipDefIndexNode irFlipDefIndexNode = new FlipDefIndexNode(); - irFlipDefIndexNode.setLocation(userBraceNode.getIndexNode().getLocation()); + FlipDefIndexNode irFlipDefIndexNode = new FlipDefIndexNode(userBraceNode.getIndexNode().getLocation()); irFlipDefIndexNode.setExpressionType(indexType); irFlipDefIndexNode.setChildNode(irIndexNode); irIndexNode = irFlipDefIndexNode; if (write || compound) { - StoreBraceDefNode irStoreBraceNode = new StoreBraceDefNode(); - irStoreBraceNode.setLocation(location); + StoreBraceDefNode irStoreBraceNode = new StoreBraceDefNode(location); irStoreBraceNode.setExpressionType(read ? valueType : void.class); irStoreBraceNode.setStoreType(valueType); irStoreBraceNode.setIndexType(indexType); @@ -1734,16 +1627,14 @@ public class DefaultUserTreeToIRTreePhase implements UserTreeVisitor returnType = scriptScope.getScriptClassInfo().getGetReturns().get(i); - DeclarationNode irDeclarationNode = new DeclarationNode(); - irDeclarationNode.setLocation(internalLocation); + DeclarationNode irDeclarationNode = new DeclarationNode(internalLocation); irDeclarationNode.setName(name); irDeclarationNode.setDeclarationType(returnType); irBlockNode.getStatementsNodes().add(0, irDeclarationNode); - InvokeCallMemberNode irInvokeCallMemberNode = new InvokeCallMemberNode(); - irInvokeCallMemberNode.setLocation(internalLocation); + InvokeCallMemberNode irInvokeCallMemberNode = new InvokeCallMemberNode(internalLocation); irInvokeCallMemberNode.setExpressionType(irDeclarationNode.getDeclarationType()); irInvokeCallMemberNode.setLocalFunction(new LocalFunction( getMethod.getName(), returnType, Collections.emptyList(), true, false)); @@ -316,8 +295,7 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase name = name.substring(5); name = Character.toLowerCase(name.charAt(0)) + name.substring(1); - FunctionNode irFunctionNode = new FunctionNode(); - irFunctionNode.setLocation(internalLocation); + FunctionNode irFunctionNode = new FunctionNode(internalLocation); irFunctionNode.setName(needsMethod.getName()); irFunctionNode.setReturnType(boolean.class); irFunctionNode.setStatic(false); @@ -327,19 +305,16 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase irClassNode.addFunctionNode(irFunctionNode); - BlockNode irBlockNode = new BlockNode(); - irBlockNode.setLocation(internalLocation); + BlockNode irBlockNode = new BlockNode(internalLocation); irBlockNode.setAllEscape(true); irFunctionNode.setBlockNode(irBlockNode); - ReturnNode irReturnNode = new ReturnNode(); - irReturnNode.setLocation(internalLocation); + ReturnNode irReturnNode = new ReturnNode(internalLocation); irBlockNode.addStatementNode(irReturnNode); - ConstantNode irConstantNode = new ConstantNode(); - irConstantNode.setLocation(internalLocation); + ConstantNode irConstantNode = new ConstantNode(internalLocation); irConstantNode.setExpressionType(boolean.class); irConstantNode.setConstant(scriptScope.getUsedVariables().contains(name)); @@ -361,30 +336,25 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase Location internalLocation = new Location("$internal$ScriptInjectionPhase$injectSandboxExceptions", 0); BlockNode irBlockNode = irFunctionNode.getBlockNode(); - TryNode irTryNode = new TryNode(); - irTryNode.setLocation(internalLocation); + TryNode irTryNode = new TryNode(internalLocation); irTryNode.setBlockNode(irBlockNode); - CatchNode irCatchNode = new CatchNode(); - irCatchNode.setLocation(internalLocation); + CatchNode irCatchNode = new CatchNode(internalLocation); irCatchNode.setExceptionType(PainlessExplainError.class); irCatchNode.setSymbol("#painlessExplainError"); irTryNode.addCatchNode(irCatchNode); - BlockNode irCatchBlockNode = new BlockNode(); - irCatchBlockNode.setLocation(internalLocation); + BlockNode irCatchBlockNode = new BlockNode(internalLocation); irCatchBlockNode.setAllEscape(true); irCatchNode.setBlockNode(irCatchBlockNode); - ThrowNode irThrowNode = new ThrowNode(); - irThrowNode.setLocation(internalLocation); + ThrowNode irThrowNode = new ThrowNode(internalLocation); irCatchBlockNode.addStatementNode(irThrowNode); - InvokeCallMemberNode irInvokeCallMemberNode = new InvokeCallMemberNode(); - irInvokeCallMemberNode.setLocation(internalLocation); + InvokeCallMemberNode irInvokeCallMemberNode = new InvokeCallMemberNode(internalLocation); irInvokeCallMemberNode.setExpressionType(ScriptException.class); irInvokeCallMemberNode.setLocalFunction( new LocalFunction( @@ -398,28 +368,24 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase irThrowNode.setExpressionNode(irInvokeCallMemberNode); - LoadVariableNode irLoadVariableNode = new LoadVariableNode(); - irLoadVariableNode.setLocation(internalLocation); + LoadVariableNode irLoadVariableNode = new LoadVariableNode(internalLocation); irLoadVariableNode.setExpressionType(ScriptException.class); irLoadVariableNode.setName("#painlessExplainError"); irInvokeCallMemberNode.addArgumentNode(irLoadVariableNode); - BinaryImplNode irBinaryImplNode = new BinaryImplNode(); - irBinaryImplNode.setLocation(internalLocation); + BinaryImplNode irBinaryImplNode = new BinaryImplNode(internalLocation); irBinaryImplNode.setExpressionType(Map.class); irInvokeCallMemberNode.addArgumentNode(irBinaryImplNode); - irLoadVariableNode = new LoadVariableNode(); - irLoadVariableNode.setLocation(internalLocation); + irLoadVariableNode = new LoadVariableNode(internalLocation); irLoadVariableNode.setExpressionType(PainlessExplainError.class); irLoadVariableNode.setName("#painlessExplainError"); irBinaryImplNode.setLeftNode(irLoadVariableNode); - InvokeCallNode irInvokeCallNode = new InvokeCallNode(); - irInvokeCallNode.setLocation(internalLocation); + InvokeCallNode irInvokeCallNode = new InvokeCallNode(internalLocation); irInvokeCallNode.setExpressionType(Map.class); irInvokeCallNode.setBox(PainlessExplainError.class); irInvokeCallNode.setMethod( @@ -438,8 +404,7 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase irBinaryImplNode.setRightNode(irInvokeCallNode); - LoadFieldMemberNode irLoadFieldMemberNode = new LoadFieldMemberNode(); - irLoadFieldMemberNode.setLocation(internalLocation); + LoadFieldMemberNode irLoadFieldMemberNode = new LoadFieldMemberNode(internalLocation); irLoadFieldMemberNode.setExpressionType(PainlessLookup.class); irLoadFieldMemberNode.setName("$DEFINITION"); irLoadFieldMemberNode.setStatic(true); @@ -452,26 +417,22 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase String name = throwable.getSimpleName(); name = "#" + Character.toLowerCase(name.charAt(0)) + name.substring(1); - irCatchNode = new CatchNode(); - irCatchNode.setLocation(internalLocation); + irCatchNode = new CatchNode(internalLocation); irCatchNode.setExceptionType(throwable); irCatchNode.setSymbol(name); irTryNode.addCatchNode(irCatchNode); - irCatchBlockNode = new BlockNode(); - irCatchBlockNode.setLocation(internalLocation); + irCatchBlockNode = new BlockNode(internalLocation); irCatchBlockNode.setAllEscape(true); irCatchNode.setBlockNode(irCatchBlockNode); - irThrowNode = new ThrowNode(); - irThrowNode.setLocation(internalLocation); + irThrowNode = new ThrowNode(internalLocation); irCatchBlockNode.addStatementNode(irThrowNode); - irInvokeCallMemberNode = new InvokeCallMemberNode(); - irInvokeCallMemberNode.setLocation(internalLocation); + irInvokeCallMemberNode = new InvokeCallMemberNode(internalLocation); irInvokeCallMemberNode.setExpressionType(ScriptException.class); irInvokeCallMemberNode.setLocalFunction( new LocalFunction( @@ -485,27 +446,23 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase irThrowNode.setExpressionNode(irInvokeCallMemberNode); - irLoadVariableNode = new LoadVariableNode(); - irLoadVariableNode.setLocation(internalLocation); + irLoadVariableNode = new LoadVariableNode(internalLocation); irLoadVariableNode.setExpressionType(ScriptException.class); irLoadVariableNode.setName(name); irInvokeCallMemberNode.addArgumentNode(irLoadVariableNode); - irBinaryImplNode = new BinaryImplNode(); - irBinaryImplNode.setLocation(internalLocation); + irBinaryImplNode = new BinaryImplNode(internalLocation); irBinaryImplNode.setExpressionType(Map.class); irInvokeCallMemberNode.addArgumentNode(irBinaryImplNode); - StaticNode irStaticNode = new StaticNode(); - irStaticNode.setLocation(internalLocation); + StaticNode irStaticNode = new StaticNode(internalLocation); irStaticNode.setExpressionType(Collections.class); irBinaryImplNode.setLeftNode(irStaticNode); - irInvokeCallNode = new InvokeCallNode(); - irInvokeCallNode.setLocation(internalLocation); + irInvokeCallNode = new InvokeCallNode(internalLocation); irInvokeCallNode.setExpressionType(Map.class); irInvokeCallNode.setBox(Collections.class); irInvokeCallNode.setMethod( @@ -523,8 +480,7 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase irBinaryImplNode.setRightNode(irInvokeCallNode); } - irBlockNode = new BlockNode(); - irBlockNode.setLocation(internalLocation); + irBlockNode = new BlockNode(internalLocation); irBlockNode.setAllEscape(true); irBlockNode.addStatementNode(irTryNode); @@ -564,8 +520,7 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase ReturnNode returnNode = (ReturnNode) irNode; // inject converter - InvokeCallMemberNode irInvokeCallMemberNode = new InvokeCallMemberNode(); - irInvokeCallMemberNode.setLocation(userStatementNode.getLocation()); + InvokeCallMemberNode irInvokeCallMemberNode = new InvokeCallMemberNode(userStatementNode.getLocation()); irInvokeCallMemberNode.setLocalFunction(converter.getConverter()); ExpressionNode returnExpression = returnNode.getExpressionNode(); returnNode.setExpressionNode(irInvokeCallMemberNode);