public static Callable GetNameFunctionAndThis(string name, Context cx, Scriptable scope)
{
Scriptable parent = scope.GetParentScope();
if (parent == null)
{
object result = TopScopeName(cx, scope, name);
if (!(result is Callable))
{
if (result == ScriptableConstants.NOT_FOUND)
{
throw NotFoundError(scope, name);
}
else
{
throw NotFunctionError(result, name);
}
}
// Top scope is not NativeWith or NativeCall => thisObj == scope
Scriptable thisObj = scope;
StoreScriptable(cx, thisObj);
return (Callable)result;
}
// name will call storeScriptable(cx, thisObj);
return (Callable)NameOrFunction(cx, scope, parent, name, true);
}