Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Unified Diff: src/parsing/preparser.cc

Issue 2256163002: [parser] Refactor preparser GetSymbol (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@nickie-2179423002-ref-traits
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/preparser.cc
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc
index e6424d8370288adc4c3a9e017f25695c02099921..d90d943d9fb70ac6b1b7377590ca68388ee3a50e 100644
--- a/src/parsing/preparser.cc
+++ b/src/parsing/preparser.cc
@@ -58,38 +58,34 @@ void PreParserTraits::ReportMessageAt(Scanner::Location location,
PreParserIdentifier PreParserTraits::GetSymbol(Scanner* scanner) {
- if (scanner->current_token() == Token::ENUM) {
- return PreParserIdentifier::Enum();
- } else if (scanner->current_token() == Token::AWAIT) {
- return PreParserIdentifier::Await();
- } else if (scanner->current_token() ==
- Token::FUTURE_STRICT_RESERVED_WORD) {
- return PreParserIdentifier::FutureStrictReserved();
- } else if (scanner->current_token() == Token::LET) {
- return PreParserIdentifier::Let();
- } else if (scanner->current_token() == Token::STATIC) {
- return PreParserIdentifier::Static();
- } else if (scanner->current_token() == Token::YIELD) {
- return PreParserIdentifier::Yield();
- } else if (scanner->current_token() == Token::ASYNC) {
- return PreParserIdentifier::Async();
- }
- if (scanner->UnescapedLiteralMatches("eval", 4)) {
- return PreParserIdentifier::Eval();
- }
- if (scanner->UnescapedLiteralMatches("arguments", 9)) {
- return PreParserIdentifier::Arguments();
- }
- if (scanner->UnescapedLiteralMatches("undefined", 9)) {
- return PreParserIdentifier::Undefined();
- }
- if (scanner->LiteralMatches("prototype", 9)) {
- return PreParserIdentifier::Prototype();
- }
- if (scanner->LiteralMatches("constructor", 11)) {
- return PreParserIdentifier::Constructor();
+ switch (scanner->current_token()) {
+ case Token::ENUM:
+ return PreParserIdentifier::Enum();
+ case Token::AWAIT:
+ return PreParserIdentifier::Await();
+ case Token::FUTURE_STRICT_RESERVED_WORD:
+ return PreParserIdentifier::FutureStrictReserved();
+ case Token::LET:
+ return PreParserIdentifier::Let();
+ case Token::STATIC:
+ return PreParserIdentifier::Static();
+ case Token::YIELD:
+ return PreParserIdentifier::Yield();
+ case Token::ASYNC:
+ return PreParserIdentifier::Async();
+ default:
+ if (scanner->UnescapedLiteralMatches("eval", 4))
+ return PreParserIdentifier::Eval();
+ if (scanner->UnescapedLiteralMatches("arguments", 9))
+ return PreParserIdentifier::Arguments();
+ if (scanner->UnescapedLiteralMatches("undefined", 9))
+ return PreParserIdentifier::Undefined();
+ if (scanner->LiteralMatches("prototype", 9))
+ return PreParserIdentifier::Prototype();
+ if (scanner->LiteralMatches("constructor", 11))
+ return PreParserIdentifier::Constructor();
+ return PreParserIdentifier::Default();
}
- return PreParserIdentifier::Default();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698