Search in sources :

Example 16 with AExpression

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);
}
Also used : EAssignment(org.elasticsearch.painless.node.EAssignment) AExpression(org.elasticsearch.painless.node.AExpression) Operation(org.elasticsearch.painless.Operation)

Example 17 with AExpression

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);
}
Also used : AExpression(org.elasticsearch.painless.node.AExpression) EExplicit(org.elasticsearch.painless.node.EExplicit) EString(org.elasticsearch.painless.node.EString)

Example 18 with AExpression

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());
}
Also used : ENewArray(org.elasticsearch.painless.node.ENewArray) ExpressionContext(org.elasticsearch.painless.antlr.PainlessParser.ExpressionContext) AExpression(org.elasticsearch.painless.node.AExpression) ArrayList(java.util.ArrayList) EString(org.elasticsearch.painless.node.EString)

Example 19 with AExpression

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."));
    }
}
Also used : SWhile(org.elasticsearch.painless.node.SWhile) AExpression(org.elasticsearch.painless.node.AExpression) SBlock(org.elasticsearch.painless.node.SBlock)

Example 20 with AExpression

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);
}
Also used : AExpression(org.elasticsearch.painless.node.AExpression) EElvis(org.elasticsearch.painless.node.EElvis)

Aggregations

AExpression (org.elasticsearch.painless.node.AExpression)25 EString (org.elasticsearch.painless.node.EString)11 Operation (org.elasticsearch.painless.Operation)7 SBlock (org.elasticsearch.painless.node.SBlock)6 ArrayList (java.util.ArrayList)5 EAssignment (org.elasticsearch.painless.node.EAssignment)3 ExpressionContext (org.elasticsearch.painless.antlr.PainlessParser.ExpressionContext)2 ENewArray (org.elasticsearch.painless.node.ENewArray)2 SEach (org.elasticsearch.painless.node.SEach)2 DeclvarContext (org.elasticsearch.painless.antlr.PainlessParser.DeclvarContext)1 DynamicContext (org.elasticsearch.painless.antlr.PainlessParser.DynamicContext)1 LamtypeContext (org.elasticsearch.painless.antlr.PainlessParser.LamtypeContext)1 MaptokenContext (org.elasticsearch.painless.antlr.PainlessParser.MaptokenContext)1 NumericContext (org.elasticsearch.painless.antlr.PainlessParser.NumericContext)1 ReadContext (org.elasticsearch.painless.antlr.PainlessParser.ReadContext)1 StatementContext (org.elasticsearch.painless.antlr.PainlessParser.StatementContext)1 ANode (org.elasticsearch.painless.node.ANode)1 AStatement (org.elasticsearch.painless.node.AStatement)1 EBinary (org.elasticsearch.painless.node.EBinary)1 EBool (org.elasticsearch.painless.node.EBool)1