public ConditionAnalyzer(ExecutableStatement stmt, Declaration[] declarations, String conditionClass) { this.declarations = declarations; this.conditionClass = conditionClass; if (stmt instanceof ExecutableLiteral) { executableLiteral = (ExecutableLiteral)stmt; } else if (stmt instanceof CompiledExpression) { node = ((CompiledExpression)stmt).getFirstNode(); } else { node = ((ExecutableAccessor)stmt).getNode(); } }
public static Serializable optimizeTree(final CompiledExpression compiled) { /** * If there is only one token, and it's an identifier, we can optimize this as an accessor expression. */ if (!compiled.isImportInjectionRequired() && compiled.getParserConfiguration().isAllowBootstrapBypass() && compiled.isSingleNode()) { return _optimizeTree(compiled); } return compiled; }
public static Serializable optimizeTree(final CompiledExpression compiled) { /** * If there is only one token, and it's an identifier, we can optimize this as an accessor expression. */ if (!compiled.isImportInjectionRequired() && compiled.getParserContext().isAllowBootstrapBypass() && compiled.isSingleNode()) { return _optimizeTree(compiled); } return compiled; }
public Object getValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory) { if (!optimized) setupOptimizers(); return getValue(ctx, variableFactory); }
public Object getValue(Object staticContext, VariableResolverFactory factory) { if (!optimized) { setupOptimizers(); try { return getValue(staticContext, factory); } finally { OptimizerFactory.clearThreadAccessorOptimizer(); } } return getDirectValue(staticContext, factory); }
private static Serializable _optimizeTree(final CompiledExpression compiled) { /** * If there is only one token, and it's an identifier, we can optimize this as an accessor expression. */ if (compiled.isSingleNode()) { ASTNode tk = compiled.getFirstNode(); if (tk.isLiteral() && !tk.isThisVal()) { return new ExecutableLiteral(tk.getLiteralValue()); } return tk.canSerializeAccessor() ? new ExecutableAccessorSafe(tk, compiled.getKnownEgressType()) : new ExecutableAccessor(tk, compiled.getKnownEgressType()); } return compiled; }
public Type resolveEgressType(String expression) throws ExpressionCompileException { // try to get the type from the cache Type type = egressTypes.get(expression); if (type != null) { return type; } CompiledExpression compiled = compileExpression(expression); final Class<?> egressClass = compiled.getKnownEgressType(); final Type[] parameters = getParserContext().getLastTypeParameters(); if (parameters == null) { // the class is not parameterised (generic) type = egressClass; } else { // reconstruct the Type from mvel's generics details type = new ParameterizedTypeImpl(egressClass, parameters, egressClass.getEnclosingClass()); } egressTypes.put(expression, type); return type; }
public Type resolveEgressType(String expression) throws ExpressionCompileException { // try to get the type from the cache Type type = egressTypes.get(expression); if (type != null) { return type; } CompiledExpression compiled = compileExpression(expression); final Class<?> egressClass = compiled.getKnownEgressType(); final Type[] parameters = compiled.getParserContext().getLastTypeParameters(); if (parameters == null) { // the class is not parameterised (generic) type = egressClass; } else { // reconstruct the Type from mvel's generics details type = new ParameterizedTypeImpl(egressClass, parameters, egressClass.getEnclosingClass()); } egressTypes.put(expression, type); return type; }
public static void executeExpression(Iterable<CompiledExpression> compiledExpression, Object ctx, VariableResolverFactory vars) { for (CompiledExpression ce : compiledExpression) { ce.getValue(ctx, vars); } }
public static Object executeDebugger(CompiledExpression expression, Object ctx, VariableResolverFactory vars) { if (expression.isImportInjectionRequired()) { return execute(true, expression, ctx, new ClassImportResolverFactory(expression.getParserConfiguration(), vars, false)); } else { return execute(true, expression, ctx, vars); } }
private CompiledExpression asCompiledExpression(ASTNode node) { return new CompiledExpression(new ASTLinkedList(node), null, Object.class, parserConfiguration, false); }
public static Object executeDebugger(CompiledExpression expression, Object ctx, VariableResolverFactory vars) { try { if (expression.isImportInjectionRequired()) { return execute(true, expression, ctx, new ClassImportResolverFactory(expression .getParserContext().getParserConfiguration(), vars)); } else { return execute(true, expression, ctx, vars); } } catch (EndWithValue e) { return e.getValue(); } }
public int checkBreak(LineLabel label, VariableResolverFactory factory, CompiledExpression expression) { if (debuggerState == Debugger.STEP || hasBreakpoint(label)) { if (debugger == null) throw new RuntimeException("no debugger registered to handle breakpoint"); return debuggerState = debugger.onBreak(new Frame(label, factory, expression.getParserContext())); } return 0; }
public Object getValue(Object staticContext, VariableResolverFactory factory) { if (!optimized) setupOptimizers(); if (importInjectionRequired) { return execute(false, this, staticContext, new ClassImportResolverFactory(parserContext.getParserConfiguration(), factory)); } else { return execute(false, this, staticContext, factory); } }
protected void createMvelConditionEvaluator(InternalWorkingMemory workingMemory) { if (compilationUnit != null) { MVELDialectRuntimeData data = getMVELDialectRuntimeData(workingMemory); ExecutableStatement statement = (ExecutableStatement)compilationUnit.getCompiledExpression(data); ParserConfiguration configuration = statement instanceof CompiledExpression ? ((CompiledExpression)statement).getParserConfiguration() : data.getParserConfiguration(); conditionEvaluator = new MvelConditionEvaluator(compilationUnit, configuration, statement, declarations, getAccessedClass()); } else { conditionEvaluator = new MvelConditionEvaluator(getParserConfiguration(workingMemory), expression, declarations, getAccessedClass()); } }
private static Serializable _optimizeTree(final CompiledExpression compiled) { /** * If there is only one token, and it's an identifier, we can optimize this as an accessor expression. */ if (compiled.isSingleNode()) { ASTNode tk = compiled.getFirstNode(); if (tk.isLiteral() && !tk.isThisVal()) { return new ExecutableLiteral(tk.getLiteralValue()); } return tk.canSerializeAccessor() ? new ExecutableAccessorSafe(tk, compiled.getKnownEgressType()) : new ExecutableAccessor(tk, compiled.getKnownEgressType()); } return compiled; }
public Type resolveEgressType(String expression) throws ExpressionCompileException { // try to get the type from the cache Type type = egressTypes.get(expression); if (type != null) { return type; } CompiledExpression compiled = compileExpression(expression); final Class<?> egressClass = compiled.getKnownEgressType(); final Type[] parameters = getParserContext().getLastTypeParameters(); if (parameters == null) { // the class is not parameterised (generic) type = egressClass; } else { // reconstruct the Type from mvel's generics details type = new ParameterizedTypeImpl(egressClass, parameters, egressClass.getEnclosingClass()); } egressTypes.put(expression, type); return type; }
public Object getValue(Object staticContext, VariableResolverFactory factory) { if (!optimized) { setupOptimizers(); try { return getValue(staticContext, factory); } finally { OptimizerFactory.clearThreadAccessorOptimizer(); } } return getDirectValue(staticContext, factory); }
public Object getValue(Object ctx, Object elCtx, VariableResolverFactory variableFactory) { if (!optimized) { setupOptimizers(); try { return getValue(ctx, variableFactory); } finally { OptimizerFactory.clearThreadAccessorOptimizer(); } } return getValue(ctx, variableFactory); }
public static void executeExpression(Iterable<CompiledExpression> compiledExpression, Object ctx) { for (CompiledExpression ce : compiledExpression) { ce.getValue(ctx, null); } }