ECMA handling of undefined args for call & apply.

This commit is contained in:
rogerl%netscape.com 1999-10-27 22:17:05 +00:00
parent 32feff141e
commit 59bbd1a9d3
2 changed files with 30 additions and 6 deletions

View File

@ -919,9 +919,21 @@ public class NativeFunction extends ScriptableObject implements Function {
return jsFunction_call(cx, thisObj, args, funObj);
Object val = thisObj.getDefaultValue(ScriptRuntime.FunctionClass);
Scriptable newThis = args[0] == null
? null
? ScriptableObject.getTopLevelScope(thisObj)
: ScriptRuntime.toObject(funObj, args[0]);
Object[] newArgs = cx.getElements((Scriptable) args[1]);
Object[] newArgs;
if (args.length > 1) {
if ((args[1] instanceof NativeArray)
|| (args[1] instanceof Arguments))
newArgs = cx.getElements((Scriptable) args[1]);
else
throw NativeGlobal.constructError(
cx, "TypeError",
ScriptRuntime.getMessage("msg.arg.isnt.array", null),
thisObj);
}
else
newArgs = new Object[0];
return ScriptRuntime.call(cx, val, newThis, newArgs);
}
@ -941,7 +953,7 @@ public class NativeFunction extends ScriptableObject implements Function {
ScriptRuntime.emptyArgs);
} else {
Scriptable newThis = args[0] == null
? null
? ScriptableObject.getTopLevelScope(thisObj)
: ScriptRuntime.toObject(funObj, args[0]);
Object[] newArgs = new Object[args.length - 1];

View File

@ -919,9 +919,21 @@ public class NativeFunction extends ScriptableObject implements Function {
return jsFunction_call(cx, thisObj, args, funObj);
Object val = thisObj.getDefaultValue(ScriptRuntime.FunctionClass);
Scriptable newThis = args[0] == null
? null
? ScriptableObject.getTopLevelScope(thisObj)
: ScriptRuntime.toObject(funObj, args[0]);
Object[] newArgs = cx.getElements((Scriptable) args[1]);
Object[] newArgs;
if (args.length > 1) {
if ((args[1] instanceof NativeArray)
|| (args[1] instanceof Arguments))
newArgs = cx.getElements((Scriptable) args[1]);
else
throw NativeGlobal.constructError(
cx, "TypeError",
ScriptRuntime.getMessage("msg.arg.isnt.array", null),
thisObj);
}
else
newArgs = new Object[0];
return ScriptRuntime.call(cx, val, newThis, newArgs);
}
@ -941,7 +953,7 @@ public class NativeFunction extends ScriptableObject implements Function {
ScriptRuntime.emptyArgs);
} else {
Scriptable newThis = args[0] == null
? null
? ScriptableObject.getTopLevelScope(thisObj)
: ScriptRuntime.toObject(funObj, args[0]);
Object[] newArgs = new Object[args.length - 1];