Bug 884920 - Remove TokenStream::lastFunctionKeyword, r=luke.

This commit is contained in:
Brian Hackett 2013-06-24 10:47:11 -06:00
parent 356866d0f4
commit c11255dff3
4 changed files with 13 additions and 19 deletions

View File

@ -2318,6 +2318,10 @@ typename ParseHandler::Node
Parser<ParseHandler>::functionStmt()
{
JS_ASSERT(tokenStream.currentToken().type == TOK_FUNCTION);
TokenStream::Position start(keepAtoms);
tokenStream.tell(&start);
RootedPropertyName name(context);
if (tokenStream.getToken(TSF_KEYWORD_IS_NAME) == TOK_NAME) {
name = tokenStream.currentToken().name();
@ -2327,9 +2331,6 @@ Parser<ParseHandler>::functionStmt()
return null();
}
TokenStream::Position start(keepAtoms);
tokenStream.positionAfterLastFunctionKeyword(start);
/* We forbid function statements in strict mode code. */
if (!pc->atBodyLevel() && pc->sc->needStrictChecks() &&
!report(ParseStrictError, pc->sc->strict, null(), JSMSG_STRICT_FUNCTION_STATEMENT))
@ -2345,7 +2346,7 @@ Parser<ParseHandler>::functionExpr()
RootedPropertyName name(context);
JS_ASSERT(tokenStream.currentToken().type == TOK_FUNCTION);
TokenStream::Position start(keepAtoms);
tokenStream.positionAfterLastFunctionKeyword(start);
tokenStream.tell(&start);
if (tokenStream.getToken(TSF_KEYWORD_IS_NAME) == TOK_NAME)
name = tokenStream.currentToken().name();
else

View File

@ -284,7 +284,6 @@ TokenStream::TokenStream(JSContext *cx, const CompileOptions &options,
originPrincipals(JSScript::normalizeOriginPrincipals(options.principals,
options.originPrincipals)),
strictModeGetter(smg),
lastFunctionKeyword(keepAtoms),
tokenSkip(cx, &tokens),
linebaseSkip(cx, &linebase),
prevLinebaseSkip(cx, &prevLinebase)
@ -574,17 +573,9 @@ void
TokenStream::seek(const Position &pos, const TokenStream &other)
{
srcCoords.fill(other.srcCoords);
lastFunctionKeyword = other.lastFunctionKeyword;
seek(pos);
}
void
TokenStream::positionAfterLastFunctionKeyword(Position &pos)
{
JS_ASSERT(lastFunctionKeyword.buf > userbuf.base());
PodAssign(&pos, &lastFunctionKeyword);
}
bool
TokenStream::reportStrictModeErrorNumberVA(uint32_t offset, bool strictMode, unsigned errorNumber,
va_list args)
@ -1172,11 +1163,8 @@ TokenStream::getTokenInternal()
tt = TOK_NAME;
if (!checkForKeyword(chars, length, &tt, &tp->t_op))
goto error;
if (tt != TOK_NAME) {
if (tt == TOK_FUNCTION)
tell(&lastFunctionKeyword);
if (tt != TOK_NAME)
goto out;
}
}
/*

View File

@ -660,7 +660,6 @@ class MOZ_STACK_CLASS TokenStream
void tell(Position *);
void seek(const Position &pos);
void seek(const Position &pos, const TokenStream &other);
void positionAfterLastFunctionKeyword(Position &pos);
size_t positionToOffset(const Position &pos) const {
return pos.buf - userbuf.base();
@ -920,7 +919,6 @@ class MOZ_STACK_CLASS TokenStream
JSContext *const cx;
JSPrincipals *const originPrincipals;
StrictModeGetter *strictModeGetter; /* used to test for strict mode */
Position lastFunctionKeyword; /* used as a starting point for reparsing strict functions */
/*
* The tokens array stores pointers to JSAtoms. These are rooted by the

View File

@ -0,0 +1,7 @@
// |jit-test| error:SyntaxError
function testcase({}, a = b, ... x) {
"use strict";
function f() { };
with ( f(3) );
}