use of org.mvel2.optimizers.AccessorOptimizer in project mvel by mikebrock.
the class ASTNode method optimize.
private Object optimize(Object ctx, Object thisValue, VariableResolverFactory factory) {
if ((fields & DEOP) != 0) {
fields ^= DEOP;
}
AccessorOptimizer optimizer;
Object retVal = null;
if ((fields & NOJIT) != 0 || factory != null && factory.isResolveable(nameCache)) {
optimizer = getAccessorCompiler(SAFE_REFLECTIVE);
} else {
optimizer = getDefaultAccessorCompiler();
}
ParserContext pCtx;
if ((fields & PCTX_STORED) != 0) {
pCtx = (ParserContext) literal;
} else {
pCtx = new ParserContext(new ParserConfiguration(getInjectedImports(factory), null));
}
try {
pCtx.optimizationNotify();
setAccessor(optimizer.optimizeAccessor(pCtx, expr, start, offset, ctx, thisValue, factory, true, egressType));
} catch (OptimizationNotSupported ne) {
setAccessor((optimizer = getAccessorCompiler(SAFE_REFLECTIVE)).optimizeAccessor(pCtx, expr, start, offset, ctx, thisValue, factory, true, null));
}
if (accessor == null) {
return get(expr, start, offset, ctx, factory, thisValue);
}
if (retVal == null) {
retVal = optimizer.getResultOptPass();
}
if (egressType == null) {
egressType = optimizer.getEgressType();
}
return retVal;
}
use of org.mvel2.optimizers.AccessorOptimizer in project mvel by mikebrock.
the class InlineCollectionNode method getReducedValueAccelerated.
public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
if (accessor != null) {
return accessor.getValue(ctx, thisValue, factory);
} else {
try {
AccessorOptimizer ao = OptimizerFactory.getThreadAccessorOptimizer();
if (collectionGraph == null)
parseGraph(true, null, null);
accessor = ao.optimizeCollection(AbstractParser.getCurrentThreadParserContext(), collectionGraph, egressType, expr, trailingStart, trailingOffset, ctx, thisValue, factory);
egressType = ao.getEgressType();
return accessor.getValue(ctx, thisValue, factory);
} finally {
OptimizerFactory.clearThreadAccessorOptimizer();
}
}
}
use of org.mvel2.optimizers.AccessorOptimizer in project mvel by mikebrock.
the class Union method get.
private Object get(Object ctx, Object elCtx, VariableResolverFactory variableFactory) {
if (nextAccessor == null) {
Object o = accessor.getValue(ctx, elCtx, variableFactory);
AccessorOptimizer ao = OptimizerFactory.getDefaultAccessorCompiler();
Class ingress = accessor.getKnownEgressType();
nextAccessor = ao.optimizeAccessor(getCurrentThreadParserContext(), nextExpr, start, offset, o, elCtx, variableFactory, false, ingress);
return ao.getResultOptPass();
} else {
return accessor.getValue(ctx, elCtx, variableFactory);
}
}
Aggregations