use of org.elasticsearch.painless.node.EAssignment in project elasticsearch by elastic.
the class Walker method visitPre.
@Override
public ANode visitPre(PreContext ctx) {
AExpression expression = (AExpression) visit(ctx.chain());
final Operation operation;
if (ctx.INCR() != null) {
operation = Operation.INCR;
} else if (ctx.DECR() != null) {
operation = Operation.DECR;
} else {
throw location(ctx).createError(new IllegalStateException("Illegal tree structure."));
}
return new EAssignment(location(ctx), expression, null, true, false, operation);
}
use of org.elasticsearch.painless.node.EAssignment in project elasticsearch by elastic.
the class Walker method visitPost.
@Override
public ANode visitPost(PostContext ctx) {
AExpression expression = (AExpression) visit(ctx.chain());
final Operation operation;
if (ctx.INCR() != null) {
operation = Operation.INCR;
} else if (ctx.DECR() != null) {
operation = Operation.DECR;
} else {
throw location(ctx).createError(new IllegalStateException("Illegal tree structure."));
}
return new EAssignment(location(ctx), expression, null, false, true, operation);
}
use of org.elasticsearch.painless.node.EAssignment in project elasticsearch by elastic.
the class Walker method visitAssignment.
@Override
public ANode visitAssignment(AssignmentContext ctx) {
AExpression lhs = (AExpression) visit(ctx.expression(0));
AExpression rhs = (AExpression) visit(ctx.expression(1));
final Operation operation;
if (ctx.ASSIGN() != null) {
operation = null;
} else if (ctx.AMUL() != null) {
operation = Operation.MUL;
} else if (ctx.ADIV() != null) {
operation = Operation.DIV;
} else if (ctx.AREM() != null) {
operation = Operation.REM;
} else if (ctx.AADD() != null) {
operation = Operation.ADD;
} else if (ctx.ASUB() != null) {
operation = Operation.SUB;
} else if (ctx.ALSH() != null) {
operation = Operation.LSH;
} else if (ctx.ARSH() != null) {
operation = Operation.RSH;
} else if (ctx.AUSH() != null) {
operation = Operation.USH;
} else if (ctx.AAND() != null) {
operation = Operation.BWAND;
} else if (ctx.AXOR() != null) {
operation = Operation.XOR;
} else if (ctx.AOR() != null) {
operation = Operation.BWOR;
} else {
throw location(ctx).createError(new IllegalStateException("Illegal tree structure."));
}
return new EAssignment(location(ctx), lhs, rhs, false, false, operation);
}
Aggregations