use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitDo.
@Override
public ANode visitDo(DoContext ctx) {
reserved.peek().setMaxLoopCounter(settings.getMaxLoopCounter());
AExpression expression = (AExpression) visit(ctx.expression());
SBlock block = (SBlock) visit(ctx.block());
return new SDo(location(ctx), block, expression);
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitInstanceof.
@Override
public ANode visitInstanceof(InstanceofContext ctx) {
AExpression expr = (AExpression) visit(ctx.expression());
String type = ctx.decltype().getText();
return new EInstanceof(location(ctx), expr, type);
}
use of org.elasticsearch.painless.node.AExpression 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);
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitDeclaration.
@Override
public ANode visitDeclaration(DeclarationContext ctx) {
String type = ctx.decltype().getText();
List<SDeclaration> declarations = new ArrayList<>();
for (DeclvarContext declvar : ctx.declvar()) {
String name = declvar.ID().getText();
AExpression expression = declvar.expression() == null ? null : (AExpression) visit(declvar.expression());
declarations.add(new SDeclaration(location(declvar), type, name, expression));
}
return new SDeclBlock(location(ctx), declarations);
}
use of org.elasticsearch.painless.node.AExpression in project elasticsearch by elastic.
the class Walker method visitNewobject.
@Override
public ANode visitNewobject(NewobjectContext ctx) {
String type = ctx.TYPE().getText();
List<AExpression> arguments = collectArguments(ctx.arguments());
return new ENewObj(location(ctx), type, arguments);
}
Aggregations