| 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/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // example, Parser keeps track of which function literals should be marked as | 35 // example, Parser keeps track of which function literals should be marked as |
| 36 // pretenured, and PreParser doesn't care. | 36 // pretenured, and PreParser doesn't care. |
| 37 | 37 |
| 38 // The traits are expected to contain the following typedefs: | 38 // The traits are expected to contain the following typedefs: |
| 39 // struct Traits { | 39 // struct Traits { |
| 40 // // In particular... | 40 // // In particular... |
| 41 // struct Type { | 41 // struct Type { |
| 42 // // Used by FunctionState and BlockState. | 42 // // Used by FunctionState and BlockState. |
| 43 // typedef Scope; | 43 // typedef Scope; |
| 44 // typedef GeneratorVariable; | 44 // typedef GeneratorVariable; |
| 45 // typedef Zone; | |
| 46 // // Return types for traversing functions. | 45 // // Return types for traversing functions. |
| 47 // typedef Identifier; | 46 // typedef Identifier; |
| 48 // typedef Expression; | 47 // typedef Expression; |
| 49 // typedef FunctionLiteral; | 48 // typedef FunctionLiteral; |
| 50 // typedef ClassLiteral; | 49 // typedef ClassLiteral; |
| 51 // typedef ObjectLiteralProperty; | 50 // typedef ObjectLiteralProperty; |
| 52 // typedef Literal; | 51 // typedef Literal; |
| 53 // typedef ExpressionList; | 52 // typedef ExpressionList; |
| 54 // typedef PropertyList; | 53 // typedef PropertyList; |
| 55 // // For constructing objects returned by the traversing functions. | 54 // // For constructing objects returned by the traversing functions. |
| 56 // typedef Factory; | 55 // typedef Factory; |
| 57 // }; | 56 // }; |
| 58 // // ... | 57 // // ... |
| 59 // }; | 58 // }; |
| 60 | 59 |
| 61 template <typename Traits> | 60 template <typename Traits> |
| 62 class ParserBase : public Traits { | 61 class ParserBase : public Traits { |
| 63 public: | 62 public: |
| 64 // Shorten type names defined by Traits. | 63 // Shorten type names defined by Traits. |
| 65 typedef typename Traits::Type::Expression ExpressionT; | 64 typedef typename Traits::Type::Expression ExpressionT; |
| 66 typedef typename Traits::Type::Identifier IdentifierT; | 65 typedef typename Traits::Type::Identifier IdentifierT; |
| 67 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; | 66 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; |
| 68 typedef typename Traits::Type::Literal LiteralT; | 67 typedef typename Traits::Type::Literal LiteralT; |
| 69 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; | 68 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; |
| 70 | 69 |
| 71 ParserBase(Isolate* isolate, typename Traits::Type::Zone* zone, | 70 ParserBase(Isolate* isolate, Zone* zone, Scanner* scanner, |
| 72 Scanner* scanner, uintptr_t stack_limit, v8::Extension* extension, | 71 uintptr_t stack_limit, v8::Extension* extension, |
| 73 ParserRecorder* log, typename Traits::Type::Parser this_object) | 72 AstValueFactory* ast_value_factory, ParserRecorder* log, |
| 73 typename Traits::Type::Parser this_object) |
| 74 : Traits(this_object), | 74 : Traits(this_object), |
| 75 parenthesized_function_(false), | 75 parenthesized_function_(false), |
| 76 scope_(NULL), | 76 scope_(NULL), |
| 77 function_state_(NULL), | 77 function_state_(NULL), |
| 78 extension_(extension), | 78 extension_(extension), |
| 79 fni_(NULL), | 79 fni_(NULL), |
| 80 ast_value_factory_(ast_value_factory), |
| 80 log_(log), | 81 log_(log), |
| 81 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. | 82 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. |
| 82 stack_limit_(stack_limit), | 83 stack_limit_(stack_limit), |
| 83 isolate_(isolate), | 84 isolate_(isolate), |
| 84 zone_(zone), | 85 zone_(zone), |
| 85 scanner_(scanner), | 86 scanner_(scanner), |
| 86 stack_overflow_(false), | 87 stack_overflow_(false), |
| 87 allow_lazy_(false), | 88 allow_lazy_(false), |
| 88 allow_natives_(false), | 89 allow_natives_(false), |
| 89 allow_harmony_arrow_functions_(false), | 90 allow_harmony_arrow_functions_(false), |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 bool is_generator_; | 247 bool is_generator_; |
| 247 // For generators, this variable may hold the generator object. It variable | 248 // For generators, this variable may hold the generator object. It variable |
| 248 // is used by yield expressions and return statements. It is not necessary | 249 // is used by yield expressions and return statements. It is not necessary |
| 249 // for generator functions to have this variable set. | 250 // for generator functions to have this variable set. |
| 250 Variable* generator_object_variable_; | 251 Variable* generator_object_variable_; |
| 251 | 252 |
| 252 FunctionState** function_state_stack_; | 253 FunctionState** function_state_stack_; |
| 253 FunctionState* outer_function_state_; | 254 FunctionState* outer_function_state_; |
| 254 typename Traits::Type::Scope** scope_stack_; | 255 typename Traits::Type::Scope** scope_stack_; |
| 255 typename Traits::Type::Scope* outer_scope_; | 256 typename Traits::Type::Scope* outer_scope_; |
| 256 typename Traits::Type::Zone* extra_param_; | |
| 257 typename Traits::Type::Factory* factory_; | 257 typename Traits::Type::Factory* factory_; |
| 258 | 258 |
| 259 friend class ParserTraits; | 259 friend class ParserTraits; |
| 260 friend class Checkpoint; | 260 friend class Checkpoint; |
| 261 }; | 261 }; |
| 262 | 262 |
| 263 // Annoyingly, arrow functions first parse as comma expressions, then when we | 263 // Annoyingly, arrow functions first parse as comma expressions, then when we |
| 264 // see the => we have to go back and reinterpret the arguments as being formal | 264 // see the => we have to go back and reinterpret the arguments as being formal |
| 265 // parameters. To do so we need to reset some of the parser state back to | 265 // parameters. To do so we need to reset some of the parser state back to |
| 266 // what it was before the arguments were first seen. | 266 // what it was before the arguments were first seen. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 parser_->mode_ = old_mode_; | 299 parser_->mode_ = old_mode_; |
| 300 } | 300 } |
| 301 | 301 |
| 302 private: | 302 private: |
| 303 ParserBase* parser_; | 303 ParserBase* parser_; |
| 304 Mode old_mode_; | 304 Mode old_mode_; |
| 305 }; | 305 }; |
| 306 | 306 |
| 307 Isolate* isolate() const { return isolate_; } | 307 Isolate* isolate() const { return isolate_; } |
| 308 Scanner* scanner() const { return scanner_; } | 308 Scanner* scanner() const { return scanner_; } |
| 309 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } |
| 309 int position() { return scanner_->location().beg_pos; } | 310 int position() { return scanner_->location().beg_pos; } |
| 310 int peek_position() { return scanner_->peek_location().beg_pos; } | 311 int peek_position() { return scanner_->peek_location().beg_pos; } |
| 311 bool stack_overflow() const { return stack_overflow_; } | 312 bool stack_overflow() const { return stack_overflow_; } |
| 312 void set_stack_overflow() { stack_overflow_ = true; } | 313 void set_stack_overflow() { stack_overflow_ = true; } |
| 313 Mode mode() const { return mode_; } | 314 Mode mode() const { return mode_; } |
| 314 typename Traits::Type::Zone* zone() const { return zone_; } | 315 Zone* zone() const { return zone_; } |
| 315 | 316 |
| 316 INLINE(Token::Value peek()) { | 317 INLINE(Token::Value peek()) { |
| 317 if (stack_overflow_) return Token::ILLEGAL; | 318 if (stack_overflow_) return Token::ILLEGAL; |
| 318 return scanner()->peek(); | 319 return scanner()->peek(); |
| 319 } | 320 } |
| 320 | 321 |
| 321 INLINE(Token::Value Next()) { | 322 INLINE(Token::Value Next()) { |
| 322 if (stack_overflow_) return Token::ILLEGAL; | 323 if (stack_overflow_) return Token::ILLEGAL; |
| 323 { | 324 { |
| 324 if (GetCurrentStackPosition() < stack_limit_) { | 325 if (GetCurrentStackPosition() < stack_limit_) { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 // If true, the next (and immediately following) function literal is | 610 // If true, the next (and immediately following) function literal is |
| 610 // preceded by a parenthesis. | 611 // preceded by a parenthesis. |
| 611 // Heuristically that means that the function will be called immediately, | 612 // Heuristically that means that the function will be called immediately, |
| 612 // so never lazily compile it. | 613 // so never lazily compile it. |
| 613 bool parenthesized_function_; | 614 bool parenthesized_function_; |
| 614 | 615 |
| 615 typename Traits::Type::Scope* scope_; // Scope stack. | 616 typename Traits::Type::Scope* scope_; // Scope stack. |
| 616 FunctionState* function_state_; // Function state stack. | 617 FunctionState* function_state_; // Function state stack. |
| 617 v8::Extension* extension_; | 618 v8::Extension* extension_; |
| 618 FuncNameInferrer* fni_; | 619 FuncNameInferrer* fni_; |
| 620 AstValueFactory* ast_value_factory_; // Not owned. |
| 619 ParserRecorder* log_; | 621 ParserRecorder* log_; |
| 620 Mode mode_; | 622 Mode mode_; |
| 621 uintptr_t stack_limit_; | 623 uintptr_t stack_limit_; |
| 622 | 624 |
| 623 private: | 625 private: |
| 624 Isolate* isolate_; | 626 Isolate* isolate_; |
| 625 typename Traits::Type::Zone* zone_; // Only used by Parser. | 627 Zone* zone_; |
| 626 | 628 |
| 627 Scanner* scanner_; | 629 Scanner* scanner_; |
| 628 bool stack_overflow_; | 630 bool stack_overflow_; |
| 629 | 631 |
| 630 bool allow_lazy_; | 632 bool allow_lazy_; |
| 631 bool allow_natives_; | 633 bool allow_natives_; |
| 632 bool allow_harmony_arrow_functions_; | 634 bool allow_harmony_arrow_functions_; |
| 633 bool allow_harmony_object_literals_; | 635 bool allow_harmony_object_literals_; |
| 634 bool allow_harmony_sloppy_; | 636 bool allow_harmony_sloppy_; |
| 635 bool allow_harmony_computed_property_names_; | 637 bool allow_harmony_computed_property_names_; |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 // it needs. | 1184 // it needs. |
| 1183 typedef PreParser* Parser; | 1185 typedef PreParser* Parser; |
| 1184 | 1186 |
| 1185 // Used by FunctionState and BlockState. | 1187 // Used by FunctionState and BlockState. |
| 1186 typedef PreParserScope Scope; | 1188 typedef PreParserScope Scope; |
| 1187 typedef PreParserScope ScopePtr; | 1189 typedef PreParserScope ScopePtr; |
| 1188 inline static Scope* ptr_to_scope(ScopePtr& scope) { return &scope; } | 1190 inline static Scope* ptr_to_scope(ScopePtr& scope) { return &scope; } |
| 1189 | 1191 |
| 1190 // PreParser doesn't need to store generator variables. | 1192 // PreParser doesn't need to store generator variables. |
| 1191 typedef void GeneratorVariable; | 1193 typedef void GeneratorVariable; |
| 1192 // No interaction with Zones. | |
| 1193 typedef void Zone; | |
| 1194 | 1194 |
| 1195 typedef int AstProperties; | 1195 typedef int AstProperties; |
| 1196 typedef Vector<PreParserIdentifier> ParameterIdentifierVector; | 1196 typedef Vector<PreParserIdentifier> ParameterIdentifierVector; |
| 1197 | 1197 |
| 1198 // Return types for traversing functions. | 1198 // Return types for traversing functions. |
| 1199 typedef PreParserIdentifier Identifier; | 1199 typedef PreParserIdentifier Identifier; |
| 1200 typedef PreParserExpression Expression; | 1200 typedef PreParserExpression Expression; |
| 1201 typedef PreParserExpression YieldExpression; | 1201 typedef PreParserExpression YieldExpression; |
| 1202 typedef PreParserExpression FunctionLiteral; | 1202 typedef PreParserExpression FunctionLiteral; |
| 1203 typedef PreParserExpression ClassLiteral; | 1203 typedef PreParserExpression ClassLiteral; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1404 | 1404 |
| 1405 PreParserExpression ExpressionFromString(int pos, | 1405 PreParserExpression ExpressionFromString(int pos, |
| 1406 Scanner* scanner, | 1406 Scanner* scanner, |
| 1407 PreParserFactory* factory = NULL); | 1407 PreParserFactory* factory = NULL); |
| 1408 | 1408 |
| 1409 PreParserExpression GetIterator(PreParserExpression iterable, | 1409 PreParserExpression GetIterator(PreParserExpression iterable, |
| 1410 PreParserFactory* factory) { | 1410 PreParserFactory* factory) { |
| 1411 return PreParserExpression::Default(); | 1411 return PreParserExpression::Default(); |
| 1412 } | 1412 } |
| 1413 | 1413 |
| 1414 static PreParserExpressionList NewExpressionList(int size, void* zone) { | 1414 static PreParserExpressionList NewExpressionList(int size, Zone* zone) { |
| 1415 return PreParserExpressionList(); | 1415 return PreParserExpressionList(); |
| 1416 } | 1416 } |
| 1417 | 1417 |
| 1418 static PreParserStatementList NewStatementList(int size, void* zone) { | 1418 static PreParserStatementList NewStatementList(int size, Zone* zone) { |
| 1419 return PreParserStatementList(); | 1419 return PreParserStatementList(); |
| 1420 } | 1420 } |
| 1421 | 1421 |
| 1422 static PreParserExpressionList NewPropertyList(int size, void* zone) { | 1422 static PreParserExpressionList NewPropertyList(int size, Zone* zone) { |
| 1423 return PreParserExpressionList(); | 1423 return PreParserExpressionList(); |
| 1424 } | 1424 } |
| 1425 | 1425 |
| 1426 V8_INLINE void SkipLazyFunctionBody(PreParserIdentifier function_name, | 1426 V8_INLINE void SkipLazyFunctionBody(PreParserIdentifier function_name, |
| 1427 int* materialized_literal_count, | 1427 int* materialized_literal_count, |
| 1428 int* expected_property_count, bool* ok) { | 1428 int* expected_property_count, bool* ok) { |
| 1429 UNREACHABLE(); | 1429 UNREACHABLE(); |
| 1430 } | 1430 } |
| 1431 | 1431 |
| 1432 V8_INLINE PreParserStatementList | 1432 V8_INLINE PreParserStatementList |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1460 } | 1460 } |
| 1461 return EmptyExpression(); | 1461 return EmptyExpression(); |
| 1462 } | 1462 } |
| 1463 inline void MaterializeTemplateCallsiteLiterals(); | 1463 inline void MaterializeTemplateCallsiteLiterals(); |
| 1464 PreParserExpression NoTemplateTag() { | 1464 PreParserExpression NoTemplateTag() { |
| 1465 return PreParserExpression::NoTemplateTag(); | 1465 return PreParserExpression::NoTemplateTag(); |
| 1466 } | 1466 } |
| 1467 static bool IsTaggedTemplate(const PreParserExpression tag) { | 1467 static bool IsTaggedTemplate(const PreParserExpression tag) { |
| 1468 return !tag.IsNoTemplateTag(); | 1468 return !tag.IsNoTemplateTag(); |
| 1469 } | 1469 } |
| 1470 static AstValueFactory* ast_value_factory() { return NULL; } | |
| 1471 | 1470 |
| 1472 void CheckConflictingVarDeclarations(PreParserScope scope, bool* ok) {} | 1471 void CheckConflictingVarDeclarations(PreParserScope scope, bool* ok) {} |
| 1473 | 1472 |
| 1474 // Temporary glue; these functions will move to ParserBase. | 1473 // Temporary glue; these functions will move to ParserBase. |
| 1475 PreParserExpression ParseV8Intrinsic(bool* ok); | 1474 PreParserExpression ParseV8Intrinsic(bool* ok); |
| 1476 PreParserExpression ParseFunctionLiteral( | 1475 PreParserExpression ParseFunctionLiteral( |
| 1477 PreParserIdentifier name, Scanner::Location function_name_location, | 1476 PreParserIdentifier name, Scanner::Location function_name_location, |
| 1478 bool name_is_strict_reserved, FunctionKind kind, | 1477 bool name_is_strict_reserved, FunctionKind kind, |
| 1479 int function_token_position, FunctionLiteral::FunctionType type, | 1478 int function_token_position, FunctionLiteral::FunctionType type, |
| 1480 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1479 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1505 public: | 1504 public: |
| 1506 typedef PreParserIdentifier Identifier; | 1505 typedef PreParserIdentifier Identifier; |
| 1507 typedef PreParserExpression Expression; | 1506 typedef PreParserExpression Expression; |
| 1508 typedef PreParserStatement Statement; | 1507 typedef PreParserStatement Statement; |
| 1509 | 1508 |
| 1510 enum PreParseResult { | 1509 enum PreParseResult { |
| 1511 kPreParseStackOverflow, | 1510 kPreParseStackOverflow, |
| 1512 kPreParseSuccess | 1511 kPreParseSuccess |
| 1513 }; | 1512 }; |
| 1514 | 1513 |
| 1515 PreParser(Isolate* isolate, Scanner* scanner, ParserRecorder* log, | 1514 PreParser(Isolate* isolate, Zone* zone, Scanner* scanner, |
| 1515 AstValueFactory* ast_value_factory, ParserRecorder* log, |
| 1516 uintptr_t stack_limit) | 1516 uintptr_t stack_limit) |
| 1517 : ParserBase<PreParserTraits>(isolate, NULL, scanner, stack_limit, NULL, | 1517 : ParserBase<PreParserTraits>(isolate, zone, scanner, stack_limit, NULL, |
| 1518 log, this) {} | 1518 ast_value_factory, log, this) {} |
| 1519 | 1519 |
| 1520 // Pre-parse the program from the character stream; returns true on | 1520 // Pre-parse the program from the character stream; returns true on |
| 1521 // success (even if parsing failed, the pre-parse data successfully | 1521 // success (even if parsing failed, the pre-parse data successfully |
| 1522 // captured the syntax error), and false if a stack-overflow happened | 1522 // captured the syntax error), and false if a stack-overflow happened |
| 1523 // during parsing. | 1523 // during parsing. |
| 1524 PreParseResult PreParseProgram(int* materialized_literals = 0) { | 1524 PreParseResult PreParseProgram(int* materialized_literals = 0) { |
| 1525 PreParserScope scope(scope_, SCRIPT_SCOPE); | 1525 PreParserScope scope(scope_, SCRIPT_SCOPE); |
| 1526 PreParserFactory factory(NULL); | 1526 PreParserFactory factory(NULL); |
| 1527 FunctionState top_scope(&function_state_, &scope_, &scope, &factory); | 1527 FunctionState top_scope(&function_state_, &scope_, &scope, &factory); |
| 1528 bool ok = true; | 1528 bool ok = true; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1730 AllowEvalOrArgumentsAsIdentifier allow_eval_or_arguments, | 1730 AllowEvalOrArgumentsAsIdentifier allow_eval_or_arguments, |
| 1731 bool* ok) { | 1731 bool* ok) { |
| 1732 Token::Value next = Next(); | 1732 Token::Value next = Next(); |
| 1733 if (next == Token::IDENTIFIER) { | 1733 if (next == Token::IDENTIFIER) { |
| 1734 IdentifierT name = this->GetSymbol(scanner()); | 1734 IdentifierT name = this->GetSymbol(scanner()); |
| 1735 if (allow_eval_or_arguments == kDontAllowEvalOrArguments && | 1735 if (allow_eval_or_arguments == kDontAllowEvalOrArguments && |
| 1736 is_strict(language_mode()) && this->IsEvalOrArguments(name)) { | 1736 is_strict(language_mode()) && this->IsEvalOrArguments(name)) { |
| 1737 ReportMessage("strict_eval_arguments"); | 1737 ReportMessage("strict_eval_arguments"); |
| 1738 *ok = false; | 1738 *ok = false; |
| 1739 } | 1739 } |
| 1740 if (name->IsArguments(this->ast_value_factory())) | 1740 if (name->IsArguments(ast_value_factory())) scope_->RecordArgumentsUsage(); |
| 1741 scope_->RecordArgumentsUsage(); | |
| 1742 return name; | 1741 return name; |
| 1743 } else if (is_sloppy(language_mode()) && | 1742 } else if (is_sloppy(language_mode()) && |
| 1744 (next == Token::FUTURE_STRICT_RESERVED_WORD || | 1743 (next == Token::FUTURE_STRICT_RESERVED_WORD || |
| 1745 next == Token::LET || next == Token::STATIC || | 1744 next == Token::LET || next == Token::STATIC || |
| 1746 (next == Token::YIELD && !is_generator()))) { | 1745 (next == Token::YIELD && !is_generator()))) { |
| 1747 return this->GetSymbol(scanner()); | 1746 return this->GetSymbol(scanner()); |
| 1748 } else { | 1747 } else { |
| 1749 this->ReportUnexpectedToken(next); | 1748 this->ReportUnexpectedToken(next); |
| 1750 *ok = false; | 1749 *ok = false; |
| 1751 return Traits::EmptyIdentifier(); | 1750 return Traits::EmptyIdentifier(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1764 next == Token::STATIC || | 1763 next == Token::STATIC || |
| 1765 (next == Token::YIELD && !this->is_generator())) { | 1764 (next == Token::YIELD && !this->is_generator())) { |
| 1766 *is_strict_reserved = true; | 1765 *is_strict_reserved = true; |
| 1767 } else { | 1766 } else { |
| 1768 ReportUnexpectedToken(next); | 1767 ReportUnexpectedToken(next); |
| 1769 *ok = false; | 1768 *ok = false; |
| 1770 return Traits::EmptyIdentifier(); | 1769 return Traits::EmptyIdentifier(); |
| 1771 } | 1770 } |
| 1772 | 1771 |
| 1773 IdentifierT name = this->GetSymbol(scanner()); | 1772 IdentifierT name = this->GetSymbol(scanner()); |
| 1774 if (name->IsArguments(this->ast_value_factory())) | 1773 if (name->IsArguments(ast_value_factory())) scope_->RecordArgumentsUsage(); |
| 1775 scope_->RecordArgumentsUsage(); | |
| 1776 return name; | 1774 return name; |
| 1777 } | 1775 } |
| 1778 | 1776 |
| 1779 | 1777 |
| 1780 template <class Traits> | 1778 template <class Traits> |
| 1781 typename ParserBase<Traits>::IdentifierT | 1779 typename ParserBase<Traits>::IdentifierT |
| 1782 ParserBase<Traits>::ParseIdentifierName(bool* ok) { | 1780 ParserBase<Traits>::ParseIdentifierName(bool* ok) { |
| 1783 Token::Value next = Next(); | 1781 Token::Value next = Next(); |
| 1784 if (next != Token::IDENTIFIER && next != Token::FUTURE_RESERVED_WORD && | 1782 if (next != Token::IDENTIFIER && next != Token::FUTURE_RESERVED_WORD && |
| 1785 next != Token::LET && next != Token::STATIC && next != Token::YIELD && | 1783 next != Token::LET && next != Token::STATIC && next != Token::YIELD && |
| 1786 next != Token::FUTURE_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) { | 1784 next != Token::FUTURE_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) { |
| 1787 this->ReportUnexpectedToken(next); | 1785 this->ReportUnexpectedToken(next); |
| 1788 *ok = false; | 1786 *ok = false; |
| 1789 return Traits::EmptyIdentifier(); | 1787 return Traits::EmptyIdentifier(); |
| 1790 } | 1788 } |
| 1791 | 1789 |
| 1792 IdentifierT name = this->GetSymbol(scanner()); | 1790 IdentifierT name = this->GetSymbol(scanner()); |
| 1793 if (name->IsArguments(this->ast_value_factory())) | 1791 if (name->IsArguments(ast_value_factory())) scope_->RecordArgumentsUsage(); |
| 1794 scope_->RecordArgumentsUsage(); | |
| 1795 return name; | 1792 return name; |
| 1796 } | 1793 } |
| 1797 | 1794 |
| 1798 | 1795 |
| 1799 template <class Traits> | 1796 template <class Traits> |
| 1800 typename ParserBase<Traits>::IdentifierT | 1797 typename ParserBase<Traits>::IdentifierT |
| 1801 ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get, | 1798 ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get, |
| 1802 bool* is_set, | 1799 bool* is_set, |
| 1803 bool* ok) { | 1800 bool* ok) { |
| 1804 IdentifierT result = ParseIdentifierName(ok); | 1801 IdentifierT result = ParseIdentifierName(ok); |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2807 ExpressionT params_ast, | 2804 ExpressionT params_ast, |
| 2808 bool* ok) { | 2805 bool* ok) { |
| 2809 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, ARROW_SCOPE); | 2806 typename Traits::Type::ScopePtr scope = this->NewScope(scope_, ARROW_SCOPE); |
| 2810 typename Traits::Type::StatementList body; | 2807 typename Traits::Type::StatementList body; |
| 2811 int num_parameters = -1; | 2808 int num_parameters = -1; |
| 2812 int materialized_literal_count = -1; | 2809 int materialized_literal_count = -1; |
| 2813 int expected_property_count = -1; | 2810 int expected_property_count = -1; |
| 2814 int handler_count = 0; | 2811 int handler_count = 0; |
| 2815 | 2812 |
| 2816 { | 2813 { |
| 2817 typename Traits::Type::Factory function_factory(this->ast_value_factory()); | 2814 typename Traits::Type::Factory function_factory(ast_value_factory()); |
| 2818 FunctionState function_state(&function_state_, &scope_, | 2815 FunctionState function_state(&function_state_, &scope_, |
| 2819 Traits::Type::ptr_to_scope(scope), | 2816 Traits::Type::ptr_to_scope(scope), |
| 2820 &function_factory); | 2817 &function_factory); |
| 2821 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); | 2818 Scanner::Location dupe_error_loc = Scanner::Location::invalid(); |
| 2822 num_parameters = Traits::DeclareArrowParametersFromExpression( | 2819 num_parameters = Traits::DeclareArrowParametersFromExpression( |
| 2823 params_ast, scope_, &dupe_error_loc, ok); | 2820 params_ast, scope_, &dupe_error_loc, ok); |
| 2824 if (!*ok) { | 2821 if (!*ok) { |
| 2825 ReportMessageAt( | 2822 ReportMessageAt( |
| 2826 Scanner::Location(start_pos, scanner()->location().beg_pos), | 2823 Scanner::Location(start_pos, scanner()->location().beg_pos), |
| 2827 "malformed_arrow_function_parameter_list"); | 2824 "malformed_arrow_function_parameter_list"); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2886 if (is_strict(language_mode())) { | 2883 if (is_strict(language_mode())) { |
| 2887 CheckStrictOctalLiteral(start_pos, scanner()->location().end_pos, | 2884 CheckStrictOctalLiteral(start_pos, scanner()->location().end_pos, |
| 2888 CHECK_OK); | 2885 CHECK_OK); |
| 2889 } | 2886 } |
| 2890 | 2887 |
| 2891 if (allow_harmony_scoping() && is_strict(language_mode())) | 2888 if (allow_harmony_scoping() && is_strict(language_mode())) |
| 2892 this->CheckConflictingVarDeclarations(scope, CHECK_OK); | 2889 this->CheckConflictingVarDeclarations(scope, CHECK_OK); |
| 2893 } | 2890 } |
| 2894 | 2891 |
| 2895 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( | 2892 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( |
| 2896 this->EmptyIdentifierString(), this->ast_value_factory(), scope, body, | 2893 this->EmptyIdentifierString(), ast_value_factory(), scope, body, |
| 2897 materialized_literal_count, expected_property_count, handler_count, | 2894 materialized_literal_count, expected_property_count, handler_count, |
| 2898 num_parameters, FunctionLiteral::kNoDuplicateParameters, | 2895 num_parameters, FunctionLiteral::kNoDuplicateParameters, |
| 2899 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, | 2896 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, |
| 2900 FunctionLiteral::kNotParenthesized, FunctionKind::kArrowFunction, | 2897 FunctionLiteral::kNotParenthesized, FunctionKind::kArrowFunction, |
| 2901 start_pos); | 2898 start_pos); |
| 2902 | 2899 |
| 2903 function_literal->set_function_token_position(start_pos); | 2900 function_literal->set_function_token_position(start_pos); |
| 2904 | 2901 |
| 2905 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); | 2902 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); |
| 2906 | 2903 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3076 *ok = false; | 3073 *ok = false; |
| 3077 return; | 3074 return; |
| 3078 } | 3075 } |
| 3079 has_seen_constructor_ = true; | 3076 has_seen_constructor_ = true; |
| 3080 return; | 3077 return; |
| 3081 } | 3078 } |
| 3082 } | 3079 } |
| 3083 } } // v8::internal | 3080 } } // v8::internal |
| 3084 | 3081 |
| 3085 #endif // V8_PREPARSER_H | 3082 #endif // V8_PREPARSER_H |
| OLD | NEW |