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

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

Issue 2279773002: [parser] Clean up type definitions (Closed)
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 | « no previous file | src/parsing/parser.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 #define ERROR_CODES(T) \ 15 #define ERROR_CODES(T) \
16 T(ExpressionProduction, 0) \ 16 T(ExpressionProduction, 0) \
17 T(FormalParameterInitializerProduction, 1) \ 17 T(FormalParameterInitializerProduction, 1) \
18 T(BindingPatternProduction, 2) \ 18 T(BindingPatternProduction, 2) \
19 T(AssignmentPatternProduction, 3) \ 19 T(AssignmentPatternProduction, 3) \
20 T(DistinctFormalParametersProduction, 4) \ 20 T(DistinctFormalParametersProduction, 4) \
21 T(StrictModeFormalParametersProduction, 5) \ 21 T(StrictModeFormalParametersProduction, 5) \
22 T(ArrowFormalParametersProduction, 6) \ 22 T(ArrowFormalParametersProduction, 6) \
23 T(LetPatternProduction, 7) \ 23 T(LetPatternProduction, 7) \
24 T(ObjectLiteralProduction, 8) \ 24 T(ObjectLiteralProduction, 8) \
25 T(TailCallExpressionProduction, 9) \ 25 T(TailCallExpressionProduction, 9) \
26 T(AsyncArrowFormalParametersProduction, 10) 26 T(AsyncArrowFormalParametersProduction, 10)
27 27
28 template <typename Traits> 28 template <typename Types>
29 class ExpressionClassifier { 29 class ExpressionClassifier {
30 public: 30 public:
31 enum ErrorKind : unsigned { 31 enum ErrorKind : unsigned {
32 #define DEFINE_ERROR_KIND(NAME, CODE) k##NAME = CODE, 32 #define DEFINE_ERROR_KIND(NAME, CODE) k##NAME = CODE,
33 ERROR_CODES(DEFINE_ERROR_KIND) 33 ERROR_CODES(DEFINE_ERROR_KIND)
34 #undef DEFINE_ERROR_KIND 34 #undef DEFINE_ERROR_KIND
35 kUnusedError = 15 // Larger than error codes; should fit in 4 bits 35 kUnusedError = 15 // Larger than error codes; should fit in 4 bits
36 }; 36 };
37 37
38 struct Error { 38 struct Error {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 AllProductions = 70 AllProductions =
71 (ExpressionProductions | PatternProductions | 71 (ExpressionProductions | PatternProductions |
72 FormalParametersProductions | ArrowFormalParametersProduction | 72 FormalParametersProductions | ArrowFormalParametersProduction |
73 ObjectLiteralProduction | AsyncArrowFormalParametersProduction) 73 ObjectLiteralProduction | AsyncArrowFormalParametersProduction)
74 }; 74 };
75 75
76 enum FunctionProperties : unsigned { 76 enum FunctionProperties : unsigned {
77 NonSimpleParameter = 1 << 0 77 NonSimpleParameter = 1 << 0
78 }; 78 };
79 79
80 explicit ExpressionClassifier(const typename Traits::Type::Base* base, 80 explicit ExpressionClassifier(const typename Types::Base* base,
81 DuplicateFinder* duplicate_finder = nullptr) 81 DuplicateFinder* duplicate_finder = nullptr)
82 : zone_(base->impl()->zone()), 82 : zone_(base->impl()->zone()),
83 non_patterns_to_rewrite_(base->impl()->GetNonPatternList()), 83 non_patterns_to_rewrite_(base->impl()->GetNonPatternList()),
84 reported_errors_(base->impl()->GetReportedErrorList()), 84 reported_errors_(base->impl()->GetReportedErrorList()),
85 duplicate_finder_(duplicate_finder), 85 duplicate_finder_(duplicate_finder),
86 invalid_productions_(0), 86 invalid_productions_(0),
87 function_properties_(0) { 87 function_properties_(0) {
88 reported_errors_begin_ = reported_errors_end_ = reported_errors_->length(); 88 reported_errors_begin_ = reported_errors_end_ = reported_errors_->length();
89 non_pattern_begin_ = non_patterns_to_rewrite_->length(); 89 non_pattern_begin_ = non_patterns_to_rewrite_->length();
90 } 90 }
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 // in an inner classifier) or it could be an existing error (in case a 418 // in an inner classifier) or it could be an existing error (in case a
419 // copy is needed). 419 // copy is needed).
420 V8_INLINE void Copy(int i) { 420 V8_INLINE void Copy(int i) {
421 DCHECK_LT(i, reported_errors_->length()); 421 DCHECK_LT(i, reported_errors_->length());
422 if (reported_errors_end_ != i) 422 if (reported_errors_end_ != i)
423 reported_errors_->at(reported_errors_end_) = reported_errors_->at(i); 423 reported_errors_->at(reported_errors_end_) = reported_errors_->at(i);
424 reported_errors_end_++; 424 reported_errors_end_++;
425 } 425 }
426 426
427 Zone* zone_; 427 Zone* zone_;
428 ZoneList<typename Traits::Type::Expression>* non_patterns_to_rewrite_; 428 ZoneList<typename Types::Expression>* non_patterns_to_rewrite_;
429 ZoneList<Error>* reported_errors_; 429 ZoneList<Error>* reported_errors_;
430 DuplicateFinder* duplicate_finder_; 430 DuplicateFinder* duplicate_finder_;
431 // The uint16_t for non_pattern_begin_ will not be enough in the case, 431 // The uint16_t for non_pattern_begin_ will not be enough in the case,
432 // e.g., of an array literal containing more than 64K inner array 432 // e.g., of an array literal containing more than 64K inner array
433 // literals with spreads, as in: 433 // literals with spreads, as in:
434 // var N=65536; eval("var x=[];" + "[" + "[...x],".repeat(N) + "].length"); 434 // var N=65536; eval("var x=[];" + "[" + "[...x],".repeat(N) + "].length");
435 // An implementation limit error in ParserBase::AddNonPatternForRewriting 435 // An implementation limit error in ParserBase::AddNonPatternForRewriting
436 // will be triggered in this case. 436 // will be triggered in this case.
437 uint16_t non_pattern_begin_; 437 uint16_t non_pattern_begin_;
438 unsigned invalid_productions_ : 14; 438 unsigned invalid_productions_ : 14;
(...skipping 10 matching lines...) Expand all
449 }; 449 };
450 450
451 451
452 #undef ERROR_CODES 452 #undef ERROR_CODES
453 453
454 454
455 } // namespace internal 455 } // namespace internal
456 } // namespace v8 456 } // namespace v8
457 457
458 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H 458 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H
OLDNEW
« no previous file with comments | « no previous file | src/parsing/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698