As the scope parameter for the bind and getBase methods should never be null, make sure they trigger NullPointerException on "scope == null" to detect bad API usage earlier.

git-svn-id: svn://10.0.0.236/trunk@118790 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
igor%mir2.org 2002-04-11 21:36:31 +00:00
parent e4f258ecce
commit ab92539dc3

View File

@ -1092,19 +1092,19 @@ public class ScriptRuntime {
* See ECMA 10.1.4
*/
public static Scriptable bind(Scriptable scope, String id) {
Scriptable obj = scope;
while (obj != null && !ScriptableObject.hasProperty(obj, id)) {
obj = obj.getParentScope();
while (!ScriptableObject.hasProperty(scope, id)) {
scope = scope.getParentScope();
if (scope == null) {
break;
}
}
return obj;
return scope;
}
public static Scriptable getBase(Scriptable scope, String id) {
Scriptable obj = scope;
while (obj != null) {
if (ScriptableObject.hasProperty(obj, id))
return obj;
obj = obj.getParentScope();
Scriptable base = bind(scope, id);
if (base != null) {
return base;
}
throw NativeGlobal.constructError(
Context.getContext(), "ReferenceError",