mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 10:25:15 +00:00
Merge pull request #18298 from jdconrad/line
Make Line Number Available in Painless
This commit is contained in:
commit
ec4825d49e
@ -146,6 +146,10 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
return parser.source();
|
return parser.source();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int line(final ParserRuleContext ctx) {
|
||||||
|
return ctx.getStart().getLine();
|
||||||
|
}
|
||||||
|
|
||||||
private String location(final ParserRuleContext ctx) {
|
private String location(final ParserRuleContext ctx) {
|
||||||
return "[ " + ctx.getStart().getLine() + " : " + ctx.getStart().getCharPositionInLine() + " ]";
|
return "[ " + ctx.getStart().getLine() + " : " + ctx.getStart().getCharPositionInLine() + " ]";
|
||||||
}
|
}
|
||||||
@ -158,7 +162,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
statements.add((AStatement)visit(statement));
|
statements.add((AStatement)visit(statement));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SSource(location(ctx), statements);
|
return new SSource(line(ctx), location(ctx), statements);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -167,7 +171,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
final AStatement ifblock = (AStatement)visit(ctx.block(0));
|
final AStatement ifblock = (AStatement)visit(ctx.block(0));
|
||||||
final AStatement elseblock = ctx.block(1) == null ? null : (AStatement)visit(ctx.block(1));
|
final AStatement elseblock = ctx.block(1) == null ? null : (AStatement)visit(ctx.block(1));
|
||||||
|
|
||||||
return new SIfElse(location(ctx), condition, ifblock, elseblock);
|
return new SIfElse(line(ctx), location(ctx), condition, ifblock, elseblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -177,7 +181,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
|
|
||||||
reserved.usesLoop();
|
reserved.usesLoop();
|
||||||
|
|
||||||
return new SWhile(location(ctx), condition, block);
|
return new SWhile(line(ctx), location(ctx), condition, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -187,7 +191,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
|
|
||||||
reserved.usesLoop();
|
reserved.usesLoop();
|
||||||
|
|
||||||
return new SDo(location(ctx), block, condition);
|
return new SDo(line(ctx), location(ctx), block, condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -199,7 +203,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
|
|
||||||
reserved.usesLoop();
|
reserved.usesLoop();
|
||||||
|
|
||||||
return new SFor(location(ctx), intializer, condition, afterthought, block);
|
return new SFor(line(ctx), location(ctx), intializer, condition, afterthought, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -209,19 +213,19 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ANode visitContinue(final ContinueContext ctx) {
|
public ANode visitContinue(final ContinueContext ctx) {
|
||||||
return new SContinue(location(ctx));
|
return new SContinue(line(ctx), location(ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ANode visitBreak(final BreakContext ctx) {
|
public ANode visitBreak(final BreakContext ctx) {
|
||||||
return new SBreak(location(ctx));
|
return new SBreak(line(ctx), location(ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ANode visitReturn(final ReturnContext ctx) {
|
public ANode visitReturn(final ReturnContext ctx) {
|
||||||
final AExpression expression = (AExpression)visit(ctx.expression());
|
final AExpression expression = (AExpression)visit(ctx.expression());
|
||||||
|
|
||||||
return new SReturn(location(ctx), expression);
|
return new SReturn(line(ctx), location(ctx), expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -233,21 +237,21 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
traps.add((STrap)visit(trap));
|
traps.add((STrap)visit(trap));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new STry(location(ctx), block, traps);
|
return new STry(line(ctx), location(ctx), block, traps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ANode visitThrow(final ThrowContext ctx) {
|
public ANode visitThrow(final ThrowContext ctx) {
|
||||||
final AExpression expression = (AExpression)visit(ctx.expression());
|
final AExpression expression = (AExpression)visit(ctx.expression());
|
||||||
|
|
||||||
return new SThrow(location(ctx), expression);
|
return new SThrow(line(ctx), location(ctx), expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ANode visitExpr(final ExprContext ctx) {
|
public ANode visitExpr(final ExprContext ctx) {
|
||||||
final AExpression expression = (AExpression)visit(ctx.expression());
|
final AExpression expression = (AExpression)visit(ctx.expression());
|
||||||
|
|
||||||
return new SExpression(location(ctx), expression);
|
return new SExpression(line(ctx), location(ctx), expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -258,7 +262,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
statements.add((AStatement)visit(statement));
|
statements.add((AStatement)visit(statement));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SBlock(location(ctx), statements);
|
return new SBlock(line(ctx), location(ctx), statements);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -266,7 +270,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
final List<AStatement> statements = new ArrayList<>();
|
final List<AStatement> statements = new ArrayList<>();
|
||||||
statements.add((AStatement)visit(ctx.statement()));
|
statements.add((AStatement)visit(ctx.statement()));
|
||||||
|
|
||||||
return new SBlock(location(ctx), statements);
|
return new SBlock(line(ctx), location(ctx), statements);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -303,10 +307,10 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
for (final DeclvarContext declvar : ctx.declvar()) {
|
for (final DeclvarContext declvar : ctx.declvar()) {
|
||||||
final String name = declvar.identifier().getText();
|
final String name = declvar.identifier().getText();
|
||||||
final AExpression expression = declvar.expression() == null ? null : (AExpression)visit(declvar.expression());
|
final AExpression expression = declvar.expression() == null ? null : (AExpression)visit(declvar.expression());
|
||||||
declarations.add(new SDeclaration(location(ctx), type, name, expression));
|
declarations.add(new SDeclaration(line(ctx), location(ctx), type, name, expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SDeclBlock(location(ctx), declarations);
|
return new SDeclBlock(line(ctx), location(ctx), declarations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -325,7 +329,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
final String name = ctx.identifier(1).getText();
|
final String name = ctx.identifier(1).getText();
|
||||||
final AStatement block = ctx.block() == null ? null : (AStatement)visit(ctx.block());
|
final AStatement block = ctx.block() == null ? null : (AStatement)visit(ctx.block());
|
||||||
|
|
||||||
return new STrap(location(ctx), type, name, block);
|
return new STrap(line(ctx), location(ctx), type, name, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -348,13 +352,13 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
final boolean negate = ctx.parent instanceof UnaryContext && ((UnaryContext)ctx.parent).SUB() != null;
|
final boolean negate = ctx.parent instanceof UnaryContext && ((UnaryContext)ctx.parent).SUB() != null;
|
||||||
|
|
||||||
if (ctx.DECIMAL() != null) {
|
if (ctx.DECIMAL() != null) {
|
||||||
return new EDecimal(location(ctx), (negate ? "-" : "") + ctx.DECIMAL().getText());
|
return new EDecimal(line(ctx), location(ctx), (negate ? "-" : "") + ctx.DECIMAL().getText());
|
||||||
} else if (ctx.HEX() != null) {
|
} else if (ctx.HEX() != null) {
|
||||||
return new ENumeric(location(ctx), (negate ? "-" : "") + ctx.HEX().getText().substring(2), 16);
|
return new ENumeric(line(ctx), location(ctx), (negate ? "-" : "") + ctx.HEX().getText().substring(2), 16);
|
||||||
} else if (ctx.INTEGER() != null) {
|
} else if (ctx.INTEGER() != null) {
|
||||||
return new ENumeric(location(ctx), (negate ? "-" : "") + ctx.INTEGER().getText(), 10);
|
return new ENumeric(line(ctx), location(ctx), (negate ? "-" : "") + ctx.INTEGER().getText(), 10);
|
||||||
} else if (ctx.OCTAL() != null) {
|
} else if (ctx.OCTAL() != null) {
|
||||||
return new ENumeric(location(ctx), (negate ? "-" : "") + ctx.OCTAL().getText().substring(1), 8);
|
return new ENumeric(line(ctx), location(ctx), (negate ? "-" : "") + ctx.OCTAL().getText().substring(1), 8);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
||||||
}
|
}
|
||||||
@ -362,17 +366,17 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ANode visitTrue(final TrueContext ctx) {
|
public ANode visitTrue(final TrueContext ctx) {
|
||||||
return new EBoolean(location(ctx), true);
|
return new EBoolean(line(ctx), location(ctx), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ANode visitFalse(FalseContext ctx) {
|
public ANode visitFalse(FalseContext ctx) {
|
||||||
return new EBoolean(location(ctx), false);
|
return new EBoolean(line(ctx), location(ctx), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ANode visitNull(final NullContext ctx) {
|
public ANode visitNull(final NullContext ctx) {
|
||||||
return new ENull(location(ctx));
|
return new ENull(line(ctx), location(ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -390,7 +394,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EChain(location(ctx), links, false, true, operation, null);
|
return new EChain(line(ctx), location(ctx), links, false, true, operation, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -408,7 +412,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EChain(location(ctx), links, true, false, operation, null);
|
return new EChain(line(ctx), location(ctx), links, true, false, operation, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -417,7 +421,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
|
|
||||||
visitChain(ctx.chain(), links);
|
visitChain(ctx.chain(), links);
|
||||||
|
|
||||||
return new EChain(location(ctx), links, false, false, null, null);
|
return new EChain(line(ctx), location(ctx), links, false, false, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -439,13 +443,13 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EUnary(location(ctx), operation, (AExpression)visit(ctx.expression()));
|
return new EUnary(line(ctx), location(ctx), operation, (AExpression)visit(ctx.expression()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ANode visitCast(final CastContext ctx) {
|
public ANode visitCast(final CastContext ctx) {
|
||||||
return new EExplicit(location(ctx), ctx.decltype().getText(), (AExpression)visit(ctx.expression()));
|
return new EExplicit(line(ctx), location(ctx), ctx.decltype().getText(), (AExpression)visit(ctx.expression()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -480,7 +484,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EBinary(location(ctx), operation, left, right);
|
return new EBinary(line(ctx), location(ctx), operation, left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -509,7 +513,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EComp(location(ctx), operation, left, right);
|
return new EComp(line(ctx), location(ctx), operation, left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -526,7 +530,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EBool(location(ctx), operation, left, right);
|
return new EBool(line(ctx), location(ctx), operation, left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -536,7 +540,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
final AExpression left = (AExpression)visit(ctx.expression(1));
|
final AExpression left = (AExpression)visit(ctx.expression(1));
|
||||||
final AExpression right = (AExpression)visit(ctx.expression(2));
|
final AExpression right = (AExpression)visit(ctx.expression(2));
|
||||||
|
|
||||||
return new EConditional(location(ctx), condition, left, right);
|
return new EConditional(line(ctx), location(ctx), condition, left, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -572,7 +576,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
operation = null;
|
operation = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EChain(location(ctx), links, false, false, operation, (AExpression)visit(ctx.expression()));
|
return new EChain(line(ctx), location(ctx), links, false, false, operation, (AExpression)visit(ctx.expression()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void visitChain(final ChainContext ctx, final List<ALink> links) {
|
private void visitChain(final ChainContext ctx, final List<ALink> links) {
|
||||||
@ -638,7 +642,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
||||||
}
|
}
|
||||||
|
|
||||||
links.add(new LCast(location(ctx), ctx.decltype().getText()));
|
links.add(new LCast(line(ctx), location(ctx), ctx.decltype().getText()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -647,7 +651,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void visitLinkbrace(final LinkbraceContext ctx, final List<ALink> links) {
|
private void visitLinkbrace(final LinkbraceContext ctx, final List<ALink> links) {
|
||||||
links.add(new LBrace(location(ctx), (AExpression)visit(ctx.expression())));
|
links.add(new LBrace(line(ctx), location(ctx), (AExpression)visit(ctx.expression())));
|
||||||
|
|
||||||
if (ctx.linkbrace() != null) {
|
if (ctx.linkbrace() != null) {
|
||||||
visitLinkbrace(ctx.linkbrace(), links);
|
visitLinkbrace(ctx.linkbrace(), links);
|
||||||
@ -681,7 +685,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
arguments.add((AExpression)visit(expression));
|
arguments.add((AExpression)visit(expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
links.add(new LCall(location(ctx), ctx.EXTID().getText(), arguments));
|
links.add(new LCall(line(ctx), location(ctx), ctx.EXTID().getText(), arguments));
|
||||||
|
|
||||||
if (ctx.linkbrace() != null) {
|
if (ctx.linkbrace() != null) {
|
||||||
visitLinkbrace(ctx.linkbrace(), links);
|
visitLinkbrace(ctx.linkbrace(), links);
|
||||||
@ -700,7 +704,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
|
|
||||||
reserved.markReserved(name);
|
reserved.markReserved(name);
|
||||||
|
|
||||||
links.add(new LVariable(location(ctx), name));
|
links.add(new LVariable(line(ctx), location(ctx), name));
|
||||||
|
|
||||||
if (ctx.linkbrace() != null) {
|
if (ctx.linkbrace() != null) {
|
||||||
visitLinkbrace(ctx.linkbrace(), links);
|
visitLinkbrace(ctx.linkbrace(), links);
|
||||||
@ -725,7 +729,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
||||||
}
|
}
|
||||||
|
|
||||||
links.add(new LField(location(ctx), value));
|
links.add(new LField(line(ctx), location(ctx), value));
|
||||||
|
|
||||||
if (ctx.linkbrace() != null) {
|
if (ctx.linkbrace() != null) {
|
||||||
visitLinkbrace(ctx.linkbrace(), links);
|
visitLinkbrace(ctx.linkbrace(), links);
|
||||||
@ -747,13 +751,13 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
arguments.add((AExpression)visit(expression));
|
arguments.add((AExpression)visit(expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
links.add(new LNewObj(location(ctx), ctx.identifier().getText(), arguments));
|
links.add(new LNewObj(line(ctx), location(ctx), ctx.identifier().getText(), arguments));
|
||||||
} else if (ctx.expression().size() > 0) {
|
} else if (ctx.expression().size() > 0) {
|
||||||
for (final ExpressionContext expression : ctx.expression()) {
|
for (final ExpressionContext expression : ctx.expression()) {
|
||||||
arguments.add((AExpression)visit(expression));
|
arguments.add((AExpression)visit(expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
links.add(new LNewArray(location(ctx), ctx.identifier().getText(), arguments));
|
links.add(new LNewArray(line(ctx), location(ctx), ctx.identifier().getText(), arguments));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
||||||
}
|
}
|
||||||
@ -769,7 +773,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void visitLinkstring(final LinkstringContext ctx, final List<ALink> links) {
|
private void visitLinkstring(final LinkstringContext ctx, final List<ALink> links) {
|
||||||
links.add(new LString(location(ctx), ctx.STRING().getText().substring(1, ctx.STRING().getText().length() - 1)));
|
links.add(new LString(line(ctx), location(ctx), ctx.STRING().getText().substring(1, ctx.STRING().getText().length() - 1)));
|
||||||
|
|
||||||
if (ctx.linkbrace() != null) {
|
if (ctx.linkbrace() != null) {
|
||||||
visitLinkbrace(ctx.linkbrace(), links);
|
visitLinkbrace(ctx.linkbrace(), links);
|
||||||
|
@ -94,8 +94,8 @@ public abstract class AExpression extends ANode {
|
|||||||
*/
|
*/
|
||||||
protected Label fals = null;
|
protected Label fals = null;
|
||||||
|
|
||||||
public AExpression(final String location) {
|
public AExpression(final int line, final String location) {
|
||||||
super(location);
|
super(line, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,7 +120,7 @@ public abstract class AExpression extends ANode {
|
|||||||
if (constant == null || this instanceof EConstant) {
|
if (constant == null || this instanceof EConstant) {
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
final EConstant econstant = new EConstant(location, constant);
|
final EConstant econstant = new EConstant(line, location, constant);
|
||||||
econstant.analyze(settings, definition, variables);
|
econstant.analyze(settings, definition, variables);
|
||||||
|
|
||||||
if (!expected.equals(econstant.actual)) {
|
if (!expected.equals(econstant.actual)) {
|
||||||
@ -131,7 +131,7 @@ public abstract class AExpression extends ANode {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (constant == null) {
|
if (constant == null) {
|
||||||
final ECast ecast = new ECast(location, this, cast);
|
final ECast ecast = new ECast(line, location, this, cast);
|
||||||
ecast.statement = statement;
|
ecast.statement = statement;
|
||||||
ecast.actual = expected;
|
ecast.actual = expected;
|
||||||
ecast.isNull = isNull;
|
ecast.isNull = isNull;
|
||||||
@ -141,7 +141,7 @@ public abstract class AExpression extends ANode {
|
|||||||
if (expected.sort.constant) {
|
if (expected.sort.constant) {
|
||||||
constant = AnalyzerCaster.constCast(location, constant, cast);
|
constant = AnalyzerCaster.constCast(location, constant, cast);
|
||||||
|
|
||||||
final EConstant econstant = new EConstant(location, constant);
|
final EConstant econstant = new EConstant(line, location, constant);
|
||||||
econstant.analyze(settings, definition, variables);
|
econstant.analyze(settings, definition, variables);
|
||||||
|
|
||||||
if (!expected.equals(econstant.actual)) {
|
if (!expected.equals(econstant.actual)) {
|
||||||
@ -150,19 +150,19 @@ public abstract class AExpression extends ANode {
|
|||||||
|
|
||||||
return econstant;
|
return econstant;
|
||||||
} else if (this instanceof EConstant) {
|
} else if (this instanceof EConstant) {
|
||||||
final ECast ecast = new ECast(location, this, cast);
|
final ECast ecast = new ECast(line, location, this, cast);
|
||||||
ecast.actual = expected;
|
ecast.actual = expected;
|
||||||
|
|
||||||
return ecast;
|
return ecast;
|
||||||
} else {
|
} else {
|
||||||
final EConstant econstant = new EConstant(location, constant);
|
final EConstant econstant = new EConstant(line, location, constant);
|
||||||
econstant.analyze(settings, definition, variables);
|
econstant.analyze(settings, definition, variables);
|
||||||
|
|
||||||
if (!actual.equals(econstant.actual)) {
|
if (!actual.equals(econstant.actual)) {
|
||||||
throw new IllegalStateException(error("Illegal tree structure."));
|
throw new IllegalStateException(error("Illegal tree structure."));
|
||||||
}
|
}
|
||||||
|
|
||||||
final ECast ecast = new ECast(location, econstant, cast);
|
final ECast ecast = new ECast(line, location, econstant, cast);
|
||||||
ecast.actual = expected;
|
ecast.actual = expected;
|
||||||
|
|
||||||
return ecast;
|
return ecast;
|
||||||
|
@ -75,8 +75,8 @@ public abstract class ALink extends ANode {
|
|||||||
*/
|
*/
|
||||||
String string = null;
|
String string = null;
|
||||||
|
|
||||||
ALink(final String location, final int size) {
|
ALink(final int line, final String location, final int size) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,18 @@ package org.elasticsearch.painless.node;
|
|||||||
*/
|
*/
|
||||||
public abstract class ANode {
|
public abstract class ANode {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The line number in the original source used for debug messages.
|
||||||
|
*/
|
||||||
|
final int line;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location in the original source to be printed in error messages.
|
* The location in the original source to be printed in error messages.
|
||||||
*/
|
*/
|
||||||
final String location;
|
final String location;
|
||||||
|
|
||||||
ANode(final String location) {
|
ANode(final int line, final String location) {
|
||||||
|
this.line = line;
|
||||||
this.location = location;
|
this.location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +109,8 @@ public abstract class AStatement extends ANode {
|
|||||||
*/
|
*/
|
||||||
Label brake = null;
|
Label brake = null;
|
||||||
|
|
||||||
AStatement(final String location) {
|
AStatement(final int line, final String location) {
|
||||||
super(location);
|
super(line, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,8 +40,8 @@ public final class EBinary extends AExpression {
|
|||||||
|
|
||||||
boolean cat = false;
|
boolean cat = false;
|
||||||
|
|
||||||
public EBinary(final String location, final Operation operation, final AExpression left, final AExpression right) {
|
public EBinary(final int line, final String location, final Operation operation, final AExpression left, final AExpression right) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
this.left = left;
|
this.left = left;
|
||||||
|
@ -35,8 +35,8 @@ public final class EBool extends AExpression {
|
|||||||
AExpression left;
|
AExpression left;
|
||||||
AExpression right;
|
AExpression right;
|
||||||
|
|
||||||
public EBool(final String location, final Operation operation, final AExpression left, final AExpression right) {
|
public EBool(final int line, final String location, final Operation operation, final AExpression left, final AExpression right) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
this.left = left;
|
this.left = left;
|
||||||
|
@ -29,8 +29,8 @@ import org.objectweb.asm.commons.GeneratorAdapter;
|
|||||||
*/
|
*/
|
||||||
public final class EBoolean extends AExpression {
|
public final class EBoolean extends AExpression {
|
||||||
|
|
||||||
public EBoolean(final String location, final boolean constant) {
|
public EBoolean(final int line, final String location, final boolean constant) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.constant = constant;
|
this.constant = constant;
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ final class ECast extends AExpression {
|
|||||||
|
|
||||||
Cast cast = null;
|
Cast cast = null;
|
||||||
|
|
||||||
ECast(final String location, final AExpression child, final Cast cast) {
|
ECast(final int line, final String location, final AExpression child, final Cast cast) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.type = null;
|
this.type = null;
|
||||||
this.child = child;
|
this.child = child;
|
||||||
|
@ -49,9 +49,9 @@ public final class EChain extends AExpression {
|
|||||||
Cast there = null;
|
Cast there = null;
|
||||||
Cast back = null;
|
Cast back = null;
|
||||||
|
|
||||||
public EChain(final String location, final List<ALink> links,
|
public EChain(final int line, final String location, final List<ALink> links,
|
||||||
final boolean pre, final boolean post, final Operation operation, final AExpression expression) {
|
final boolean pre, final boolean post, final Operation operation, final AExpression expression) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.links = links;
|
this.links = links;
|
||||||
this.pre = pre;
|
this.pre = pre;
|
||||||
@ -127,25 +127,25 @@ public final class EChain extends AExpression {
|
|||||||
|
|
||||||
if (operation == Operation.INCR) {
|
if (operation == Operation.INCR) {
|
||||||
if (sort == Sort.DOUBLE) {
|
if (sort == Sort.DOUBLE) {
|
||||||
expression = new EConstant(location, 1D);
|
expression = new EConstant(line, location, 1D);
|
||||||
} else if (sort == Sort.FLOAT) {
|
} else if (sort == Sort.FLOAT) {
|
||||||
expression = new EConstant(location, 1F);
|
expression = new EConstant(line, location, 1F);
|
||||||
} else if (sort == Sort.LONG) {
|
} else if (sort == Sort.LONG) {
|
||||||
expression = new EConstant(location, 1L);
|
expression = new EConstant(line, location, 1L);
|
||||||
} else {
|
} else {
|
||||||
expression = new EConstant(location, 1);
|
expression = new EConstant(line, location, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
operation = Operation.ADD;
|
operation = Operation.ADD;
|
||||||
} else if (operation == Operation.DECR) {
|
} else if (operation == Operation.DECR) {
|
||||||
if (sort == Sort.DOUBLE) {
|
if (sort == Sort.DOUBLE) {
|
||||||
expression = new EConstant(location, 1D);
|
expression = new EConstant(line, location, 1D);
|
||||||
} else if (sort == Sort.FLOAT) {
|
} else if (sort == Sort.FLOAT) {
|
||||||
expression = new EConstant(location, 1F);
|
expression = new EConstant(line, location, 1F);
|
||||||
} else if (sort == Sort.LONG) {
|
} else if (sort == Sort.LONG) {
|
||||||
expression = new EConstant(location, 1L);
|
expression = new EConstant(line, location, 1L);
|
||||||
} else {
|
} else {
|
||||||
expression = new EConstant(location, 1);
|
expression = new EConstant(line, location, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
operation = Operation.SUB;
|
operation = Operation.SUB;
|
||||||
|
@ -45,8 +45,8 @@ public final class EComp extends AExpression {
|
|||||||
AExpression left;
|
AExpression left;
|
||||||
AExpression right;
|
AExpression right;
|
||||||
|
|
||||||
public EComp(final String location, final Operation operation, final AExpression left, final AExpression right) {
|
public EComp(final int line, final String location, final Operation operation, final AExpression left, final AExpression right) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
this.left = left;
|
this.left = left;
|
||||||
|
@ -36,8 +36,9 @@ public final class EConditional extends AExpression {
|
|||||||
AExpression left;
|
AExpression left;
|
||||||
AExpression right;
|
AExpression right;
|
||||||
|
|
||||||
public EConditional(final String location, final AExpression condition, final AExpression left, final AExpression right) {
|
public EConditional(final int line, final String location,
|
||||||
super(location);
|
final AExpression condition, final AExpression left, final AExpression right) {
|
||||||
|
super(line, location);
|
||||||
|
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
this.left = left;
|
this.left = left;
|
||||||
|
@ -32,8 +32,8 @@ import org.objectweb.asm.commons.GeneratorAdapter;
|
|||||||
*/
|
*/
|
||||||
final class EConstant extends AExpression {
|
final class EConstant extends AExpression {
|
||||||
|
|
||||||
EConstant(final String location, final Object constant) {
|
EConstant(final int line, final String location, final Object constant) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.constant = constant;
|
this.constant = constant;
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,8 @@ public final class EDecimal extends AExpression {
|
|||||||
|
|
||||||
final String value;
|
final String value;
|
||||||
|
|
||||||
public EDecimal(final String location, final String value) {
|
public EDecimal(final int line, final String location, final String value) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,8 @@ public final class EExplicit extends AExpression {
|
|||||||
|
|
||||||
Cast cast = null;
|
Cast cast = null;
|
||||||
|
|
||||||
public EExplicit(final String location, final String type, final AExpression child) {
|
public EExplicit(final int line, final String location, final String type, final AExpression child) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.child = child;
|
this.child = child;
|
||||||
|
@ -30,8 +30,8 @@ import org.objectweb.asm.commons.GeneratorAdapter;
|
|||||||
*/
|
*/
|
||||||
public final class ENull extends AExpression {
|
public final class ENull extends AExpression {
|
||||||
|
|
||||||
public ENull(final String location) {
|
public ENull(final int line, final String location) {
|
||||||
super(location);
|
super(line, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,8 +33,8 @@ public final class ENumeric extends AExpression {
|
|||||||
final String value;
|
final String value;
|
||||||
int radix;
|
int radix;
|
||||||
|
|
||||||
public ENumeric(final String location, final String value, final int radix) {
|
public ENumeric(final int line, final String location, final String value, final int radix) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.radix = radix;
|
this.radix = radix;
|
||||||
|
@ -43,8 +43,8 @@ public final class EUnary extends AExpression {
|
|||||||
Operation operation;
|
Operation operation;
|
||||||
AExpression child;
|
AExpression child;
|
||||||
|
|
||||||
public EUnary(final String location, final Operation operation, final AExpression child) {
|
public EUnary(final int line, final String location, final Operation operation, final AExpression child) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
this.child = child;
|
this.child = child;
|
||||||
|
@ -31,8 +31,8 @@ public final class LArrayLength extends ALink {
|
|||||||
|
|
||||||
final String value;
|
final String value;
|
||||||
|
|
||||||
LArrayLength(final String location, final String value) {
|
LArrayLength(final int line, final String location, final String value) {
|
||||||
super(location, -1);
|
super(line, location, -1);
|
||||||
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,8 @@ public final class LBrace extends ALink {
|
|||||||
|
|
||||||
AExpression index;
|
AExpression index;
|
||||||
|
|
||||||
public LBrace(final String location, final AExpression index) {
|
public LBrace(final int line, final String location, final AExpression index) {
|
||||||
super(location, 2);
|
super(line, location, 2);
|
||||||
|
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
@ -58,12 +58,12 @@ public final class LBrace extends ALink {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
} else if (sort == Sort.DEF) {
|
} else if (sort == Sort.DEF) {
|
||||||
return new LDefArray(location, index).copy(this).analyze(settings, definition, variables);
|
return new LDefArray(line, location, index).copy(this).analyze(settings, definition, variables);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
before.clazz.asSubclass(Map.class);
|
before.clazz.asSubclass(Map.class);
|
||||||
|
|
||||||
return new LMapShortcut(location, index).copy(this).analyze(settings, definition, variables);
|
return new LMapShortcut(line, location, index).copy(this).analyze(settings, definition, variables);
|
||||||
} catch (final ClassCastException exception) {
|
} catch (final ClassCastException exception) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ public final class LBrace extends ALink {
|
|||||||
try {
|
try {
|
||||||
before.clazz.asSubclass(List.class);
|
before.clazz.asSubclass(List.class);
|
||||||
|
|
||||||
return new LListShortcut(location, index).copy(this).analyze(settings, definition, variables);
|
return new LListShortcut(line, location, index).copy(this).analyze(settings, definition, variables);
|
||||||
} catch (final ClassCastException exception) {
|
} catch (final ClassCastException exception) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ public final class LCall extends ALink {
|
|||||||
|
|
||||||
Method method = null;
|
Method method = null;
|
||||||
|
|
||||||
public LCall(final String location, final String name, final List<AExpression> arguments) {
|
public LCall(final int line, final String location, final String name, final List<AExpression> arguments) {
|
||||||
super(location, -1);
|
super(line, location, -1);
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.arguments = arguments;
|
this.arguments = arguments;
|
||||||
@ -80,7 +80,7 @@ public final class LCall extends ALink {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
} else if (before.sort == Definition.Sort.DEF) {
|
} else if (before.sort == Definition.Sort.DEF) {
|
||||||
final ALink link = new LDefCall(location, name, arguments);
|
final ALink link = new LDefCall(line, location, name, arguments);
|
||||||
link.copy(this);
|
link.copy(this);
|
||||||
|
|
||||||
return link.analyze(settings, definition, variables);
|
return link.analyze(settings, definition, variables);
|
||||||
|
@ -36,8 +36,8 @@ public final class LCast extends ALink {
|
|||||||
|
|
||||||
Cast cast = null;
|
Cast cast = null;
|
||||||
|
|
||||||
public LCast(final String location, final String type) {
|
public LCast(final int line, final String location, final String type) {
|
||||||
super(location, -1);
|
super(line, location, -1);
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ final class LDefArray extends ALink {
|
|||||||
|
|
||||||
AExpression index;
|
AExpression index;
|
||||||
|
|
||||||
LDefArray(final String location, final AExpression index) {
|
LDefArray(final int line, final String location, final AExpression index) {
|
||||||
super(location, 0);
|
super(line, location, 0);
|
||||||
|
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ final class LDefCall extends ALink {
|
|||||||
final String name;
|
final String name;
|
||||||
final List<AExpression> arguments;
|
final List<AExpression> arguments;
|
||||||
|
|
||||||
LDefCall(final String location, final String name, final List<AExpression> arguments) {
|
LDefCall(final int line, final String location, final String name, final List<AExpression> arguments) {
|
||||||
super(location, -1);
|
super(line, location, -1);
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.arguments = arguments;
|
this.arguments = arguments;
|
||||||
|
@ -36,8 +36,8 @@ final class LDefField extends ALink {
|
|||||||
|
|
||||||
final String value;
|
final String value;
|
||||||
|
|
||||||
LDefField(final String location, final String value) {
|
LDefField(final int line, final String location, final String value) {
|
||||||
super(location, 1);
|
super(line, location, 1);
|
||||||
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@ public final class LField extends ALink {
|
|||||||
|
|
||||||
Field field;
|
Field field;
|
||||||
|
|
||||||
public LField(final String location, final String value) {
|
public LField(final int line, final String location, final String value) {
|
||||||
super(location, 1);
|
super(line, location, 1);
|
||||||
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
@ -54,9 +54,9 @@ public final class LField extends ALink {
|
|||||||
final Sort sort = before.sort;
|
final Sort sort = before.sort;
|
||||||
|
|
||||||
if (sort == Sort.ARRAY) {
|
if (sort == Sort.ARRAY) {
|
||||||
return new LArrayLength(location, value).copy(this).analyze(settings, definition, variables);
|
return new LArrayLength(line, location, value).copy(this).analyze(settings, definition, variables);
|
||||||
} else if (sort == Sort.DEF) {
|
} else if (sort == Sort.DEF) {
|
||||||
return new LDefField(location, value).copy(this).analyze(settings, definition, variables);
|
return new LDefField(line, location, value).copy(this).analyze(settings, definition, variables);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Struct struct = before.struct;
|
final Struct struct = before.struct;
|
||||||
@ -77,15 +77,15 @@ public final class LField extends ALink {
|
|||||||
struct.methods.containsKey("set" + Character.toUpperCase(value.charAt(0)) + value.substring(1));
|
struct.methods.containsKey("set" + Character.toUpperCase(value.charAt(0)) + value.substring(1));
|
||||||
|
|
||||||
if (shortcut) {
|
if (shortcut) {
|
||||||
return new LShortcut(location, value).copy(this).analyze(settings, definition, variables);
|
return new LShortcut(line, location, value).copy(this).analyze(settings, definition, variables);
|
||||||
} else {
|
} else {
|
||||||
final EConstant index = new EConstant(location, value);
|
final EConstant index = new EConstant(line, location, value);
|
||||||
index.analyze(settings, definition, variables);
|
index.analyze(settings, definition, variables);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
before.clazz.asSubclass(Map.class);
|
before.clazz.asSubclass(Map.class);
|
||||||
|
|
||||||
return new LMapShortcut(location, index).copy(this).analyze(settings, definition, variables);
|
return new LMapShortcut(line, location, index).copy(this).analyze(settings, definition, variables);
|
||||||
} catch (final ClassCastException exception) {
|
} catch (final ClassCastException exception) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ public final class LField extends ALink {
|
|||||||
try {
|
try {
|
||||||
before.clazz.asSubclass(List.class);
|
before.clazz.asSubclass(List.class);
|
||||||
|
|
||||||
return new LListShortcut(location, index).copy(this).analyze(settings, definition, variables);
|
return new LListShortcut(line, location, index).copy(this).analyze(settings, definition, variables);
|
||||||
} catch (final ClassCastException exception) {
|
} catch (final ClassCastException exception) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ final class LListShortcut extends ALink {
|
|||||||
Method getter;
|
Method getter;
|
||||||
Method setter;
|
Method setter;
|
||||||
|
|
||||||
LListShortcut(final String location, final AExpression index) {
|
LListShortcut(final int line, final String location, final AExpression index) {
|
||||||
super(location, 2);
|
super(line, location, 2);
|
||||||
|
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ final class LMapShortcut extends ALink {
|
|||||||
Method getter;
|
Method getter;
|
||||||
Method setter;
|
Method setter;
|
||||||
|
|
||||||
LMapShortcut(final String location, final AExpression index) {
|
LMapShortcut(final int line, final String location, final AExpression index) {
|
||||||
super(location, 2);
|
super(line, location, 2);
|
||||||
|
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,8 @@ public final class LNewArray extends ALink {
|
|||||||
final String type;
|
final String type;
|
||||||
final List<AExpression> arguments;
|
final List<AExpression> arguments;
|
||||||
|
|
||||||
public LNewArray(final String location, final String type, final List<AExpression> arguments) {
|
public LNewArray(final int line, final String location, final String type, final List<AExpression> arguments) {
|
||||||
super(location, -1);
|
super(line, location, -1);
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.arguments = arguments;
|
this.arguments = arguments;
|
||||||
|
@ -39,8 +39,8 @@ public final class LNewObj extends ALink {
|
|||||||
|
|
||||||
Constructor constructor;
|
Constructor constructor;
|
||||||
|
|
||||||
public LNewObj(final String location, final String type, final List<AExpression> arguments) {
|
public LNewObj(final int line, final String location, final String type, final List<AExpression> arguments) {
|
||||||
super(location, -1);
|
super(line, location, -1);
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.arguments = arguments;
|
this.arguments = arguments;
|
||||||
|
@ -38,8 +38,8 @@ final class LShortcut extends ALink {
|
|||||||
Method getter = null;
|
Method getter = null;
|
||||||
Method setter = null;
|
Method setter = null;
|
||||||
|
|
||||||
LShortcut(final String location, final String value) {
|
LShortcut(final int line, final String location, final String value) {
|
||||||
super(location, 1);
|
super(line, location, 1);
|
||||||
|
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ import org.objectweb.asm.commons.GeneratorAdapter;
|
|||||||
*/
|
*/
|
||||||
public final class LString extends ALink {
|
public final class LString extends ALink {
|
||||||
|
|
||||||
public LString(final String location, final String string) {
|
public LString(final int line, final String location, final String string) {
|
||||||
super(location, -1);
|
super(line, location, -1);
|
||||||
|
|
||||||
this.string = string;
|
this.string = string;
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ public final class LVariable extends ALink {
|
|||||||
|
|
||||||
int slot;
|
int slot;
|
||||||
|
|
||||||
public LVariable(final String location, final String name) {
|
public LVariable(final int line, final String location, final String name) {
|
||||||
super(location, 0);
|
super(line, location, 0);
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ public final class SBlock extends AStatement {
|
|||||||
|
|
||||||
final List<AStatement> statements;
|
final List<AStatement> statements;
|
||||||
|
|
||||||
public SBlock(final String location, final List<AStatement> statements) {
|
public SBlock(final int line, final String location, final List<AStatement> statements) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.statements = Collections.unmodifiableList(statements);
|
this.statements = Collections.unmodifiableList(statements);
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ import org.objectweb.asm.commons.GeneratorAdapter;
|
|||||||
*/
|
*/
|
||||||
public final class SBreak extends AStatement {
|
public final class SBreak extends AStatement {
|
||||||
|
|
||||||
public SBreak(final String location) {
|
public SBreak(final int line, final String location) {
|
||||||
super(location);
|
super(line, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,8 +29,8 @@ import org.objectweb.asm.commons.GeneratorAdapter;
|
|||||||
*/
|
*/
|
||||||
public final class SContinue extends AStatement {
|
public final class SContinue extends AStatement {
|
||||||
|
|
||||||
public SContinue(final String location) {
|
public SContinue(final int line, final String location) {
|
||||||
super(location);
|
super(line, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,8 +34,8 @@ public final class SDeclBlock extends AStatement {
|
|||||||
|
|
||||||
final List<SDeclaration> declarations;
|
final List<SDeclaration> declarations;
|
||||||
|
|
||||||
public SDeclBlock(final String location, final List<SDeclaration> declarations) {
|
public SDeclBlock(final int line, final String location, final List<SDeclaration> declarations) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.declarations = Collections.unmodifiableList(declarations);
|
this.declarations = Collections.unmodifiableList(declarations);
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ public final class SDeclaration extends AStatement {
|
|||||||
|
|
||||||
Variable variable;
|
Variable variable;
|
||||||
|
|
||||||
public SDeclaration(final String location, final String type, final String name, final AExpression expression) {
|
public SDeclaration(final int line, final String location, final String type, final String name, final AExpression expression) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -34,8 +34,8 @@ public final class SDo extends AStatement {
|
|||||||
final AStatement block;
|
final AStatement block;
|
||||||
AExpression condition;
|
AExpression condition;
|
||||||
|
|
||||||
public SDo(final String location, final AStatement block, final AExpression condition) {
|
public SDo(final int line, final String location, final AStatement block, final AExpression condition) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
this.block = block;
|
this.block = block;
|
||||||
|
@ -33,8 +33,8 @@ public final class SExpression extends AStatement {
|
|||||||
|
|
||||||
AExpression expression;
|
AExpression expression;
|
||||||
|
|
||||||
public SExpression(final String location, final AExpression expression) {
|
public SExpression(final int line, final String location, final AExpression expression) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,9 @@ public final class SFor extends AStatement {
|
|||||||
AExpression afterthought;
|
AExpression afterthought;
|
||||||
final AStatement block;
|
final AStatement block;
|
||||||
|
|
||||||
public SFor(final String location,
|
public SFor(final int line, final String location,
|
||||||
final ANode initializer, final AExpression condition, final AExpression afterthought, final AStatement block) {
|
final ANode initializer, final AExpression condition, final AExpression afterthought, final AStatement block) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.initializer = initializer;
|
this.initializer = initializer;
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
|
@ -34,8 +34,9 @@ public final class SIfElse extends AStatement {
|
|||||||
final AStatement ifblock;
|
final AStatement ifblock;
|
||||||
final AStatement elseblock;
|
final AStatement elseblock;
|
||||||
|
|
||||||
public SIfElse(final String location, final AExpression condition, final AStatement ifblock, final AStatement elseblock) {
|
public SIfElse(final int line, final String location,
|
||||||
super(location);
|
final AExpression condition, final AStatement ifblock, final AStatement elseblock) {
|
||||||
|
super(line, location);
|
||||||
|
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
this.ifblock = ifblock;
|
this.ifblock = ifblock;
|
||||||
|
@ -31,8 +31,8 @@ public final class SReturn extends AStatement {
|
|||||||
|
|
||||||
AExpression expression;
|
AExpression expression;
|
||||||
|
|
||||||
public SReturn(final String location, final AExpression expression) {
|
public SReturn(final int line, final String location, final AExpression expression) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,8 @@ public final class SSource extends AStatement {
|
|||||||
|
|
||||||
final List<AStatement> statements;
|
final List<AStatement> statements;
|
||||||
|
|
||||||
public SSource(final String location, final List<AStatement> statements) {
|
public SSource(final int line, final String location, final List<AStatement> statements) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.statements = Collections.unmodifiableList(statements);
|
this.statements = Collections.unmodifiableList(statements);
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,8 @@ public final class SThrow extends AStatement {
|
|||||||
|
|
||||||
AExpression expression;
|
AExpression expression;
|
||||||
|
|
||||||
public SThrow(final String location, final AExpression expression) {
|
public SThrow(final int line, final String location, final AExpression expression) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ public final class STrap extends AStatement {
|
|||||||
Label end;
|
Label end;
|
||||||
Label exception;
|
Label exception;
|
||||||
|
|
||||||
public STrap(final String location, final String type, final String name, final AStatement block) {
|
public STrap(final int line, final String location, final String type, final String name, final AStatement block) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -36,8 +36,8 @@ public final class STry extends AStatement {
|
|||||||
final AStatement block;
|
final AStatement block;
|
||||||
final List<STrap> traps;
|
final List<STrap> traps;
|
||||||
|
|
||||||
public STry(final String location, final AStatement block, final List<STrap> traps) {
|
public STry(final int line, final String location, final AStatement block, final List<STrap> traps) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.block = block;
|
this.block = block;
|
||||||
this.traps = Collections.unmodifiableList(traps);
|
this.traps = Collections.unmodifiableList(traps);
|
||||||
|
@ -34,8 +34,8 @@ public final class SWhile extends AStatement {
|
|||||||
AExpression condition;
|
AExpression condition;
|
||||||
final AStatement block;
|
final AStatement block;
|
||||||
|
|
||||||
public SWhile(final String location, final AExpression condition, final AStatement block) {
|
public SWhile(final int line, final String location, final AExpression condition, final AStatement block) {
|
||||||
super(location);
|
super(line, location);
|
||||||
|
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
this.block = block;
|
this.block = block;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user