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.

This commit is contained in:
igor%mir2.org 2002-04-11 21:36:31 +00:00
parent e5b390ed80
commit 050ea5f4cf

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",