Fix API botch where 'var x=0' vs. 'x=0' could put x in a different object (65553, r=mccabe, sr=jband).

git-svn-id: svn://10.0.0.236/trunk@85067 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
brendan%mozilla.org
2001-01-18 03:00:31 +00:00
parent d383f0e075
commit a8e8c0ed81
7 changed files with 17 additions and 14 deletions

View File

@@ -3110,7 +3110,7 @@ JS_PUBLIC_API(JSBool)
JS_ExecuteScript(JSContext *cx, JSObject *obj, JSScript *script, jsval *rval)
{
CHECK_REQUEST(cx);
if (!js_Execute(cx, obj, script, NULL, NULL, 0, rval)) {
if (!js_Execute(cx, obj, script, NULL, 0, rval)) {
#if JS_HAS_EXCEPTIONS
js_ReportUncaughtException(cx);
#endif
@@ -3214,7 +3214,7 @@ JS_EvaluateUCScriptForPrincipals(JSContext *cx, JSObject *obj,
filename, lineno);
if (!script)
return JS_FALSE;
ok = js_Execute(cx, obj, script, NULL, NULL, 0, rval);
ok = js_Execute(cx, obj, script, NULL, 0, rval);
#if JS_HAS_EXCEPTIONS
if (!ok)
js_ReportUncaughtException(cx);

View File

@@ -747,8 +747,7 @@ JS_EvaluateInStackFrame(JSContext *cx, JSStackFrame *fp,
bytes, length, filename, lineno);
if (!script)
return JS_FALSE;
ok = js_Execute(cx, fp->scopeChain, script, fp->fun, fp, JSFRAME_DEBUGGER,
rval);
ok = js_Execute(cx, fp->scopeChain, script, fp, JSFRAME_DEBUGGER, rval);
js_DestroyScript(cx, script);
return ok;
}

View File

@@ -965,8 +965,8 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
script = js_NewScriptFromCG(cx, &cg2, NULL);
if (!script)
return JS_FALSE;
ok = js_Execute(cx, cx->fp->scopeChain, script, NULL,
cx->fp, 0, &pn3->pn_val);
ok = js_Execute(cx, cx->fp->scopeChain, script, cx->fp, 0,
&pn3->pn_val);
js_DestroyScript(cx, script);
if (!ok)
return JS_FALSE;

View File

@@ -886,10 +886,11 @@ out:
}
JSBool
js_Execute(JSContext *cx, JSObject *chain, JSScript *script, JSFunction *fun,
js_Execute(JSContext *cx, JSObject *chain, JSScript *script,
JSStackFrame *down, uintN special, jsval *result)
{
JSStackFrame *oldfp, frame;
JSObject *obj, *tmp;
JSBool ok;
JSInterpreterHook hook;
void *hookData;
@@ -899,10 +900,10 @@ js_Execute(JSContext *cx, JSObject *chain, JSScript *script, JSFunction *fun,
oldfp = cx->fp;
frame.callobj = frame.argsobj = NULL;
frame.script = script;
frame.fun = fun;
if (down) {
/* Propagate arg/var state for eval and the debugger API. */
frame.varobj = down->varobj;
frame.fun = down->fun;
frame.thisp = down->thisp;
frame.argc = down->argc;
frame.argv = down->argv;
@@ -911,7 +912,10 @@ js_Execute(JSContext *cx, JSObject *chain, JSScript *script, JSFunction *fun,
frame.annotation = down->annotation;
frame.sharpArray = down->sharpArray;
} else {
frame.varobj = chain;
for (obj = chain; (tmp = OBJ_GET_PARENT(cx, obj)) != NULL; obj = tmp)
continue;
frame.varobj = obj;
frame.fun = NULL;
frame.thisp = chain;
frame.argc = frame.nvars = 0;
frame.argv = frame.vars = NULL;

View File

@@ -245,8 +245,8 @@ js_InternalInvoke(JSContext *cx, JSObject *obj, jsval fval, uintN flags,
uintN argc, jsval *argv, jsval *rval);
extern JSBool
js_Execute(JSContext *cx, JSObject *chain, JSScript *script, JSFunction *fun,
JSStackFrame *down, uintN flags, jsval *result);
js_Execute(JSContext *cx, JSObject *chain, JSScript *script,
JSStackFrame *down, uintN flags, jsval *result);
extern JSBool
js_CheckRedeclaration(JSContext *cx, JSObject *obj, jsid id, uintN attrs,

View File

@@ -948,8 +948,8 @@ obj_eval(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
scopeobj = caller->scopeChain;
}
#endif
ok = js_Execute(cx, scopeobj, script, caller->fun, caller,
cx->fp->special & JSFRAME_EVAL,
ok = js_Execute(cx, scopeobj, script, caller,
cx->fp->special & JSFRAME_EVAL,
rval);
JS_DestroyScript(cx, script);

View File

@@ -242,7 +242,7 @@ script_exec(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
fp->thisp = caller->thisp;
JS_ASSERT(fp->scopeChain == caller->scopeChain);
fp->sharpArray = caller->sharpArray;
return js_Execute(cx, scopeobj, script, NULL, fp, 0, rval);
return js_Execute(cx, scopeobj, script, fp, 0, rval);
}
#if JS_HAS_XDR