| 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_EXPRESSION_CLASSIFIER_H | 5 #ifndef V8_EXPRESSION_CLASSIFIER_H |
| 6 #define V8_EXPRESSION_CLASSIFIER_H | 6 #define V8_EXPRESSION_CLASSIFIER_H |
| 7 | 7 |
| 8 #include "src/messages.h" | 8 #include "src/messages.h" |
| 9 #include "src/scanner.h" | 9 #include "src/scanner.h" |
| 10 #include "src/token.h" | 10 #include "src/token.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 PatternProductions = | 41 PatternProductions = |
| 42 (BindingPatternProduction | AssignmentPatternProduction), | 42 (BindingPatternProduction | AssignmentPatternProduction), |
| 43 FormalParametersProductions = (DistinctFormalParametersProduction | | 43 FormalParametersProductions = (DistinctFormalParametersProduction | |
| 44 StrictModeFormalParametersProduction | | 44 StrictModeFormalParametersProduction | |
| 45 StrongModeFormalParametersProduction), | 45 StrongModeFormalParametersProduction), |
| 46 StandardProductions = ExpressionProductions | PatternProductions, | 46 StandardProductions = ExpressionProductions | PatternProductions, |
| 47 AllProductions = (StandardProductions | FormalParametersProductions | | 47 AllProductions = (StandardProductions | FormalParametersProductions | |
| 48 ArrowFormalParametersProduction) | 48 ArrowFormalParametersProduction) |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 enum FunctionProperties { NonSimpleParameter = 1 << 0 }; | 51 enum FunctionProperties { |
| 52 NonSimpleParameter = 1 << 0, |
| 53 ContainsExpressions = 1 << 1, |
| 54 ArgumentsParameter = 1 << 2 |
| 55 }; |
| 52 | 56 |
| 53 ExpressionClassifier() | 57 ExpressionClassifier() |
| 54 : invalid_productions_(0), | 58 : invalid_productions_(0), |
| 55 function_properties_(0), | 59 function_properties_(0), |
| 56 duplicate_finder_(nullptr) {} | 60 duplicate_finder_(nullptr) {} |
| 57 | 61 |
| 58 explicit ExpressionClassifier(DuplicateFinder* duplicate_finder) | 62 explicit ExpressionClassifier(DuplicateFinder* duplicate_finder) |
| 59 : invalid_productions_(0), | 63 : invalid_productions_(0), |
| 60 function_properties_(0), | 64 function_properties_(0), |
| 61 duplicate_finder_(duplicate_finder) {} | 65 duplicate_finder_(duplicate_finder) {} |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 133 } |
| 130 | 134 |
| 131 bool is_simple_parameter_list() const { | 135 bool is_simple_parameter_list() const { |
| 132 return !(function_properties_ & NonSimpleParameter); | 136 return !(function_properties_ & NonSimpleParameter); |
| 133 } | 137 } |
| 134 | 138 |
| 135 void RecordNonSimpleParameter() { | 139 void RecordNonSimpleParameter() { |
| 136 function_properties_ |= NonSimpleParameter; | 140 function_properties_ |= NonSimpleParameter; |
| 137 } | 141 } |
| 138 | 142 |
| 143 bool contains_expressions() const { |
| 144 return (function_properties_ & ContainsExpressions); |
| 145 } |
| 146 |
| 147 void RecordContainsExpressions() { |
| 148 function_properties_ |= ContainsExpressions; |
| 149 } |
| 150 |
| 151 bool has_arguments_parameter() const { |
| 152 return (function_properties_ & ArgumentsParameter); |
| 153 } |
| 154 |
| 155 void RecordArgumentsParameter() { |
| 156 function_properties_ |= ArgumentsParameter; |
| 157 } |
| 158 |
| 139 void RecordExpressionError(const Scanner::Location& loc, | 159 void RecordExpressionError(const Scanner::Location& loc, |
| 140 MessageTemplate::Template message, | 160 MessageTemplate::Template message, |
| 141 const char* arg = nullptr) { | 161 const char* arg = nullptr) { |
| 142 if (!is_valid_expression()) return; | 162 if (!is_valid_expression()) return; |
| 143 invalid_productions_ |= ExpressionProduction; | 163 invalid_productions_ |= ExpressionProduction; |
| 144 expression_error_.location = loc; | 164 expression_error_.location = loc; |
| 145 expression_error_.message = message; | 165 expression_error_.message = message; |
| 146 expression_error_.arg = arg; | 166 expression_error_.arg = arg; |
| 147 } | 167 } |
| 148 | 168 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 Error arrow_formal_parameters_error_; | 296 Error arrow_formal_parameters_error_; |
| 277 Error duplicate_formal_parameter_error_; | 297 Error duplicate_formal_parameter_error_; |
| 278 Error strict_mode_formal_parameter_error_; | 298 Error strict_mode_formal_parameter_error_; |
| 279 Error strong_mode_formal_parameter_error_; | 299 Error strong_mode_formal_parameter_error_; |
| 280 DuplicateFinder* duplicate_finder_; | 300 DuplicateFinder* duplicate_finder_; |
| 281 }; | 301 }; |
| 282 } | 302 } |
| 283 } // v8::internal | 303 } // v8::internal |
| 284 | 304 |
| 285 #endif // V8_EXPRESSION_CLASSIFIER_H | 305 #endif // V8_EXPRESSION_CLASSIFIER_H |
| OLD | NEW |