Search in sources :

Example 1 with EBinary

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

Aggregations

Operation (org.elasticsearch.painless.Operation)1 AExpression (org.elasticsearch.painless.node.AExpression)1 EBinary (org.elasticsearch.painless.node.EBinary)1