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();
|
||||
}
|
||||
|
||||
private int line(final ParserRuleContext ctx) {
|
||||
return ctx.getStart().getLine();
|
||||
}
|
||||
|
||||
private String location(final ParserRuleContext ctx) {
|
||||
return "[ " + ctx.getStart().getLine() + " : " + ctx.getStart().getCharPositionInLine() + " ]";
|
||||
}
|
||||
|
@ -158,7 +162,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
statements.add((AStatement)visit(statement));
|
||||
}
|
||||
|
||||
return new SSource(location(ctx), statements);
|
||||
return new SSource(line(ctx), location(ctx), statements);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -167,7 +171,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
final AStatement ifblock = (AStatement)visit(ctx.block(0));
|
||||
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
|
||||
|
@ -177,7 +181,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
|
||||
reserved.usesLoop();
|
||||
|
||||
return new SWhile(location(ctx), condition, block);
|
||||
return new SWhile(line(ctx), location(ctx), condition, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -187,7 +191,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
|
||||
reserved.usesLoop();
|
||||
|
||||
return new SDo(location(ctx), block, condition);
|
||||
return new SDo(line(ctx), location(ctx), block, condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -199,7 +203,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
|
||||
reserved.usesLoop();
|
||||
|
||||
return new SFor(location(ctx), intializer, condition, afterthought, block);
|
||||
return new SFor(line(ctx), location(ctx), intializer, condition, afterthought, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -209,19 +213,19 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
|
||||
@Override
|
||||
public ANode visitContinue(final ContinueContext ctx) {
|
||||
return new SContinue(location(ctx));
|
||||
return new SContinue(line(ctx), location(ctx));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ANode visitBreak(final BreakContext ctx) {
|
||||
return new SBreak(location(ctx));
|
||||
return new SBreak(line(ctx), location(ctx));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ANode visitReturn(final ReturnContext ctx) {
|
||||
final AExpression expression = (AExpression)visit(ctx.expression());
|
||||
|
||||
return new SReturn(location(ctx), expression);
|
||||
return new SReturn(line(ctx), location(ctx), expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -233,21 +237,21 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
traps.add((STrap)visit(trap));
|
||||
}
|
||||
|
||||
return new STry(location(ctx), block, traps);
|
||||
return new STry(line(ctx), location(ctx), block, traps);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ANode visitThrow(final ThrowContext ctx) {
|
||||
final AExpression expression = (AExpression)visit(ctx.expression());
|
||||
|
||||
return new SThrow(location(ctx), expression);
|
||||
return new SThrow(line(ctx), location(ctx), expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ANode visitExpr(final ExprContext ctx) {
|
||||
final AExpression expression = (AExpression)visit(ctx.expression());
|
||||
|
||||
return new SExpression(location(ctx), expression);
|
||||
return new SExpression(line(ctx), location(ctx), expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -258,7 +262,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
statements.add((AStatement)visit(statement));
|
||||
}
|
||||
|
||||
return new SBlock(location(ctx), statements);
|
||||
return new SBlock(line(ctx), location(ctx), statements);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -266,7 +270,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
final List<AStatement> statements = new ArrayList<>();
|
||||
statements.add((AStatement)visit(ctx.statement()));
|
||||
|
||||
return new SBlock(location(ctx), statements);
|
||||
return new SBlock(line(ctx), location(ctx), statements);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -303,10 +307,10 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
for (final DeclvarContext declvar : ctx.declvar()) {
|
||||
final String name = declvar.identifier().getText();
|
||||
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
|
||||
|
@ -325,7 +329,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
final String name = ctx.identifier(1).getText();
|
||||
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
|
||||
|
@ -348,13 +352,13 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
final boolean negate = ctx.parent instanceof UnaryContext && ((UnaryContext)ctx.parent).SUB() != 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) {
|
||||
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) {
|
||||
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) {
|
||||
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 {
|
||||
throw new IllegalStateException("Error " + location(ctx) + ": Unexpected state.");
|
||||
}
|
||||
|
@ -362,17 +366,17 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
|
||||
@Override
|
||||
public ANode visitTrue(final TrueContext ctx) {
|
||||
return new EBoolean(location(ctx), true);
|
||||
return new EBoolean(line(ctx), location(ctx), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ANode visitFalse(FalseContext ctx) {
|
||||
return new EBoolean(location(ctx), false);
|
||||
return new EBoolean(line(ctx), location(ctx), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ANode visitNull(final NullContext ctx) {
|
||||
return new ENull(location(ctx));
|
||||
return new ENull(line(ctx), location(ctx));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -390,7 +394,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
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
|
||||
|
@ -408,7 +412,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
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
|
||||
|
@ -417,7 +421,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
|
||||
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
|
||||
|
@ -439,13 +443,13 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
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
|
||||
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
|
||||
|
@ -480,7 +484,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
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
|
||||
|
@ -509,7 +513,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
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
|
||||
|
@ -526,7 +530,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
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 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
|
||||
|
@ -572,7 +576,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
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) {
|
||||
|
@ -638,7 +642,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
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
|
||||
|
@ -647,7 +651,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
}
|
||||
|
||||
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) {
|
||||
visitLinkbrace(ctx.linkbrace(), links);
|
||||
|
@ -681,7 +685,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
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) {
|
||||
visitLinkbrace(ctx.linkbrace(), links);
|
||||
|
@ -700,7 +704,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
|
||||
reserved.markReserved(name);
|
||||
|
||||
links.add(new LVariable(location(ctx), name));
|
||||
links.add(new LVariable(line(ctx), location(ctx), name));
|
||||
|
||||
if (ctx.linkbrace() != null) {
|
||||
visitLinkbrace(ctx.linkbrace(), links);
|
||||
|
@ -725,7 +729,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
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) {
|
||||
visitLinkbrace(ctx.linkbrace(), links);
|
||||
|
@ -747,13 +751,13 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
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) {
|
||||
for (final ExpressionContext expression : ctx.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 {
|
||||
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) {
|
||||
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) {
|
||||
visitLinkbrace(ctx.linkbrace(), links);
|
||||
|
|
|
@ -94,8 +94,8 @@ public abstract class AExpression extends ANode {
|
|||
*/
|
||||
protected Label fals = null;
|
||||
|
||||
public AExpression(final String location) {
|
||||
super(location);
|
||||
public AExpression(final int line, final String location) {
|
||||
super(line, location);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,7 +120,7 @@ public abstract class AExpression extends ANode {
|
|||
if (constant == null || this instanceof EConstant) {
|
||||
return this;
|
||||
} else {
|
||||
final EConstant econstant = new EConstant(location, constant);
|
||||
final EConstant econstant = new EConstant(line, location, constant);
|
||||
econstant.analyze(settings, definition, variables);
|
||||
|
||||
if (!expected.equals(econstant.actual)) {
|
||||
|
@ -131,7 +131,7 @@ public abstract class AExpression extends ANode {
|
|||
}
|
||||
} else {
|
||||
if (constant == null) {
|
||||
final ECast ecast = new ECast(location, this, cast);
|
||||
final ECast ecast = new ECast(line, location, this, cast);
|
||||
ecast.statement = statement;
|
||||
ecast.actual = expected;
|
||||
ecast.isNull = isNull;
|
||||
|
@ -141,7 +141,7 @@ public abstract class AExpression extends ANode {
|
|||
if (expected.sort.constant) {
|
||||
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);
|
||||
|
||||
if (!expected.equals(econstant.actual)) {
|
||||
|
@ -150,19 +150,19 @@ public abstract class AExpression extends ANode {
|
|||
|
||||
return 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;
|
||||
|
||||
return ecast;
|
||||
} else {
|
||||
final EConstant econstant = new EConstant(location, constant);
|
||||
final EConstant econstant = new EConstant(line, location, constant);
|
||||
econstant.analyze(settings, definition, variables);
|
||||
|
||||
if (!actual.equals(econstant.actual)) {
|
||||
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;
|
||||
|
||||
return ecast;
|
||||
|
|
|
@ -75,8 +75,8 @@ public abstract class ALink extends ANode {
|
|||
*/
|
||||
String string = null;
|
||||
|
||||
ALink(final String location, final int size) {
|
||||
super(location);
|
||||
ALink(final int line, final String location, final int size) {
|
||||
super(line, location);
|
||||
|
||||
this.size = size;
|
||||
}
|
||||
|
|
|
@ -24,12 +24,18 @@ package org.elasticsearch.painless.node;
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
final String location;
|
||||
|
||||
ANode(final String location) {
|
||||
ANode(final int line, final String location) {
|
||||
this.line = line;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,8 +109,8 @@ public abstract class AStatement extends ANode {
|
|||
*/
|
||||
Label brake = null;
|
||||
|
||||
AStatement(final String location) {
|
||||
super(location);
|
||||
AStatement(final int line, final String location) {
|
||||
super(line, location);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,8 +40,8 @@ public final class EBinary extends AExpression {
|
|||
|
||||
boolean cat = false;
|
||||
|
||||
public EBinary(final String location, final Operation operation, final AExpression left, final AExpression right) {
|
||||
super(location);
|
||||
public EBinary(final int line, final String location, final Operation operation, final AExpression left, final AExpression right) {
|
||||
super(line, location);
|
||||
|
||||
this.operation = operation;
|
||||
this.left = left;
|
||||
|
|
|
@ -35,8 +35,8 @@ public final class EBool extends AExpression {
|
|||
AExpression left;
|
||||
AExpression right;
|
||||
|
||||
public EBool(final String location, final Operation operation, final AExpression left, final AExpression right) {
|
||||
super(location);
|
||||
public EBool(final int line, final String location, final Operation operation, final AExpression left, final AExpression right) {
|
||||
super(line, location);
|
||||
|
||||
this.operation = operation;
|
||||
this.left = left;
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.objectweb.asm.commons.GeneratorAdapter;
|
|||
*/
|
||||
public final class EBoolean extends AExpression {
|
||||
|
||||
public EBoolean(final String location, final boolean constant) {
|
||||
super(location);
|
||||
public EBoolean(final int line, final String location, final boolean constant) {
|
||||
super(line, location);
|
||||
|
||||
this.constant = constant;
|
||||
}
|
||||
|
|
|
@ -37,8 +37,8 @@ final class ECast extends AExpression {
|
|||
|
||||
Cast cast = null;
|
||||
|
||||
ECast(final String location, final AExpression child, final Cast cast) {
|
||||
super(location);
|
||||
ECast(final int line, final String location, final AExpression child, final Cast cast) {
|
||||
super(line, location);
|
||||
|
||||
this.type = null;
|
||||
this.child = child;
|
||||
|
|
|
@ -49,9 +49,9 @@ public final class EChain extends AExpression {
|
|||
Cast there = 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) {
|
||||
super(location);
|
||||
super(line, location);
|
||||
|
||||
this.links = links;
|
||||
this.pre = pre;
|
||||
|
@ -127,25 +127,25 @@ public final class EChain extends AExpression {
|
|||
|
||||
if (operation == Operation.INCR) {
|
||||
if (sort == Sort.DOUBLE) {
|
||||
expression = new EConstant(location, 1D);
|
||||
expression = new EConstant(line, location, 1D);
|
||||
} else if (sort == Sort.FLOAT) {
|
||||
expression = new EConstant(location, 1F);
|
||||
expression = new EConstant(line, location, 1F);
|
||||
} else if (sort == Sort.LONG) {
|
||||
expression = new EConstant(location, 1L);
|
||||
expression = new EConstant(line, location, 1L);
|
||||
} else {
|
||||
expression = new EConstant(location, 1);
|
||||
expression = new EConstant(line, location, 1);
|
||||
}
|
||||
|
||||
operation = Operation.ADD;
|
||||
} else if (operation == Operation.DECR) {
|
||||
if (sort == Sort.DOUBLE) {
|
||||
expression = new EConstant(location, 1D);
|
||||
expression = new EConstant(line, location, 1D);
|
||||
} else if (sort == Sort.FLOAT) {
|
||||
expression = new EConstant(location, 1F);
|
||||
expression = new EConstant(line, location, 1F);
|
||||
} else if (sort == Sort.LONG) {
|
||||
expression = new EConstant(location, 1L);
|
||||
expression = new EConstant(line, location, 1L);
|
||||
} else {
|
||||
expression = new EConstant(location, 1);
|
||||
expression = new EConstant(line, location, 1);
|
||||
}
|
||||
|
||||
operation = Operation.SUB;
|
||||
|
|
|
@ -45,8 +45,8 @@ public final class EComp extends AExpression {
|
|||
AExpression left;
|
||||
AExpression right;
|
||||
|
||||
public EComp(final String location, final Operation operation, final AExpression left, final AExpression right) {
|
||||
super(location);
|
||||
public EComp(final int line, final String location, final Operation operation, final AExpression left, final AExpression right) {
|
||||
super(line, location);
|
||||
|
||||
this.operation = operation;
|
||||
this.left = left;
|
||||
|
|
|
@ -36,8 +36,9 @@ public final class EConditional extends AExpression {
|
|||
AExpression left;
|
||||
AExpression right;
|
||||
|
||||
public EConditional(final String location, final AExpression condition, final AExpression left, final AExpression right) {
|
||||
super(location);
|
||||
public EConditional(final int line, final String location,
|
||||
final AExpression condition, final AExpression left, final AExpression right) {
|
||||
super(line, location);
|
||||
|
||||
this.condition = condition;
|
||||
this.left = left;
|
||||
|
|
|
@ -32,8 +32,8 @@ import org.objectweb.asm.commons.GeneratorAdapter;
|
|||
*/
|
||||
final class EConstant extends AExpression {
|
||||
|
||||
EConstant(final String location, final Object constant) {
|
||||
super(location);
|
||||
EConstant(final int line, final String location, final Object constant) {
|
||||
super(line, location);
|
||||
|
||||
this.constant = constant;
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ public final class EDecimal extends AExpression {
|
|||
|
||||
final String value;
|
||||
|
||||
public EDecimal(final String location, final String value) {
|
||||
super(location);
|
||||
public EDecimal(final int line, final String location, final String value) {
|
||||
super(line, location);
|
||||
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ public final class EExplicit extends AExpression {
|
|||
|
||||
Cast cast = null;
|
||||
|
||||
public EExplicit(final String location, final String type, final AExpression child) {
|
||||
super(location);
|
||||
public EExplicit(final int line, final String location, final String type, final AExpression child) {
|
||||
super(line, location);
|
||||
|
||||
this.type = type;
|
||||
this.child = child;
|
||||
|
|
|
@ -30,8 +30,8 @@ import org.objectweb.asm.commons.GeneratorAdapter;
|
|||
*/
|
||||
public final class ENull extends AExpression {
|
||||
|
||||
public ENull(final String location) {
|
||||
super(location);
|
||||
public ENull(final int line, final String location) {
|
||||
super(line, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,8 +33,8 @@ public final class ENumeric extends AExpression {
|
|||
final String value;
|
||||
int radix;
|
||||
|
||||
public ENumeric(final String location, final String value, final int radix) {
|
||||
super(location);
|
||||
public ENumeric(final int line, final String location, final String value, final int radix) {
|
||||
super(line, location);
|
||||
|
||||
this.value = value;
|
||||
this.radix = radix;
|
||||
|
|
|
@ -43,8 +43,8 @@ public final class EUnary extends AExpression {
|
|||
Operation operation;
|
||||
AExpression child;
|
||||
|
||||
public EUnary(final String location, final Operation operation, final AExpression child) {
|
||||
super(location);
|
||||
public EUnary(final int line, final String location, final Operation operation, final AExpression child) {
|
||||
super(line, location);
|
||||
|
||||
this.operation = operation;
|
||||
this.child = child;
|
||||
|
|
|
@ -31,8 +31,8 @@ public final class LArrayLength extends ALink {
|
|||
|
||||
final String value;
|
||||
|
||||
LArrayLength(final String location, final String value) {
|
||||
super(location, -1);
|
||||
LArrayLength(final int line, final String location, final String value) {
|
||||
super(line, location, -1);
|
||||
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ public final class LBrace extends ALink {
|
|||
|
||||
AExpression index;
|
||||
|
||||
public LBrace(final String location, final AExpression index) {
|
||||
super(location, 2);
|
||||
public LBrace(final int line, final String location, final AExpression index) {
|
||||
super(line, location, 2);
|
||||
|
||||
this.index = index;
|
||||
}
|
||||
|
@ -58,12 +58,12 @@ public final class LBrace extends ALink {
|
|||
|
||||
return this;
|
||||
} 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 {
|
||||
try {
|
||||
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) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public final class LBrace extends ALink {
|
|||
try {
|
||||
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) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ public final class LCall extends ALink {
|
|||
|
||||
Method method = null;
|
||||
|
||||
public LCall(final String location, final String name, final List<AExpression> arguments) {
|
||||
super(location, -1);
|
||||
public LCall(final int line, final String location, final String name, final List<AExpression> arguments) {
|
||||
super(line, location, -1);
|
||||
|
||||
this.name = name;
|
||||
this.arguments = arguments;
|
||||
|
@ -80,7 +80,7 @@ public final class LCall extends ALink {
|
|||
|
||||
return this;
|
||||
} 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);
|
||||
|
||||
return link.analyze(settings, definition, variables);
|
||||
|
|
|
@ -36,8 +36,8 @@ public final class LCast extends ALink {
|
|||
|
||||
Cast cast = null;
|
||||
|
||||
public LCast(final String location, final String type) {
|
||||
super(location, -1);
|
||||
public LCast(final int line, final String location, final String type) {
|
||||
super(line, location, -1);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ final class LDefArray extends ALink {
|
|||
|
||||
AExpression index;
|
||||
|
||||
LDefArray(final String location, final AExpression index) {
|
||||
super(location, 0);
|
||||
LDefArray(final int line, final String location, final AExpression index) {
|
||||
super(line, location, 0);
|
||||
|
||||
this.index = index;
|
||||
}
|
||||
|
|
|
@ -37,8 +37,8 @@ final class LDefCall extends ALink {
|
|||
final String name;
|
||||
final List<AExpression> arguments;
|
||||
|
||||
LDefCall(final String location, final String name, final List<AExpression> arguments) {
|
||||
super(location, -1);
|
||||
LDefCall(final int line, final String location, final String name, final List<AExpression> arguments) {
|
||||
super(line, location, -1);
|
||||
|
||||
this.name = name;
|
||||
this.arguments = arguments;
|
||||
|
|
|
@ -36,8 +36,8 @@ final class LDefField extends ALink {
|
|||
|
||||
final String value;
|
||||
|
||||
LDefField(final String location, final String value) {
|
||||
super(location, 1);
|
||||
LDefField(final int line, final String location, final String value) {
|
||||
super(line, location, 1);
|
||||
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ public final class LField extends ALink {
|
|||
|
||||
Field field;
|
||||
|
||||
public LField(final String location, final String value) {
|
||||
super(location, 1);
|
||||
public LField(final int line, final String location, final String value) {
|
||||
super(line, location, 1);
|
||||
|
||||
this.value = value;
|
||||
}
|
||||
|
@ -54,9 +54,9 @@ public final class LField extends ALink {
|
|||
final Sort sort = before.sort;
|
||||
|
||||
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) {
|
||||
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;
|
||||
|
@ -77,15 +77,15 @@ public final class LField extends ALink {
|
|||
struct.methods.containsKey("set" + Character.toUpperCase(value.charAt(0)) + value.substring(1));
|
||||
|
||||
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 {
|
||||
final EConstant index = new EConstant(location, value);
|
||||
final EConstant index = new EConstant(line, location, value);
|
||||
index.analyze(settings, definition, variables);
|
||||
|
||||
try {
|
||||
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) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public final class LField extends ALink {
|
|||
try {
|
||||
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) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ final class LListShortcut extends ALink {
|
|||
Method getter;
|
||||
Method setter;
|
||||
|
||||
LListShortcut(final String location, final AExpression index) {
|
||||
super(location, 2);
|
||||
LListShortcut(final int line, final String location, final AExpression index) {
|
||||
super(line, location, 2);
|
||||
|
||||
this.index = index;
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ final class LMapShortcut extends ALink {
|
|||
Method getter;
|
||||
Method setter;
|
||||
|
||||
LMapShortcut(final String location, final AExpression index) {
|
||||
super(location, 2);
|
||||
LMapShortcut(final int line, final String location, final AExpression index) {
|
||||
super(line, location, 2);
|
||||
|
||||
this.index = index;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ public final class LNewArray extends ALink {
|
|||
final String type;
|
||||
final List<AExpression> arguments;
|
||||
|
||||
public LNewArray(final String location, final String type, final List<AExpression> arguments) {
|
||||
super(location, -1);
|
||||
public LNewArray(final int line, final String location, final String type, final List<AExpression> arguments) {
|
||||
super(line, location, -1);
|
||||
|
||||
this.type = type;
|
||||
this.arguments = arguments;
|
||||
|
|
|
@ -39,8 +39,8 @@ public final class LNewObj extends ALink {
|
|||
|
||||
Constructor constructor;
|
||||
|
||||
public LNewObj(final String location, final String type, final List<AExpression> arguments) {
|
||||
super(location, -1);
|
||||
public LNewObj(final int line, final String location, final String type, final List<AExpression> arguments) {
|
||||
super(line, location, -1);
|
||||
|
||||
this.type = type;
|
||||
this.arguments = arguments;
|
||||
|
|
|
@ -38,8 +38,8 @@ final class LShortcut extends ALink {
|
|||
Method getter = null;
|
||||
Method setter = null;
|
||||
|
||||
LShortcut(final String location, final String value) {
|
||||
super(location, 1);
|
||||
LShortcut(final int line, final String location, final String value) {
|
||||
super(line, location, 1);
|
||||
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.objectweb.asm.commons.GeneratorAdapter;
|
|||
*/
|
||||
public final class LString extends ALink {
|
||||
|
||||
public LString(final String location, final String string) {
|
||||
super(location, -1);
|
||||
public LString(final int line, final String location, final String string) {
|
||||
super(line, location, -1);
|
||||
|
||||
this.string = string;
|
||||
}
|
||||
|
|
|
@ -36,8 +36,8 @@ public final class LVariable extends ALink {
|
|||
|
||||
int slot;
|
||||
|
||||
public LVariable(final String location, final String name) {
|
||||
super(location, 0);
|
||||
public LVariable(final int line, final String location, final String name) {
|
||||
super(line, location, 0);
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ public final class SBlock extends AStatement {
|
|||
|
||||
final List<AStatement> statements;
|
||||
|
||||
public SBlock(final String location, final List<AStatement> statements) {
|
||||
super(location);
|
||||
public SBlock(final int line, final String location, final List<AStatement> statements) {
|
||||
super(line, location);
|
||||
|
||||
this.statements = Collections.unmodifiableList(statements);
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.objectweb.asm.commons.GeneratorAdapter;
|
|||
*/
|
||||
public final class SBreak extends AStatement {
|
||||
|
||||
public SBreak(final String location) {
|
||||
super(location);
|
||||
public SBreak(final int line, final String location) {
|
||||
super(line, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,8 +29,8 @@ import org.objectweb.asm.commons.GeneratorAdapter;
|
|||
*/
|
||||
public final class SContinue extends AStatement {
|
||||
|
||||
public SContinue(final String location) {
|
||||
super(location);
|
||||
public SContinue(final int line, final String location) {
|
||||
super(line, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,8 +34,8 @@ public final class SDeclBlock extends AStatement {
|
|||
|
||||
final List<SDeclaration> declarations;
|
||||
|
||||
public SDeclBlock(final String location, final List<SDeclaration> declarations) {
|
||||
super(location);
|
||||
public SDeclBlock(final int line, final String location, final List<SDeclaration> declarations) {
|
||||
super(line, location);
|
||||
|
||||
this.declarations = Collections.unmodifiableList(declarations);
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ public final class SDeclaration extends AStatement {
|
|||
|
||||
Variable variable;
|
||||
|
||||
public SDeclaration(final String location, final String type, final String name, final AExpression expression) {
|
||||
super(location);
|
||||
public SDeclaration(final int line, final String location, final String type, final String name, final AExpression expression) {
|
||||
super(line, location);
|
||||
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
|
|
|
@ -34,8 +34,8 @@ public final class SDo extends AStatement {
|
|||
final AStatement block;
|
||||
AExpression condition;
|
||||
|
||||
public SDo(final String location, final AStatement block, final AExpression condition) {
|
||||
super(location);
|
||||
public SDo(final int line, final String location, final AStatement block, final AExpression condition) {
|
||||
super(line, location);
|
||||
|
||||
this.condition = condition;
|
||||
this.block = block;
|
||||
|
|
|
@ -33,8 +33,8 @@ public final class SExpression extends AStatement {
|
|||
|
||||
AExpression expression;
|
||||
|
||||
public SExpression(final String location, final AExpression expression) {
|
||||
super(location);
|
||||
public SExpression(final int line, final String location, final AExpression expression) {
|
||||
super(line, location);
|
||||
|
||||
this.expression = expression;
|
||||
}
|
||||
|
|
|
@ -36,9 +36,9 @@ public final class SFor extends AStatement {
|
|||
AExpression afterthought;
|
||||
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) {
|
||||
super(location);
|
||||
super(line, location);
|
||||
|
||||
this.initializer = initializer;
|
||||
this.condition = condition;
|
||||
|
|
|
@ -34,8 +34,9 @@ public final class SIfElse extends AStatement {
|
|||
final AStatement ifblock;
|
||||
final AStatement elseblock;
|
||||
|
||||
public SIfElse(final String location, final AExpression condition, final AStatement ifblock, final AStatement elseblock) {
|
||||
super(location);
|
||||
public SIfElse(final int line, final String location,
|
||||
final AExpression condition, final AStatement ifblock, final AStatement elseblock) {
|
||||
super(line, location);
|
||||
|
||||
this.condition = condition;
|
||||
this.ifblock = ifblock;
|
||||
|
|
|
@ -31,8 +31,8 @@ public final class SReturn extends AStatement {
|
|||
|
||||
AExpression expression;
|
||||
|
||||
public SReturn(final String location, final AExpression expression) {
|
||||
super(location);
|
||||
public SReturn(final int line, final String location, final AExpression expression) {
|
||||
super(line, location);
|
||||
|
||||
this.expression = expression;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ public final class SSource extends AStatement {
|
|||
|
||||
final List<AStatement> statements;
|
||||
|
||||
public SSource(final String location, final List<AStatement> statements) {
|
||||
super(location);
|
||||
public SSource(final int line, final String location, final List<AStatement> statements) {
|
||||
super(line, location);
|
||||
|
||||
this.statements = Collections.unmodifiableList(statements);
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ public final class SThrow extends AStatement {
|
|||
|
||||
AExpression expression;
|
||||
|
||||
public SThrow(final String location, final AExpression expression) {
|
||||
super(location);
|
||||
public SThrow(final int line, final String location, final AExpression expression) {
|
||||
super(line, location);
|
||||
|
||||
this.expression = expression;
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ public final class STrap extends AStatement {
|
|||
Label end;
|
||||
Label exception;
|
||||
|
||||
public STrap(final String location, final String type, final String name, final AStatement block) {
|
||||
super(location);
|
||||
public STrap(final int line, final String location, final String type, final String name, final AStatement block) {
|
||||
super(line, location);
|
||||
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
|
|
|
@ -36,8 +36,8 @@ public final class STry extends AStatement {
|
|||
final AStatement block;
|
||||
final List<STrap> traps;
|
||||
|
||||
public STry(final String location, final AStatement block, final List<STrap> traps) {
|
||||
super(location);
|
||||
public STry(final int line, final String location, final AStatement block, final List<STrap> traps) {
|
||||
super(line, location);
|
||||
|
||||
this.block = block;
|
||||
this.traps = Collections.unmodifiableList(traps);
|
||||
|
|
|
@ -34,8 +34,8 @@ public final class SWhile extends AStatement {
|
|||
AExpression condition;
|
||||
final AStatement block;
|
||||
|
||||
public SWhile(final String location, final AExpression condition, final AStatement block) {
|
||||
super(location);
|
||||
public SWhile(final int line, final String location, final AExpression condition, final AStatement block) {
|
||||
super(line, location);
|
||||
|
||||
this.condition = condition;
|
||||
this.block = block;
|
||||
|
|
Loading…
Reference in New Issue