From f6bd49caa2d25ad0cdf13b503c9bdfd02733ba6b Mon Sep 17 00:00:00 2001 From: "igor%mir2.org" Date: Thu, 21 Oct 2004 17:55:14 +0000 Subject: [PATCH] Compatibility with Rhino+Continuation fork: in ScriptableObject.callMethod always use object as scope source even if the scope from function does not belong to its prototype chain. --- .../org/mozilla/javascript/ScriptableObject.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/js/rhino/src/org/mozilla/javascript/ScriptableObject.java b/js/rhino/src/org/mozilla/javascript/ScriptableObject.java index 369e431fc7ff..41f5a24e4dc0 100644 --- a/js/rhino/src/org/mozilla/javascript/ScriptableObject.java +++ b/js/rhino/src/org/mozilla/javascript/ScriptableObject.java @@ -1483,13 +1483,14 @@ public abstract class ScriptableObject implements Scriptable, Serializable, throw ScriptRuntime.notFunctionError(obj, methodName); } Function fun = (Function)funObj; - Scriptable scope = ScriptableObject.getTopLevelScope(fun); - // XXX: The following is only necessary for dynamic scope setup, - // but to check for that Context instance is required. - // Since it should not harm non-dynamic scope setup, do it always - // for now. - Scriptable dynamicScope = ScriptableObject.getTopLevelScope(obj); - scope = ScriptRuntime.checkDynamicScope(dynamicScope, scope); + // XXX: What should be the scope when calling funObj? + // The following favor scope stored in the object on the assumption + // that is more useful especially under dynamic scope setup. + // An alternative is to check for dynamic scope flag + // and use ScriptableObject.getTopLevelScope(fun) if the flag is not + // set. But that require access to Context and messy code + // so for now it is not checked. + Scriptable scope = ScriptableObject.getTopLevelScope(obj); if (cx != null) { return fun.call(cx, scope, obj, args); } else {