mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 10:45:42 +00:00
Bug 884920 - Remove TokenStream::lastFunctionKeyword, r=luke.
This commit is contained in:
parent
356866d0f4
commit
c11255dff3
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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
|
||||
|
7
js/src/jit-test/tests/basic/bug884920.js
Normal file
7
js/src/jit-test/tests/basic/bug884920.js
Normal file
@ -0,0 +1,7 @@
|
||||
// |jit-test| error:SyntaxError
|
||||
|
||||
function testcase({}, a = b, ... x) {
|
||||
"use strict";
|
||||
function f() { };
|
||||
with ( f(3) );
|
||||
}
|
Loading…
Reference in New Issue
Block a user