public override object ExecIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, object[] args)
{
if (!f.HasTag(FUNCTION_TAG))
{
return base.ExecIdCall(f, cx, scope, thisObj, args);
}
int id = f.MethodId();
switch (id)
{
case Id_constructor:
{
return JsConstructor(cx, scope, args);
}
case Id_toString:
{
Rhino.BaseFunction realf = RealFunction(thisObj, f);
int indent = ScriptRuntime.ToInt32(args, 0);
return realf.Decompile(indent, 0);
}
case Id_toSource:
{
Rhino.BaseFunction realf = RealFunction(thisObj, f);
int indent = 0;
int flags = Decompiler.TO_SOURCE_FLAG;
if (args.Length != 0)
{
indent = ScriptRuntime.ToInt32(args[0]);
if (indent >= 0)
{
flags = 0;
}
else
{
indent = 0;
}
}
return realf.Decompile(indent, flags);
}
case Id_apply:
case Id_call:
{
return ScriptRuntime.ApplyOrCall(id == Id_apply, cx, scope, thisObj, args);
}
case Id_bind:
{
if (!(thisObj is Callable))
{
throw ScriptRuntime.NotFunctionError(thisObj);
}
Callable targetFunction = (Callable)thisObj;
int argc = args.Length;
Scriptable boundThis;
object[] boundArgs;
if (argc > 0)
{
boundThis = ScriptRuntime.ToObjectOrNull(cx, args[0], scope);
boundArgs = new object[argc - 1];
System.Array.Copy(args, 1, boundArgs, 0, argc - 1);
}
else
{
boundThis = null;
boundArgs = ScriptRuntime.emptyArgs;
}
return new BoundFunction(cx, scope, targetFunction, boundThis, boundArgs);
}
}
throw new ArgumentException(id.ToString());
}