Bug 872416, part 1 - Move js::frontend::LexicalLookup from a header into the only file that uses it. r=luke.

This commit is contained in:
Jason Orendorff 2013-06-04 16:24:42 -05:00
parent a50604fd0f
commit df9f5f7056
2 changed files with 45 additions and 45 deletions

View File

@ -2765,6 +2765,51 @@ PopStatementPC(JSContext *cx, ParseContext<ParseHandler> *pc)
}
}
/*
* The function LexicalLookup searches a static binding for the given name in
* the stack of statements enclosing the statement currently being parsed. Each
* statement that introduces a new scope has a corresponding scope object, on
* which the bindings for that scope are stored. LexicalLookup either returns
* the innermost statement which has a scope object containing a binding with
* the given name, or NULL.
*/
template <class ContextT>
typename ContextT::StmtInfo *
LexicalLookup(ContextT *ct, HandleAtom atom, int *slotp, typename ContextT::StmtInfo *stmt)
{
RootedId id(ct->sc->context, AtomToId(atom));
if (!stmt)
stmt = ct->topScopeStmt;
for (; stmt; stmt = stmt->downScope) {
/*
* With-statements introduce dynamic bindings. Since dynamic bindings
* can potentially override any static bindings introduced by statements
* further up the stack, we have to abort the search.
*/
if (stmt->type == STMT_WITH)
break;
// Skip statements that do not introduce a new scope
if (!stmt->isBlockScope)
continue;
StaticBlockObject &blockObj = *stmt->blockObj;
Shape *shape = blockObj.nativeLookup(ct->sc->context, id);
if (shape) {
JS_ASSERT(shape->hasShortID());
if (slotp)
*slotp = blockObj.stackDepth() + shape->shortid();
return stmt;
}
}
if (slotp)
*slotp = -1;
return stmt;
}
template <typename ParseHandler>
static inline bool
OuterLet(ParseContext<ParseHandler> *pc, StmtInfoPC *stmt, HandleAtom atom)

View File

@ -93,51 +93,6 @@ frontend::FinishPopStatement(ContextT *ct)
}
}
/*
* The function LexicalLookup searches a static binding for the given name in
* the stack of statements enclosing the statement currently being parsed. Each
* statement that introduces a new scope has a corresponding scope object, on
* which the bindings for that scope are stored. LexicalLookup either returns
* the innermost statement which has a scope object containing a binding with
* the given name, or NULL.
*/
template <class ContextT>
typename ContextT::StmtInfo *
frontend::LexicalLookup(ContextT *ct, HandleAtom atom, int *slotp, typename ContextT::StmtInfo *stmt)
{
RootedId id(ct->sc->context, AtomToId(atom));
if (!stmt)
stmt = ct->topScopeStmt;
for (; stmt; stmt = stmt->downScope) {
/*
* With-statements introduce dynamic bindings. Since dynamic bindings
* can potentially override any static bindings introduced by statements
* further up the stack, we have to abort the search.
*/
if (stmt->type == STMT_WITH)
break;
// Skip statements that do not introduce a new scope
if (!stmt->isBlockScope)
continue;
StaticBlockObject &blockObj = *stmt->blockObj;
Shape *shape = blockObj.nativeLookup(ct->sc->context, id);
if (shape) {
JS_ASSERT(shape->hasShortID());
if (slotp)
*slotp = blockObj.stackDepth() + shape->shortid();
return stmt;
}
}
if (slotp)
*slotp = -1;
return stmt;
}
} // namespace js
#endif // SharedContext_inl_h__