Search in sources :

Example 1 with CallerImpl

use of lucee.runtime.type.scope.CallerImpl in project Lucee by lucee.

the class CFTag method release.

@Override
public void release() {
    super.release();
    hasBody = false;
    // filename=null;
    // .clear();
    attributesScope = new StructImpl();
    callerScope = new CallerImpl();
    if (thistagScope != null)
        thistagScope = null;
    if (ctVariablesScope != null)
        ctVariablesScope = null;
    isEndTag = false;
    // cfc=null;
    source = null;
}
Also used : CallerImpl(lucee.runtime.type.scope.CallerImpl) StructImpl(lucee.runtime.type.StructImpl)

Example 2 with CallerImpl

use of lucee.runtime.type.scope.CallerImpl in project Lucee by lucee.

the class Evaluate method call.

public static Object call(PageContext pc, Object[] objs, boolean preciseMath) throws PageException {
    // define a ohter enviroment for the function
    if (objs.length > 1 && objs[objs.length - 1] instanceof Scope) {
        // Variables Scope
        Variables var = null;
        Local lcl = null, cLcl = null;
        Argument arg = null, cArg = null;
        if (objs[objs.length - 1] instanceof Variables) {
            var = (Variables) objs[objs.length - 1];
        } else if (objs[objs.length - 1] instanceof CallerImpl) {
            CallerImpl ci = ((CallerImpl) objs[objs.length - 1]);
            var = ci.getVariablesScope();
            lcl = ci.getLocalScope();
            arg = ci.getArgumentsScope();
        }
        if (var != null) {
            Variables cVar = pc.variablesScope();
            pc.setVariablesScope(var);
            if (lcl != null && !(lcl instanceof LocalNotSupportedScope)) {
                cLcl = pc.localScope();
                cArg = pc.argumentsScope();
                pc.setFunctionScopes(lcl, arg);
            }
            try {
                return _call(pc, objs, objs.length - 1, preciseMath);
            } finally {
                pc.setVariablesScope(cVar);
                if (cLcl != null)
                    pc.setFunctionScopes(cLcl, cArg);
            }
        } else // Undefined Scope
        if (objs[objs.length - 1] instanceof Undefined) {
            PageContextImpl pci = (PageContextImpl) pc;
            Undefined undefined = (Undefined) objs[objs.length - 1];
            boolean check = undefined.getCheckArguments();
            Variables orgVar = pc.variablesScope();
            Argument orgArgs = pc.argumentsScope();
            Local orgLocal = pc.localScope();
            pci.setVariablesScope(undefined.variablesScope());
            if (check)
                pci.setFunctionScopes(undefined.localScope(), undefined.argumentsScope());
            try {
                return _call(pc, objs, objs.length - 1, preciseMath);
            } finally {
                pc.setVariablesScope(orgVar);
                if (check)
                    pci.setFunctionScopes(orgLocal, orgArgs);
            }
        }
    }
    return _call(pc, objs, objs.length, preciseMath);
}
Also used : Variables(lucee.runtime.type.scope.Variables) Undefined(lucee.runtime.type.scope.Undefined) CallerImpl(lucee.runtime.type.scope.CallerImpl) Scope(lucee.runtime.type.scope.Scope) LocalNotSupportedScope(lucee.runtime.type.scope.LocalNotSupportedScope) Argument(lucee.runtime.type.scope.Argument) LocalNotSupportedScope(lucee.runtime.type.scope.LocalNotSupportedScope) Local(lucee.runtime.type.scope.Local) PageContextImpl(lucee.runtime.PageContextImpl)

Example 3 with CallerImpl

use of lucee.runtime.type.scope.CallerImpl in project Lucee by lucee.

the class VariableInterpreter method _variable.

public static Object _variable(PageContext pc, String str, Object value, Scope scope) throws PageException {
    // define a ohter enviroment for the function
    if (scope != null) {
        // Variables Scope
        Variables var = null;
        if (scope instanceof Variables) {
            var = (Variables) scope;
        } else if (scope instanceof CallerImpl) {
            var = ((CallerImpl) scope).getVariablesScope();
        }
        if (var != null) {
            Variables current = pc.variablesScope();
            pc.setVariablesScope(var);
            try {
                if (value != NULL)
                    return setVariable(pc, str, value);
                return getVariable(pc, str);
            } finally {
                pc.setVariablesScope(current);
            }
        } else // Undefined Scope
        if (scope instanceof Undefined) {
            PageContextImpl pci = (PageContextImpl) pc;
            Undefined undefined = (Undefined) scope;
            boolean check = undefined.getCheckArguments();
            Variables orgVar = pc.variablesScope();
            Argument orgArgs = pc.argumentsScope();
            Local orgLocal = pc.localScope();
            pci.setVariablesScope(undefined.variablesScope());
            if (check)
                pci.setFunctionScopes(undefined.localScope(), undefined.argumentsScope());
            try {
                if (value != NULL)
                    return setVariable(pc, str, value);
                return getVariable(pc, str);
            } finally {
                pc.setVariablesScope(orgVar);
                if (check)
                    pci.setFunctionScopes(orgLocal, orgArgs);
            }
        }
    }
    if (value != NULL)
        return setVariable(pc, str, value);
    return getVariable(pc, str);
}
Also used : Variables(lucee.runtime.type.scope.Variables) Undefined(lucee.runtime.type.scope.Undefined) CallerImpl(lucee.runtime.type.scope.CallerImpl) Argument(lucee.runtime.type.scope.Argument) Local(lucee.runtime.type.scope.Local) PageContextImpl(lucee.runtime.PageContextImpl)

Aggregations

CallerImpl (lucee.runtime.type.scope.CallerImpl)3 PageContextImpl (lucee.runtime.PageContextImpl)2 Argument (lucee.runtime.type.scope.Argument)2 Local (lucee.runtime.type.scope.Local)2 Undefined (lucee.runtime.type.scope.Undefined)2 Variables (lucee.runtime.type.scope.Variables)2 StructImpl (lucee.runtime.type.StructImpl)1 LocalNotSupportedScope (lucee.runtime.type.scope.LocalNotSupportedScope)1 Scope (lucee.runtime.type.scope.Scope)1