| 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_PREPARSER_H | 5 #ifndef V8_PREPARSER_H |
| 6 #define V8_PREPARSER_H | 6 #define V8_PREPARSER_H |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/func-name-inferrer.h" | 10 #include "src/func-name-inferrer.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 public: | 61 public: |
| 62 // Shorten type names defined by Traits. | 62 // Shorten type names defined by Traits. |
| 63 typedef typename Traits::Type::Expression ExpressionT; | 63 typedef typename Traits::Type::Expression ExpressionT; |
| 64 typedef typename Traits::Type::Identifier IdentifierT; | 64 typedef typename Traits::Type::Identifier IdentifierT; |
| 65 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; | 65 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; |
| 66 typedef typename Traits::Type::Literal LiteralT; | 66 typedef typename Traits::Type::Literal LiteralT; |
| 67 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; | 67 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; |
| 68 | 68 |
| 69 ParserBase(Scanner* scanner, uintptr_t stack_limit, v8::Extension* extension, | 69 ParserBase(Scanner* scanner, uintptr_t stack_limit, v8::Extension* extension, |
| 70 ParserRecorder* log, typename Traits::Type::Zone* zone, | 70 ParserRecorder* log, typename Traits::Type::Zone* zone, |
| 71 int* ast_node_id_counter, |
| 71 typename Traits::Type::Parser this_object) | 72 typename Traits::Type::Parser this_object) |
| 72 : Traits(this_object), | 73 : Traits(this_object), |
| 73 parenthesized_function_(false), | 74 parenthesized_function_(false), |
| 74 scope_(NULL), | 75 scope_(NULL), |
| 75 function_state_(NULL), | 76 function_state_(NULL), |
| 76 extension_(extension), | 77 extension_(extension), |
| 77 fni_(NULL), | 78 fni_(NULL), |
| 78 log_(log), | 79 log_(log), |
| 79 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. | 80 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. |
| 80 scanner_(scanner), | 81 scanner_(scanner), |
| 81 stack_limit_(stack_limit), | 82 stack_limit_(stack_limit), |
| 82 stack_overflow_(false), | 83 stack_overflow_(false), |
| 83 allow_lazy_(false), | 84 allow_lazy_(false), |
| 84 allow_natives_syntax_(false), | 85 allow_natives_syntax_(false), |
| 85 allow_generators_(false), | 86 allow_generators_(false), |
| 86 allow_arrow_functions_(false), | 87 allow_arrow_functions_(false), |
| 87 zone_(zone) {} | 88 zone_(zone), |
| 89 ast_node_id_counter_(ast_node_id_counter) {} |
| 88 | 90 |
| 89 // Getters that indicate whether certain syntactical constructs are | 91 // Getters that indicate whether certain syntactical constructs are |
| 90 // allowed to be parsed by this instance of the parser. | 92 // allowed to be parsed by this instance of the parser. |
| 91 bool allow_lazy() const { return allow_lazy_; } | 93 bool allow_lazy() const { return allow_lazy_; } |
| 92 bool allow_natives_syntax() const { return allow_natives_syntax_; } | 94 bool allow_natives_syntax() const { return allow_natives_syntax_; } |
| 93 bool allow_generators() const { return allow_generators_; } | 95 bool allow_generators() const { return allow_generators_; } |
| 94 bool allow_arrow_functions() const { return allow_arrow_functions_; } | 96 bool allow_arrow_functions() const { return allow_arrow_functions_; } |
| 95 bool allow_modules() const { return scanner()->HarmonyModules(); } | 97 bool allow_modules() const { return scanner()->HarmonyModules(); } |
| 96 bool allow_harmony_scoping() const { return scanner()->HarmonyScoping(); } | 98 bool allow_harmony_scoping() const { return scanner()->HarmonyScoping(); } |
| 97 bool allow_harmony_numeric_literals() const { | 99 bool allow_harmony_numeric_literals() const { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 ~BlockState() { *scope_stack_ = outer_scope_; } | 150 ~BlockState() { *scope_stack_ = outer_scope_; } |
| 149 | 151 |
| 150 private: | 152 private: |
| 151 typename Traits::Type::Scope** scope_stack_; | 153 typename Traits::Type::Scope** scope_stack_; |
| 152 typename Traits::Type::Scope* outer_scope_; | 154 typename Traits::Type::Scope* outer_scope_; |
| 153 typename Traits::Type::Scope* scope_; | 155 typename Traits::Type::Scope* scope_; |
| 154 }; | 156 }; |
| 155 | 157 |
| 156 class FunctionState BASE_EMBEDDED { | 158 class FunctionState BASE_EMBEDDED { |
| 157 public: | 159 public: |
| 158 FunctionState( | 160 FunctionState(FunctionState** function_state_stack, |
| 159 FunctionState** function_state_stack, | 161 typename Traits::Type::Scope** scope_stack, |
| 160 typename Traits::Type::Scope** scope_stack, | 162 typename Traits::Type::Scope* scope, |
| 161 typename Traits::Type::Scope* scope, | 163 typename Traits::Type::Zone* zone = NULL, |
| 162 typename Traits::Type::Zone* zone = NULL, | 164 AstValueFactory* ast_value_factory = NULL, |
| 163 AstValueFactory* ast_value_factory = NULL); | 165 int* ast_node_id_counter = NULL); |
| 164 FunctionState(FunctionState** function_state_stack, | 166 FunctionState(FunctionState** function_state_stack, |
| 165 typename Traits::Type::Scope** scope_stack, | 167 typename Traits::Type::Scope** scope_stack, |
| 166 typename Traits::Type::Scope** scope, | 168 typename Traits::Type::Scope** scope, |
| 167 typename Traits::Type::Zone* zone = NULL, | 169 typename Traits::Type::Zone* zone = NULL, |
| 168 AstValueFactory* ast_value_factory = NULL); | 170 AstValueFactory* ast_value_factory = NULL, |
| 171 int* ast_node_id_counter = NULL); |
| 169 ~FunctionState(); | 172 ~FunctionState(); |
| 170 | 173 |
| 171 int NextMaterializedLiteralIndex() { | 174 int NextMaterializedLiteralIndex() { |
| 172 return next_materialized_literal_index_++; | 175 return next_materialized_literal_index_++; |
| 173 } | 176 } |
| 174 int materialized_literal_count() { | 177 int materialized_literal_count() { |
| 175 return next_materialized_literal_index_ - JSFunction::kLiteralsPrefixSize; | 178 return next_materialized_literal_index_ - JSFunction::kLiteralsPrefixSize; |
| 176 } | 179 } |
| 177 | 180 |
| 178 int NextHandlerIndex() { return next_handler_index_++; } | 181 int NextHandlerIndex() { return next_handler_index_++; } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // For generators, this variable may hold the generator object. It variable | 218 // For generators, this variable may hold the generator object. It variable |
| 216 // is used by yield expressions and return statements. It is not necessary | 219 // is used by yield expressions and return statements. It is not necessary |
| 217 // for generator functions to have this variable set. | 220 // for generator functions to have this variable set. |
| 218 Variable* generator_object_variable_; | 221 Variable* generator_object_variable_; |
| 219 | 222 |
| 220 FunctionState** function_state_stack_; | 223 FunctionState** function_state_stack_; |
| 221 FunctionState* outer_function_state_; | 224 FunctionState* outer_function_state_; |
| 222 typename Traits::Type::Scope** scope_stack_; | 225 typename Traits::Type::Scope** scope_stack_; |
| 223 typename Traits::Type::Scope* outer_scope_; | 226 typename Traits::Type::Scope* outer_scope_; |
| 224 int saved_ast_node_id_; // Only used by ParserTraits. | 227 int saved_ast_node_id_; // Only used by ParserTraits. |
| 228 int* ast_node_id_counter_; // Ditto. |
| 225 typename Traits::Type::Zone* extra_param_; | 229 typename Traits::Type::Zone* extra_param_; |
| 226 typename Traits::Type::Factory factory_; | 230 typename Traits::Type::Factory factory_; |
| 227 | 231 |
| 228 friend class ParserTraits; | 232 friend class ParserTraits; |
| 229 friend class CheckpointBase; | 233 friend class CheckpointBase; |
| 230 }; | 234 }; |
| 231 | 235 |
| 232 // Annoyingly, arrow functions first parse as comma expressions, then when we | 236 // Annoyingly, arrow functions first parse as comma expressions, then when we |
| 233 // see the => we have to go back and reinterpret the arguments as being formal | 237 // see the => we have to go back and reinterpret the arguments as being formal |
| 234 // parameters. To do so we need to reset some of the parser state back to | 238 // parameters. To do so we need to reset some of the parser state back to |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 Mode old_mode_; | 277 Mode old_mode_; |
| 274 }; | 278 }; |
| 275 | 279 |
| 276 Scanner* scanner() const { return scanner_; } | 280 Scanner* scanner() const { return scanner_; } |
| 277 int position() { return scanner_->location().beg_pos; } | 281 int position() { return scanner_->location().beg_pos; } |
| 278 int peek_position() { return scanner_->peek_location().beg_pos; } | 282 int peek_position() { return scanner_->peek_location().beg_pos; } |
| 279 bool stack_overflow() const { return stack_overflow_; } | 283 bool stack_overflow() const { return stack_overflow_; } |
| 280 void set_stack_overflow() { stack_overflow_ = true; } | 284 void set_stack_overflow() { stack_overflow_ = true; } |
| 281 Mode mode() const { return mode_; } | 285 Mode mode() const { return mode_; } |
| 282 typename Traits::Type::Zone* zone() const { return zone_; } | 286 typename Traits::Type::Zone* zone() const { return zone_; } |
| 287 int* ast_node_id_counter() const { return ast_node_id_counter_; } |
| 283 | 288 |
| 284 INLINE(Token::Value peek()) { | 289 INLINE(Token::Value peek()) { |
| 285 if (stack_overflow_) return Token::ILLEGAL; | 290 if (stack_overflow_) return Token::ILLEGAL; |
| 286 return scanner()->peek(); | 291 return scanner()->peek(); |
| 287 } | 292 } |
| 288 | 293 |
| 289 INLINE(Token::Value Next()) { | 294 INLINE(Token::Value Next()) { |
| 290 if (stack_overflow_) return Token::ILLEGAL; | 295 if (stack_overflow_) return Token::ILLEGAL; |
| 291 { | 296 { |
| 292 if (GetCurrentStackPosition() < stack_limit_) { | 297 if (GetCurrentStackPosition() < stack_limit_) { |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 Scanner* scanner_; | 518 Scanner* scanner_; |
| 514 uintptr_t stack_limit_; | 519 uintptr_t stack_limit_; |
| 515 bool stack_overflow_; | 520 bool stack_overflow_; |
| 516 | 521 |
| 517 bool allow_lazy_; | 522 bool allow_lazy_; |
| 518 bool allow_natives_syntax_; | 523 bool allow_natives_syntax_; |
| 519 bool allow_generators_; | 524 bool allow_generators_; |
| 520 bool allow_arrow_functions_; | 525 bool allow_arrow_functions_; |
| 521 | 526 |
| 522 typename Traits::Type::Zone* zone_; // Only used by Parser. | 527 typename Traits::Type::Zone* zone_; // Only used by Parser. |
| 528 int* ast_node_id_counter_; |
| 523 }; | 529 }; |
| 524 | 530 |
| 525 | 531 |
| 526 class PreParserIdentifier { | 532 class PreParserIdentifier { |
| 527 public: | 533 public: |
| 528 PreParserIdentifier() : type_(kUnknownIdentifier) {} | 534 PreParserIdentifier() : type_(kUnknownIdentifier) {} |
| 529 static PreParserIdentifier Default() { | 535 static PreParserIdentifier Default() { |
| 530 return PreParserIdentifier(kUnknownIdentifier); | 536 return PreParserIdentifier(kUnknownIdentifier); |
| 531 } | 537 } |
| 532 static PreParserIdentifier Eval() { | 538 static PreParserIdentifier Eval() { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 PreParserScope* operator->() { return this; } | 883 PreParserScope* operator->() { return this; } |
| 878 | 884 |
| 879 private: | 885 private: |
| 880 ScopeType scope_type_; | 886 ScopeType scope_type_; |
| 881 StrictMode strict_mode_; | 887 StrictMode strict_mode_; |
| 882 }; | 888 }; |
| 883 | 889 |
| 884 | 890 |
| 885 class PreParserFactory { | 891 class PreParserFactory { |
| 886 public: | 892 public: |
| 887 explicit PreParserFactory(void* extra_param1, void* extra_param2) {} | 893 PreParserFactory(void*, void*, void*) {} |
| 888 PreParserExpression NewStringLiteral(PreParserIdentifier identifier, | 894 PreParserExpression NewStringLiteral(PreParserIdentifier identifier, |
| 889 int pos) { | 895 int pos) { |
| 890 return PreParserExpression::Default(); | 896 return PreParserExpression::Default(); |
| 891 } | 897 } |
| 892 PreParserExpression NewNumberLiteral(double number, | 898 PreParserExpression NewNumberLiteral(double number, |
| 893 int pos) { | 899 int pos) { |
| 894 return PreParserExpression::Default(); | 900 return PreParserExpression::Default(); |
| 895 } | 901 } |
| 896 PreParserExpression NewRegExpLiteral(PreParserIdentifier js_pattern, | 902 PreParserExpression NewRegExpLiteral(PreParserIdentifier js_pattern, |
| 897 PreParserIdentifier js_flags, | 903 PreParserIdentifier js_flags, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 // For constructing objects returned by the traversing functions. | 1049 // For constructing objects returned by the traversing functions. |
| 1044 typedef PreParserFactory Factory; | 1050 typedef PreParserFactory Factory; |
| 1045 }; | 1051 }; |
| 1046 | 1052 |
| 1047 class Checkpoint; | 1053 class Checkpoint; |
| 1048 | 1054 |
| 1049 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {} | 1055 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {} |
| 1050 | 1056 |
| 1051 // Custom operations executed when FunctionStates are created and | 1057 // Custom operations executed when FunctionStates are created and |
| 1052 // destructed. (The PreParser doesn't need to do anything.) | 1058 // destructed. (The PreParser doesn't need to do anything.) |
| 1053 template<typename FunctionState> | 1059 template <typename FunctionState> |
| 1054 static void SetUpFunctionState(FunctionState* function_state, void*) {} | 1060 static void SetUpFunctionState(FunctionState* function_state) {} |
| 1055 template<typename FunctionState> | 1061 template <typename FunctionState> |
| 1056 static void TearDownFunctionState(FunctionState* function_state, void*) {} | 1062 static void TearDownFunctionState(FunctionState* function_state) {} |
| 1057 | 1063 |
| 1058 // Helper functions for recursive descent. | 1064 // Helper functions for recursive descent. |
| 1059 static bool IsEvalOrArguments(PreParserIdentifier identifier) { | 1065 static bool IsEvalOrArguments(PreParserIdentifier identifier) { |
| 1060 return identifier.IsEvalOrArguments(); | 1066 return identifier.IsEvalOrArguments(); |
| 1061 } | 1067 } |
| 1062 | 1068 |
| 1063 // Returns true if the expression is of type "this.foo". | 1069 // Returns true if the expression is of type "this.foo". |
| 1064 static bool IsThisProperty(PreParserExpression expression) { | 1070 static bool IsThisProperty(PreParserExpression expression) { |
| 1065 return expression.IsThisProperty(); | 1071 return expression.IsThisProperty(); |
| 1066 } | 1072 } |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 typedef PreParserIdentifier Identifier; | 1305 typedef PreParserIdentifier Identifier; |
| 1300 typedef PreParserExpression Expression; | 1306 typedef PreParserExpression Expression; |
| 1301 typedef PreParserStatement Statement; | 1307 typedef PreParserStatement Statement; |
| 1302 | 1308 |
| 1303 enum PreParseResult { | 1309 enum PreParseResult { |
| 1304 kPreParseStackOverflow, | 1310 kPreParseStackOverflow, |
| 1305 kPreParseSuccess | 1311 kPreParseSuccess |
| 1306 }; | 1312 }; |
| 1307 | 1313 |
| 1308 PreParser(Scanner* scanner, ParserRecorder* log, uintptr_t stack_limit) | 1314 PreParser(Scanner* scanner, ParserRecorder* log, uintptr_t stack_limit) |
| 1309 : ParserBase<PreParserTraits>(scanner, stack_limit, NULL, log, NULL, | 1315 : ParserBase<PreParserTraits>(scanner, stack_limit, NULL, log, NULL, NULL, |
| 1310 this) {} | 1316 this) {} |
| 1311 | 1317 |
| 1312 // Pre-parse the program from the character stream; returns true on | 1318 // Pre-parse the program from the character stream; returns true on |
| 1313 // success (even if parsing failed, the pre-parse data successfully | 1319 // success (even if parsing failed, the pre-parse data successfully |
| 1314 // captured the syntax error), and false if a stack-overflow happened | 1320 // captured the syntax error), and false if a stack-overflow happened |
| 1315 // during parsing. | 1321 // during parsing. |
| 1316 PreParseResult PreParseProgram() { | 1322 PreParseResult PreParseProgram() { |
| 1317 PreParserScope scope(scope_, GLOBAL_SCOPE); | 1323 PreParserScope scope(scope_, GLOBAL_SCOPE); |
| 1318 FunctionState top_scope(&function_state_, &scope_, &scope); | 1324 FunctionState top_scope(&function_state_, &scope_, &scope); |
| 1319 bool ok = true; | 1325 bool ok = true; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1434 | 1440 |
| 1435 | 1441 |
| 1436 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( | 1442 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( |
| 1437 PreParserIdentifier function_name, int pos, Variable* fvar, | 1443 PreParserIdentifier function_name, int pos, Variable* fvar, |
| 1438 Token::Value fvar_init_op, bool is_generator, bool* ok) { | 1444 Token::Value fvar_init_op, bool is_generator, bool* ok) { |
| 1439 return pre_parser_->ParseEagerFunctionBody(function_name, pos, fvar, | 1445 return pre_parser_->ParseEagerFunctionBody(function_name, pos, fvar, |
| 1440 fvar_init_op, is_generator, ok); | 1446 fvar_init_op, is_generator, ok); |
| 1441 } | 1447 } |
| 1442 | 1448 |
| 1443 | 1449 |
| 1444 template<class Traits> | 1450 template <class Traits> |
| 1445 ParserBase<Traits>::FunctionState::FunctionState( | 1451 ParserBase<Traits>::FunctionState::FunctionState( |
| 1446 FunctionState** function_state_stack, | 1452 FunctionState** function_state_stack, |
| 1447 typename Traits::Type::Scope** scope_stack, | 1453 typename Traits::Type::Scope** scope_stack, |
| 1448 typename Traits::Type::Scope* scope, | 1454 typename Traits::Type::Scope* scope, typename Traits::Type::Zone* zone, |
| 1449 typename Traits::Type::Zone* extra_param, | 1455 AstValueFactory* ast_value_factory, int* ast_node_id_counter) |
| 1450 AstValueFactory* ast_value_factory) | |
| 1451 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), | 1456 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), |
| 1452 next_handler_index_(0), | 1457 next_handler_index_(0), |
| 1453 expected_property_count_(0), | 1458 expected_property_count_(0), |
| 1454 is_generator_(false), | 1459 is_generator_(false), |
| 1455 generator_object_variable_(NULL), | 1460 generator_object_variable_(NULL), |
| 1456 function_state_stack_(function_state_stack), | 1461 function_state_stack_(function_state_stack), |
| 1457 outer_function_state_(*function_state_stack), | 1462 outer_function_state_(*function_state_stack), |
| 1458 scope_stack_(scope_stack), | 1463 scope_stack_(scope_stack), |
| 1459 outer_scope_(*scope_stack), | 1464 outer_scope_(*scope_stack), |
| 1460 saved_ast_node_id_(0), | 1465 saved_ast_node_id_(0), |
| 1461 extra_param_(extra_param), | 1466 ast_node_id_counter_(ast_node_id_counter), |
| 1462 factory_(extra_param, ast_value_factory) { | 1467 factory_(zone, ast_value_factory, ast_node_id_counter) { |
| 1463 *scope_stack_ = scope; | 1468 *scope_stack_ = scope; |
| 1464 *function_state_stack = this; | 1469 *function_state_stack = this; |
| 1465 Traits::SetUpFunctionState(this, extra_param); | 1470 Traits::SetUpFunctionState(this); |
| 1466 } | 1471 } |
| 1467 | 1472 |
| 1468 | 1473 |
| 1469 template <class Traits> | 1474 template <class Traits> |
| 1470 ParserBase<Traits>::FunctionState::FunctionState( | 1475 ParserBase<Traits>::FunctionState::FunctionState( |
| 1471 FunctionState** function_state_stack, | 1476 FunctionState** function_state_stack, |
| 1472 typename Traits::Type::Scope** scope_stack, | 1477 typename Traits::Type::Scope** scope_stack, |
| 1473 typename Traits::Type::Scope** scope, | 1478 typename Traits::Type::Scope** scope, typename Traits::Type::Zone* zone, |
| 1474 typename Traits::Type::Zone* extra_param, | 1479 AstValueFactory* ast_value_factory, int* ast_node_id_counter) |
| 1475 AstValueFactory* ast_value_factory) | |
| 1476 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), | 1480 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), |
| 1477 next_handler_index_(0), | 1481 next_handler_index_(0), |
| 1478 expected_property_count_(0), | 1482 expected_property_count_(0), |
| 1479 is_generator_(false), | 1483 is_generator_(false), |
| 1480 generator_object_variable_(NULL), | 1484 generator_object_variable_(NULL), |
| 1481 function_state_stack_(function_state_stack), | 1485 function_state_stack_(function_state_stack), |
| 1482 outer_function_state_(*function_state_stack), | 1486 outer_function_state_(*function_state_stack), |
| 1483 scope_stack_(scope_stack), | 1487 scope_stack_(scope_stack), |
| 1484 outer_scope_(*scope_stack), | 1488 outer_scope_(*scope_stack), |
| 1485 saved_ast_node_id_(0), | 1489 saved_ast_node_id_(0), |
| 1486 extra_param_(extra_param), | 1490 ast_node_id_counter_(ast_node_id_counter), |
| 1487 factory_(extra_param, ast_value_factory) { | 1491 factory_(zone, ast_value_factory, ast_node_id_counter) { |
| 1488 *scope_stack_ = *scope; | 1492 *scope_stack_ = *scope; |
| 1489 *function_state_stack = this; | 1493 *function_state_stack = this; |
| 1490 Traits::SetUpFunctionState(this, extra_param); | 1494 Traits::SetUpFunctionState(this); |
| 1491 } | 1495 } |
| 1492 | 1496 |
| 1493 | 1497 |
| 1494 template <class Traits> | 1498 template <class Traits> |
| 1495 ParserBase<Traits>::FunctionState::~FunctionState() { | 1499 ParserBase<Traits>::FunctionState::~FunctionState() { |
| 1496 *scope_stack_ = outer_scope_; | 1500 *scope_stack_ = outer_scope_; |
| 1497 *function_state_stack_ = outer_function_state_; | 1501 *function_state_stack_ = outer_function_state_; |
| 1498 Traits::TearDownFunctionState(this, extra_param_); | 1502 Traits::TearDownFunctionState(this); |
| 1499 } | 1503 } |
| 1500 | 1504 |
| 1501 | 1505 |
| 1502 template<class Traits> | 1506 template<class Traits> |
| 1503 void ParserBase<Traits>::ReportUnexpectedToken(Token::Value token) { | 1507 void ParserBase<Traits>::ReportUnexpectedToken(Token::Value token) { |
| 1504 Scanner::Location source_location = scanner()->location(); | 1508 Scanner::Location source_location = scanner()->location(); |
| 1505 | 1509 |
| 1506 // Four of the tokens are treated specially | 1510 // Four of the tokens are treated specially |
| 1507 switch (token) { | 1511 switch (token) { |
| 1508 case Token::EOS: | 1512 case Token::EOS: |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2440 typename Traits::Type::StatementList body; | 2444 typename Traits::Type::StatementList body; |
| 2441 typename Traits::Type::AstProperties ast_properties; | 2445 typename Traits::Type::AstProperties ast_properties; |
| 2442 BailoutReason dont_optimize_reason = kNoReason; | 2446 BailoutReason dont_optimize_reason = kNoReason; |
| 2443 int num_parameters = -1; | 2447 int num_parameters = -1; |
| 2444 int materialized_literal_count = -1; | 2448 int materialized_literal_count = -1; |
| 2445 int expected_property_count = -1; | 2449 int expected_property_count = -1; |
| 2446 int handler_count = 0; | 2450 int handler_count = 0; |
| 2447 | 2451 |
| 2448 { | 2452 { |
| 2449 FunctionState function_state(&function_state_, &scope_, &scope, zone(), | 2453 FunctionState function_state(&function_state_, &scope_, &scope, zone(), |
| 2450 this->ast_value_factory()); | 2454 this->ast_value_factory(), |
| 2455 ast_node_id_counter_); |
| 2451 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); | 2456 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); |
| 2452 num_parameters = Traits::DeclareArrowParametersFromExpression( | 2457 num_parameters = Traits::DeclareArrowParametersFromExpression( |
| 2453 params_ast, scope_, &dupe_error_loc, ok); | 2458 params_ast, scope_, &dupe_error_loc, ok); |
| 2454 if (!*ok) { | 2459 if (!*ok) { |
| 2455 ReportMessageAt( | 2460 ReportMessageAt( |
| 2456 Scanner::Location(start_pos, scanner()->location().beg_pos), | 2461 Scanner::Location(start_pos, scanner()->location().beg_pos), |
| 2457 "malformed_arrow_function_parameter_list"); | 2462 "malformed_arrow_function_parameter_list"); |
| 2458 return this->EmptyExpression(); | 2463 return this->EmptyExpression(); |
| 2459 } | 2464 } |
| 2460 | 2465 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2568 } | 2573 } |
| 2569 | 2574 |
| 2570 | 2575 |
| 2571 #undef CHECK_OK | 2576 #undef CHECK_OK |
| 2572 #undef CHECK_OK_CUSTOM | 2577 #undef CHECK_OK_CUSTOM |
| 2573 | 2578 |
| 2574 | 2579 |
| 2575 } } // v8::internal | 2580 } } // v8::internal |
| 2576 | 2581 |
| 2577 #endif // V8_PREPARSER_H | 2582 #endif // V8_PREPARSER_H |
| OLD | NEW |