Search in sources :

Example 1 with FunctionVariableResolverFactory

use of org.mvel2.integration.impl.FunctionVariableResolverFactory 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)

Aggregations

VariableResolver (org.mvel2.integration.VariableResolver)1 DefaultLocalVariableResolverFactory (org.mvel2.integration.impl.DefaultLocalVariableResolverFactory)1 FunctionVariableResolverFactory (org.mvel2.integration.impl.FunctionVariableResolverFactory)1