use of org.elasticsearch.painless.node.AExpression 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.AExpression in project elasticsearch by elastic.
the class Walker method visitBinary.
@Override
public ANode visitBinary(BinaryContext ctx) {
AExpression left = (AExpression) visit(ctx.expression(0));
AExpression right = (AExpression) visit(ctx.expression(1));
final Operation operation;
if (ctx.MUL() != null) {
operation = Operation.MUL;
} else if (ctx.DIV() != null) {
operation = Operation.DIV;
} else if (ctx.REM() != null) {
operation = Operation.REM;
} else if (ctx.ADD() != null) {
operation = Operation.ADD;
} else if (ctx.SUB() != null) {
operation = Operation.SUB;
} else if (ctx.FIND() != null) {
operation = Operation.FIND;
} else if (ctx.MATCH() != null) {
operation = Operation.MATCH;
} else if (ctx.LSH() != null) {
operation = Operation.LSH;
} else if (ctx.RSH() != null) {
operation = Operation.RSH;
} else if (ctx.USH() != null) {
operation = Operation.USH;
} else if (ctx.BWAND() != null) {
operation = Operation.BWAND;
} else if (ctx.XOR() != null) {
operation = Operation.XOR;
} else if (ctx.BWOR() != null) {
operation = Operation.BWOR;
} else {
throw location(ctx).createError(new IllegalStateException("Illegal tree structure."));
}
return new EBinary(location(ctx), operation, left, right);
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitIf.
@Override
public ANode visitIf(IfContext ctx) {
AExpression expression = (AExpression) visit(ctx.expression());
SBlock ifblock = (SBlock) visit(ctx.trailer(0));
if (ctx.trailer().size() > 1) {
SBlock elseblock = (SBlock) visit(ctx.trailer(1));
return new SIfElse(location(ctx), expression, ifblock, elseblock);
} else {
return new SIf(location(ctx), expression, ifblock);
}
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitIneach.
@Override
public ANode visitIneach(IneachContext ctx) {
reserved.peek().setMaxLoopCounter(settings.getMaxLoopCounter());
String name = ctx.ID().getText();
AExpression expression = (AExpression) visit(ctx.expression());
SBlock block = (SBlock) visit(ctx.trailer());
return new SEach(location(ctx), "def", name, expression, block);
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitNewstandardarray.
@Override
public ANode visitNewstandardarray(NewstandardarrayContext ctx) {
String type = ctx.TYPE().getText();
List<AExpression> expressions = new ArrayList<>();
for (ExpressionContext expression : ctx.expression()) {
expressions.add((AExpression) visit(expression));
}
return buildPostfixChain(new ENewArray(location(ctx), type, expressions, false), ctx.postdot(), ctx.postfix());
}
Aggregations