Search in sources :

Example 6 with OperatorNode

use of org.mvel2.ast.OperatorNode in project mvel by mvel.

the class ExpressionCompiler method compileReduce.

private boolean compileReduce(int opCode, ASTLinkedList astBuild) {
    switch(arithmeticFunctionReduction(opCode)) {
        case -1:
            /**
             * The reduction failed because we encountered a non-literal,
             * so we must now back out and cleanup.
             */
            stk.xswap_op();
            astBuild.addTokenNode(new LiteralNode(stk.pop(), pCtx));
            astBuild.addTokenNode((OperatorNode) splitAccumulator.pop(), verify(pCtx, (ASTNode) splitAccumulator.pop()));
            return false;
        case -2:
            /**
             * Back out completely, pull everything back off the stack and add the instructions
             * to the output payload as they are.
             */
            LiteralNode rightValue = new LiteralNode(stk.pop(), pCtx);
            OperatorNode operator = new OperatorNode((Integer) stk.pop(), expr, st, pCtx);
            astBuild.addTokenNode(new LiteralNode(stk.pop(), pCtx), operator);
            astBuild.addTokenNode(rightValue, (OperatorNode) splitAccumulator.pop());
            astBuild.addTokenNode(verify(pCtx, (ASTNode) splitAccumulator.pop()));
    }
    return true;
}
Also used : LiteralNode(org.mvel2.ast.LiteralNode) ASTNode(org.mvel2.ast.ASTNode) OperatorNode(org.mvel2.ast.OperatorNode)

Aggregations

CompileException (org.mvel2.CompileException)5 OperatorNode (org.mvel2.ast.OperatorNode)5 ASTNode (org.mvel2.ast.ASTNode)4 LiteralNode (org.mvel2.ast.LiteralNode)4 Substatement (org.mvel2.ast.Substatement)2 AssertNode (org.mvel2.ast.AssertNode)1 AssignmentNode (org.mvel2.ast.AssignmentNode)1 BooleanNode (org.mvel2.ast.BooleanNode)1 DeclTypedVarNode (org.mvel2.ast.DeclTypedVarNode)1 DeepAssignmentNode (org.mvel2.ast.DeepAssignmentNode)1 EndOfStatement (org.mvel2.ast.EndOfStatement)1 Fold (org.mvel2.ast.Fold)1 ImportNode (org.mvel2.ast.ImportNode)1 IndexedAssignmentNode (org.mvel2.ast.IndexedAssignmentNode)1 IndexedDeclTypedVarNode (org.mvel2.ast.IndexedDeclTypedVarNode)1 IndexedOperativeAssign (org.mvel2.ast.IndexedOperativeAssign)1 IndexedPostFixDecNode (org.mvel2.ast.IndexedPostFixDecNode)1 IndexedPostFixIncNode (org.mvel2.ast.IndexedPostFixIncNode)1 IndexedPreFixDecNode (org.mvel2.ast.IndexedPreFixDecNode)1 IndexedPreFixIncNode (org.mvel2.ast.IndexedPreFixIncNode)1