| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
| 6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
| 7 | 7 |
| 8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
| 9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
| 10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 typedef typename Types::StatementList StatementListT; | 184 typedef typename Types::StatementList StatementListT; |
| 185 typedef typename Types::Block BlockT; | 185 typedef typename Types::Block BlockT; |
| 186 typedef typename v8::internal::ExpressionClassifier<Types> | 186 typedef typename v8::internal::ExpressionClassifier<Types> |
| 187 ExpressionClassifier; | 187 ExpressionClassifier; |
| 188 | 188 |
| 189 // All implementation-specific methods must be called through this. | 189 // All implementation-specific methods must be called through this. |
| 190 Impl* impl() { return static_cast<Impl*>(this); } | 190 Impl* impl() { return static_cast<Impl*>(this); } |
| 191 const Impl* impl() const { return static_cast<const Impl*>(this); } | 191 const Impl* impl() const { return static_cast<const Impl*>(this); } |
| 192 | 192 |
| 193 ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit, | 193 ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit, |
| 194 v8::Extension* extension, AstValueFactory* ast_value_factory) | 194 v8::Extension* extension, AstValueFactory* ast_value_factory, |
| 195 RuntimeCallStats* runtime_call_stats) |
| 195 : scope_state_(nullptr), | 196 : scope_state_(nullptr), |
| 196 function_state_(nullptr), | 197 function_state_(nullptr), |
| 197 extension_(extension), | 198 extension_(extension), |
| 198 fni_(nullptr), | 199 fni_(nullptr), |
| 199 ast_value_factory_(ast_value_factory), | 200 ast_value_factory_(ast_value_factory), |
| 200 ast_node_factory_(ast_value_factory), | 201 ast_node_factory_(ast_value_factory), |
| 202 runtime_call_stats_(runtime_call_stats), |
| 201 parsing_module_(false), | 203 parsing_module_(false), |
| 202 stack_limit_(stack_limit), | 204 stack_limit_(stack_limit), |
| 203 zone_(zone), | 205 zone_(zone), |
| 204 classifier_(nullptr), | 206 classifier_(nullptr), |
| 205 scanner_(scanner), | 207 scanner_(scanner), |
| 206 stack_overflow_(false), | 208 stack_overflow_(false), |
| 207 default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile), | 209 default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile), |
| 208 allow_lazy_(false), | 210 allow_lazy_(false), |
| 209 allow_natives_(false), | 211 allow_natives_(false), |
| 210 allow_tailcalls_(false), | 212 allow_tailcalls_(false), |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 } | 1415 } |
| 1414 | 1416 |
| 1415 // Parser base's protected field members. | 1417 // Parser base's protected field members. |
| 1416 | 1418 |
| 1417 ScopeState* scope_state_; // Scope stack. | 1419 ScopeState* scope_state_; // Scope stack. |
| 1418 FunctionState* function_state_; // Function state stack. | 1420 FunctionState* function_state_; // Function state stack. |
| 1419 v8::Extension* extension_; | 1421 v8::Extension* extension_; |
| 1420 FuncNameInferrer* fni_; | 1422 FuncNameInferrer* fni_; |
| 1421 AstValueFactory* ast_value_factory_; // Not owned. | 1423 AstValueFactory* ast_value_factory_; // Not owned. |
| 1422 typename Types::Factory ast_node_factory_; | 1424 typename Types::Factory ast_node_factory_; |
| 1425 RuntimeCallStats* runtime_call_stats_; |
| 1423 bool parsing_module_; | 1426 bool parsing_module_; |
| 1424 uintptr_t stack_limit_; | 1427 uintptr_t stack_limit_; |
| 1425 | 1428 |
| 1426 // Parser base's private field members. | 1429 // Parser base's private field members. |
| 1427 | 1430 |
| 1428 private: | 1431 private: |
| 1429 Zone* zone_; | 1432 Zone* zone_; |
| 1430 ExpressionClassifier* classifier_; | 1433 ExpressionClassifier* classifier_; |
| 1431 | 1434 |
| 1432 Scanner* scanner_; | 1435 Scanner* scanner_; |
| (...skipping 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3880 return true; | 3883 return true; |
| 3881 } | 3884 } |
| 3882 } | 3885 } |
| 3883 return false; | 3886 return false; |
| 3884 } | 3887 } |
| 3885 | 3888 |
| 3886 template <typename Impl> | 3889 template <typename Impl> |
| 3887 typename ParserBase<Impl>::ExpressionT | 3890 typename ParserBase<Impl>::ExpressionT |
| 3888 ParserBase<Impl>::ParseArrowFunctionLiteral( | 3891 ParserBase<Impl>::ParseArrowFunctionLiteral( |
| 3889 bool accept_IN, const FormalParametersT& formal_parameters, bool* ok) { | 3892 bool accept_IN, const FormalParametersT& formal_parameters, bool* ok) { |
| 3893 RuntimeCallTimerScope runtime_timer( |
| 3894 runtime_call_stats_, |
| 3895 Impl::IsPreParser() ? &RuntimeCallStats::ParseArrowFunctionLiteral |
| 3896 : &RuntimeCallStats::PreParseArrowFunctionLiteral); |
| 3897 |
| 3890 if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) { | 3898 if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) { |
| 3891 // ASI inserts `;` after arrow parameters if a line terminator is found. | 3899 // ASI inserts `;` after arrow parameters if a line terminator is found. |
| 3892 // `=> ...` is never a valid expression, so report as syntax error. | 3900 // `=> ...` is never a valid expression, so report as syntax error. |
| 3893 // If next token is not `=>`, it's a syntax error anyways. | 3901 // If next token is not `=>`, it's a syntax error anyways. |
| 3894 ReportUnexpectedTokenAt(scanner_->peek_location(), Token::ARROW); | 3902 ReportUnexpectedTokenAt(scanner_->peek_location(), Token::ARROW); |
| 3895 *ok = false; | 3903 *ok = false; |
| 3896 return impl()->EmptyExpression(); | 3904 return impl()->EmptyExpression(); |
| 3897 } | 3905 } |
| 3898 | 3906 |
| 3899 StatementListT body = impl()->NullStatementList(); | 3907 StatementListT body = impl()->NullStatementList(); |
| (...skipping 1546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5446 has_seen_constructor_ = true; | 5454 has_seen_constructor_ = true; |
| 5447 return; | 5455 return; |
| 5448 } | 5456 } |
| 5449 } | 5457 } |
| 5450 | 5458 |
| 5451 | 5459 |
| 5452 } // namespace internal | 5460 } // namespace internal |
| 5453 } // namespace v8 | 5461 } // namespace v8 |
| 5454 | 5462 |
| 5455 #endif // V8_PARSING_PARSER_BASE_H | 5463 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |