|
|
@@ -139,8 +139,8 @@ import org.elasticsearch.painless.node.ENull;
|
|
|
import org.elasticsearch.painless.node.ENumeric;
|
|
|
import org.elasticsearch.painless.node.ERegex;
|
|
|
import org.elasticsearch.painless.node.EString;
|
|
|
+import org.elasticsearch.painless.node.ESymbol;
|
|
|
import org.elasticsearch.painless.node.EUnary;
|
|
|
-import org.elasticsearch.painless.node.EVariable;
|
|
|
import org.elasticsearch.painless.node.SBlock;
|
|
|
import org.elasticsearch.painless.node.SBreak;
|
|
|
import org.elasticsearch.painless.node.SCatch;
|
|
|
@@ -178,11 +178,19 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
private final CompilerSettings settings;
|
|
|
private final String sourceName;
|
|
|
|
|
|
+ private int identifier;
|
|
|
+
|
|
|
private Walker(ScriptClassInfo scriptClassInfo, String sourceName, String sourceText, CompilerSettings settings) {
|
|
|
this.scriptClassInfo = scriptClassInfo;
|
|
|
this.settings = settings;
|
|
|
this.sourceName = sourceName;
|
|
|
this.source = (SClass)visit(buildAntlrTree(sourceText));
|
|
|
+
|
|
|
+ this.identifier = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int nextIdentifier() {
|
|
|
+ return identifier++;
|
|
|
}
|
|
|
|
|
|
private SourceContext buildAntlrTree(String source) {
|
|
|
@@ -248,7 +256,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
String name = method.getName().substring(3);
|
|
|
name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
|
|
|
|
|
|
- statements.add(new SDeclaration(location(ctx),
|
|
|
+ statements.add(new SDeclaration(nextIdentifier(), location(ctx),
|
|
|
new DResolvedType(location(ctx), scriptClassInfo.getGetReturns().get(index), false), name, false, null));
|
|
|
}
|
|
|
|
|
|
@@ -266,11 +274,11 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
}
|
|
|
|
|
|
// generate the execute method from the collected statements and parameters
|
|
|
- SFunction execute = new SFunction(location(ctx), returnCanonicalTypeName, "execute", paramTypes, paramNames, new SBlock(
|
|
|
- location(ctx), statements), true, false, false, true);
|
|
|
+ SFunction execute = new SFunction(nextIdentifier(), location(ctx), returnCanonicalTypeName, "execute", paramTypes, paramNames,
|
|
|
+ new SBlock(nextIdentifier(), location(ctx), statements), true, false, false, true);
|
|
|
functions.add(execute);
|
|
|
|
|
|
- return new SClass(location(ctx), functions);
|
|
|
+ return new SClass(nextIdentifier(), location(ctx), functions);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -297,8 +305,8 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
statements.add((AStatement)visit(ctx.block().dstatement()));
|
|
|
}
|
|
|
|
|
|
- return new SFunction(
|
|
|
- location(ctx), rtnType, name, paramTypes, paramNames, new SBlock(location(ctx), statements), false, true, false, false);
|
|
|
+ return new SFunction(nextIdentifier(), location(ctx),
|
|
|
+ rtnType, name, paramTypes, paramNames, new SBlock(nextIdentifier(), location(ctx), statements), false, true, false, false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -325,9 +333,9 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
if (ctx.trailer().size() > 1) {
|
|
|
SBlock elseblock = (SBlock)visit(ctx.trailer(1));
|
|
|
|
|
|
- return new SIfElse(location(ctx), expression, ifblock, elseblock);
|
|
|
+ return new SIfElse(nextIdentifier(), location(ctx), expression, ifblock, elseblock);
|
|
|
} else {
|
|
|
- return new SIf(location(ctx), expression, ifblock);
|
|
|
+ return new SIf(nextIdentifier(), location(ctx), expression, ifblock);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -338,9 +346,9 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
if (ctx.trailer() != null) {
|
|
|
SBlock block = (SBlock)visit(ctx.trailer());
|
|
|
|
|
|
- return new SWhile(location(ctx), expression, block);
|
|
|
+ return new SWhile(nextIdentifier(), location(ctx), expression, block);
|
|
|
} else if (ctx.empty() != null) {
|
|
|
- return new SWhile(location(ctx), expression, null);
|
|
|
+ return new SWhile(nextIdentifier(), location(ctx), expression, null);
|
|
|
} else {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
@@ -351,7 +359,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
AExpression expression = (AExpression)visit(ctx.expression());
|
|
|
SBlock block = (SBlock)visit(ctx.block());
|
|
|
|
|
|
- return new SDo(location(ctx), block, expression);
|
|
|
+ return new SDo(nextIdentifier(), location(ctx), expression, block);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -363,9 +371,9 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
if (ctx.trailer() != null) {
|
|
|
SBlock block = (SBlock)visit(ctx.trailer());
|
|
|
|
|
|
- return new SFor(location(ctx), initializer, expression, afterthought, block);
|
|
|
+ return new SFor(nextIdentifier(), location(ctx), initializer, expression, afterthought, block);
|
|
|
} else if (ctx.empty() != null) {
|
|
|
- return new SFor(location(ctx), initializer, expression, afterthought, null);
|
|
|
+ return new SFor(nextIdentifier(), location(ctx), initializer, expression, afterthought, null);
|
|
|
} else {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
@@ -378,7 +386,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
AExpression expression = (AExpression)visit(ctx.expression());
|
|
|
SBlock block = (SBlock)visit(ctx.trailer());
|
|
|
|
|
|
- return new SEach(location(ctx), type, name, expression, block);
|
|
|
+ return new SEach(nextIdentifier(), location(ctx), type, name, expression, block);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -387,7 +395,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
AExpression expression = (AExpression)visit(ctx.expression());
|
|
|
SBlock block = (SBlock)visit(ctx.trailer());
|
|
|
|
|
|
- return new SEach(location(ctx), "def", name, expression, block);
|
|
|
+ return new SEach(nextIdentifier(), location(ctx), "def", name, expression, block);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -397,12 +405,12 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
|
|
|
@Override
|
|
|
public ANode visitContinue(ContinueContext ctx) {
|
|
|
- return new SContinue(location(ctx));
|
|
|
+ return new SContinue(nextIdentifier(), location(ctx));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ANode visitBreak(BreakContext ctx) {
|
|
|
- return new SBreak(location(ctx));
|
|
|
+ return new SBreak(nextIdentifier(), location(ctx));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -413,7 +421,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
expression = (AExpression) visit(ctx.expression());
|
|
|
}
|
|
|
|
|
|
- return new SReturn(location(ctx), expression);
|
|
|
+ return new SReturn(nextIdentifier(), location(ctx), expression);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -425,21 +433,21 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
catches.add((SCatch)visit(trap));
|
|
|
}
|
|
|
|
|
|
- return new STry(location(ctx), block, catches);
|
|
|
+ return new STry(nextIdentifier(), location(ctx), block, catches);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ANode visitThrow(ThrowContext ctx) {
|
|
|
AExpression expression = (AExpression)visit(ctx.expression());
|
|
|
|
|
|
- return new SThrow(location(ctx), expression);
|
|
|
+ return new SThrow(nextIdentifier(), location(ctx), expression);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ANode visitExpr(ExprContext ctx) {
|
|
|
AExpression expression = (AExpression)visit(ctx.expression());
|
|
|
|
|
|
- return new SExpression(location(ctx), expression);
|
|
|
+ return new SExpression(nextIdentifier(), location(ctx), expression);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -450,7 +458,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
List<AStatement> statements = new ArrayList<>();
|
|
|
statements.add((AStatement)visit(ctx.statement()));
|
|
|
|
|
|
- return new SBlock(location(ctx), statements);
|
|
|
+ return new SBlock(nextIdentifier(), location(ctx), statements);
|
|
|
} else {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
@@ -471,7 +479,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
statements.add((AStatement)visit(ctx.dstatement()));
|
|
|
}
|
|
|
|
|
|
- return new SBlock(location(ctx), statements);
|
|
|
+ return new SBlock(nextIdentifier(), location(ctx), statements);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -506,10 +514,10 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
AExpression expression = declvar.expression() == null ? null : (AExpression)visit(declvar.expression());
|
|
|
DUnresolvedType unresolvedType = new DUnresolvedType(location(declvar), type);
|
|
|
|
|
|
- declarations.add(new SDeclaration(location(declvar), unresolvedType, name, true, expression));
|
|
|
+ declarations.add(new SDeclaration(nextIdentifier(), location(declvar), unresolvedType, name, true, expression));
|
|
|
}
|
|
|
|
|
|
- return new SDeclBlock(location(ctx), declarations);
|
|
|
+ return new SDeclBlock(nextIdentifier(), location(ctx), declarations);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -533,8 +541,9 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
String name = ctx.ID().getText();
|
|
|
SBlock block = (SBlock)visit(ctx.block());
|
|
|
|
|
|
- return new SCatch(location(ctx), new DResolvedType(location(ctx), Exception.class),
|
|
|
- new SDeclaration(location(ctx.type()), new DUnresolvedType(location(ctx.type()), type), name, false, null), block);
|
|
|
+ return new SCatch(nextIdentifier(), location(ctx), Exception.class,
|
|
|
+ new SDeclaration(nextIdentifier(), location(ctx.type()),
|
|
|
+ new DUnresolvedType(location(ctx.type()), type), name, false, null), block);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -578,7 +587,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
|
|
|
- return new EBinary(location(ctx), operation, left, right);
|
|
|
+ return new EBinary(nextIdentifier(), location(ctx), left, right, operation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -607,7 +616,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
|
|
|
- return new EComp(location(ctx), operation, left, right);
|
|
|
+ return new EComp(nextIdentifier(), location(ctx), left, right, operation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -615,7 +624,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
AExpression expr = (AExpression)visit(ctx.noncondexpression());
|
|
|
String type = ctx.decltype().getText();
|
|
|
|
|
|
- return new EInstanceof(location(ctx), expr, type);
|
|
|
+ return new EInstanceof(nextIdentifier(), location(ctx), expr, type);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -632,7 +641,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
|
|
|
- return new EBool(location(ctx), operation, left, right);
|
|
|
+ return new EBool(nextIdentifier(), location(ctx), left, right, operation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -640,7 +649,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
AExpression left = (AExpression)visit(ctx.noncondexpression(0));
|
|
|
AExpression right = (AExpression)visit(ctx.noncondexpression(1));
|
|
|
|
|
|
- return new EElvis(location(ctx), left, right);
|
|
|
+ return new EElvis(nextIdentifier(), location(ctx), left, right);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -654,7 +663,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
AExpression left = (AExpression)visit(ctx.expression(0));
|
|
|
AExpression right = (AExpression)visit(ctx.expression(1));
|
|
|
|
|
|
- return new EConditional(location(ctx), condition, left, right);
|
|
|
+ return new EConditional(nextIdentifier(), location(ctx), condition, left, right);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -692,7 +701,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
|
|
|
- return new EAssignment(location(ctx), lhs, rhs, false, operation);
|
|
|
+ return new EAssignment(nextIdentifier(), location(ctx), lhs, rhs, false, operation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -709,7 +718,8 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
|
|
|
- return new EAssignment(location(ctx), expression, new EConstant(location(ctx), 1), false, operation);
|
|
|
+ return new EAssignment(nextIdentifier(), location(ctx), expression,
|
|
|
+ new EConstant(nextIdentifier(), location(ctx), 1), false, operation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -726,7 +736,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
|
|
|
- return new EUnary(location(ctx), operation, expression);
|
|
|
+ return new EUnary(nextIdentifier(), location(ctx), expression, operation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -753,7 +763,8 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
|
|
|
- return new EAssignment(location(ctx), expression, new EConstant(location(ctx), 1), true, operation);
|
|
|
+ return new EAssignment(nextIdentifier(), location(ctx), expression,
|
|
|
+ new EConstant(nextIdentifier(), location(ctx), 1), true, operation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -770,7 +781,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
|
|
|
- return new EUnary(location(ctx), operation, expression);
|
|
|
+ return new EUnary(nextIdentifier(), location(ctx), expression, operation);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -783,7 +794,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
String type = ctx.primordefcasttype().getText();
|
|
|
AExpression child = (AExpression)visit(ctx.unary());
|
|
|
|
|
|
- return new EExplicit(location(ctx), new DUnresolvedType(location(ctx.primordefcasttype()), type), child);
|
|
|
+ return new EExplicit(nextIdentifier(), location(ctx), new DUnresolvedType(location(ctx.primordefcasttype()), type), child);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -791,7 +802,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
String type = ctx.refcasttype().getText();
|
|
|
AExpression child = (AExpression)visit(ctx.unarynotaddsub());
|
|
|
|
|
|
- return new EExplicit(location(ctx), new DUnresolvedType(location(ctx.refcasttype()), type), child);
|
|
|
+ return new EExplicit(nextIdentifier(), location(ctx), new DUnresolvedType(location(ctx.refcasttype()), type), child);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -824,13 +835,13 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
@Override
|
|
|
public ANode visitNumeric(NumericContext ctx) {
|
|
|
if (ctx.DECIMAL() != null) {
|
|
|
- return new EDecimal(location(ctx), ctx.DECIMAL().getText());
|
|
|
+ return new EDecimal(nextIdentifier(), location(ctx), ctx.DECIMAL().getText());
|
|
|
} else if (ctx.HEX() != null) {
|
|
|
- return new ENumeric(location(ctx), ctx.HEX().getText().substring(2), 16);
|
|
|
+ return new ENumeric(nextIdentifier(), location(ctx), ctx.HEX().getText().substring(2), 16);
|
|
|
} else if (ctx.INTEGER() != null) {
|
|
|
- return new ENumeric(location(ctx), ctx.INTEGER().getText(), 10);
|
|
|
+ return new ENumeric(nextIdentifier(), location(ctx), ctx.INTEGER().getText(), 10);
|
|
|
} else if (ctx.OCTAL() != null) {
|
|
|
- return new ENumeric(location(ctx), ctx.OCTAL().getText().substring(1), 8);
|
|
|
+ return new ENumeric(nextIdentifier(), location(ctx), ctx.OCTAL().getText().substring(1), 8);
|
|
|
} else {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
@@ -838,17 +849,17 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
|
|
|
@Override
|
|
|
public ANode visitTrue(TrueContext ctx) {
|
|
|
- return new EBoolean(location(ctx), true);
|
|
|
+ return new EBoolean(nextIdentifier(), location(ctx), true);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ANode visitFalse(FalseContext ctx) {
|
|
|
- return new EBoolean(location(ctx), false);
|
|
|
+ return new EBoolean(nextIdentifier(), location(ctx), false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ANode visitNull(NullContext ctx) {
|
|
|
- return new ENull(location(ctx));
|
|
|
+ return new ENull(nextIdentifier(), location(ctx));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -873,7 +884,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
}
|
|
|
string.setLength(dest);
|
|
|
|
|
|
- return new EString(location(ctx), string.toString());
|
|
|
+ return new EString(nextIdentifier(), location(ctx), string.toString());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -883,7 +894,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
String pattern = text.substring(1, lastSlash);
|
|
|
String flags = text.substring(lastSlash + 1);
|
|
|
|
|
|
- return new ERegex(location(ctx), pattern, flags);
|
|
|
+ return new ERegex(nextIdentifier(), location(ctx), pattern, flags);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -900,7 +911,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
public ANode visitVariable(VariableContext ctx) {
|
|
|
String name = ctx.ID().getText();
|
|
|
|
|
|
- return new EVariable(location(ctx), name);
|
|
|
+ return new ESymbol(nextIdentifier(), location(ctx), name);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -908,7 +919,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
String name = ctx.ID().getText();
|
|
|
List<AExpression> arguments = collectArguments(ctx.arguments());
|
|
|
|
|
|
- return new ECallLocal(location(ctx), name, arguments);
|
|
|
+ return new ECallLocal(nextIdentifier(), location(ctx), name, arguments);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -916,7 +927,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
String type = ctx.type().getText();
|
|
|
List<AExpression> arguments = collectArguments(ctx.arguments());
|
|
|
|
|
|
- return new ENewObj(location(ctx), type, arguments);
|
|
|
+ return new ENewObj(nextIdentifier(), location(ctx), type, arguments);
|
|
|
}
|
|
|
|
|
|
private AExpression buildPostfixChain(AExpression primary, PostdotContext postdot, List<PostfixContext> postfixes) {
|
|
|
@@ -974,7 +985,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
String name = ctx.DOTID().getText();
|
|
|
List<AExpression> arguments = collectArguments(ctx.arguments());
|
|
|
|
|
|
- return new ECall(location(ctx), prefix, name, arguments, ctx.NSDOT() != null);
|
|
|
+ return new ECall(nextIdentifier(), location(ctx), prefix, name, arguments, ctx.NSDOT() != null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -993,7 +1004,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
throw location(ctx).createError(new IllegalStateException("illegal tree structure"));
|
|
|
}
|
|
|
|
|
|
- return new EDot(location(ctx), prefix, ctx.NSDOT() != null, value);
|
|
|
+ return new EDot(nextIdentifier(), location(ctx), prefix, value, ctx.NSDOT() != null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1004,7 +1015,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
public AExpression visitBraceaccess(BraceaccessContext ctx, AExpression prefix) {
|
|
|
AExpression expression = (AExpression)visit(ctx.expression());
|
|
|
|
|
|
- return new EBrace(location(ctx), prefix, expression);
|
|
|
+ return new EBrace(nextIdentifier(), location(ctx), prefix, expression);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1017,7 +1028,8 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
expressions.add((AExpression)visit(expression));
|
|
|
}
|
|
|
|
|
|
- return buildPostfixChain(new ENewArray(location(ctx), type.toString(), expressions, false), ctx.postdot(), ctx.postfix());
|
|
|
+ return buildPostfixChain(
|
|
|
+ new ENewArray(nextIdentifier(), location(ctx), type.toString(), expressions, false), ctx.postdot(), ctx.postfix());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1029,7 +1041,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
expressions.add((AExpression)visit(expression));
|
|
|
}
|
|
|
|
|
|
- return buildPostfixChain(new ENewArray(location(ctx), type, expressions, true), null, ctx.postfix());
|
|
|
+ return buildPostfixChain(new ENewArray(nextIdentifier(), location(ctx), type, expressions, true), null, ctx.postfix());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1040,7 +1052,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
values.add((AExpression)visit(expression));
|
|
|
}
|
|
|
|
|
|
- return new EListInit(location(ctx), values);
|
|
|
+ return new EListInit(nextIdentifier(), location(ctx), values);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1053,7 +1065,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
values.add((AExpression)visit(maptoken.expression(1)));
|
|
|
}
|
|
|
|
|
|
- return new EMapInit(location(ctx), keys, values);
|
|
|
+ return new EMapInit(nextIdentifier(), location(ctx), keys, values);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1108,13 +1120,13 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
if (ctx.expression() != null) {
|
|
|
// single expression
|
|
|
AExpression expression = (AExpression)visit(ctx.expression());
|
|
|
- block = new SBlock(location(ctx),
|
|
|
- Collections.singletonList(new SReturn(location(ctx), expression)));
|
|
|
+ block = new SBlock(nextIdentifier(), location(ctx),
|
|
|
+ Collections.singletonList(new SReturn(nextIdentifier(), location(ctx), expression)));
|
|
|
} else {
|
|
|
block = (SBlock)visit(ctx.block());
|
|
|
}
|
|
|
|
|
|
- return new ELambda(location(ctx), paramTypes, paramNames, block);
|
|
|
+ return new ELambda(nextIdentifier(), location(ctx), paramTypes, paramNames, block);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -1124,18 +1136,18 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|
|
|
|
|
@Override
|
|
|
public ANode visitClassfuncref(ClassfuncrefContext ctx) {
|
|
|
- return new EFunctionRef(location(ctx), ctx.decltype().getText(), ctx.ID().getText());
|
|
|
+ return new EFunctionRef(nextIdentifier(), location(ctx), ctx.decltype().getText(), ctx.ID().getText());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ANode visitConstructorfuncref(ConstructorfuncrefContext ctx) {
|
|
|
return ctx.decltype().LBRACE().isEmpty() ?
|
|
|
- new EFunctionRef(location(ctx), ctx.decltype().getText(), ctx.NEW().getText()) :
|
|
|
- new ENewArrayFunctionRef(location(ctx), ctx.decltype().getText());
|
|
|
+ new EFunctionRef(nextIdentifier(), location(ctx), ctx.decltype().getText(), ctx.NEW().getText()) :
|
|
|
+ new ENewArrayFunctionRef(nextIdentifier(), location(ctx), ctx.decltype().getText());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ANode visitLocalfuncref(LocalfuncrefContext ctx) {
|
|
|
- return new EFunctionRef(location(ctx), ctx.THIS().getText(), ctx.ID().getText());
|
|
|
+ return new EFunctionRef(nextIdentifier(), location(ctx), ctx.THIS().getText(), ctx.ID().getText());
|
|
|
}
|
|
|
}
|