Long ago, mccabe copied the principals setting code in Function from late to early in the function (should've moved, but no one noticed); last month, I fixed bug 90546 in the original site but not in the copy; this change eliminates the duplication, moving the fix up to the copy's site (90546, r=jst, sr=jband, a=chofmann).

git-svn-id: svn://10.0.0.236/trunk@110410 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
brendan%mozilla.org
2001-12-13 00:27:20 +00:00
parent 5f05504111
commit 3a8c6f3d85

View File

@@ -1632,14 +1632,33 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
if (!fun)
return JS_FALSE;
if ((fp = cx->fp) != NULL && (fp = fp->down) != NULL && fp->script) {
filename = fp->script->filename;
lineno = js_PCToLineNumber(fp->script, fp->pc);
principals = fp->script->principals;
} else {
filename = NULL;
lineno = 0;
principals = NULL;
/*
* Function is static and not called directly by other functions in this
* file, therefore it is callable only as a native function by js_Invoke.
* Find the scripted caller, possibly skipping other native frames such as
* are built for Function.prototype.call or .apply activations that invoke
* Function indirectly from a script.
*/
fp = cx->fp;
JS_ASSERT(!fp->script && fp->fun && fp->fun->native == Function);
for (;;) {
fp = fp->down;
if (!fp) {
filename = NULL;
lineno = 0;
principals = NULL;
break;
}
if (fp->script) {
/*
* Load fp->script->* before calling js_PCToLineNumber, to avoid
* a pessimal reload of fp->script.
*/
principals = fp->script->principals;
filename = fp->script->filename;
lineno = js_PCToLineNumber(fp->script, fp->pc);
break;
}
}
n = argc ? argc - 1 : 0;
@@ -1794,31 +1813,6 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
argv[(intn)(argc-1)] = STRING_TO_JSVAL(str);
}
/*
* Function is static and not called directly by other functions in this
* file, therefore it is callable only as a native function by js_Invoke.
* Find the scripted caller, possibly skipping other native frames such as
* are built for Function.prototype.call or .apply activations that invoke
* Function indirectly from a script.
*/
fp = cx->fp;
JS_ASSERT(!fp->script && fp->fun && fp->fun->native == Function);
for (;;) {
fp = fp->down;
if (!fp) {
filename = NULL;
lineno = 0;
principals = NULL;
break;
}
if (fp->script) {
filename = fp->script->filename;
lineno = js_PCToLineNumber(fp->script, fp->pc);
principals = fp->script->principals;
break;
}
}
mark = JS_ARENA_MARK(&cx->tempPool);
ts = js_NewTokenStream(cx, JSSTRING_CHARS(str), JSSTRING_LENGTH(str),
filename, lineno, principals);