Search in sources :

Example 11 with VariableResolver

use of org.mvel2.integration.VariableResolver in project mvel by mikebrock.

the class DebugTools method getAllVariableResolvers.

public static Map<String, VariableResolver> getAllVariableResolvers(VariableResolverFactory rootFactory) {
    Map<String, VariableResolver> allVariableResolvers = new HashMap<String, VariableResolver>();
    VariableResolverFactory vrf = rootFactory;
    do {
        for (String var : vrf.getKnownVariables()) {
            allVariableResolvers.put(var, vrf.getVariableResolver(var));
        }
    } while ((vrf = vrf.getNextFactory()) != null);
    return allVariableResolvers;
}
Also used : VariableResolverFactory(org.mvel2.integration.VariableResolverFactory) HashMap(java.util.HashMap) VariableResolver(org.mvel2.integration.VariableResolver)

Example 12 with VariableResolver

use of org.mvel2.integration.VariableResolver in project mvel by mikebrock.

the class IndexedVariableResolverFactory method createIndexedVariable.

public VariableResolver createIndexedVariable(int index, String name, Object value) {
    VariableResolver r = indexedVariableResolvers[index];
    r.setValue(value);
    return r;
}
Also used : VariableResolver(org.mvel2.integration.VariableResolver)

Example 13 with VariableResolver

use of org.mvel2.integration.VariableResolver in project mvel by mikebrock.

the class Function method call.

public Object call(Object ctx, Object thisValue, VariableResolverFactory factory, Object[] parms) {
    if (parms != null && parms.length != 0) {
        // detect tail recursion
        if (factory instanceof FunctionVariableResolverFactory && ((FunctionVariableResolverFactory) factory).getIndexedVariableResolvers().length == parms.length) {
            FunctionVariableResolverFactory fvrf = (FunctionVariableResolverFactory) factory;
            if (fvrf.getFunction().equals(this)) {
                VariableResolver[] swapVR = fvrf.getIndexedVariableResolvers();
                fvrf.updateParameters(parms);
                try {
                    return compiledBlock.getValue(ctx, thisValue, fvrf);
                } finally {
                    fvrf.setIndexedVariableResolvers(swapVR);
                }
            }
        }
        return compiledBlock.getValue(thisValue, new FunctionVariableResolverFactory(this, factory, parameters, parms));
    } else if (cMode) {
        return compiledBlock.getValue(thisValue, new DefaultLocalVariableResolverFactory(factory, parameters).setNoTilt(true));
    } else {
        return compiledBlock.getValue(thisValue, new DefaultLocalVariableResolverFactory(factory, parameters).setNoTilt(true));
    }
}
Also used : FunctionVariableResolverFactory(org.mvel2.integration.impl.FunctionVariableResolverFactory) DefaultLocalVariableResolverFactory(org.mvel2.integration.impl.DefaultLocalVariableResolverFactory) VariableResolver(org.mvel2.integration.VariableResolver)

Example 14 with VariableResolver

use of org.mvel2.integration.VariableResolver in project mvel by mikebrock.

the class IndexedOperativeAssign method getReducedValue.

public Object getReducedValue(Object ctx, Object thisValue, VariableResolverFactory factory) {
    VariableResolver resolver = factory.getIndexedVariableResolver(register);
    resolver.setValue(ctx = MathProcessor.doOperations(resolver.getValue(), operation, eval(expr, start, offset, ctx, factory)));
    return ctx;
}
Also used : VariableResolver(org.mvel2.integration.VariableResolver)

Example 15 with VariableResolver

use of org.mvel2.integration.VariableResolver in project mvel by mikebrock.

the class IndexedPreFixIncNode method getReducedValueAccelerated.

public Object getReducedValueAccelerated(Object ctx, Object thisValue, VariableResolverFactory factory) {
    VariableResolver vResolver = factory.getIndexedVariableResolver(register);
    vResolver.setValue(ctx = MathProcessor.doOperations(vResolver.getValue(), Operator.ADD, DataTypes.INTEGER, 1));
    return ctx;
}
Also used : VariableResolver(org.mvel2.integration.VariableResolver)

Aggregations

VariableResolver (org.mvel2.integration.VariableResolver)18 HashMap (java.util.HashMap)1 AgendaItem (org.drools.core.common.AgendaItem)1 Declaration (org.drools.core.rule.Declaration)1 UnresolveablePropertyException (org.mvel2.UnresolveablePropertyException)1 VariableResolverFactory (org.mvel2.integration.VariableResolverFactory)1 DefaultLocalVariableResolverFactory (org.mvel2.integration.impl.DefaultLocalVariableResolverFactory)1 FunctionVariableResolverFactory (org.mvel2.integration.impl.FunctionVariableResolverFactory)1