use of org.elasticsearch.painless.Operation 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.Operation in project elasticsearch by elastic.
the class Walker method visitComp.
@Override
public ANode visitComp(CompContext ctx) {
AExpression left = (AExpression) visit(ctx.expression(0));
AExpression right = (AExpression) visit(ctx.expression(1));
final Operation operation;
if (ctx.LT() != null) {
operation = Operation.LT;
} else if (ctx.LTE() != null) {
operation = Operation.LTE;
} else if (ctx.GT() != null) {
operation = Operation.GT;
} else if (ctx.GTE() != null) {
operation = Operation.GTE;
} else if (ctx.EQ() != null) {
operation = Operation.EQ;
} else if (ctx.EQR() != null) {
operation = Operation.EQR;
} else if (ctx.NE() != null) {
operation = Operation.NE;
} else if (ctx.NER() != null) {
operation = Operation.NER;
} else {
throw location(ctx).createError(new IllegalStateException("Illegal tree structure."));
}
return new EComp(location(ctx), operation, left, right);
}
use of org.elasticsearch.painless.Operation in project elasticsearch by elastic.
the class Walker method visitOperator.
@Override
public ANode visitOperator(OperatorContext ctx) {
AExpression expression = (AExpression) visit(ctx.unary());
final Operation operation;
if (ctx.BOOLNOT() != null) {
operation = Operation.NOT;
} else if (ctx.BWNOT() != null) {
operation = Operation.BWNOT;
} else if (ctx.ADD() != null) {
operation = Operation.ADD;
} else if (ctx.SUB() != null) {
if (ctx.unary() instanceof ReadContext && ((ReadContext) ctx.unary()).chain() instanceof DynamicContext && ((DynamicContext) ((ReadContext) ctx.unary()).chain()).primary() instanceof NumericContext && ((DynamicContext) ((ReadContext) ctx.unary()).chain()).postfix().isEmpty()) {
return expression;
}
operation = Operation.SUB;
} else {
throw location(ctx).createError(new IllegalStateException("Illegal tree structure."));
}
return new EUnary(location(ctx), operation, expression);
}
use of org.elasticsearch.painless.Operation in project elasticsearch by elastic.
the class Walker method visitPre.
@Override
public ANode visitPre(PreContext 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, true, false, operation);
}
use of org.elasticsearch.painless.Operation 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);
}
Aggregations