use of org.mule.mvel2.compiler.CompiledExpression in project mvel by mvel.
the class WithTests method testInlineWith5.
public void testInlineWith5() {
OptimizerFactory.setDefaultOptimizer("ASM");
ParserContext pCtx = new ParserContext();
pCtx.setStrongTyping(true);
pCtx.addInput("foo", Foo.class);
CompiledExpression expr = new ExpressionCompiler("foo.{name='poopy', aValue='bar'}", pCtx).compile();
Foo f = (Foo) executeExpression(expr, createTestMap());
assertEquals("poopy", f.getName());
assertEquals("bar", f.aValue);
}
use of org.mule.mvel2.compiler.CompiledExpression in project mvel by mvel.
the class WithTests method testInlineWith3a.
public void testInlineWith3a() {
CompiledExpression expr = new ExpressionCompiler("foo.{name='poopy',aValue='bar',bar.{name='foobie'},toUC('doopy')}").compile();
Foo f = (Foo) executeExpression(expr, createTestMap());
assertEquals("poopy", f.getName());
assertEquals("bar", f.aValue);
assertEquals("foobie", f.getBar().getName());
assertEquals("doopy", f.register);
}
use of org.mule.mvel2.compiler.CompiledExpression in project mvel by mvel.
the class WithTests method testInlineWith2.
public void testInlineWith2() {
CompiledExpression expr = new ExpressionCompiler("foo.{name = 'poopy', aValue = 'bar', bar.{name = 'foobie'}}").compile();
Foo f = (Foo) executeExpression(expr, createTestMap());
assertEquals("poopy", f.getName());
assertEquals("bar", f.aValue);
assertEquals("foobie", f.getBar().getName());
}
use of org.mule.mvel2.compiler.CompiledExpression in project mvel by mvel.
the class WithTests method testExecuteCoercionTwice.
public void testExecuteCoercionTwice() {
OptimizerFactory.setDefaultOptimizer("reflective");
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("foo", new Foo());
vars.put("$value", new Long(5));
ParserContext ctx = new ParserContext();
ctx.setSourceFile("test.mv");
ctx.setDebugSymbols(true);
ExpressionCompiler compiler = new ExpressionCompiler("with (foo) { countTest = $value };", ctx);
CompiledExpression compiled = compiler.compile();
executeExpression(compiled, null, vars);
executeExpression(compiled, null, vars);
}
use of org.mule.mvel2.compiler.CompiledExpression in project drools by kiegroup.
the class MVELConsequence method evaluate.
public void evaluate(final KnowledgeHelper knowledgeHelper, final WorkingMemory workingMemory) throws Exception {
VariableResolverFactory factory = unit.getFactory(knowledgeHelper, ((AgendaItem) knowledgeHelper.getMatch()).getTerminalNode().getRequiredDeclarations(), knowledgeHelper.getRule(), knowledgeHelper.getTuple(), null, (InternalWorkingMemory) workingMemory, workingMemory.getGlobalResolver());
// do we have any functions for this namespace?
InternalKnowledgePackage pkg = workingMemory.getKnowledgeBase().getPackage("MAIN");
if (pkg != null) {
MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData(this.id);
factory.setNextFactory(data.getFunctionFactory());
}
CompiledExpression compexpr = (CompiledExpression) this.expr;
if (MVELDebugHandler.isDebugMode()) {
if (MVELDebugHandler.verbose) {
logger.info(DebugTools.decompile(compexpr));
}
MVEL.executeDebugger(compexpr, knowledgeHelper, factory);
} else {
MVEL.executeExpression(compexpr, knowledgeHelper, factory);
}
}
Aggregations