use of org.elasticsearch.painless.node.AExpression 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.AExpression in project elasticsearch by elastic.
the class Walker method visitCast.
@Override
public ANode visitCast(CastContext ctx) {
String type = ctx.decltype().getText();
AExpression child = (AExpression) visit(ctx.unary());
return new EExplicit(location(ctx), type, child);
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitNewinitializedarray.
@Override
public ANode visitNewinitializedarray(NewinitializedarrayContext 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, true), null, ctx.postfix());
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitWhile.
@Override
public ANode visitWhile(WhileContext ctx) {
reserved.peek().setMaxLoopCounter(settings.getMaxLoopCounter());
AExpression expression = (AExpression) visit(ctx.expression());
if (ctx.trailer() != null) {
SBlock block = (SBlock) visit(ctx.trailer());
return new SWhile(location(ctx), expression, block);
} else if (ctx.empty() != null) {
return new SWhile(location(ctx), expression, null);
} else {
throw location(ctx).createError(new IllegalStateException("Illegal tree structure."));
}
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitElvis.
@Override
public ANode visitElvis(ElvisContext ctx) {
AExpression left = (AExpression) visit(ctx.expression(0));
AExpression right = (AExpression) visit(ctx.expression(1));
return new EElvis(location(ctx), left, right);
}
Aggregations