Reflect call object into runtime scope chain before reflecting block objects (352797, r=mrbkap).

This commit is contained in:
brendan%mozilla.org 2006-10-10 21:59:37 +00:00
parent 60895ac5c3
commit 9ff2661554
2 changed files with 19 additions and 0 deletions

View File

@ -611,6 +611,7 @@ js_GetCallObject(JSContext *cx, JSStackFrame *fp, JSObject *parent)
fp->callobj = callobj;
/* Make callobj be the scope chain and the variables object. */
JS_ASSERT(fp->scopeChain == parent);
fp->scopeChain = callobj;
fp->varobj = callobj;
return callobj;

View File

@ -471,10 +471,28 @@ js_GetScopeChain(JSContext *cx, JSStackFrame *fp)
obj = fp->blockChain;
if (!obj) {
/*
* Don't force a call object for a lightweight function call, but do
* insist that there is a call object for a heavyweight function call.
*/
JS_ASSERT(!fp->fun ||
!(fp->fun->flags & JSFUN_HEAVYWEIGHT) ||
fp->callobj);
JS_ASSERT(fp->scopeChain);
return fp->scopeChain;
}
/*
* We have one or more lexical scopes to reflect into fp->scopeChain, so
* make sure there's a call object at the current head of the scope chain,
* if this frame is a call frame.
*/
if (fp->fun && !fp->callobj) {
JS_ASSERT(OBJ_GET_CLASS(cx, fp->scopeChain) != &js_BlockClass);
if (!js_GetCallObject(cx, fp, fp->scopeChain))
return NULL;
}
/*
* Clone the block chain. To avoid recursive cloning we set the parent of
* the cloned child after we clone the parent. In the following loop when