use of lucee.runtime.type.scope.Argument in project Lucee by lucee.
the class ComponentImpl method onMissingMethod.
public Object onMissingMethod(PageContext pc, int access, Member member, String name, Object[] _args, Struct _namedArgs, boolean superAccess) throws PageException {
Member ommm = access == -1 ? getMember(pc, KeyConstants._onmissingmethod, false, superAccess) : getMember(access, KeyConstants._onmissingmethod, false, superAccess);
if (ommm instanceof UDF) {
Argument args = new ArgumentImpl();
if (_args != null) {
for (int i = 0; i < _args.length; i++) {
args.setEL(ArgumentIntKey.init(i + 1), _args[i]);
}
} else if (_namedArgs != null) {
UDFUtil.argumentCollection(_namedArgs, new FunctionArgument[] {});
Iterator<Entry<Key, Object>> it = _namedArgs.entryIterator();
Entry<Key, Object> e;
while (it.hasNext()) {
e = it.next();
args.setEL(e.getKey(), e.getValue());
}
}
// Struct newArgs=new StructImpl(StructImpl.TYPE_SYNC);
// newArgs.setEL(MISSING_METHOD_NAME, name);
// newArgs.setEL(MISSING_METHOD_ARGS, args);
Object[] newArgs = new Object[] { name, args };
return _call(pc, KeyConstants._onmissingmethod, (UDFPlus) ommm, null, newArgs);
}
if (member == null)
throw ComponentUtil.notFunction(this, KeyImpl.init(name), null, access);
throw ComponentUtil.notFunction(this, KeyImpl.init(name), member.getValue(), access);
}
use of lucee.runtime.type.scope.Argument 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