Search in sources :

Example 6 with Variables

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

the class ComponentImpl method beforeStaticConstructor.

@Override
public Variables beforeStaticConstructor(PageContext pc) {
    insideStaticConstr = true;
    Variables parent = pc.variablesScope();
    pc.setVariablesScope(_static);
    return parent;
}
Also used : Variables(lucee.runtime.type.scope.Variables)

Example 7 with Variables

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

the class StaticScope method _call.

Object _call(PageContext pc, Collection.Key calledName, UDFPlus udf, Struct namedArgs, Object[] args) throws PageException {
    Object rtn = null;
    Variables parent = null;
    // debug yes
    if (pc.getConfig().debug()) {
        // new DebugEntry(src,udf.getFunctionName());
        DebugEntryTemplate debugEntry = pc.getDebugger().getEntry(pc, cp.getPageSource(), udf.getFunctionName());
        long currTime = pc.getExecutionTime();
        long time = System.nanoTime();
        // sync yes
        if (c.top.properties._synchronized) {
            synchronized (this) {
                try {
                    parent = c.beforeStaticConstructor(pc);
                    if (args != null)
                        rtn = udf.call(pc, calledName, args, true);
                    else
                        rtn = udf.callWithNamedValues(pc, calledName, namedArgs, true);
                } finally {
                    c.afterStaticConstructor(pc, parent);
                    long diff = ((System.nanoTime() - time) - (pc.getExecutionTime() - currTime));
                    pc.setExecutionTime(pc.getExecutionTime() + diff);
                    debugEntry.updateExeTime(diff);
                }
            }
        } else // sync no
        {
            try {
                parent = c.beforeStaticConstructor(pc);
                if (args != null)
                    rtn = udf.call(pc, calledName, args, true);
                else
                    rtn = udf.callWithNamedValues(pc, calledName, namedArgs, true);
            } finally {
                c.afterStaticConstructor(pc, parent);
                long diff = ((System.nanoTime() - time) - (pc.getExecutionTime() - currTime));
                pc.setExecutionTime(pc.getExecutionTime() + diff);
                debugEntry.updateExeTime(diff);
            }
        }
    } else // debug no
    {
        // sync yes
        if (c.top.properties._synchronized) {
            synchronized (this) {
                try {
                    parent = c.beforeStaticConstructor(pc);
                    if (args != null)
                        rtn = udf.call(pc, calledName, args, true);
                    else
                        rtn = udf.callWithNamedValues(pc, calledName, namedArgs, true);
                } finally {
                    c.afterStaticConstructor(pc, parent);
                }
            }
        } else {
            try {
                parent = c.beforeStaticConstructor(pc);
                if (args != null)
                    rtn = udf.call(pc, calledName, args, true);
                else
                    rtn = udf.callWithNamedValues(pc, calledName, namedArgs, true);
            } finally {
                c.afterStaticConstructor(pc, parent);
            }
        }
    }
    return rtn;
}
Also used : Variables(lucee.runtime.type.scope.Variables) DebugEntryTemplate(lucee.runtime.debug.DebugEntryTemplate)

Example 8 with Variables

use of lucee.runtime.type.scope.Variables 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

Variables (lucee.runtime.type.scope.Variables)8 Undefined (lucee.runtime.type.scope.Undefined)3 PageContextImpl (lucee.runtime.PageContextImpl)2 DebugEntryTemplate (lucee.runtime.debug.DebugEntryTemplate)2 Argument (lucee.runtime.type.scope.Argument)2 CallerImpl (lucee.runtime.type.scope.CallerImpl)2 Local (lucee.runtime.type.scope.Local)2 Mapping (lucee.runtime.Mapping)1 Page (lucee.runtime.Page)1 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)1 ExpressionException (lucee.runtime.exp.ExpressionException)1 UDF (lucee.runtime.type.UDF)1 LocalNotSupportedScope (lucee.runtime.type.scope.LocalNotSupportedScope)1 Scope (lucee.runtime.type.scope.Scope)1 QueryStack (lucee.runtime.util.QueryStack)1 QueryStackImpl (lucee.runtime.util.QueryStackImpl)1