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;
}
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;
}
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);
}
Aggregations