use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitMapinitializer.
@Override
public ANode visitMapinitializer(MapinitializerContext ctx) {
List<AExpression> keys = new ArrayList<>();
List<AExpression> values = new ArrayList<>();
for (MaptokenContext maptoken : ctx.maptoken()) {
keys.add((AExpression) visit(maptoken.expression(0)));
values.add((AExpression) visit(maptoken.expression(1)));
}
return new EMapInit(location(ctx), keys, values);
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitCalllocal.
@Override
public ANode visitCalllocal(CalllocalContext ctx) {
String name = ctx.ID().getText();
List<AExpression> arguments = collectArguments(ctx.arguments());
return new ECallLocal(location(ctx), name, arguments);
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitBool.
@Override
public ANode visitBool(BoolContext ctx) {
AExpression left = (AExpression) visit(ctx.expression(0));
AExpression right = (AExpression) visit(ctx.expression(1));
final Operation operation;
if (ctx.BOOLAND() != null) {
operation = Operation.AND;
} else if (ctx.BOOLOR() != null) {
operation = Operation.OR;
} else {
throw location(ctx).createError(new IllegalStateException("Illegal tree structure."));
}
return new EBool(location(ctx), operation, left, right);
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitConditional.
@Override
public ANode visitConditional(ConditionalContext ctx) {
AExpression condition = (AExpression) visit(ctx.expression(0));
AExpression left = (AExpression) visit(ctx.expression(1));
AExpression right = (AExpression) visit(ctx.expression(2));
return new EConditional(location(ctx), condition, left, right);
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitFor.
@Override
public ANode visitFor(ForContext ctx) {
reserved.peek().setMaxLoopCounter(settings.getMaxLoopCounter());
ANode initializer = ctx.initializer() == null ? null : visit(ctx.initializer());
AExpression expression = ctx.expression() == null ? null : (AExpression) visit(ctx.expression());
AExpression afterthought = ctx.afterthought() == null ? null : (AExpression) visit(ctx.afterthought());
if (ctx.trailer() != null) {
SBlock block = (SBlock) visit(ctx.trailer());
return new SFor(location(ctx), initializer, expression, afterthought, block);
} else if (ctx.empty() != null) {
return new SFor(location(ctx), initializer, expression, afterthought, null);
} else {
throw location(ctx).createError(new IllegalStateException("Illegal tree structure."));
}
}
Aggregations