Bug 745057 part 2 - Rename FrameRegsIter to ScriptFrameIter. r=luke

This commit is contained in:
Nicolas Pierron 2012-04-27 15:03:12 -07:00
parent fca5fbaada
commit b704824ee8
14 changed files with 43 additions and 53 deletions

View File

@ -6619,7 +6619,7 @@ JS_DescribeScriptedCaller(JSContext *cx, JSScript **script, unsigned *lineno)
if (lineno)
*lineno = 0;
FrameRegsIter i(cx);
ScriptFrameIter i(cx);
if (i.done())
return JS_FALSE;
@ -6724,7 +6724,7 @@ JS_DecodeInterpretedFunction(JSContext *cx, const void *data, uint32_t length,
JS_PUBLIC_API(JSObject *)
JS_GetScriptedGlobal(JSContext *cx)
{
FrameRegsIter i(cx);
ScriptFrameIter i(cx);
if (i.done())
return JS_GetGlobalForScopeChain(cx);

View File

@ -339,14 +339,13 @@ PopulateReportBlame(JSContext *cx, JSErrorReport *report)
* Walk stack until we find a frame that is associated with some script
* rather than a native frame.
*/
for (FrameRegsIter iter(cx); !iter.done(); ++iter) {
if (iter.fp()->isScriptFrame()) {
report->filename = iter.fp()->script()->filename;
report->lineno = PCToLineNumber(iter.fp()->script(), iter.pc());
report->originPrincipals = iter.fp()->script()->originPrincipals;
break;
}
}
ScriptFrameIter iter(cx);
if (iter.done())
return;
report->filename = iter.script()->filename;
report->lineno = PCToLineNumber(iter.script(), iter.pc());
report->originPrincipals = iter.script()->originPrincipals;
}
/*

View File

@ -1797,7 +1797,7 @@ JS_UnwrapObject(JSObject *obj)
JS_FRIEND_API(JSBool)
js_CallContextDebugHandler(JSContext *cx)
{
FrameRegsIter iter(cx);
ScriptFrameIter iter(cx);
JS_ASSERT(!iter.done());
jsval rval;

View File

@ -292,36 +292,31 @@ InitExnPrivate(JSContext *cx, HandleObject exnObject, HandleString message,
Vector<JSStackTraceStackElem> frames(cx);
{
SuppressErrorsGuard seg(cx);
for (FrameRegsIter i(cx); !i.done(); ++i) {
for (ScriptFrameIter i(cx); !i.done(); ++i) {
StackFrame *fp = i.fp();
/*
* Ask the crystal CAPS ball whether we can see across compartments.
* NB: this means 'fp' may point to cross-compartment frames.
*/
if (checkAccess && fp->isNonEvalFunctionFrame()) {
if (checkAccess && i.isNonEvalFunctionFrame()) {
Value v = NullValue();
jsid callerid = ATOM_TO_JSID(cx->runtime->atomState.callerAtom);
if (!checkAccess(cx, &fp->callee(), callerid, JSACC_READ, &v))
if (!checkAccess(cx, i.callee(), callerid, JSACC_READ, &v))
break;
}
if (!frames.growBy(1))
return false;
JSStackTraceStackElem &frame = frames.back();
if (fp->isNonEvalFunctionFrame())
if (i.isNonEvalFunctionFrame())
frame.funName = fp->fun()->atom ? fp->fun()->atom : cx->runtime->emptyString;
else
frame.funName = NULL;
if (fp->isScriptFrame()) {
frame.filename = SaveScriptFilename(cx, fp->script()->filename);
frame.filename = SaveScriptFilename(cx, i.script()->filename);
if (!frame.filename)
return false;
frame.ulineno = PCToLineNumber(fp->script(), i.pc());
} else {
frame.ulineno = 0;
frame.filename = NULL;
}
frame.ulineno = PCToLineNumber(i.script(), i.pc());
}
}
@ -660,9 +655,7 @@ Exception(JSContext *cx, unsigned argc, Value *vp)
}
/* Find the scripted caller. */
FrameRegsIter iter(cx);
while (!iter.done() && !iter.fp()->isScriptFrame())
++iter;
ScriptFrameIter iter(cx);
/* Set the 'fileName' property. */
RootedVarString filename(cx);
@ -673,7 +666,7 @@ Exception(JSContext *cx, unsigned argc, Value *vp)
args[1].setString(filename);
} else {
if (!iter.done()) {
filename = FilenameToString(cx, iter.fp()->script()->filename);
filename = FilenameToString(cx, iter.script()->filename);
if (!filename)
return false;
} else {
@ -687,7 +680,7 @@ Exception(JSContext *cx, unsigned argc, Value *vp)
if (!ToUint32(cx, args[2], &lineno))
return false;
} else {
lineno = iter.done() ? 0 : PCToLineNumber(iter.fp()->script(), iter.pc());
lineno = iter.done() ? 0 : PCToLineNumber(iter.script(), iter.pc());
}
int exnType = args.callee().toFunction()->getExtendedSlot(0).toInt32();

View File

@ -1371,9 +1371,9 @@ js_ReportIsNotFunction(JSContext *cx, const Value *vp, unsigned flags)
*/
ptrdiff_t spindex = 0;
FrameRegsIter i(cx);
ScriptFrameIter i(cx);
if (!i.done()) {
unsigned depth = js_ReconstructStackDepth(cx, i.fp()->script(), i.pc());
unsigned depth = js_ReconstructStackDepth(cx, i.script(), i.pc());
Value *simsp = i.fp()->base() + depth;
if (i.fp()->base() <= vp && vp < Min(simsp, i.sp()))
spindex = vp - simsp;

View File

@ -3046,7 +3046,7 @@ TypeObject::clearNewScript(JSContext *cx)
* the stack and fix up any such objects.
*/
Vector<uint32_t, 32> pcOffsets(cx);
for (FrameRegsIter iter(cx); !iter.done(); ++iter) {
for (ScriptFrameIter iter(cx); !iter.done(); ++iter) {
pcOffsets.append(uint32_t(iter.pc() - iter.script()->code));
if (iter.isConstructing() &&
iter.callee() == newScript->fun &&

View File

@ -6203,7 +6203,7 @@ JS_FRIEND_API(void)
js_DumpStackFrame(JSContext *cx, StackFrame *start)
{
/* This should only called during live debugging. */
FrameRegsIter i(cx, StackIter::GO_THROUGH_SAVED);
ScriptFrameIter i(cx, StackIter::GO_THROUGH_SAVED);
if (!start) {
if (i.done()) {
fprintf(stderr, "no stack for cx = %p\n", (void*) cx);

View File

@ -2720,7 +2720,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, int nb)
*/
uint32_t format = cs->format;
bool matchPC = false;
FrameRegsIter iter(cx);
ScriptFrameIter iter(cx);
if (!iter.done()) {
jsbytecode *npc = iter.pc();
if (pc == npc) {

View File

@ -160,7 +160,7 @@ class StackFrame;
class StackSegment;
class StackSpace;
class ContextStack;
class FrameRegsIter;
class ScriptFrameIter;
class CallReceiver;
class CallArgs;

View File

@ -1719,9 +1719,7 @@ void
CurrentScriptFileLineOriginSlow(JSContext *cx, const char **file, unsigned *linenop,
JSPrincipals **origin)
{
FrameRegsIter iter(cx);
while (!iter.done() && !iter.fp()->isScriptFrame())
++iter;
ScriptFrameIter iter(cx);
if (iter.done()) {
*file = NULL;
@ -1730,9 +1728,9 @@ CurrentScriptFileLineOriginSlow(JSContext *cx, const char **file, unsigned *line
return;
}
JSScript *script = iter.fp()->script();
JSScript *script = iter.script();
*file = script->filename;
*linenop = PCToLineNumber(iter.fp()->script(), iter.pc());
*linenop = PCToLineNumber(iter.script(), iter.pc());
*origin = script->originPrincipals;
}

View File

@ -1783,12 +1783,12 @@ ParseXMLSource(JSContext *cx, JSString *src)
xml = NULL;
filename = NULL;
lineno = 1;
FrameRegsIter i(cx);
ScriptFrameIter i(cx);
if (!i.done()) {
op = (JSOp) *i.pc();
if (op == JSOP_TOXML || op == JSOP_TOXMLLIST) {
filename = i.fp()->script()->filename;
lineno = PCToLineNumber(i.fp()->script(), i.pc());
filename = i.script()->filename;
lineno = PCToLineNumber(i.script(), i.pc());
for (endp = srcp + srclen; srcp < endp; srcp++) {
if (*srcp == '\n')
--lineno;

View File

@ -1329,7 +1329,7 @@ TrapHandler(JSContext *cx, JSScript *, jsbytecode *pc, jsval *rval,
{
JSString *str = JSVAL_TO_STRING(closure);
FrameRegsIter iter(cx);
ScriptFrameIter iter(cx);
JS_ASSERT(!iter.done());
JSStackFrame *caller = Jsvalify(iter.fp());
@ -2683,7 +2683,7 @@ EvalInFrame(JSContext *cx, unsigned argc, jsval *vp)
JS_ASSERT(cx->hasfp());
FrameRegsIter fi(cx);
ScriptFrameIter fi(cx);
for (uint32_t i = 0; i < upCount; ++i, ++fi) {
if (!fi.fp()->prev())
break;

View File

@ -2109,9 +2109,9 @@ class Debugger::ScriptQuery {
* Since eval scripts have no global, we need to find them via the call
* stack, where frame's scope tells us the global in use.
*/
for (FrameRegsIter fri(cx); !fri.done(); ++fri) {
if (fri.fp()->isEvalFrame()) {
JSScript *script = fri.fp()->script();
for (ScriptFrameIter fri(cx); !fri.done(); ++fri) {
if (fri.isEvalFrame()) {
JSScript *script = fri.script();
/*
* If eval scripts never have global objects set, then we don't need

View File

@ -71,7 +71,7 @@ class DummyFrameGuard;
class GeneratorFrameGuard;
class CallIter;
class FrameRegsIter;
class ScriptFrameIter;
class AllFramesIter;
class ArgumentsObject;
@ -582,7 +582,7 @@ class StackFrame
* for ( ...; fp; fp = fp->prev())
* ... fp->pcQuadratic(cx->stack);
*
* Using next can avoid this, but in most cases prefer FrameRegsIter;
* Using next can avoid this, but in most cases prefer ScriptFrameIter;
* it is amortized O(1).
*
* When I get to the bottom I go back to the top of the stack
@ -1865,7 +1865,7 @@ class StackIter
};
/* A filtering of the StackIter to only stop at scripts. */
class FrameRegsIter : public StackIter
class ScriptFrameIter : public StackIter
{
void settle() {
while (!done() && !isScript())
@ -1873,10 +1873,10 @@ class FrameRegsIter : public StackIter
}
public:
FrameRegsIter(JSContext *cx, StackIter::SavedOption opt = StackIter::STOP_AT_SAVED)
ScriptFrameIter(JSContext *cx, StackIter::SavedOption opt = StackIter::STOP_AT_SAVED)
: StackIter(cx, opt) { settle(); }
FrameRegsIter &operator++() { StackIter::operator++(); settle(); return *this; }
ScriptFrameIter &operator++() { StackIter::operator++(); settle(); return *this; }
};
/*****************************************************************************/