Bug 355820: follow-up to fix eval breakage. patch by crowder@fiverocks.com, r=brendan

This commit is contained in:
crowder%fiverocks.com 2007-01-28 19:17:29 +00:00
parent 42afbc5d4a
commit 5a1b387260

View File

@ -1244,20 +1244,18 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
if (caller && !caller->varobj && !js_GetCallObject(cx, caller, NULL))
return JS_FALSE;
scopeobj = NULL;
#if JS_HAS_SCRIPT_OBJECT
/*
* Script.prototype.compile/exec and Object.prototype.eval all take an
* optional trailing argument that overrides the scope object.
*/
scopeobj = NULL;
if (argc >= 2) {
if (!js_ValueToObject(cx, argv[1], &scopeobj))
return JS_FALSE;
argv[1] = OBJECT_TO_JSVAL(scopeobj);
}
if (!scopeobj)
#endif
{
if (!scopeobj) {
#if JS_HAS_EVAL_THIS_SCOPE
/* If obj.eval(str), emulate 'with (obj) eval(str)' in the caller. */
if (indirectCall) {
@ -1343,10 +1341,7 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
goto out;
}
#if JS_HAS_SCRIPT_OBJECT
if (argc < 2)
#endif
{
if (argc < 2) {
/* Execute using caller's new scope object (might be a Call object). */
if (caller)
scopeobj = caller->scopeChain;