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.
This commit is contained in:
parent
cf75abb021
commit
d134b4f70b
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 <Scope> void visit(IRTreeVisitor<Scope> irTreeVisitor, Scope scope);
|
||||
|
||||
/**
|
||||
* Visits all child ir tree nodes for this ir tree node.
|
||||
*/
|
||||
public abstract <Scope> void visitChildren(IRTreeVisitor<Scope> irTreeVisitor, Scope scope);
|
||||
|
||||
/* ---- end visitor ---- */
|
||||
|
||||
public IRNode(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
protected abstract void write(ClassWriter classWriter, MethodWriter methodWriter, WriteScope writeScope);
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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())) {
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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()));
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -448,7 +448,7 @@ public class DefaultConstantFoldingOptimizationPhase extends IRTreeBaseVisitor<C
|
|||
irConstantNode.setExpressionType(String.class);
|
||||
irStringConcatenationNode.getArgumentNodes().remove(i + 1);
|
||||
} else if (irLeftNode instanceof NullNode && irRightNode instanceof NullNode) {
|
||||
ConstantNode irConstantNode = new ConstantNode();
|
||||
ConstantNode irConstantNode = new ConstantNode(irLeftNode.getLocation());
|
||||
irConstantNode.setConstant("" + null + null);
|
||||
irConstantNode.setExpressionType(String.class);
|
||||
irStringConcatenationNode.getArgumentNodes().set(i, irConstantNode);
|
||||
|
@ -531,12 +531,10 @@ public class DefaultConstantFoldingOptimizationPhase extends IRTreeBaseVisitor<C
|
|||
} else if (type == double.class) {
|
||||
irLeftConstantNode.setConstant((double)irLeftConstantNode.getConstant() == (double)irRightConstantNode.getConstant());
|
||||
} else if (irLeftConstantNode == null && irRightConstantNode == null) {
|
||||
irLeftConstantNode = new ConstantNode();
|
||||
irLeftConstantNode.setLocation(irComparisonNode.getLeftNode().getLocation());
|
||||
irLeftConstantNode = new ConstantNode(irComparisonNode.getLeftNode().getLocation());
|
||||
irLeftConstantNode.setConstant(true);
|
||||
} else if (irLeftConstantNode == null || irRightConstantNode == null) {
|
||||
irLeftConstantNode = new ConstantNode();
|
||||
irLeftConstantNode.setLocation(irComparisonNode.getLeftNode().getLocation());
|
||||
irLeftConstantNode = new ConstantNode(irComparisonNode.getLeftNode().getLocation());
|
||||
irLeftConstantNode.setConstant(false);
|
||||
} else {
|
||||
if (operation == Operation.EQ) {
|
||||
|
@ -560,12 +558,10 @@ public class DefaultConstantFoldingOptimizationPhase extends IRTreeBaseVisitor<C
|
|||
} else if (type == double.class) {
|
||||
irLeftConstantNode.setConstant((double)irLeftConstantNode.getConstant() != (double)irRightConstantNode.getConstant());
|
||||
} else if (irLeftConstantNode == null && irRightConstantNode == null) {
|
||||
irLeftConstantNode = new ConstantNode();
|
||||
irLeftConstantNode.setLocation(irComparisonNode.getLeftNode().getLocation());
|
||||
irLeftConstantNode = new ConstantNode(irComparisonNode.getLeftNode().getLocation());
|
||||
irLeftConstantNode.setConstant(false);
|
||||
} else if (irLeftConstantNode == null || irRightConstantNode == null) {
|
||||
irLeftConstantNode = new ConstantNode();
|
||||
irLeftConstantNode.setLocation(irComparisonNode.getLeftNode().getLocation());
|
||||
irLeftConstantNode = new ConstantNode(irComparisonNode.getLeftNode().getLocation());
|
||||
irLeftConstantNode.setConstant(true);
|
||||
} else {
|
||||
if (operation == Operation.NE) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -91,8 +91,7 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase
|
|||
irExpressionNode = null;
|
||||
} else {
|
||||
if (returnType.isPrimitive()) {
|
||||
ConstantNode irConstantNode = new ConstantNode();
|
||||
irConstantNode.setLocation(userFunctionNode.getLocation());
|
||||
ConstantNode irConstantNode = new ConstantNode(userFunctionNode.getLocation());
|
||||
irConstantNode.setExpressionType(returnType);
|
||||
|
||||
if (returnType == boolean.class) {
|
||||
|
@ -114,14 +113,12 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase
|
|||
|
||||
irExpressionNode = irConstantNode;
|
||||
} else {
|
||||
irExpressionNode = new NullNode();
|
||||
irExpressionNode.setLocation(userFunctionNode.getLocation());
|
||||
irExpressionNode = new NullNode(userFunctionNode.getLocation());
|
||||
irExpressionNode.setExpressionType(returnType);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnNode irReturnNode = new ReturnNode();
|
||||
irReturnNode.setLocation(userFunctionNode.getLocation());
|
||||
ReturnNode irReturnNode = new ReturnNode(userFunctionNode.getLocation());
|
||||
irReturnNode.setExpressionNode(irExpressionNode);
|
||||
|
||||
irBlockNode.addStatementNode(irReturnNode);
|
||||
|
@ -133,9 +130,8 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase
|
|||
parameterNames.add(methodArgument.getName());
|
||||
}
|
||||
|
||||
FunctionNode irFunctionNode = new FunctionNode();
|
||||
FunctionNode irFunctionNode = new FunctionNode(userFunctionNode.getLocation());
|
||||
irFunctionNode.setBlockNode(irBlockNode);
|
||||
irFunctionNode.setLocation(userFunctionNode.getLocation());
|
||||
irFunctionNode.setName("execute");
|
||||
irFunctionNode.setReturnType(returnType);
|
||||
irFunctionNode.getTypeParameters().addAll(localFunction.getTypeParameters());
|
||||
|
@ -161,32 +157,28 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase
|
|||
Location internalLocation = new Location("$internal$ScriptInjectionPhase$injectStaticFieldsAndGetters", 0);
|
||||
int modifiers = Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC;
|
||||
|
||||
FieldNode irFieldNode = new FieldNode();
|
||||
irFieldNode.setLocation(internalLocation);
|
||||
FieldNode irFieldNode = new FieldNode(internalLocation);
|
||||
irFieldNode.setModifiers(modifiers);
|
||||
irFieldNode.setFieldType(String.class);
|
||||
irFieldNode.setName("$NAME");
|
||||
|
||||
irClassNode.addFieldNode(irFieldNode);
|
||||
|
||||
irFieldNode = new FieldNode();
|
||||
irFieldNode.setLocation(internalLocation);
|
||||
irFieldNode = new FieldNode(internalLocation);
|
||||
irFieldNode.setModifiers(modifiers);
|
||||
irFieldNode.setFieldType(String.class);
|
||||
irFieldNode.setName("$SOURCE");
|
||||
|
||||
irClassNode.addFieldNode(irFieldNode);
|
||||
|
||||
irFieldNode = new FieldNode();
|
||||
irFieldNode.setLocation(internalLocation);
|
||||
irFieldNode = new FieldNode(internalLocation);
|
||||
irFieldNode.setModifiers(modifiers);
|
||||
irFieldNode.setFieldType(BitSet.class);
|
||||
irFieldNode.setName("$STATEMENTS");
|
||||
|
||||
irClassNode.addFieldNode(irFieldNode);
|
||||
|
||||
FunctionNode irFunctionNode = new FunctionNode();
|
||||
irFunctionNode.setLocation(internalLocation);
|
||||
FunctionNode irFunctionNode = new FunctionNode(internalLocation);
|
||||
irFunctionNode.setName("getName");
|
||||
irFunctionNode.setReturnType(String.class);
|
||||
irFunctionNode.setStatic(false);
|
||||
|
@ -196,27 +188,23 @@ 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);
|
||||
|
||||
LoadFieldMemberNode irLoadFieldMemberNode = new LoadFieldMemberNode();
|
||||
irLoadFieldMemberNode.setLocation(internalLocation);
|
||||
LoadFieldMemberNode irLoadFieldMemberNode = new LoadFieldMemberNode(internalLocation);
|
||||
irLoadFieldMemberNode.setExpressionType(String.class);
|
||||
irLoadFieldMemberNode.setName("$NAME");
|
||||
irLoadFieldMemberNode.setStatic(true);
|
||||
|
||||
irReturnNode.setExpressionNode(irLoadFieldMemberNode);
|
||||
|
||||
irFunctionNode = new FunctionNode();
|
||||
irFunctionNode.setLocation(internalLocation);
|
||||
irFunctionNode = new FunctionNode(internalLocation);
|
||||
irFunctionNode.setName("getSource");
|
||||
irFunctionNode.setReturnType(String.class);
|
||||
irFunctionNode.setStatic(false);
|
||||
|
@ -226,27 +214,23 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase
|
|||
|
||||
irClassNode.addFunctionNode(irFunctionNode);
|
||||
|
||||
irBlockNode = new BlockNode();
|
||||
irBlockNode.setLocation(internalLocation);
|
||||
irBlockNode = new BlockNode(internalLocation);
|
||||
irBlockNode.setAllEscape(true);
|
||||
|
||||
irFunctionNode.setBlockNode(irBlockNode);
|
||||
|
||||
irReturnNode = new ReturnNode();
|
||||
irReturnNode.setLocation(internalLocation);
|
||||
irReturnNode = new ReturnNode(internalLocation);
|
||||
|
||||
irBlockNode.addStatementNode(irReturnNode);
|
||||
|
||||
irLoadFieldMemberNode = new LoadFieldMemberNode();
|
||||
irLoadFieldMemberNode.setLocation(internalLocation);
|
||||
irLoadFieldMemberNode = new LoadFieldMemberNode(internalLocation);
|
||||
irLoadFieldMemberNode.setExpressionType(String.class);
|
||||
irLoadFieldMemberNode.setName("$SOURCE");
|
||||
irLoadFieldMemberNode.setStatic(true);
|
||||
|
||||
irReturnNode.setExpressionNode(irLoadFieldMemberNode);
|
||||
|
||||
irFunctionNode = new FunctionNode();
|
||||
irFunctionNode.setLocation(internalLocation);
|
||||
irFunctionNode = new FunctionNode(internalLocation);
|
||||
irFunctionNode.setName("getStatements");
|
||||
irFunctionNode.setReturnType(BitSet.class);
|
||||
irFunctionNode.setStatic(false);
|
||||
|
@ -256,19 +240,16 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase
|
|||
|
||||
irClassNode.addFunctionNode(irFunctionNode);
|
||||
|
||||
irBlockNode = new BlockNode();
|
||||
irBlockNode.setLocation(internalLocation);
|
||||
irBlockNode = new BlockNode(internalLocation);
|
||||
irBlockNode.setAllEscape(true);
|
||||
|
||||
irFunctionNode.setBlockNode(irBlockNode);
|
||||
|
||||
irReturnNode = new ReturnNode();
|
||||
irReturnNode.setLocation(internalLocation);
|
||||
irReturnNode = new ReturnNode(internalLocation);
|
||||
|
||||
irBlockNode.addStatementNode(irReturnNode);
|
||||
|
||||
irLoadFieldMemberNode = new LoadFieldMemberNode();
|
||||
irLoadFieldMemberNode.setLocation(internalLocation);
|
||||
irLoadFieldMemberNode = new LoadFieldMemberNode(internalLocation);
|
||||
irLoadFieldMemberNode.setExpressionType(BitSet.class);
|
||||
irLoadFieldMemberNode.setName("$STATEMENTS");
|
||||
irLoadFieldMemberNode.setStatic(true);
|
||||
|
@ -291,14 +272,12 @@ public class PainlessUserTreeToIRTreePhase extends DefaultUserTreeToIRTreePhase
|
|||
if (scriptScope.getUsedVariables().contains(name)) {
|
||||
Class<?> 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);
|
||||
|
|
Loading…
Reference in New Issue