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

Side by Side Diff: src/parsing/preparser.cc

Issue 2274113002: [parser] Clean up (pre)parser traits, part 4 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 23 matching lines...) Expand all
34 #define DUMMY ) // to make indentation work 34 #define DUMMY ) // to make indentation work
35 #undef DUMMY 35 #undef DUMMY
36 36
37 // Used in functions where the return type is not ExpressionT. 37 // Used in functions where the return type is not ExpressionT.
38 #define CHECK_OK_CUSTOM(x) ok); \ 38 #define CHECK_OK_CUSTOM(x) ok); \
39 if (!*ok) return this->x(); \ 39 if (!*ok) return this->x(); \
40 ((void)0 40 ((void)0
41 #define DUMMY ) // to make indentation work 41 #define DUMMY ) // to make indentation work
42 #undef DUMMY 42 #undef DUMMY
43 43
44 PreParserIdentifier ParserBaseTraits<PreParser>::GetSymbol( 44 PreParserIdentifier PreParser::GetSymbol() const {
45 Scanner* scanner) const { 45 switch (scanner()->current_token()) {
46 switch (scanner->current_token()) {
47 case Token::ENUM: 46 case Token::ENUM:
48 return PreParserIdentifier::Enum(); 47 return PreParserIdentifier::Enum();
49 case Token::AWAIT: 48 case Token::AWAIT:
50 return PreParserIdentifier::Await(); 49 return PreParserIdentifier::Await();
51 case Token::FUTURE_STRICT_RESERVED_WORD: 50 case Token::FUTURE_STRICT_RESERVED_WORD:
52 return PreParserIdentifier::FutureStrictReserved(); 51 return PreParserIdentifier::FutureStrictReserved();
53 case Token::LET: 52 case Token::LET:
54 return PreParserIdentifier::Let(); 53 return PreParserIdentifier::Let();
55 case Token::STATIC: 54 case Token::STATIC:
56 return PreParserIdentifier::Static(); 55 return PreParserIdentifier::Static();
57 case Token::YIELD: 56 case Token::YIELD:
58 return PreParserIdentifier::Yield(); 57 return PreParserIdentifier::Yield();
59 case Token::ASYNC: 58 case Token::ASYNC:
60 return PreParserIdentifier::Async(); 59 return PreParserIdentifier::Async();
61 default: 60 default:
62 if (scanner->UnescapedLiteralMatches("eval", 4)) 61 if (scanner()->UnescapedLiteralMatches("eval", 4))
63 return PreParserIdentifier::Eval(); 62 return PreParserIdentifier::Eval();
64 if (scanner->UnescapedLiteralMatches("arguments", 9)) 63 if (scanner()->UnescapedLiteralMatches("arguments", 9))
65 return PreParserIdentifier::Arguments(); 64 return PreParserIdentifier::Arguments();
66 if (scanner->UnescapedLiteralMatches("undefined", 9)) 65 if (scanner()->UnescapedLiteralMatches("undefined", 9))
67 return PreParserIdentifier::Undefined(); 66 return PreParserIdentifier::Undefined();
68 if (scanner->LiteralMatches("prototype", 9)) 67 if (scanner()->LiteralMatches("prototype", 9))
69 return PreParserIdentifier::Prototype(); 68 return PreParserIdentifier::Prototype();
70 if (scanner->LiteralMatches("constructor", 11)) 69 if (scanner()->LiteralMatches("constructor", 11))
71 return PreParserIdentifier::Constructor(); 70 return PreParserIdentifier::Constructor();
72 return PreParserIdentifier::Default(); 71 return PreParserIdentifier::Default();
73 } 72 }
74 } 73 }
75 74
76 PreParserExpression ParserBaseTraits<PreParser>::ExpressionFromString(
77 int pos, Scanner* scanner, PreParserFactory* factory) const {
78 if (scanner->UnescapedLiteralMatches("use strict", 10)) {
79 return PreParserExpression::UseStrictStringLiteral();
80 }
81 return PreParserExpression::StringLiteral();
82 }
83
84 PreParser::PreParseResult PreParser::PreParseLazyFunction( 75 PreParser::PreParseResult PreParser::PreParseLazyFunction(
85 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters, 76 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters,
86 bool parsing_module, ParserRecorder* log, Scanner::BookmarkScope* bookmark, 77 bool parsing_module, ParserRecorder* log, Scanner::BookmarkScope* bookmark,
87 int* use_counts) { 78 int* use_counts) {
88 parsing_module_ = parsing_module; 79 parsing_module_ = parsing_module;
89 log_ = log; 80 log_ = log;
90 use_counts_ = use_counts; 81 use_counts_ = use_counts;
91 // Lazy functions always have trivial outer scopes (no with/catch scopes). 82 // Lazy functions always have trivial outer scopes (no with/catch scopes).
92 DCHECK_NULL(scope_state_); 83 DCHECK_NULL(scope_state_);
93 DeclarationScope* top_scope = NewScriptScope(); 84 DeclarationScope* top_scope = NewScriptScope();
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 1242
1252 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); 1243 body->Add(PreParserStatement::ExpressionStatement(return_value), zone());
1253 } 1244 }
1254 1245
1255 #undef CHECK_OK 1246 #undef CHECK_OK
1256 #undef CHECK_OK_CUSTOM 1247 #undef CHECK_OK_CUSTOM
1257 1248
1258 1249
1259 } // namespace internal 1250 } // namespace internal
1260 } // namespace v8 1251 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698