/** * Evaluate an expression against a context object and return the value * * @param expression A char[] containing the expression to be evaluated. * @param ctx The context object to evaluate against * @param vars The variables to be injected * @return The resultant value * @see #eval(String, Object, VariableResolverFactory) */ public static Object eval(char[] expression, Object ctx, VariableResolverFactory vars) { return new MVELInterpretedRuntime(expression, ctx, vars).parse(); }
reduceRight(); if (unwindStatement(operator)) { return -1; reduceRight(); if (unwindStatement(operator)) { return OP_TERMINATE; if ((tk = nextToken()) == null || tk.isOperator(Operator.TERNARY_ELSE)) break; captureToEOS(); return OP_RESET_FRAME; if (hasMore()) { holdOverRegister = stk.pop(); stk.clear();
while ((tk = nextToken()) != null) { holdOverRegister = null; Object o = stk.peek(); if (o instanceof Integer) { arithmeticFunctionReduction((Integer) o); if (tk instanceof Substatement && (tk = nextToken()) != null) { if (isArithmeticOperator(operator = tk.getOperator())) { stk.push(nextToken().getReducedValue(ctx, ctx, variableFactory), operator); if (procBooleanOperator(arithmeticFunctionReduction(operator)) == -1) return stk.peek(); else switch (procBooleanOperator(operator = tk.getOperator())) { case RETURN: variableFactory.setTiltFlag(true); stk.push(nextToken().getReducedValue(ctx, ctx, variableFactory), operator); switch ((operator = arithmeticFunctionReduction(operator))) { case OP_TERMINATE: return stk.peek(); if (procBooleanOperator(operator) == OP_TERMINATE) return stk.peek();
MVELInterpretedRuntime runtime = new MVELInterpretedRuntime(inBuffer.toString(), ctxObject, lvrf); runtime.newContext(pCtx); outputBuffer = runtime.parse();
public Object parse() { try { stk = new ExecutionStack(); dStack = new ExecutionStack(); cursor = 0; return parseAndExecuteInterpreted(); } catch (ArrayIndexOutOfBoundsException e) { e.printStackTrace(); throw new ParseException("unexpected end of statement", expr, length); } catch (NullPointerException e) { e.printStackTrace(); if (cursor >= length) { throw new ParseException("unexpected end of statement", expr, length); } else { throw e; } } catch (EndWithValue end) { return end.getValue(); } finally { if (parserContext != null) contextControl(REMOVE, null, null); } }
/** * This method peforms the equivilent of an XSWAP operation to flip the operator * over to the top of the stack, and loads the stored values on the d-stack onto * the main program stack. */ private void reduceRight() { if (dStack.isEmpty()) return; Object o = stk.pop(); stk.push(dStack.pop(), o, dStack.pop()); reduce(); }
/** * This method is called to unwind the current statement without any reduction or further parsing. * * @param operator - * @return - */ private boolean unwindStatement(int operator) { ASTNode tk; switch (operator) { case AND: while ((tk = nextToken()) != null && !tk.isOperator(Operator.END_OF_STMT) && !tk.isOperator(Operator.OR)) { //nothing } break; default: while ((tk = nextToken()) != null && !tk.isOperator(Operator.END_OF_STMT)) { //nothing } } return tk == null; }
public Object parse() { try { stk = new ExecutionStack(); dStack = new ExecutionStack(); variableFactory.setTiltFlag(false); cursor = start; return parseAndExecuteInterpreted(); } catch (ArrayIndexOutOfBoundsException e) { e.printStackTrace(); throw new CompileException("unexpected end of statement", expr, length); } catch (NullPointerException e) { e.printStackTrace(); if (cursor >= length) { throw new CompileException("unexpected end of statement", expr, length); } else { throw e; } } catch (CompileException e) { throw ErrorUtil.rewriteIfNeeded(e, expr, cursor); } }
reduceRight(); if (unwindStatement(operator)) { return -1; reduceRight(); if (unwindStatement(operator)) { return OP_TERMINATE; if ((tk = nextToken()) == null || tk.isOperator(Operator.TERNARY_ELSE)) break; captureToEOS(); return OP_RESET_FRAME; if (hasMore()) { holdOverRegister = stk.pop(); stk.clear();
while ((tk = nextToken()) != null) { holdOverRegister = null; if (tk instanceof Substatement && (tk = nextToken()) != null) { if (isArithmeticOperator(operator = tk.getOperator())) { stk.push(nextToken().getReducedValue(ctx, ctx, variableFactory), operator); if (procBooleanOperator(arithmeticFunctionReduction(operator)) == -1) return stk.peek(); else switch (procBooleanOperator(operator = tk.getOperator())) { case OP_TERMINATE: return stk.peek(); stk.push(nextToken().getReducedValue(ctx, ctx, variableFactory), operator); switch ((operator = arithmeticFunctionReduction(operator))) { case OP_TERMINATE: return stk.peek(); if (procBooleanOperator(operator) == -1) return stk.peek();
/** * This method peforms the equivilent of an XSWAP operation to flip the operator * over to the top of the stack, and loads the stored values on the d-stack onto * the main program stack. */ private void reduceRight() { if (dStack.isEmpty()) return; Object o = stk.pop(); stk.push(dStack.pop(), o, dStack.pop()); reduce(); }
/** * This method is called to unwind the current statement without any reduction or further parsing. * * @param operator - * @return - */ private boolean unwindStatement(int operator) { ASTNode tk; switch (operator) { case AND: while ((tk = nextToken()) != null && !tk.isOperator(Operator.END_OF_STMT) && !tk.isOperator(Operator.OR)) { //nothing } break; default: while ((tk = nextToken()) != null && !tk.isOperator(Operator.END_OF_STMT)) { //nothing } } return tk == null; }
public Object parse() { try { stk = new ExecutionStack(); dStack = new ExecutionStack(); variableFactory.setTiltFlag(false); cursor = start; return parseAndExecuteInterpreted(); } catch (ArrayIndexOutOfBoundsException e) { e.printStackTrace(); throw new CompileException("unexpected end of statement", expr, length); } catch (NullPointerException e) { e.printStackTrace(); if (cursor >= length) { throw new CompileException("unexpected end of statement", expr, length); } else { throw e; } } catch (CompileException e) { throw ErrorUtil.rewriteIfNeeded(e, expr, cursor); } }
/** * Evaluate an expression against a context object and return the value * * @param expression A char[] containing the expression to be evaluated. * @param ctx The context object to evaluate against * @return The resultant value * @see #eval(String, Object) */ public static Object eval(char[] expression, Object ctx) { return new MVELInterpretedRuntime(expression, ctx).parse(); }
reduceRight(); if (unwindStatement(operator)) { return -1; reduceRight(); if (unwindStatement(operator)) { return -1; while ((tk = nextToken()) != null && !tk.isOperator(Operator.TERNARY_ELSE)) { captureToEOS(); return 0; if (hasMore()) { holdOverRegister = stk.pop(); stk.clear();
while ((tk = nextToken()) != null) { holdOverRegister = null; Object o = stk.peek(); if (o instanceof Integer) { arithmeticFunctionReduction((Integer) o); if (tk instanceof Substatement && (tk = nextToken()) != null) { if (isArithmeticOperator(operator = tk.getOperator())) { stk.push(nextToken().getReducedValue(ctx, ctx, variableFactory), operator); if (procBooleanOperator(arithmeticFunctionReduction(operator)) == -1) return stk.peek(); else switch (procBooleanOperator(operator = tk.getOperator())) { case RETURN: variableFactory.setTiltFlag(true); stk.push(nextToken().getReducedValue(ctx, ctx, variableFactory), operator); switch ((operator = arithmeticFunctionReduction(operator))) { case OP_TERMINATE: return stk.peek(); if (procBooleanOperator(operator) == OP_TERMINATE) return stk.peek();
/** * This method peforms the equivilent of an XSWAP operation to flip the operator * over to the top of the stack, and loads the stored values on the d-stack onto * the main program stack. */ private void reduceRight() { if (dStack.isEmpty()) return; Object o = stk.pop(); stk.push(dStack.pop()); stk.push(o); stk.push(dStack.pop()); reduce(); }
/** * This method is called to unwind the current statement without any reduction or further parsing. * * @param operator - * @return - */ private boolean unwindStatement(int operator) { ASTNode tk; switch (operator) { case AND: while ((tk = nextToken()) != null && !tk.isOperator(Operator.END_OF_STMT) && !tk.isOperator(Operator.OR)) { //nothing } break; default: while ((tk = nextToken()) != null && !tk.isOperator(Operator.END_OF_STMT)) { //nothing } } return tk == null; }
/** * Evaluate an expression against a context object and return the value * * @param expression A char[] containing the expression to be evaluated. * @param ctx The context object to evaluate against * @param vars A Map of variables to be injected * @return The resultant value * @see #eval(String, Object, Map) */ public static Object eval(char[] expression, Object ctx, Map vars) { return new MVELInterpretedRuntime(expression, ctx, vars).parse(); }
/** * Evaluate an expression and return the value. * * @param expression A String containing the expression to be evaluated. * @return the resultant value */ public static Object eval(String expression) { return new MVELInterpretedRuntime(expression, MVELRuntime.IMMUTABLE_DEFAULT_FACTORY).parse(); }