Chromium Code Reviews| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 RuntimeCallStats* runtime_call_stats, |
| 196 bool parsing_on_main_thread = true) | |
| 196 : scope_state_(nullptr), | 197 : scope_state_(nullptr), |
| 197 function_state_(nullptr), | 198 function_state_(nullptr), |
| 198 extension_(extension), | 199 extension_(extension), |
| 199 fni_(nullptr), | 200 fni_(nullptr), |
| 200 ast_value_factory_(ast_value_factory), | 201 ast_value_factory_(ast_value_factory), |
| 201 ast_node_factory_(ast_value_factory), | 202 ast_node_factory_(ast_value_factory), |
| 202 runtime_call_stats_(runtime_call_stats), | 203 runtime_call_stats_(runtime_call_stats), |
| 204 parsing_on_main_thread_(parsing_on_main_thread), | |
| 203 parsing_module_(false), | 205 parsing_module_(false), |
| 204 stack_limit_(stack_limit), | 206 stack_limit_(stack_limit), |
| 205 zone_(zone), | 207 zone_(zone), |
| 206 classifier_(nullptr), | 208 classifier_(nullptr), |
| 207 scanner_(scanner), | 209 scanner_(scanner), |
| 208 stack_overflow_(false), | 210 stack_overflow_(false), |
| 209 default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile), | 211 default_eager_compile_hint_(FunctionLiteral::kShouldLazyCompile), |
| 210 allow_natives_(false), | 212 allow_natives_(false), |
| 211 allow_tailcalls_(false), | 213 allow_tailcalls_(false), |
| 212 allow_harmony_do_expressions_(false), | 214 allow_harmony_do_expressions_(false), |
| (...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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_; |
| 1423 RuntimeCallStats* runtime_call_stats_; | 1425 RuntimeCallStats* runtime_call_stats_; |
| 1426 bool parsing_on_main_thread_; | |
| 1424 bool parsing_module_; | 1427 bool parsing_module_; |
| 1425 uintptr_t stack_limit_; | 1428 uintptr_t stack_limit_; |
| 1426 | 1429 |
| 1427 // Parser base's private field members. | 1430 // Parser base's private field members. |
| 1428 | 1431 |
| 1429 private: | 1432 private: |
| 1430 Zone* zone_; | 1433 Zone* zone_; |
| 1431 ExpressionClassifier* classifier_; | 1434 ExpressionClassifier* classifier_; |
| 1432 | 1435 |
| 1433 Scanner* scanner_; | 1436 Scanner* scanner_; |
| (...skipping 2448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) { |
| 3890 RuntimeCallTimerScope runtime_timer( | 3893 RuntimeCallTimerScope runtime_timer( |
| 3891 runtime_call_stats_, | 3894 runtime_call_stats_, |
| 3892 Impl::IsPreParser() ? &RuntimeCallStats::ParseArrowFunctionLiteral | 3895 Impl::IsPreParser() |
|
vogelheim
2016/11/16 17:23:15
style: These two-level ternary operator expression
Camillo Bruni
2016/11/16 18:21:24
You're right :)
Went with the helper array which m
| |
| 3893 : &RuntimeCallStats::PreParseArrowFunctionLiteral); | 3896 ? parsing_on_main_thread_ |
| 3897 ? &RuntimeCallStats::ParseArrowFunctionLiteral | |
| 3898 : &RuntimeCallStats::ParseBackgroundArrowFunctionLiteral | |
| 3899 : parsing_on_main_thread_ | |
| 3900 ? &RuntimeCallStats::PreParseArrowFunctionLiteral | |
| 3901 : &RuntimeCallStats::PreParseBackgroundArrowFunctionLiteral); | |
| 3894 | 3902 |
| 3895 if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) { | 3903 if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) { |
| 3896 // ASI inserts `;` after arrow parameters if a line terminator is found. | 3904 // ASI inserts `;` after arrow parameters if a line terminator is found. |
| 3897 // `=> ...` is never a valid expression, so report as syntax error. | 3905 // `=> ...` is never a valid expression, so report as syntax error. |
| 3898 // If next token is not `=>`, it's a syntax error anyways. | 3906 // If next token is not `=>`, it's a syntax error anyways. |
| 3899 ReportUnexpectedTokenAt(scanner_->peek_location(), Token::ARROW); | 3907 ReportUnexpectedTokenAt(scanner_->peek_location(), Token::ARROW); |
| 3900 *ok = false; | 3908 *ok = false; |
| 3901 return impl()->EmptyExpression(); | 3909 return impl()->EmptyExpression(); |
| 3902 } | 3910 } |
| 3903 | 3911 |
| (...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5451 has_seen_constructor_ = true; | 5459 has_seen_constructor_ = true; |
| 5452 return; | 5460 return; |
| 5453 } | 5461 } |
| 5454 } | 5462 } |
| 5455 | 5463 |
| 5456 | 5464 |
| 5457 } // namespace internal | 5465 } // namespace internal |
| 5458 } // namespace v8 | 5466 } // namespace v8 |
| 5459 | 5467 |
| 5460 #endif // V8_PARSING_PARSER_BASE_H | 5468 #endif // V8_PARSING_PARSER_BASE_H |
| OLD | NEW |