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

Side by Side Diff: src/parsing/expression-classifier.h

Issue 2268173005: Merge ExpressionClassifier::ObjectLiteralProduction into ExpressionProduction (Closed)
Patch Set: Rebased 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 | « no previous file | src/parsing/parser-base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #ifndef V8_PARSING_EXPRESSION_CLASSIFIER_H 5 #ifndef V8_PARSING_EXPRESSION_CLASSIFIER_H
6 #define V8_PARSING_EXPRESSION_CLASSIFIER_H 6 #define V8_PARSING_EXPRESSION_CLASSIFIER_H
7 7
8 #include "src/messages.h" 8 #include "src/messages.h"
9 #include "src/parsing/scanner.h" 9 #include "src/parsing/scanner.h"
10 #include "src/parsing/token.h" 10 #include "src/parsing/token.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 14
15 class DuplicateFinder; 15 class DuplicateFinder;
16 16
17 #define ERROR_CODES(T) \ 17 #define ERROR_CODES(T) \
18 T(ExpressionProduction, 0) \ 18 T(ExpressionProduction, 0) \
19 T(FormalParameterInitializerProduction, 1) \ 19 T(FormalParameterInitializerProduction, 1) \
20 T(BindingPatternProduction, 2) \ 20 T(BindingPatternProduction, 2) \
21 T(AssignmentPatternProduction, 3) \ 21 T(AssignmentPatternProduction, 3) \
22 T(DistinctFormalParametersProduction, 4) \ 22 T(DistinctFormalParametersProduction, 4) \
23 T(StrictModeFormalParametersProduction, 5) \ 23 T(StrictModeFormalParametersProduction, 5) \
24 T(ArrowFormalParametersProduction, 6) \ 24 T(ArrowFormalParametersProduction, 6) \
25 T(LetPatternProduction, 7) \ 25 T(LetPatternProduction, 7) \
26 T(ObjectLiteralProduction, 8) \ 26 T(TailCallExpressionProduction, 8) \
27 T(TailCallExpressionProduction, 9) \ 27 T(AsyncArrowFormalParametersProduction, 9)
28 T(AsyncArrowFormalParametersProduction, 10)
29 28
30 template <typename Traits> 29 template <typename Traits>
31 class ExpressionClassifier { 30 class ExpressionClassifier {
32 public: 31 public:
33 enum ErrorKind : unsigned { 32 enum ErrorKind : unsigned {
34 #define DEFINE_ERROR_KIND(NAME, CODE) k##NAME = CODE, 33 #define DEFINE_ERROR_KIND(NAME, CODE) k##NAME = CODE,
35 ERROR_CODES(DEFINE_ERROR_KIND) 34 ERROR_CODES(DEFINE_ERROR_KIND)
36 #undef DEFINE_ERROR_KIND 35 #undef DEFINE_ERROR_KIND
37 kUnusedError = 15 // Larger than error codes; should fit in 4 bits 36 kUnusedError = 15 // Larger than error codes; should fit in 4 bits
38 }; 37 };
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 157 }
159 158
160 V8_INLINE const Error& strict_mode_formal_parameter_error() const { 159 V8_INLINE const Error& strict_mode_formal_parameter_error() const {
161 return reported_error(kStrictModeFormalParametersProduction); 160 return reported_error(kStrictModeFormalParametersProduction);
162 } 161 }
163 162
164 V8_INLINE const Error& let_pattern_error() const { 163 V8_INLINE const Error& let_pattern_error() const {
165 return reported_error(kLetPatternProduction); 164 return reported_error(kLetPatternProduction);
166 } 165 }
167 166
168 V8_INLINE bool has_object_literal_error() const {
169 return !is_valid(ObjectLiteralProduction);
170 }
171
172 V8_INLINE const Error& object_literal_error() const {
173 return reported_error(kObjectLiteralProduction);
174 }
175
176 V8_INLINE bool has_tail_call_expression() const { 167 V8_INLINE bool has_tail_call_expression() const {
177 return !is_valid(TailCallExpressionProduction); 168 return !is_valid(TailCallExpressionProduction);
178 } 169 }
179 V8_INLINE const Error& tail_call_expression_error() const { 170 V8_INLINE const Error& tail_call_expression_error() const {
180 return reported_error(kTailCallExpressionProduction); 171 return reported_error(kTailCallExpressionProduction);
181 } 172 }
182 173
183 V8_INLINE const Error& async_arrow_formal_parameters_error() const { 174 V8_INLINE const Error& async_arrow_formal_parameters_error() const {
184 return reported_error(kAsyncArrowFormalParametersProduction); 175 return reported_error(kAsyncArrowFormalParametersProduction);
185 } 176 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 265 }
275 266
276 void RecordLetPatternError(const Scanner::Location& loc, 267 void RecordLetPatternError(const Scanner::Location& loc,
277 MessageTemplate::Template message, 268 MessageTemplate::Template message,
278 const char* arg = nullptr) { 269 const char* arg = nullptr) {
279 if (!is_valid_let_pattern()) return; 270 if (!is_valid_let_pattern()) return;
280 invalid_productions_ |= LetPatternProduction; 271 invalid_productions_ |= LetPatternProduction;
281 Add(Error(loc, message, kLetPatternProduction, arg)); 272 Add(Error(loc, message, kLetPatternProduction, arg));
282 } 273 }
283 274
284 void RecordObjectLiteralError(const Scanner::Location& loc,
285 MessageTemplate::Template message,
286 const char* arg = nullptr) {
287 if (has_object_literal_error()) return;
288 invalid_productions_ |= ObjectLiteralProduction;
289 Add(Error(loc, message, kObjectLiteralProduction, arg));
290 }
291
292 void RecordTailCallExpressionError(const Scanner::Location& loc, 275 void RecordTailCallExpressionError(const Scanner::Location& loc,
293 MessageTemplate::Template message, 276 MessageTemplate::Template message,
294 const char* arg = nullptr) { 277 const char* arg = nullptr) {
295 if (has_tail_call_expression()) return; 278 if (has_tail_call_expression()) return;
296 invalid_productions_ |= TailCallExpressionProduction; 279 invalid_productions_ |= TailCallExpressionProduction;
297 Add(Error(loc, message, kTailCallExpressionProduction, arg)); 280 Add(Error(loc, message, kTailCallExpressionProduction, arg));
298 } 281 }
299 282
300 void Accumulate(ExpressionClassifier* inner, unsigned productions, 283 void Accumulate(ExpressionClassifier* inner, unsigned productions,
301 bool merge_non_patterns = true) { 284 bool merge_non_patterns = true) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 }; 442 };
460 443
461 444
462 #undef ERROR_CODES 445 #undef ERROR_CODES
463 446
464 447
465 } // namespace internal 448 } // namespace internal
466 } // namespace v8 449 } // namespace v8
467 450
468 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H 451 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H
OLDNEW
« no previous file with comments | « no previous file | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698