| OLD | NEW |
| 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" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 #undef DEFINE_PRODUCTION | 64 #undef DEFINE_PRODUCTION |
| 65 | 65 |
| 66 ExpressionProductions = | 66 ExpressionProductions = |
| 67 (ExpressionProduction | FormalParameterInitializerProduction | | 67 (ExpressionProduction | FormalParameterInitializerProduction | |
| 68 TailCallExpressionProduction), | 68 TailCallExpressionProduction), |
| 69 PatternProductions = | 69 PatternProductions = |
| 70 (BindingPatternProduction | AssignmentPatternProduction | | 70 (BindingPatternProduction | AssignmentPatternProduction | |
| 71 LetPatternProduction | AsyncBindingPatternProduction), | 71 LetPatternProduction | AsyncBindingPatternProduction), |
| 72 FormalParametersProductions = (DistinctFormalParametersProduction | | 72 FormalParametersProductions = (DistinctFormalParametersProduction | |
| 73 StrictModeFormalParametersProduction), | 73 StrictModeFormalParametersProduction), |
| 74 StandardProductions = ExpressionProductions | PatternProductions, | |
| 75 AllProductions = | 74 AllProductions = |
| 76 (StandardProductions | FormalParametersProductions | | 75 (ExpressionProductions | PatternProductions | |
| 77 ArrowFormalParametersProduction | CoverInitializedNameProduction | | 76 FormalParametersProductions | ArrowFormalParametersProduction | |
| 78 AsyncArrowFormalParametersProduction | AsyncBindingPatternProduction) | 77 CoverInitializedNameProduction | AsyncArrowFormalParametersProduction) |
| 79 }; | 78 }; |
| 80 | 79 |
| 81 enum FunctionProperties : unsigned { | 80 enum FunctionProperties : unsigned { |
| 82 NonSimpleParameter = 1 << 0 | 81 NonSimpleParameter = 1 << 0 |
| 83 }; | 82 }; |
| 84 | 83 |
| 85 explicit ExpressionClassifier(const Traits* t) | 84 explicit ExpressionClassifier(const Traits* t) |
| 86 : zone_(t->zone()), | 85 : zone_(t->zone()), |
| 87 non_patterns_to_rewrite_(t->GetNonPatternList()), | 86 non_patterns_to_rewrite_(t->GetNonPatternList()), |
| 88 reported_errors_(t->GetReportedErrorList()), | 87 reported_errors_(t->GetReportedErrorList()), |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 invalid_productions_ &= ~CoverInitializedNameProduction; | 337 invalid_productions_ &= ~CoverInitializedNameProduction; |
| 339 } | 338 } |
| 340 | 339 |
| 341 void ForgiveAssignmentPatternError() { | 340 void ForgiveAssignmentPatternError() { |
| 342 if (!(invalid_productions_ & AssignmentPatternProduction)) return; | 341 if (!(invalid_productions_ & AssignmentPatternProduction)) return; |
| 343 Error& e = reported_error(kAssignmentPatternProduction); | 342 Error& e = reported_error(kAssignmentPatternProduction); |
| 344 e.kind = kUnusedError; | 343 e.kind = kUnusedError; |
| 345 invalid_productions_ &= ~AssignmentPatternProduction; | 344 invalid_productions_ &= ~AssignmentPatternProduction; |
| 346 } | 345 } |
| 347 | 346 |
| 348 void Accumulate(ExpressionClassifier* inner, | 347 void Accumulate(ExpressionClassifier* inner, unsigned productions, |
| 349 unsigned productions = StandardProductions, | |
| 350 bool merge_non_patterns = true) { | 348 bool merge_non_patterns = true) { |
| 351 DCHECK_EQ(inner->reported_errors_, reported_errors_); | 349 DCHECK_EQ(inner->reported_errors_, reported_errors_); |
| 352 DCHECK_EQ(inner->reported_errors_begin_, reported_errors_end_); | 350 DCHECK_EQ(inner->reported_errors_begin_, reported_errors_end_); |
| 353 DCHECK_EQ(inner->reported_errors_end_, reported_errors_->length()); | 351 DCHECK_EQ(inner->reported_errors_end_, reported_errors_->length()); |
| 354 if (merge_non_patterns) MergeNonPatterns(inner); | 352 if (merge_non_patterns) MergeNonPatterns(inner); |
| 355 // Propagate errors from inner, but don't overwrite already recorded | 353 // Propagate errors from inner, but don't overwrite already recorded |
| 356 // errors. | 354 // errors. |
| 357 unsigned non_arrow_inner_invalid_productions = | 355 unsigned non_arrow_inner_invalid_productions = |
| 358 inner->invalid_productions_ & ~ArrowFormalParametersProduction; | 356 inner->invalid_productions_ & ~ArrowFormalParametersProduction; |
| 359 if (non_arrow_inner_invalid_productions) { | 357 if (non_arrow_inner_invalid_productions) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 }; | 492 }; |
| 495 | 493 |
| 496 | 494 |
| 497 #undef ERROR_CODES | 495 #undef ERROR_CODES |
| 498 | 496 |
| 499 | 497 |
| 500 } // namespace internal | 498 } // namespace internal |
| 501 } // namespace v8 | 499 } // namespace v8 |
| 502 | 500 |
| 503 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H | 501 #endif // V8_PARSING_EXPRESSION_CLASSIFIER_H |
| OLD | NEW |