| 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 AstNode::IdGen* ast_node_id_gen, |
| 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_gen_(ast_node_id_gen) {} |
| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 ~BlockState() { *scope_stack_ = outer_scope_; } | 151 ~BlockState() { *scope_stack_ = outer_scope_; } |
| 150 | 152 |
| 151 private: | 153 private: |
| 152 typename Traits::Type::Scope** scope_stack_; | 154 typename Traits::Type::Scope** scope_stack_; |
| 153 typename Traits::Type::Scope* outer_scope_; | 155 typename Traits::Type::Scope* outer_scope_; |
| 154 typename Traits::Type::Scope* scope_; | 156 typename Traits::Type::Scope* scope_; |
| 155 }; | 157 }; |
| 156 | 158 |
| 157 class FunctionState BASE_EMBEDDED { | 159 class FunctionState BASE_EMBEDDED { |
| 158 public: | 160 public: |
| 159 FunctionState( | 161 FunctionState(FunctionState** function_state_stack, |
| 160 FunctionState** function_state_stack, | 162 typename Traits::Type::Scope** scope_stack, |
| 161 typename Traits::Type::Scope** scope_stack, | 163 typename Traits::Type::Scope* scope, |
| 162 typename Traits::Type::Scope* scope, | 164 typename Traits::Type::Zone* zone = NULL, |
| 163 typename Traits::Type::Zone* zone = NULL, | 165 AstValueFactory* ast_value_factory = NULL, |
| 164 AstValueFactory* ast_value_factory = NULL); | 166 AstNode::IdGen* ast_node_id_gen = NULL); |
| 165 FunctionState(FunctionState** function_state_stack, | 167 FunctionState(FunctionState** function_state_stack, |
| 166 typename Traits::Type::Scope** scope_stack, | 168 typename Traits::Type::Scope** scope_stack, |
| 167 typename Traits::Type::Scope** scope, | 169 typename Traits::Type::Scope** scope, |
| 168 typename Traits::Type::Zone* zone = NULL, | 170 typename Traits::Type::Zone* zone = NULL, |
| 169 AstValueFactory* ast_value_factory = NULL); | 171 AstValueFactory* ast_value_factory = NULL, |
| 172 AstNode::IdGen* ast_node_id_gen = NULL); |
| 170 ~FunctionState(); | 173 ~FunctionState(); |
| 171 | 174 |
| 172 int NextMaterializedLiteralIndex() { | 175 int NextMaterializedLiteralIndex() { |
| 173 return next_materialized_literal_index_++; | 176 return next_materialized_literal_index_++; |
| 174 } | 177 } |
| 175 int materialized_literal_count() { | 178 int materialized_literal_count() { |
| 176 return next_materialized_literal_index_ - JSFunction::kLiteralsPrefixSize; | 179 return next_materialized_literal_index_ - JSFunction::kLiteralsPrefixSize; |
| 177 } | 180 } |
| 178 | 181 |
| 179 int NextHandlerIndex() { return next_handler_index_++; } | 182 int NextHandlerIndex() { return next_handler_index_++; } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 bool is_generator_; | 218 bool is_generator_; |
| 216 // For generators, this variable may hold the generator object. It variable | 219 // For generators, this variable may hold the generator object. It variable |
| 217 // is used by yield expressions and return statements. It is not necessary | 220 // is used by yield expressions and return statements. It is not necessary |
| 218 // for generator functions to have this variable set. | 221 // for generator functions to have this variable set. |
| 219 Variable* generator_object_variable_; | 222 Variable* generator_object_variable_; |
| 220 | 223 |
| 221 FunctionState** function_state_stack_; | 224 FunctionState** function_state_stack_; |
| 222 FunctionState* outer_function_state_; | 225 FunctionState* outer_function_state_; |
| 223 typename Traits::Type::Scope** scope_stack_; | 226 typename Traits::Type::Scope** scope_stack_; |
| 224 typename Traits::Type::Scope* outer_scope_; | 227 typename Traits::Type::Scope* outer_scope_; |
| 225 int saved_ast_node_id_; // Only used by ParserTraits. | 228 AstNode::IdGen* ast_node_id_gen_; // Only used by ParserTraits. |
| 229 AstNode::IdGen saved_id_gen_; // Ditto. |
| 226 typename Traits::Type::Zone* extra_param_; | 230 typename Traits::Type::Zone* extra_param_; |
| 227 typename Traits::Type::Factory factory_; | 231 typename Traits::Type::Factory factory_; |
| 228 | 232 |
| 229 friend class ParserTraits; | 233 friend class ParserTraits; |
| 230 friend class CheckpointBase; | 234 friend class CheckpointBase; |
| 231 }; | 235 }; |
| 232 | 236 |
| 233 // Annoyingly, arrow functions first parse as comma expressions, then when we | 237 // Annoyingly, arrow functions first parse as comma expressions, then when we |
| 234 // see the => we have to go back and reinterpret the arguments as being formal | 238 // see the => we have to go back and reinterpret the arguments as being formal |
| 235 // parameters. To do so we need to reset some of the parser state back to | 239 // 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... |
| 274 Mode old_mode_; | 278 Mode old_mode_; |
| 275 }; | 279 }; |
| 276 | 280 |
| 277 Scanner* scanner() const { return scanner_; } | 281 Scanner* scanner() const { return scanner_; } |
| 278 int position() { return scanner_->location().beg_pos; } | 282 int position() { return scanner_->location().beg_pos; } |
| 279 int peek_position() { return scanner_->peek_location().beg_pos; } | 283 int peek_position() { return scanner_->peek_location().beg_pos; } |
| 280 bool stack_overflow() const { return stack_overflow_; } | 284 bool stack_overflow() const { return stack_overflow_; } |
| 281 void set_stack_overflow() { stack_overflow_ = true; } | 285 void set_stack_overflow() { stack_overflow_ = true; } |
| 282 Mode mode() const { return mode_; } | 286 Mode mode() const { return mode_; } |
| 283 typename Traits::Type::Zone* zone() const { return zone_; } | 287 typename Traits::Type::Zone* zone() const { return zone_; } |
| 288 AstNode::IdGen* ast_node_id_gen() const { return ast_node_id_gen_; } |
| 284 | 289 |
| 285 INLINE(Token::Value peek()) { | 290 INLINE(Token::Value peek()) { |
| 286 if (stack_overflow_) return Token::ILLEGAL; | 291 if (stack_overflow_) return Token::ILLEGAL; |
| 287 return scanner()->peek(); | 292 return scanner()->peek(); |
| 288 } | 293 } |
| 289 | 294 |
| 290 INLINE(Token::Value Next()) { | 295 INLINE(Token::Value Next()) { |
| 291 if (stack_overflow_) return Token::ILLEGAL; | 296 if (stack_overflow_) return Token::ILLEGAL; |
| 292 { | 297 { |
| 293 if (GetCurrentStackPosition() < stack_limit_) { | 298 if (GetCurrentStackPosition() < stack_limit_) { |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 Scanner* scanner_; | 574 Scanner* scanner_; |
| 570 uintptr_t stack_limit_; | 575 uintptr_t stack_limit_; |
| 571 bool stack_overflow_; | 576 bool stack_overflow_; |
| 572 | 577 |
| 573 bool allow_lazy_; | 578 bool allow_lazy_; |
| 574 bool allow_natives_syntax_; | 579 bool allow_natives_syntax_; |
| 575 bool allow_generators_; | 580 bool allow_generators_; |
| 576 bool allow_arrow_functions_; | 581 bool allow_arrow_functions_; |
| 577 | 582 |
| 578 typename Traits::Type::Zone* zone_; // Only used by Parser. | 583 typename Traits::Type::Zone* zone_; // Only used by Parser. |
| 584 AstNode::IdGen* ast_node_id_gen_; |
| 579 }; | 585 }; |
| 580 | 586 |
| 581 | 587 |
| 582 class PreParserIdentifier { | 588 class PreParserIdentifier { |
| 583 public: | 589 public: |
| 584 PreParserIdentifier() : type_(kUnknownIdentifier) {} | 590 PreParserIdentifier() : type_(kUnknownIdentifier) {} |
| 585 static PreParserIdentifier Default() { | 591 static PreParserIdentifier Default() { |
| 586 return PreParserIdentifier(kUnknownIdentifier); | 592 return PreParserIdentifier(kUnknownIdentifier); |
| 587 } | 593 } |
| 588 static PreParserIdentifier Eval() { | 594 static PreParserIdentifier Eval() { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 PreParserScope* operator->() { return this; } | 939 PreParserScope* operator->() { return this; } |
| 934 | 940 |
| 935 private: | 941 private: |
| 936 ScopeType scope_type_; | 942 ScopeType scope_type_; |
| 937 StrictMode strict_mode_; | 943 StrictMode strict_mode_; |
| 938 }; | 944 }; |
| 939 | 945 |
| 940 | 946 |
| 941 class PreParserFactory { | 947 class PreParserFactory { |
| 942 public: | 948 public: |
| 943 explicit PreParserFactory(void* extra_param1, void* extra_param2) {} | 949 PreParserFactory(void*, void*, void*) {} |
| 944 PreParserExpression NewStringLiteral(PreParserIdentifier identifier, | 950 PreParserExpression NewStringLiteral(PreParserIdentifier identifier, |
| 945 int pos) { | 951 int pos) { |
| 946 return PreParserExpression::Default(); | 952 return PreParserExpression::Default(); |
| 947 } | 953 } |
| 948 PreParserExpression NewNumberLiteral(double number, | 954 PreParserExpression NewNumberLiteral(double number, |
| 949 int pos) { | 955 int pos) { |
| 950 return PreParserExpression::Default(); | 956 return PreParserExpression::Default(); |
| 951 } | 957 } |
| 952 PreParserExpression NewRegExpLiteral(PreParserIdentifier js_pattern, | 958 PreParserExpression NewRegExpLiteral(PreParserIdentifier js_pattern, |
| 953 PreParserIdentifier js_flags, | 959 PreParserIdentifier js_flags, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 // For constructing objects returned by the traversing functions. | 1105 // For constructing objects returned by the traversing functions. |
| 1100 typedef PreParserFactory Factory; | 1106 typedef PreParserFactory Factory; |
| 1101 }; | 1107 }; |
| 1102 | 1108 |
| 1103 class Checkpoint; | 1109 class Checkpoint; |
| 1104 | 1110 |
| 1105 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {} | 1111 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {} |
| 1106 | 1112 |
| 1107 // Custom operations executed when FunctionStates are created and | 1113 // Custom operations executed when FunctionStates are created and |
| 1108 // destructed. (The PreParser doesn't need to do anything.) | 1114 // destructed. (The PreParser doesn't need to do anything.) |
| 1109 template<typename FunctionState> | 1115 template <typename FunctionState> |
| 1110 static void SetUpFunctionState(FunctionState* function_state, void*) {} | 1116 static void SetUpFunctionState(FunctionState* function_state) {} |
| 1111 template<typename FunctionState> | 1117 template <typename FunctionState> |
| 1112 static void TearDownFunctionState(FunctionState* function_state, void*) {} | 1118 static void TearDownFunctionState(FunctionState* function_state) {} |
| 1113 | 1119 |
| 1114 // Helper functions for recursive descent. | 1120 // Helper functions for recursive descent. |
| 1115 static bool IsEvalOrArguments(PreParserIdentifier identifier) { | 1121 static bool IsEvalOrArguments(PreParserIdentifier identifier) { |
| 1116 return identifier.IsEvalOrArguments(); | 1122 return identifier.IsEvalOrArguments(); |
| 1117 } | 1123 } |
| 1118 | 1124 |
| 1119 // Returns true if the expression is of type "this.foo". | 1125 // Returns true if the expression is of type "this.foo". |
| 1120 static bool IsThisProperty(PreParserExpression expression) { | 1126 static bool IsThisProperty(PreParserExpression expression) { |
| 1121 return expression.IsThisProperty(); | 1127 return expression.IsThisProperty(); |
| 1122 } | 1128 } |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 typedef PreParserIdentifier Identifier; | 1361 typedef PreParserIdentifier Identifier; |
| 1356 typedef PreParserExpression Expression; | 1362 typedef PreParserExpression Expression; |
| 1357 typedef PreParserStatement Statement; | 1363 typedef PreParserStatement Statement; |
| 1358 | 1364 |
| 1359 enum PreParseResult { | 1365 enum PreParseResult { |
| 1360 kPreParseStackOverflow, | 1366 kPreParseStackOverflow, |
| 1361 kPreParseSuccess | 1367 kPreParseSuccess |
| 1362 }; | 1368 }; |
| 1363 | 1369 |
| 1364 PreParser(Scanner* scanner, ParserRecorder* log, uintptr_t stack_limit) | 1370 PreParser(Scanner* scanner, ParserRecorder* log, uintptr_t stack_limit) |
| 1365 : ParserBase<PreParserTraits>(scanner, stack_limit, NULL, log, NULL, | 1371 : ParserBase<PreParserTraits>(scanner, stack_limit, NULL, log, NULL, NULL, |
| 1366 this) {} | 1372 this) {} |
| 1367 | 1373 |
| 1368 // Pre-parse the program from the character stream; returns true on | 1374 // Pre-parse the program from the character stream; returns true on |
| 1369 // success (even if parsing failed, the pre-parse data successfully | 1375 // success (even if parsing failed, the pre-parse data successfully |
| 1370 // captured the syntax error), and false if a stack-overflow happened | 1376 // captured the syntax error), and false if a stack-overflow happened |
| 1371 // during parsing. | 1377 // during parsing. |
| 1372 PreParseResult PreParseProgram() { | 1378 PreParseResult PreParseProgram() { |
| 1373 PreParserScope scope(scope_, GLOBAL_SCOPE); | 1379 PreParserScope scope(scope_, GLOBAL_SCOPE); |
| 1374 FunctionState top_scope(&function_state_, &scope_, &scope); | 1380 FunctionState top_scope(&function_state_, &scope_, &scope); |
| 1375 bool ok = true; | 1381 bool ok = true; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1490 | 1496 |
| 1491 | 1497 |
| 1492 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( | 1498 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( |
| 1493 PreParserIdentifier function_name, int pos, Variable* fvar, | 1499 PreParserIdentifier function_name, int pos, Variable* fvar, |
| 1494 Token::Value fvar_init_op, bool is_generator, bool* ok) { | 1500 Token::Value fvar_init_op, bool is_generator, bool* ok) { |
| 1495 return pre_parser_->ParseEagerFunctionBody(function_name, pos, fvar, | 1501 return pre_parser_->ParseEagerFunctionBody(function_name, pos, fvar, |
| 1496 fvar_init_op, is_generator, ok); | 1502 fvar_init_op, is_generator, ok); |
| 1497 } | 1503 } |
| 1498 | 1504 |
| 1499 | 1505 |
| 1500 template<class Traits> | 1506 template <class Traits> |
| 1501 ParserBase<Traits>::FunctionState::FunctionState( | 1507 ParserBase<Traits>::FunctionState::FunctionState( |
| 1502 FunctionState** function_state_stack, | 1508 FunctionState** function_state_stack, |
| 1503 typename Traits::Type::Scope** scope_stack, | 1509 typename Traits::Type::Scope** scope_stack, |
| 1504 typename Traits::Type::Scope* scope, | 1510 typename Traits::Type::Scope* scope, typename Traits::Type::Zone* zone, |
| 1505 typename Traits::Type::Zone* extra_param, | 1511 AstValueFactory* ast_value_factory, AstNode::IdGen* ast_node_id_gen) |
| 1506 AstValueFactory* ast_value_factory) | |
| 1507 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), | 1512 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), |
| 1508 next_handler_index_(0), | 1513 next_handler_index_(0), |
| 1509 expected_property_count_(0), | 1514 expected_property_count_(0), |
| 1510 is_generator_(false), | 1515 is_generator_(false), |
| 1511 generator_object_variable_(NULL), | 1516 generator_object_variable_(NULL), |
| 1512 function_state_stack_(function_state_stack), | 1517 function_state_stack_(function_state_stack), |
| 1513 outer_function_state_(*function_state_stack), | 1518 outer_function_state_(*function_state_stack), |
| 1514 scope_stack_(scope_stack), | 1519 scope_stack_(scope_stack), |
| 1515 outer_scope_(*scope_stack), | 1520 outer_scope_(*scope_stack), |
| 1516 saved_ast_node_id_(0), | 1521 ast_node_id_gen_(ast_node_id_gen), |
| 1517 extra_param_(extra_param), | 1522 factory_(zone, ast_value_factory, ast_node_id_gen) { |
| 1518 factory_(extra_param, ast_value_factory) { | |
| 1519 *scope_stack_ = scope; | 1523 *scope_stack_ = scope; |
| 1520 *function_state_stack = this; | 1524 *function_state_stack = this; |
| 1521 Traits::SetUpFunctionState(this, extra_param); | 1525 Traits::SetUpFunctionState(this); |
| 1522 } | 1526 } |
| 1523 | 1527 |
| 1524 | 1528 |
| 1525 template <class Traits> | 1529 template <class Traits> |
| 1526 ParserBase<Traits>::FunctionState::FunctionState( | 1530 ParserBase<Traits>::FunctionState::FunctionState( |
| 1527 FunctionState** function_state_stack, | 1531 FunctionState** function_state_stack, |
| 1528 typename Traits::Type::Scope** scope_stack, | 1532 typename Traits::Type::Scope** scope_stack, |
| 1529 typename Traits::Type::Scope** scope, | 1533 typename Traits::Type::Scope** scope, typename Traits::Type::Zone* zone, |
| 1530 typename Traits::Type::Zone* extra_param, | 1534 AstValueFactory* ast_value_factory, AstNode::IdGen* ast_node_id_gen) |
| 1531 AstValueFactory* ast_value_factory) | |
| 1532 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), | 1535 : next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize), |
| 1533 next_handler_index_(0), | 1536 next_handler_index_(0), |
| 1534 expected_property_count_(0), | 1537 expected_property_count_(0), |
| 1535 is_generator_(false), | 1538 is_generator_(false), |
| 1536 generator_object_variable_(NULL), | 1539 generator_object_variable_(NULL), |
| 1537 function_state_stack_(function_state_stack), | 1540 function_state_stack_(function_state_stack), |
| 1538 outer_function_state_(*function_state_stack), | 1541 outer_function_state_(*function_state_stack), |
| 1539 scope_stack_(scope_stack), | 1542 scope_stack_(scope_stack), |
| 1540 outer_scope_(*scope_stack), | 1543 outer_scope_(*scope_stack), |
| 1541 saved_ast_node_id_(0), | 1544 ast_node_id_gen_(ast_node_id_gen), |
| 1542 extra_param_(extra_param), | 1545 factory_(zone, ast_value_factory, ast_node_id_gen) { |
| 1543 factory_(extra_param, ast_value_factory) { | |
| 1544 *scope_stack_ = *scope; | 1546 *scope_stack_ = *scope; |
| 1545 *function_state_stack = this; | 1547 *function_state_stack = this; |
| 1546 Traits::SetUpFunctionState(this, extra_param); | 1548 Traits::SetUpFunctionState(this); |
| 1547 } | 1549 } |
| 1548 | 1550 |
| 1549 | 1551 |
| 1550 template <class Traits> | 1552 template <class Traits> |
| 1551 ParserBase<Traits>::FunctionState::~FunctionState() { | 1553 ParserBase<Traits>::FunctionState::~FunctionState() { |
| 1552 *scope_stack_ = outer_scope_; | 1554 *scope_stack_ = outer_scope_; |
| 1553 *function_state_stack_ = outer_function_state_; | 1555 *function_state_stack_ = outer_function_state_; |
| 1554 Traits::TearDownFunctionState(this, extra_param_); | 1556 Traits::TearDownFunctionState(this); |
| 1555 } | 1557 } |
| 1556 | 1558 |
| 1557 | 1559 |
| 1558 template<class Traits> | 1560 template<class Traits> |
| 1559 void ParserBase<Traits>::ReportUnexpectedToken(Token::Value token) { | 1561 void ParserBase<Traits>::ReportUnexpectedToken(Token::Value token) { |
| 1560 Scanner::Location source_location = scanner()->location(); | 1562 Scanner::Location source_location = scanner()->location(); |
| 1561 | 1563 |
| 1562 // Four of the tokens are treated specially | 1564 // Four of the tokens are treated specially |
| 1563 switch (token) { | 1565 switch (token) { |
| 1564 case Token::EOS: | 1566 case Token::EOS: |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 typename Traits::Type::StatementList body; | 2509 typename Traits::Type::StatementList body; |
| 2508 typename Traits::Type::AstProperties ast_properties; | 2510 typename Traits::Type::AstProperties ast_properties; |
| 2509 BailoutReason dont_optimize_reason = kNoReason; | 2511 BailoutReason dont_optimize_reason = kNoReason; |
| 2510 int num_parameters = -1; | 2512 int num_parameters = -1; |
| 2511 int materialized_literal_count = -1; | 2513 int materialized_literal_count = -1; |
| 2512 int expected_property_count = -1; | 2514 int expected_property_count = -1; |
| 2513 int handler_count = 0; | 2515 int handler_count = 0; |
| 2514 | 2516 |
| 2515 { | 2517 { |
| 2516 FunctionState function_state(&function_state_, &scope_, &scope, zone(), | 2518 FunctionState function_state(&function_state_, &scope_, &scope, zone(), |
| 2517 this->ast_value_factory()); | 2519 this->ast_value_factory(), ast_node_id_gen_); |
| 2518 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); | 2520 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); |
| 2519 num_parameters = Traits::DeclareArrowParametersFromExpression( | 2521 num_parameters = Traits::DeclareArrowParametersFromExpression( |
| 2520 params_ast, scope_, &dupe_error_loc, ok); | 2522 params_ast, scope_, &dupe_error_loc, ok); |
| 2521 if (!*ok) { | 2523 if (!*ok) { |
| 2522 ReportMessageAt( | 2524 ReportMessageAt( |
| 2523 Scanner::Location(start_pos, scanner()->location().beg_pos), | 2525 Scanner::Location(start_pos, scanner()->location().beg_pos), |
| 2524 "malformed_arrow_function_parameter_list"); | 2526 "malformed_arrow_function_parameter_list"); |
| 2525 return this->EmptyExpression(); | 2527 return this->EmptyExpression(); |
| 2526 } | 2528 } |
| 2527 | 2529 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2661 DCHECK(IsAccessorAccessorConflict(old_type, type)); | 2663 DCHECK(IsAccessorAccessorConflict(old_type, type)); |
| 2662 // Both accessors of the same type. | 2664 // Both accessors of the same type. |
| 2663 parser()->ReportMessage("accessor_get_set"); | 2665 parser()->ReportMessage("accessor_get_set"); |
| 2664 } | 2666 } |
| 2665 *ok = false; | 2667 *ok = false; |
| 2666 } | 2668 } |
| 2667 } | 2669 } |
| 2668 } } // v8::internal | 2670 } } // v8::internal |
| 2669 | 2671 |
| 2670 #endif // V8_PREPARSER_H | 2672 #endif // V8_PREPARSER_H |
| OLD | NEW |