Search in sources :

Example 1 with LocalNotSupportedScope

use of lucee.runtime.type.scope.LocalNotSupportedScope 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 2 with LocalNotSupportedScope

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

the class CFMLFactoryImpl method getInfo.

public Array getInfo() {
    Array info = new ArrayImpl();
    // synchronized (runningPcs) {
    // int len=runningPcs.size();
    Iterator<PageContextImpl> it = runningPcs.values().iterator();
    PageContextImpl pc;
    Struct data, sctThread, scopes;
    Thread thread;
    Entry<Integer, PageContextImpl> e;
    ConfigWebImpl cw;
    while (it.hasNext()) {
        pc = it.next();
        cw = (ConfigWebImpl) pc.getConfig();
        data = new StructImpl();
        sctThread = new StructImpl();
        scopes = new StructImpl();
        data.setEL("thread", sctThread);
        data.setEL("scopes", scopes);
        if (pc.isGatewayContext())
            continue;
        thread = pc.getThread();
        if (thread == Thread.currentThread())
            continue;
        thread = pc.getThread();
        if (thread == Thread.currentThread())
            continue;
        data.setEL("startTime", new DateTimeImpl(pc.getStartTime(), false));
        data.setEL("endTime", new DateTimeImpl(pc.getStartTime() + pc.getRequestTimeout(), false));
        data.setEL(KeyConstants._timeout, new Double(pc.getRequestTimeout()));
        // thread
        sctThread.setEL(KeyConstants._name, thread.getName());
        sctThread.setEL("priority", Caster.toDouble(thread.getPriority()));
        data.setEL("TagContext", PageExceptionImpl.getTagContext(pc.getConfig(), thread.getStackTrace()));
        data.setEL("urlToken", pc.getURLToken());
        try {
            if (pc.getConfig().debug())
                data.setEL("debugger", pc.getDebugger().getDebuggingData(pc));
        } catch (PageException e2) {
        }
        try {
            data.setEL(KeyConstants._id, Hash.call(pc, pc.getId() + ":" + pc.getStartTime()));
        } catch (PageException e1) {
        }
        data.setEL(KeyConstants._hash, cw.getHash());
        data.setEL("contextId", cw.getIdentification().getId());
        data.setEL(KeyConstants._label, cw.getLabel());
        data.setEL("requestId", pc.getId());
        // Scopes
        scopes.setEL(KeyConstants._name, pc.getApplicationContext().getName());
        try {
            scopes.setEL(KeyConstants._application, pc.applicationScope());
        } catch (PageException pe) {
        }
        try {
            scopes.setEL(KeyConstants._session, pc.sessionScope());
        } catch (PageException pe) {
        }
        try {
            scopes.setEL(KeyConstants._client, pc.clientScope());
        } catch (PageException pe) {
        }
        scopes.setEL(KeyConstants._cookie, pc.cookieScope());
        scopes.setEL(KeyConstants._variables, pc.variablesScope());
        if (!(pc.localScope() instanceof LocalNotSupportedScope)) {
            scopes.setEL(KeyConstants._local, pc.localScope());
            scopes.setEL(KeyConstants._arguments, pc.argumentsScope());
        }
        scopes.setEL(KeyConstants._cgi, pc.cgiScope());
        scopes.setEL(KeyConstants._form, pc.formScope());
        scopes.setEL(KeyConstants._url, pc.urlScope());
        scopes.setEL(KeyConstants._request, pc.requestScope());
        info.appendEL(data);
    }
    return info;
// }
}
Also used : PageException(lucee.runtime.exp.PageException) LocalNotSupportedScope(lucee.runtime.type.scope.LocalNotSupportedScope) ArrayImpl(lucee.runtime.type.ArrayImpl) Struct(lucee.runtime.type.Struct) Array(lucee.runtime.type.Array) ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) StructImpl(lucee.runtime.type.StructImpl) DateTimeImpl(lucee.runtime.type.dt.DateTimeImpl)

Aggregations

LocalNotSupportedScope (lucee.runtime.type.scope.LocalNotSupportedScope)2 PageContextImpl (lucee.runtime.PageContextImpl)1 ConfigWebImpl (lucee.runtime.config.ConfigWebImpl)1 PageException (lucee.runtime.exp.PageException)1 Array (lucee.runtime.type.Array)1 ArrayImpl (lucee.runtime.type.ArrayImpl)1 Struct (lucee.runtime.type.Struct)1 StructImpl (lucee.runtime.type.StructImpl)1 DateTimeImpl (lucee.runtime.type.dt.DateTimeImpl)1 Argument (lucee.runtime.type.scope.Argument)1 CallerImpl (lucee.runtime.type.scope.CallerImpl)1 Local (lucee.runtime.type.scope.Local)1 Scope (lucee.runtime.type.scope.Scope)1 Undefined (lucee.runtime.type.scope.Undefined)1 Variables (lucee.runtime.type.scope.Variables)1