summaryrefslogtreecommitdiffstats
path: root/js/src/frontend/Parser.cpp
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-06-09 01:33:48 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-07-18 22:38:29 -0400
commitc75bd3037aa32d4a2a574feda15f43635bc0c01c (patch)
treebc2c55a4138ff6bb5e5ffbf0879b20953b3ab334 /js/src/frontend/Parser.cpp
parent3f8364e4a0342be52555adf9ae13999dc8244d1b (diff)
downloadUXP-c75bd3037aa32d4a2a574feda15f43635bc0c01c.tar
UXP-c75bd3037aa32d4a2a574feda15f43635bc0c01c.tar.gz
UXP-c75bd3037aa32d4a2a574feda15f43635bc0c01c.tar.lz
UXP-c75bd3037aa32d4a2a574feda15f43635bc0c01c.tar.xz
UXP-c75bd3037aa32d4a2a574feda15f43635bc0c01c.zip
1337143 - Tweak NamedImports parsing to eliminate a complexifying peekToken where getToken could be used.
Diffstat (limited to 'js/src/frontend/Parser.cpp')
-rw-r--r--js/src/frontend/Parser.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp
index 0ff10f73f..abb2d51ad 100644
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -4663,12 +4663,11 @@ bool
Parser<FullParseHandler>::namedImportsOrNamespaceImport(TokenKind tt, Node importSpecSet)
{
if (tt == TOK_LC) {
- TokenStream::Modifier modifier = TokenStream::KeywordIsName;
while (true) {
// Handle the forms |import {} from 'a'| and
// |import { ..., } from 'a'| (where ... is non empty), by
// escaping the loop early if the next token is }.
- if (!tokenStream.peekToken(&tt, TokenStream::KeywordIsName))
+ if (!tokenStream.getToken(&tt, TokenStream::KeywordIsName))
return false;
if (tt == TOK_RC)
@@ -4677,7 +4676,11 @@ Parser<FullParseHandler>::namedImportsOrNamespaceImport(TokenKind tt, Node impor
// If the next token is a keyword, the previous call to
// peekToken matched it as a TOK_NAME, and put it in the
// lookahead buffer, so this call will match keywords as well.
- MUST_MATCH_TOKEN_MOD(TOK_NAME, TokenStream::KeywordIsName, JSMSG_NO_IMPORT_NAME);
+ if (tt != TOK_NAME) {
+ error(JSMSG_NO_IMPORT_NAME);
+ return false;
+ }
+
Rooted<PropertyName*> importName(context, tokenStream.currentName());
TokenPos importNamePos = pos();
@@ -4735,17 +4738,18 @@ Parser<FullParseHandler>::namedImportsOrNamespaceImport(TokenKind tt, Node impor
handler.addList(importSpecSet, importSpec);
- bool matched;
- if (!tokenStream.matchToken(&matched, TOK_COMMA))
+ TokenKind next;
+ if (!tokenStream.getToken(&next))
return false;
- if (!matched) {
- modifier = TokenStream::None;
+ if (next == TOK_RC)
break;
+
+ if (next != TOK_COMMA) {
+ error(JSMSG_RC_AFTER_IMPORT_SPEC_LIST);
+ return false;
}
}
-
- MUST_MATCH_TOKEN_MOD(TOK_RC, modifier, JSMSG_RC_AFTER_IMPORT_SPEC_LIST);
} else {
MOZ_ASSERT(tt == TOK_MUL);
if (!tokenStream.getToken(&tt))