Bug 880538 - store a pointer from ParseContext to it's PNK_FUNCTION ParseNode (r=bhackett)

--HG--
extra : rebase_source : acb4b0e5d94d0c1777173a4b0f378c46591805b3
This commit is contained in:
Luke Wagner 2013-06-28 10:29:58 -07:00
Родитель 601b5bb5fc
Коммит 8e0205288c
3 изменённых файлов: 23 добавлений и 18 удалений

Просмотреть файл

@ -240,8 +240,8 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain,
// reset when this occurs.
Maybe<ParseContext<FullParseHandler> > pc;
pc.construct(&parser, (GenericParseContext *) NULL, &globalsc, (Directives *) NULL,
staticLevel, /* bodyid = */ 0);
pc.construct(&parser, (GenericParseContext *) NULL, (ParseNode *) NULL, &globalsc,
(Directives *) NULL, staticLevel, /* bodyid = */ 0);
if (!pc.ref().init())
return NULL;
@ -306,8 +306,8 @@ frontend::CompileScript(JSContext *cx, HandleObject scopeChain,
return NULL;
pc.destroy();
pc.construct(&parser, (GenericParseContext *) NULL, &globalsc,
(Directives *) NULL, staticLevel, /* bodyid = */ 0);
pc.construct(&parser, (GenericParseContext *) NULL, (ParseNode *) NULL,
&globalsc, (Directives *) NULL, staticLevel, /* bodyid = */ 0);
if (!pc.ref().init())
return NULL;
JS_ASSERT(parser.pc == pc.addr());

Просмотреть файл

@ -607,9 +607,9 @@ Parser<ParseHandler>::parse(JSObject *chain)
*/
Directives directives(options().strictOption);
GlobalSharedContext globalsc(context, chain, directives, options().extraWarningsOption);
ParseContext<ParseHandler> globalpc(this, /* parent = */ NULL, &globalsc,
/* newDirectives = */ NULL, /* staticLevel = */ 0,
/* bodyid = */ 0);
ParseContext<ParseHandler> globalpc(this, /* parent = */ NULL, ParseHandler::null(),
&globalsc, /* newDirectives = */ NULL,
/* staticLevel = */ 0, /* bodyid = */ 0);
if (!globalpc.init())
return null();
@ -867,7 +867,7 @@ Parser<FullParseHandler>::standaloneFunctionBody(HandleFunction fun, const AutoN
return null();
handler.setFunctionBox(fn, funbox);
ParseContext<FullParseHandler> funpc(this, pc, funbox, newDirectives,
ParseContext<FullParseHandler> funpc(this, pc, fn, funbox, newDirectives,
/* staticLevel = */ 0, /* bodyid = */ 0);
if (!funpc.init())
return null();
@ -2078,8 +2078,9 @@ Parser<FullParseHandler>::functionArgsAndBody(ParseNode *pn, HandleFunction fun,
tokenStream.tell(&position);
parser->tokenStream.seek(position, tokenStream);
ParseContext<SyntaxParseHandler> funpc(parser, outerpc, funbox, newDirectives,
outerpc->staticLevel + 1, outerpc->blockidGen);
ParseContext<SyntaxParseHandler> funpc(parser, outerpc, SyntaxParseHandler::null(), funbox,
newDirectives, outerpc->staticLevel + 1,
outerpc->blockidGen);
if (!funpc.init())
return false;
@ -2110,7 +2111,7 @@ Parser<FullParseHandler>::functionArgsAndBody(ParseNode *pn, HandleFunction fun,
} while (false);
// Continue doing a full parse for this inner function.
ParseContext<FullParseHandler> funpc(this, pc, funbox, newDirectives,
ParseContext<FullParseHandler> funpc(this, pc, pn, funbox, newDirectives,
outerpc->staticLevel + 1, outerpc->blockidGen);
if (!funpc.init())
return false;
@ -2148,7 +2149,7 @@ Parser<SyntaxParseHandler>::functionArgsAndBody(Node pn, HandleFunction fun,
return false;
// Initialize early for possible flags mutation via destructuringExpr.
ParseContext<SyntaxParseHandler> funpc(this, pc, funbox, newDirectives,
ParseContext<SyntaxParseHandler> funpc(this, pc, handler.null(), funbox, newDirectives,
outerpc->staticLevel + 1, outerpc->blockidGen);
if (!funpc.init())
return false;
@ -2181,7 +2182,7 @@ Parser<FullParseHandler>::standaloneLazyFunction(HandleFunction fun, unsigned st
return null();
Directives newDirectives = directives;
ParseContext<FullParseHandler> funpc(this, /* parent = */ NULL, funbox,
ParseContext<FullParseHandler> funpc(this, /* parent = */ NULL, pn, funbox,
&newDirectives, staticLevel, /* bodyid = */ 0);
if (!funpc.init())
return null();
@ -2312,8 +2313,9 @@ Parser<FullParseHandler>::moduleDecl()
return NULL;
pn->pn_modulebox = modulebox;
ParseContext<FullParseHandler> modulepc(this, pc, modulebox, /* newDirectives = */ NULL,
pc->staticLevel + 1, pc->blockidGen);
ParseContext<FullParseHandler> modulepc(this, pc, /* function = */ NULL, modulebox,
/* newDirectives = */ NULL, pc->staticLevel + 1,
pc->blockidGen);
if (!modulepc.init())
return NULL;
MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_MODULE);
@ -5990,8 +5992,9 @@ Parser<FullParseHandler>::generatorExpr(ParseNode *kid)
if (!genFunbox)
return null();
ParseContext<FullParseHandler> genpc(this, outerpc, genFunbox, /* newDirectives = */ NULL,
outerpc->staticLevel + 1, outerpc->blockidGen);
ParseContext<FullParseHandler> genpc(this, outerpc, genfn, genFunbox,
/* newDirectives = */ NULL, outerpc->staticLevel + 1,
outerpc->blockidGen);
if (!genpc.init())
return null();

Просмотреть файл

@ -99,6 +99,7 @@ struct ParseContext : public GenericParseContext
StmtInfoPC *topStmt; /* top of statement info stack */
StmtInfoPC *topScopeStmt; /* top lexical scope statement */
Rooted<StaticBlockObject *> blockChain;
Node maybeFunction; /* sc->isFunctionBox, the pn where pn->pn_funbox == sc */
/* compile time block scope chain */
const unsigned staticLevel; /* static compilation unit nesting level */
@ -233,7 +234,8 @@ struct ParseContext : public GenericParseContext
bool inDeclDestructuring:1;
ParseContext(Parser<ParseHandler> *prs, GenericParseContext *parent,
SharedContext *sc, Directives *newDirectives,
Node maybeFunction, SharedContext *sc,
Directives *newDirectives,
unsigned staticLevel, uint32_t bodyid)
: GenericParseContext(parent, sc),
bodyid(0), // initialized in init()