| 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" |
| 11 #include "src/func-name-inferrer.h" | 11 #include "src/func-name-inferrer.h" |
| 12 #include "src/hashmap.h" | 12 #include "src/hashmap.h" |
| 13 #include "src/scanner.h" | 13 #include "src/scanner.h" |
| 14 #include "src/scopes.h" | 14 #include "src/scopes.h" |
| 15 #include "src/token.h" | 15 #include "src/token.h" |
| 16 | 16 |
| 17 namespace v8 { | 17 namespace v8 { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 // Common base class shared between parser and pre-parser. Traits encapsulate | 20 // Common base class shared between parser and pre-parser. Traits encapsulate |
| 21 // the differences between Parser and PreParser: | 21 // the differences between Parser and PreParser: |
| 22 | 22 |
| 23 // - Return types: For example, Parser functions return Expression* and | 23 // - Return types: For example, Parser functions return Expression* and |
| 24 // PreParser functions return PreParserExpression. | 24 // PreParser functions return PreParserExpression. |
| 25 | 25 |
| 26 // - Creating parse tree nodes: Parser generates an AST during the recursive | 26 // - Creating parse tree nodes: Parser generates an AST during the recursive |
| 27 // descent. PreParser doesn't create a tree. Instead, it passes around minimal | 27 // descent. PreParser doesn't create a tree. Instead, it passes around minimal |
| 28 // data objects (PreParserExpression, PreParserIdentifier etc.) which contain | 28 // data objects (PreParserExpression etc.) which contain just enough data for |
| 29 // just enough data for the upper layer functions. PreParserFactory is | 29 // the upper layer functions. PreParserFactory is responsible for creating these |
| 30 // responsible for creating these dummy objects. It provides a similar kind of | 30 // dummy objects. It provides a similar kind of interface as AstNodeFactory, so |
| 31 // interface as AstNodeFactory, so ParserBase doesn't need to care which one is | 31 // ParserBase doesn't need to care which one is used. |
| 32 // used. | |
| 33 | 32 |
| 34 // - Miscellaneous other tasks interleaved with the recursive descent. For | 33 // - Miscellaneous other tasks interleaved with the recursive descent. For |
| 35 // example, Parser keeps track of which function literals should be marked as | 34 // example, Parser keeps track of which function literals should be marked as |
| 36 // pretenured, and PreParser doesn't care. | 35 // pretenured, and PreParser doesn't care. |
| 37 | 36 |
| 38 // The traits are expected to contain the following typedefs: | 37 // The traits are expected to contain the following typedefs: |
| 39 // struct Traits { | 38 // struct Traits { |
| 40 // // In particular... | 39 // // In particular... |
| 41 // struct Type { | 40 // struct Type { |
| 42 // // Used by FunctionState and BlockState. | 41 // // Used by FunctionState and BlockState. |
| 43 // typedef Scope; | 42 // typedef Scope; |
| 44 // typedef GeneratorVariable; | 43 // typedef GeneratorVariable; |
| 45 // // Return types for traversing functions. | 44 // // Return types for traversing functions. |
| 46 // typedef Identifier; | |
| 47 // typedef Expression; | 45 // typedef Expression; |
| 48 // typedef FunctionLiteral; | 46 // typedef FunctionLiteral; |
| 49 // typedef ClassLiteral; | 47 // typedef ClassLiteral; |
| 50 // typedef ObjectLiteralProperty; | 48 // typedef ObjectLiteralProperty; |
| 51 // typedef Literal; | 49 // typedef Literal; |
| 52 // typedef ExpressionList; | 50 // typedef ExpressionList; |
| 53 // typedef PropertyList; | 51 // typedef PropertyList; |
| 54 // // For constructing objects returned by the traversing functions. | 52 // // For constructing objects returned by the traversing functions. |
| 55 // typedef Factory; | 53 // typedef Factory; |
| 56 // }; | 54 // }; |
| 57 // // ... | 55 // // ... |
| 58 // }; | 56 // }; |
| 59 | 57 |
| 60 template <typename Traits> | 58 template <typename Traits> |
| 61 class ParserBase : public Traits { | 59 class ParserBase : public Traits { |
| 62 public: | 60 public: |
| 63 // Shorten type names defined by Traits. | 61 // Shorten type names defined by Traits. |
| 64 typedef typename Traits::Type::Expression ExpressionT; | 62 typedef typename Traits::Type::Expression ExpressionT; |
| 65 typedef typename Traits::Type::Identifier IdentifierT; | |
| 66 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; | 63 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; |
| 67 typedef typename Traits::Type::Literal LiteralT; | 64 typedef typename Traits::Type::Literal LiteralT; |
| 68 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; | 65 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; |
| 69 | 66 |
| 70 ParserBase(Isolate* isolate, Zone* zone, Scanner* scanner, | 67 ParserBase(Isolate* isolate, Zone* zone, Scanner* scanner, |
| 71 uintptr_t stack_limit, v8::Extension* extension, | 68 uintptr_t stack_limit, v8::Extension* extension, |
| 72 AstValueFactory* ast_value_factory, ParserRecorder* log, | 69 AstValueFactory* ast_value_factory, ParserRecorder* log, |
| 73 typename Traits::Type::Parser this_object) | 70 typename Traits::Type::Parser this_object) |
| 74 : Traits(this_object), | 71 : Traits(this_object), |
| 75 parenthesized_function_(false), | 72 parenthesized_function_(false), |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 } | 294 } |
| 298 ~ParsingModeScope() { | 295 ~ParsingModeScope() { |
| 299 parser_->mode_ = old_mode_; | 296 parser_->mode_ = old_mode_; |
| 300 } | 297 } |
| 301 | 298 |
| 302 private: | 299 private: |
| 303 ParserBase* parser_; | 300 ParserBase* parser_; |
| 304 Mode old_mode_; | 301 Mode old_mode_; |
| 305 }; | 302 }; |
| 306 | 303 |
| 304 bool IsEvalOrArguments(const AstRawString* identifier) const { |
| 305 return identifier == ast_value_factory_->eval_string() || |
| 306 identifier == ast_value_factory_->arguments_string(); |
| 307 } |
| 308 |
| 309 const AstRawString* GetSymbol(Scanner* scanner) { |
| 310 const AstRawString* result = scanner->CurrentSymbol(ast_value_factory_); |
| 311 DCHECK(result != NULL); |
| 312 return result; |
| 313 } |
| 314 |
| 315 const AstRawString* GetNumberAsSymbol(Scanner* scanner) { |
| 316 double double_value = scanner->DoubleValue(); |
| 317 char array[100]; |
| 318 const char* string = |
| 319 DoubleToCString(double_value, Vector<char>(array, arraysize(array))); |
| 320 return ast_value_factory_->GetOneByteString(string); |
| 321 } |
| 322 |
| 323 const AstRawString* GetNextSymbol(Scanner* scanner) { |
| 324 const AstRawString* result = scanner->NextSymbol(ast_value_factory_); |
| 325 DCHECK(result != NULL); |
| 326 return result; |
| 327 } |
| 328 |
| 307 Scope* NewScope(Scope* parent, ScopeType scope_type, | 329 Scope* NewScope(Scope* parent, ScopeType scope_type, |
| 308 FunctionKind kind = kNormalFunction) { | 330 FunctionKind kind = kNormalFunction) { |
| 309 DCHECK(ast_value_factory()); | 331 DCHECK(ast_value_factory()); |
| 310 DCHECK(scope_type != MODULE_SCOPE || allow_harmony_modules()); | 332 DCHECK(scope_type != MODULE_SCOPE || allow_harmony_modules()); |
| 311 DCHECK((scope_type == FUNCTION_SCOPE && IsValidFunctionKind(kind)) || | 333 DCHECK((scope_type == FUNCTION_SCOPE && IsValidFunctionKind(kind)) || |
| 312 kind == kNormalFunction); | 334 kind == kNormalFunction); |
| 313 Scope* result = | 335 Scope* result = |
| 314 new (zone()) Scope(zone(), parent, scope_type, ast_value_factory()); | 336 new (zone()) Scope(zone(), parent, scope_type, ast_value_factory()); |
| 315 bool uninitialized_this = | 337 bool uninitialized_this = |
| 316 FLAG_experimental_classes && IsSubclassConstructor(kind); | 338 FLAG_experimental_classes && IsSubclassConstructor(kind); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 CheckOctalLiteral(beg_pos, end_pos, "strict_octal_literal", ok); | 454 CheckOctalLiteral(beg_pos, end_pos, "strict_octal_literal", ok); |
| 433 } | 455 } |
| 434 | 456 |
| 435 inline void CheckTemplateOctalLiteral(int beg_pos, int end_pos, bool* ok) { | 457 inline void CheckTemplateOctalLiteral(int beg_pos, int end_pos, bool* ok) { |
| 436 CheckOctalLiteral(beg_pos, end_pos, "template_octal_literal", ok); | 458 CheckOctalLiteral(beg_pos, end_pos, "template_octal_literal", ok); |
| 437 } | 459 } |
| 438 | 460 |
| 439 // Checking the name of a function literal. This has to be done after parsing | 461 // Checking the name of a function literal. This has to be done after parsing |
| 440 // the function, since the function can declare itself strict. | 462 // the function, since the function can declare itself strict. |
| 441 void CheckFunctionName(LanguageMode language_mode, FunctionKind kind, | 463 void CheckFunctionName(LanguageMode language_mode, FunctionKind kind, |
| 442 IdentifierT function_name, | 464 const AstRawString* function_name, |
| 443 bool function_name_is_strict_reserved, | 465 bool function_name_is_strict_reserved, |
| 444 const Scanner::Location& function_name_loc, | 466 const Scanner::Location& function_name_loc, bool* ok) { |
| 445 bool* ok) { | |
| 446 // Property names are never checked. | 467 // Property names are never checked. |
| 447 if (IsConciseMethod(kind) || IsAccessorFunction(kind)) return; | 468 if (IsConciseMethod(kind) || IsAccessorFunction(kind)) return; |
| 448 // The function name needs to be checked in strict mode. | 469 // The function name needs to be checked in strict mode. |
| 449 if (is_sloppy(language_mode)) return; | 470 if (is_sloppy(language_mode)) return; |
| 450 | 471 |
| 451 if (this->IsEvalOrArguments(function_name)) { | 472 if (this->IsEvalOrArguments(function_name)) { |
| 452 Traits::ReportMessageAt(function_name_loc, "strict_eval_arguments"); | 473 Traits::ReportMessageAt(function_name_loc, "strict_eval_arguments"); |
| 453 *ok = false; | 474 *ok = false; |
| 454 return; | 475 return; |
| 455 } | 476 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 | 540 |
| 520 void ReportUnexpectedToken(Token::Value token); | 541 void ReportUnexpectedToken(Token::Value token); |
| 521 | 542 |
| 522 // Recursive descent functions: | 543 // Recursive descent functions: |
| 523 | 544 |
| 524 // Parses an identifier that is valid for the current scope, in particular it | 545 // Parses an identifier that is valid for the current scope, in particular it |
| 525 // fails on strict mode future reserved keywords in a strict scope. If | 546 // fails on strict mode future reserved keywords in a strict scope. If |
| 526 // allow_eval_or_arguments is kAllowEvalOrArguments, we allow "eval" or | 547 // allow_eval_or_arguments is kAllowEvalOrArguments, we allow "eval" or |
| 527 // "arguments" as identifier even in strict mode (this is needed in cases like | 548 // "arguments" as identifier even in strict mode (this is needed in cases like |
| 528 // "var foo = eval;"). | 549 // "var foo = eval;"). |
| 529 IdentifierT ParseIdentifier( | 550 const AstRawString* ParseIdentifier(AllowEvalOrArgumentsAsIdentifier, |
| 530 AllowEvalOrArgumentsAsIdentifier, | 551 bool* ok); |
| 531 bool* ok); | |
| 532 // Parses an identifier or a strict mode future reserved word, and indicate | 552 // Parses an identifier or a strict mode future reserved word, and indicate |
| 533 // whether it is strict mode future reserved. | 553 // whether it is strict mode future reserved. |
| 534 IdentifierT ParseIdentifierOrStrictReservedWord( | 554 const AstRawString* ParseIdentifierOrStrictReservedWord( |
| 535 bool* is_strict_reserved, | 555 bool* is_strict_reserved, bool* ok); |
| 536 bool* ok); | 556 const AstRawString* ParseIdentifierName(bool* ok); |
| 537 IdentifierT ParseIdentifierName(bool* ok); | |
| 538 // Parses an identifier and determines whether or not it is 'get' or 'set'. | 557 // Parses an identifier and determines whether or not it is 'get' or 'set'. |
| 539 IdentifierT ParseIdentifierNameOrGetOrSet(bool* is_get, | 558 const AstRawString* ParseIdentifierNameOrGetOrSet(bool* is_get, bool* is_set, |
| 540 bool* is_set, | 559 bool* ok); |
| 541 bool* ok); | |
| 542 | 560 |
| 543 ExpressionT ParseRegExpLiteral(bool seen_equal, bool* ok); | 561 ExpressionT ParseRegExpLiteral(bool seen_equal, bool* ok); |
| 544 | 562 |
| 545 ExpressionT ParsePrimaryExpression(bool* ok); | 563 ExpressionT ParsePrimaryExpression(bool* ok); |
| 546 ExpressionT ParseExpression(bool accept_IN, bool* ok); | 564 ExpressionT ParseExpression(bool accept_IN, bool* ok); |
| 547 ExpressionT ParseArrayLiteral(bool* ok); | 565 ExpressionT ParseArrayLiteral(bool* ok); |
| 548 ExpressionT ParsePropertyName(IdentifierT* name, bool* is_get, bool* is_set, | 566 ExpressionT ParsePropertyName(const AstRawString** name, bool* is_get, |
| 549 bool* is_static, bool* is_computed_name, | 567 bool* is_set, bool* is_static, |
| 550 bool* ok); | 568 bool* is_computed_name, bool* ok); |
| 551 ExpressionT ParseObjectLiteral(bool* ok); | 569 ExpressionT ParseObjectLiteral(bool* ok); |
| 552 ObjectLiteralPropertyT ParsePropertyDefinition( | 570 ObjectLiteralPropertyT ParsePropertyDefinition( |
| 553 ObjectLiteralCheckerBase* checker, bool in_class, bool has_extends, | 571 ObjectLiteralCheckerBase* checker, bool in_class, bool has_extends, |
| 554 bool is_static, bool* is_computed_name, bool* has_seen_constructor, | 572 bool is_static, bool* is_computed_name, bool* has_seen_constructor, |
| 555 bool* ok); | 573 bool* ok); |
| 556 typename Traits::Type::ExpressionList ParseArguments(bool* ok); | 574 typename Traits::Type::ExpressionList ParseArguments(bool* ok); |
| 557 ExpressionT ParseAssignmentExpression(bool accept_IN, bool* ok); | 575 ExpressionT ParseAssignmentExpression(bool accept_IN, bool* ok); |
| 558 ExpressionT ParseYieldExpression(bool* ok); | 576 ExpressionT ParseYieldExpression(bool* ok); |
| 559 ExpressionT ParseConditionalExpression(bool accept_IN, bool* ok); | 577 ExpressionT ParseConditionalExpression(bool accept_IN, bool* ok); |
| 560 ExpressionT ParseBinaryExpression(int prec, bool accept_IN, bool* ok); | 578 ExpressionT ParseBinaryExpression(int prec, bool accept_IN, bool* ok); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 bool allow_natives_; | 681 bool allow_natives_; |
| 664 bool allow_harmony_arrow_functions_; | 682 bool allow_harmony_arrow_functions_; |
| 665 bool allow_harmony_object_literals_; | 683 bool allow_harmony_object_literals_; |
| 666 bool allow_harmony_sloppy_; | 684 bool allow_harmony_sloppy_; |
| 667 bool allow_harmony_computed_property_names_; | 685 bool allow_harmony_computed_property_names_; |
| 668 bool allow_harmony_rest_params_; | 686 bool allow_harmony_rest_params_; |
| 669 bool allow_strong_mode_; | 687 bool allow_strong_mode_; |
| 670 }; | 688 }; |
| 671 | 689 |
| 672 | 690 |
| 673 class PreParserIdentifier { | |
| 674 public: | |
| 675 PreParserIdentifier() : type_(kUnknownIdentifier) {} | |
| 676 static PreParserIdentifier Default() { | |
| 677 return PreParserIdentifier(kUnknownIdentifier); | |
| 678 } | |
| 679 static PreParserIdentifier Eval() { | |
| 680 return PreParserIdentifier(kEvalIdentifier); | |
| 681 } | |
| 682 static PreParserIdentifier Arguments() { | |
| 683 return PreParserIdentifier(kArgumentsIdentifier); | |
| 684 } | |
| 685 static PreParserIdentifier FutureReserved() { | |
| 686 return PreParserIdentifier(kFutureReservedIdentifier); | |
| 687 } | |
| 688 static PreParserIdentifier FutureStrictReserved() { | |
| 689 return PreParserIdentifier(kFutureStrictReservedIdentifier); | |
| 690 } | |
| 691 static PreParserIdentifier Let() { | |
| 692 return PreParserIdentifier(kLetIdentifier); | |
| 693 } | |
| 694 static PreParserIdentifier Static() { | |
| 695 return PreParserIdentifier(kStaticIdentifier); | |
| 696 } | |
| 697 static PreParserIdentifier Yield() { | |
| 698 return PreParserIdentifier(kYieldIdentifier); | |
| 699 } | |
| 700 static PreParserIdentifier Prototype() { | |
| 701 return PreParserIdentifier(kPrototypeIdentifier); | |
| 702 } | |
| 703 static PreParserIdentifier Constructor() { | |
| 704 return PreParserIdentifier(kConstructorIdentifier); | |
| 705 } | |
| 706 bool IsEval() const { return type_ == kEvalIdentifier; } | |
| 707 bool IsArguments(const AstValueFactory* = NULL) const { | |
| 708 return type_ == kArgumentsIdentifier; | |
| 709 } | |
| 710 bool IsLet() const { return type_ == kLetIdentifier; } | |
| 711 bool IsStatic() const { return type_ == kStaticIdentifier; } | |
| 712 bool IsYield() const { return type_ == kYieldIdentifier; } | |
| 713 bool IsPrototype() const { return type_ == kPrototypeIdentifier; } | |
| 714 bool IsConstructor() const { return type_ == kConstructorIdentifier; } | |
| 715 bool IsEvalOrArguments() const { | |
| 716 return type_ == kEvalIdentifier || type_ == kArgumentsIdentifier; | |
| 717 } | |
| 718 bool IsFutureReserved() const { return type_ == kFutureReservedIdentifier; } | |
| 719 bool IsFutureStrictReserved() const { | |
| 720 return type_ == kFutureStrictReservedIdentifier || | |
| 721 type_ == kLetIdentifier || type_ == kStaticIdentifier || | |
| 722 type_ == kYieldIdentifier; | |
| 723 } | |
| 724 bool IsValidStrictVariable() const { return type_ == kUnknownIdentifier; } | |
| 725 V8_INLINE bool IsValidArrowParam() const { | |
| 726 // A valid identifier can be an arrow function parameter | |
| 727 // except for eval, arguments, yield, and reserved keywords. | |
| 728 return !(IsEval() || IsArguments() || IsFutureStrictReserved()); | |
| 729 } | |
| 730 | |
| 731 // Allow identifier->name()[->length()] to work. The preparser | |
| 732 // does not need the actual positions/lengths of the identifiers. | |
| 733 const PreParserIdentifier* operator->() const { return this; } | |
| 734 const PreParserIdentifier raw_name() const { return *this; } | |
| 735 | |
| 736 int position() const { return 0; } | |
| 737 int length() const { return 0; } | |
| 738 | |
| 739 private: | |
| 740 enum Type { | |
| 741 kUnknownIdentifier, | |
| 742 kFutureReservedIdentifier, | |
| 743 kFutureStrictReservedIdentifier, | |
| 744 kLetIdentifier, | |
| 745 kStaticIdentifier, | |
| 746 kYieldIdentifier, | |
| 747 kEvalIdentifier, | |
| 748 kArgumentsIdentifier, | |
| 749 kPrototypeIdentifier, | |
| 750 kConstructorIdentifier | |
| 751 }; | |
| 752 explicit PreParserIdentifier(Type type) : type_(type) {} | |
| 753 Type type_; | |
| 754 | |
| 755 friend class PreParserExpression; | |
| 756 }; | |
| 757 | |
| 758 | |
| 759 class PreParserExpression { | 691 class PreParserExpression { |
| 760 public: | 692 public: |
| 761 static PreParserExpression Default() { | 693 static PreParserExpression Default() { |
| 762 return PreParserExpression(TypeField::encode(kExpression)); | 694 return PreParserExpression(TypeField::encode(kExpression)); |
| 763 } | 695 } |
| 764 | 696 |
| 765 static PreParserExpression FromIdentifier(PreParserIdentifier id) { | 697 static PreParserExpression FromIdentifier( |
| 766 return PreParserExpression(TypeField::encode(kIdentifierExpression) | | 698 const AstRawString* id, bool is_valid_arrow_function_param) { |
| 767 IdentifierTypeField::encode(id.type_)); | 699 return PreParserExpression( |
| 700 TypeField::encode(kIdentifierExpression) | |
| 701 IsValidArrowParamListField::encode(is_valid_arrow_function_param), |
| 702 id); |
| 768 } | 703 } |
| 769 | 704 |
| 770 static PreParserExpression BinaryOperation(PreParserExpression left, | 705 static PreParserExpression BinaryOperation(PreParserExpression left, |
| 771 Token::Value op, | 706 Token::Value op, |
| 772 PreParserExpression right) { | 707 PreParserExpression right) { |
| 773 bool valid_arrow_param_list = | 708 bool valid_arrow_param_list = |
| 774 op == Token::COMMA && !left.is_parenthesized() && | 709 op == Token::COMMA && !left.is_parenthesized() && |
| 775 !right.is_parenthesized() && left.IsValidArrowParams() && | 710 !right.is_parenthesized() && left.IsValidArrowParams() && |
| 776 right.IsValidArrowParams(); | 711 right.IsValidArrowParams(); |
| 777 return PreParserExpression( | 712 return PreParserExpression( |
| 778 TypeField::encode(kBinaryOperationExpression) | | 713 TypeField::encode(kBinaryOperationExpression) | |
| 779 IsValidArrowParamListField::encode(valid_arrow_param_list)); | 714 IsValidArrowParamListField::encode(valid_arrow_param_list)); |
| 780 } | 715 } |
| 781 | 716 |
| 782 static PreParserExpression EmptyArrowParamList() { | 717 static PreParserExpression EmptyArrowParamList() { |
| 783 // Any expression for which IsValidArrowParamList() returns true | 718 // Any expression for which IsValidArrowParamList() returns true |
| 784 // will work here. | 719 // will work here. |
| 785 return FromIdentifier(PreParserIdentifier::Default()); | 720 return PreParserExpression(TypeField::encode(kBinaryOperationExpression) | |
| 721 IsValidArrowParamListField::encode(true)); |
| 786 } | 722 } |
| 787 | 723 |
| 788 static PreParserExpression StringLiteral() { | 724 static PreParserExpression StringLiteral() { |
| 789 return PreParserExpression(TypeField::encode(kStringLiteralExpression)); | 725 return PreParserExpression(TypeField::encode(kStringLiteralExpression)); |
| 790 } | 726 } |
| 791 | 727 |
| 792 static PreParserExpression UseStrictStringLiteral() { | 728 static PreParserExpression UseStrictStringLiteral() { |
| 793 return PreParserExpression(TypeField::encode(kStringLiteralExpression) | | 729 return PreParserExpression(TypeField::encode(kStringLiteralExpression) | |
| 794 IsUseStrictField::encode(true)); | 730 IsUseStrictField::encode(true)); |
| 795 } | 731 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 static PreParserExpression NoTemplateTag() { | 765 static PreParserExpression NoTemplateTag() { |
| 830 return PreParserExpression(TypeField::encode(kExpression) | | 766 return PreParserExpression(TypeField::encode(kExpression) | |
| 831 ExpressionTypeField::encode( | 767 ExpressionTypeField::encode( |
| 832 kNoTemplateTagExpression)); | 768 kNoTemplateTagExpression)); |
| 833 } | 769 } |
| 834 | 770 |
| 835 bool IsIdentifier() const { | 771 bool IsIdentifier() const { |
| 836 return TypeField::decode(code_) == kIdentifierExpression; | 772 return TypeField::decode(code_) == kIdentifierExpression; |
| 837 } | 773 } |
| 838 | 774 |
| 839 PreParserIdentifier AsIdentifier() const { | 775 const AstRawString* AsIdentifier() const { |
| 840 DCHECK(IsIdentifier()); | 776 DCHECK(IsIdentifier()); |
| 841 return PreParserIdentifier(IdentifierTypeField::decode(code_)); | 777 DCHECK(identifier_); |
| 778 return identifier_; |
| 842 } | 779 } |
| 843 | 780 |
| 844 bool IsStringLiteral() const { | 781 bool IsStringLiteral() const { |
| 845 return TypeField::decode(code_) == kStringLiteralExpression; | 782 return TypeField::decode(code_) == kStringLiteralExpression; |
| 846 } | 783 } |
| 847 | 784 |
| 848 bool IsUseStrictLiteral() const { | 785 bool IsUseStrictLiteral() const { |
| 849 return TypeField::decode(code_) == kStringLiteralExpression && | 786 return TypeField::decode(code_) == kStringLiteralExpression && |
| 850 IsUseStrictField::decode(code_); | 787 IsUseStrictField::decode(code_); |
| 851 } | 788 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 | 875 |
| 939 enum ExpressionType { | 876 enum ExpressionType { |
| 940 kThisExpression, | 877 kThisExpression, |
| 941 kThisPropertyExpression, | 878 kThisPropertyExpression, |
| 942 kPropertyExpression, | 879 kPropertyExpression, |
| 943 kCallExpression, | 880 kCallExpression, |
| 944 kSuperExpression, | 881 kSuperExpression, |
| 945 kNoTemplateTagExpression | 882 kNoTemplateTagExpression |
| 946 }; | 883 }; |
| 947 | 884 |
| 948 explicit PreParserExpression(uint32_t expression_code) | 885 explicit PreParserExpression(uint32_t expression_code, |
| 949 : code_(expression_code) {} | 886 const AstRawString* identifier = NULL) |
| 887 : code_(expression_code), identifier_(identifier) {} |
| 950 | 888 |
| 951 V8_INLINE bool IsValidArrowParams() const { | 889 V8_INLINE bool IsValidArrowParams() const { |
| 952 return IsBinaryOperation() | 890 return IsValidArrowParamListField::decode(code_); |
| 953 ? IsValidArrowParamListField::decode(code_) | |
| 954 : (IsIdentifier() && AsIdentifier().IsValidArrowParam()); | |
| 955 } | 891 } |
| 956 | 892 |
| 957 // The first four bits are for the Type and Parenthesization. | 893 // The first four bits are for the Type and Parenthesization. |
| 958 typedef BitField<Type, 0, 2> TypeField; | 894 typedef BitField<Type, 0, 2> TypeField; |
| 959 typedef BitField<Parenthesization, TypeField::kNext, 2> ParenthesizationField; | 895 typedef BitField<Parenthesization, TypeField::kNext, 2> ParenthesizationField; |
| 960 | 896 |
| 961 // The rest of the bits are interpreted depending on the value | 897 // The rest of the bits are interpreted depending on the value |
| 962 // of the Type field, so they can share the storage. | 898 // of the Type field, so they can share the storage. |
| 963 typedef BitField<ExpressionType, ParenthesizationField::kNext, 3> | 899 typedef BitField<ExpressionType, ParenthesizationField::kNext, 3> |
| 964 ExpressionTypeField; | 900 ExpressionTypeField; |
| 965 typedef BitField<bool, ParenthesizationField::kNext, 1> IsUseStrictField; | 901 typedef BitField<bool, ParenthesizationField::kNext, 1> IsUseStrictField; |
| 966 typedef BitField<bool, IsUseStrictField::kNext, 1> IsUseStrongField; | 902 typedef BitField<bool, IsUseStrictField::kNext, 1> IsUseStrongField; |
| 967 typedef BitField<bool, ParenthesizationField::kNext, 1> | 903 typedef BitField<bool, ParenthesizationField::kNext, 1> |
| 968 IsValidArrowParamListField; | 904 IsValidArrowParamListField; |
| 969 typedef BitField<PreParserIdentifier::Type, ParenthesizationField::kNext, 10> | |
| 970 IdentifierTypeField; | |
| 971 | 905 |
| 972 uint32_t code_; | 906 uint32_t code_; |
| 907 |
| 908 // If an expression is an identifier, this stores it. FIXME(marja): To do |
| 909 // declare variables in scopes properly, PreParserExpression needs to keep |
| 910 // track of multiple identifiers if it's an arrow function parameter list. |
| 911 const AstRawString* identifier_; |
| 973 }; | 912 }; |
| 974 | 913 |
| 975 | 914 |
| 976 // PreParserExpressionList doesn't actually store the expressions because | 915 // PreParserExpressionList doesn't actually store the expressions because |
| 977 // PreParser doesn't need to. | 916 // PreParser doesn't need to. |
| 978 class PreParserExpressionList { | 917 class PreParserExpressionList { |
| 979 public: | 918 public: |
| 980 // These functions make list->Add(some_expression) work (and do nothing). | 919 // These functions make list->Add(some_expression) work (and do nothing). |
| 981 PreParserExpressionList() : length_(0) {} | 920 PreParserExpressionList() : length_(0) {} |
| 982 PreParserExpressionList* operator->() { return this; } | 921 PreParserExpressionList* operator->() { return this; } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 // These functions make list->Add(some_expression) work as no-ops. | 989 // These functions make list->Add(some_expression) work as no-ops. |
| 1051 PreParserStatementList() {} | 990 PreParserStatementList() {} |
| 1052 PreParserStatementList* operator->() { return this; } | 991 PreParserStatementList* operator->() { return this; } |
| 1053 void Add(PreParserStatement, void*) {} | 992 void Add(PreParserStatement, void*) {} |
| 1054 }; | 993 }; |
| 1055 | 994 |
| 1056 | 995 |
| 1057 class PreParserFactory { | 996 class PreParserFactory { |
| 1058 public: | 997 public: |
| 1059 explicit PreParserFactory(void* unused_value_factory) {} | 998 explicit PreParserFactory(void* unused_value_factory) {} |
| 1060 PreParserExpression NewStringLiteral(PreParserIdentifier identifier, | 999 PreParserExpression NewStringLiteral(const AstRawString* identifier, |
| 1061 int pos) { | 1000 int pos) { |
| 1062 return PreParserExpression::Default(); | 1001 return PreParserExpression::Default(); |
| 1063 } | 1002 } |
| 1064 PreParserExpression NewNumberLiteral(double number, | 1003 PreParserExpression NewNumberLiteral(double number, |
| 1065 int pos) { | 1004 int pos) { |
| 1066 return PreParserExpression::Default(); | 1005 return PreParserExpression::Default(); |
| 1067 } | 1006 } |
| 1068 PreParserExpression NewRegExpLiteral(PreParserIdentifier js_pattern, | 1007 PreParserExpression NewRegExpLiteral(const AstRawString* js_pattern, |
| 1069 PreParserIdentifier js_flags, | 1008 const AstRawString* js_flags, |
| 1070 int literal_index, | 1009 int literal_index, int pos) { |
| 1071 int pos) { | |
| 1072 return PreParserExpression::Default(); | 1010 return PreParserExpression::Default(); |
| 1073 } | 1011 } |
| 1074 PreParserExpression NewArrayLiteral(PreParserExpressionList values, | 1012 PreParserExpression NewArrayLiteral(PreParserExpressionList values, |
| 1075 int literal_index, | 1013 int literal_index, |
| 1076 int pos) { | 1014 int pos) { |
| 1077 return PreParserExpression::Default(); | 1015 return PreParserExpression::Default(); |
| 1078 } | 1016 } |
| 1079 PreParserExpression NewObjectLiteralProperty(PreParserExpression key, | 1017 PreParserExpression NewObjectLiteralProperty(PreParserExpression key, |
| 1080 PreParserExpression value, | 1018 PreParserExpression value, |
| 1081 ObjectLiteralProperty::Kind kind, | 1019 ObjectLiteralProperty::Kind kind, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 PreParserExpression NewCallNew(PreParserExpression expression, | 1092 PreParserExpression NewCallNew(PreParserExpression expression, |
| 1155 PreParserExpressionList arguments, | 1093 PreParserExpressionList arguments, |
| 1156 int pos) { | 1094 int pos) { |
| 1157 return PreParserExpression::Default(); | 1095 return PreParserExpression::Default(); |
| 1158 } | 1096 } |
| 1159 PreParserStatement NewReturnStatement(PreParserExpression expression, | 1097 PreParserStatement NewReturnStatement(PreParserExpression expression, |
| 1160 int pos) { | 1098 int pos) { |
| 1161 return PreParserStatement::Default(); | 1099 return PreParserStatement::Default(); |
| 1162 } | 1100 } |
| 1163 PreParserExpression NewFunctionLiteral( | 1101 PreParserExpression NewFunctionLiteral( |
| 1164 PreParserIdentifier name, AstValueFactory* ast_value_factory, | 1102 const AstRawString* name, AstValueFactory* ast_value_factory, |
| 1165 Scope* scope, PreParserStatementList body, int materialized_literal_count, | 1103 Scope* scope, PreParserStatementList body, int materialized_literal_count, |
| 1166 int expected_property_count, int handler_count, int parameter_count, | 1104 int expected_property_count, int handler_count, int parameter_count, |
| 1167 FunctionLiteral::ParameterFlag has_duplicate_parameters, | 1105 FunctionLiteral::ParameterFlag has_duplicate_parameters, |
| 1168 FunctionLiteral::FunctionType function_type, | 1106 FunctionLiteral::FunctionType function_type, |
| 1169 FunctionLiteral::IsFunctionFlag is_function, | 1107 FunctionLiteral::IsFunctionFlag is_function, |
| 1170 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, | 1108 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, |
| 1171 int position) { | 1109 int position) { |
| 1172 return PreParserExpression::Default(); | 1110 return PreParserExpression::Default(); |
| 1173 } | 1111 } |
| 1174 | 1112 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1188 public: | 1126 public: |
| 1189 struct Type { | 1127 struct Type { |
| 1190 // TODO(marja): To be removed. The Traits object should contain all the data | 1128 // TODO(marja): To be removed. The Traits object should contain all the data |
| 1191 // it needs. | 1129 // it needs. |
| 1192 typedef PreParser* Parser; | 1130 typedef PreParser* Parser; |
| 1193 | 1131 |
| 1194 // PreParser doesn't need to store generator variables. | 1132 // PreParser doesn't need to store generator variables. |
| 1195 typedef void GeneratorVariable; | 1133 typedef void GeneratorVariable; |
| 1196 | 1134 |
| 1197 typedef int AstProperties; | 1135 typedef int AstProperties; |
| 1198 typedef Vector<PreParserIdentifier> ParameterIdentifierVector; | |
| 1199 | 1136 |
| 1200 // Return types for traversing functions. | 1137 // Return types for traversing functions. |
| 1201 typedef PreParserIdentifier Identifier; | |
| 1202 typedef PreParserExpression Expression; | 1138 typedef PreParserExpression Expression; |
| 1203 typedef PreParserExpression YieldExpression; | 1139 typedef PreParserExpression YieldExpression; |
| 1204 typedef PreParserExpression FunctionLiteral; | 1140 typedef PreParserExpression FunctionLiteral; |
| 1205 typedef PreParserExpression ClassLiteral; | 1141 typedef PreParserExpression ClassLiteral; |
| 1206 typedef PreParserExpression ObjectLiteralProperty; | 1142 typedef PreParserExpression ObjectLiteralProperty; |
| 1207 typedef PreParserExpression Literal; | 1143 typedef PreParserExpression Literal; |
| 1208 typedef PreParserExpressionList ExpressionList; | 1144 typedef PreParserExpressionList ExpressionList; |
| 1209 typedef PreParserExpressionList PropertyList; | 1145 typedef PreParserExpressionList PropertyList; |
| 1210 typedef PreParserStatementList StatementList; | 1146 typedef PreParserStatementList StatementList; |
| 1211 | 1147 |
| 1212 // For constructing objects returned by the traversing functions. | 1148 // For constructing objects returned by the traversing functions. |
| 1213 typedef PreParserFactory Factory; | 1149 typedef PreParserFactory Factory; |
| 1214 }; | 1150 }; |
| 1215 | 1151 |
| 1216 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {} | 1152 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {} |
| 1217 | 1153 |
| 1218 // Helper functions for recursive descent. | |
| 1219 static bool IsEvalOrArguments(PreParserIdentifier identifier) { | |
| 1220 return identifier.IsEvalOrArguments(); | |
| 1221 } | |
| 1222 | |
| 1223 static bool IsPrototype(PreParserIdentifier identifier) { | |
| 1224 return identifier.IsPrototype(); | |
| 1225 } | |
| 1226 | |
| 1227 static bool IsConstructor(PreParserIdentifier identifier) { | |
| 1228 return identifier.IsConstructor(); | |
| 1229 } | |
| 1230 | |
| 1231 // Returns true if the expression is of type "this.foo". | 1154 // Returns true if the expression is of type "this.foo". |
| 1232 static bool IsThisProperty(PreParserExpression expression) { | 1155 static bool IsThisProperty(PreParserExpression expression) { |
| 1233 return expression.IsThisProperty(); | 1156 return expression.IsThisProperty(); |
| 1234 } | 1157 } |
| 1235 | 1158 |
| 1236 static bool IsIdentifier(PreParserExpression expression) { | 1159 static bool IsIdentifier(PreParserExpression expression) { |
| 1237 return expression.IsIdentifier(); | 1160 return expression.IsIdentifier(); |
| 1238 } | 1161 } |
| 1239 | 1162 |
| 1240 static PreParserIdentifier AsIdentifier(PreParserExpression expression) { | 1163 static const AstRawString* AsIdentifier(PreParserExpression expression) { |
| 1241 return expression.AsIdentifier(); | 1164 return expression.AsIdentifier(); |
| 1242 } | 1165 } |
| 1243 | 1166 |
| 1244 static bool IsFutureStrictReserved(PreParserIdentifier identifier) { | |
| 1245 return identifier.IsFutureStrictReserved(); | |
| 1246 } | |
| 1247 | |
| 1248 static bool IsBoilerplateProperty(PreParserExpression property) { | 1167 static bool IsBoilerplateProperty(PreParserExpression property) { |
| 1249 // PreParser doesn't count boilerplate properties. | 1168 // PreParser doesn't count boilerplate properties. |
| 1250 return false; | 1169 return false; |
| 1251 } | 1170 } |
| 1252 | 1171 |
| 1253 static bool IsArrayIndex(PreParserIdentifier string, uint32_t* index) { | |
| 1254 return false; | |
| 1255 } | |
| 1256 | |
| 1257 static PreParserExpression GetPropertyValue(PreParserExpression property) { | 1172 static PreParserExpression GetPropertyValue(PreParserExpression property) { |
| 1258 return PreParserExpression::Default(); | 1173 return PreParserExpression::Default(); |
| 1259 } | 1174 } |
| 1260 | 1175 |
| 1261 // Functions for encapsulating the differences between parsing and preparsing; | 1176 // Functions for encapsulating the differences between parsing and preparsing; |
| 1262 // operations interleaved with the recursive descent. | 1177 // operations interleaved with the recursive descent. |
| 1263 static void PushLiteralName(FuncNameInferrer* fni, PreParserIdentifier id) { | 1178 static void PushLiteralName(FuncNameInferrer* fni, const AstRawString* id) { |
| 1264 // PreParser should not use FuncNameInferrer. | 1179 // PreParser should not use FuncNameInferrer. |
| 1265 UNREACHABLE(); | 1180 UNREACHABLE(); |
| 1266 } | 1181 } |
| 1267 | 1182 |
| 1268 static void PushPropertyName(FuncNameInferrer* fni, | 1183 static void PushPropertyName(FuncNameInferrer* fni, |
| 1269 PreParserExpression expression) { | 1184 PreParserExpression expression) { |
| 1270 // PreParser should not use FuncNameInferrer. | 1185 // PreParser should not use FuncNameInferrer. |
| 1271 UNREACHABLE(); | 1186 UNREACHABLE(); |
| 1272 } | 1187 } |
| 1273 | 1188 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 const char* message, | 1240 const char* message, |
| 1326 const char* arg = NULL, | 1241 const char* arg = NULL, |
| 1327 bool is_reference_error = false); | 1242 bool is_reference_error = false); |
| 1328 void ReportMessageAt(int start_pos, | 1243 void ReportMessageAt(int start_pos, |
| 1329 int end_pos, | 1244 int end_pos, |
| 1330 const char* message, | 1245 const char* message, |
| 1331 const char* arg = NULL, | 1246 const char* arg = NULL, |
| 1332 bool is_reference_error = false); | 1247 bool is_reference_error = false); |
| 1333 | 1248 |
| 1334 // "null" return type creators. | 1249 // "null" return type creators. |
| 1335 static PreParserIdentifier EmptyIdentifier() { | |
| 1336 return PreParserIdentifier::Default(); | |
| 1337 } | |
| 1338 static PreParserIdentifier EmptyIdentifierString() { | |
| 1339 return PreParserIdentifier::Default(); | |
| 1340 } | |
| 1341 static PreParserExpression EmptyExpression() { | 1250 static PreParserExpression EmptyExpression() { |
| 1342 return PreParserExpression::Default(); | 1251 return PreParserExpression::Default(); |
| 1343 } | 1252 } |
| 1344 static PreParserExpression EmptyArrowParamList() { | 1253 static PreParserExpression EmptyArrowParamList() { |
| 1345 return PreParserExpression::EmptyArrowParamList(); | 1254 return PreParserExpression::EmptyArrowParamList(); |
| 1346 } | 1255 } |
| 1347 static PreParserExpression EmptyLiteral() { | 1256 static PreParserExpression EmptyLiteral() { |
| 1348 return PreParserExpression::Default(); | 1257 return PreParserExpression::Default(); |
| 1349 } | 1258 } |
| 1350 static PreParserExpression EmptyObjectLiteralProperty() { | 1259 static PreParserExpression EmptyObjectLiteralProperty() { |
| 1351 return PreParserExpression::Default(); | 1260 return PreParserExpression::Default(); |
| 1352 } | 1261 } |
| 1353 static PreParserExpression EmptyFunctionLiteral() { | 1262 static PreParserExpression EmptyFunctionLiteral() { |
| 1354 return PreParserExpression::Default(); | 1263 return PreParserExpression::Default(); |
| 1355 } | 1264 } |
| 1356 static PreParserExpressionList NullExpressionList() { | 1265 static PreParserExpressionList NullExpressionList() { |
| 1357 return PreParserExpressionList(); | 1266 return PreParserExpressionList(); |
| 1358 } | 1267 } |
| 1359 | 1268 |
| 1360 // Odd-ball literal creators. | 1269 // Odd-ball literal creators. |
| 1361 static PreParserExpression GetLiteralTheHole(int position, | 1270 static PreParserExpression GetLiteralTheHole(int position, |
| 1362 PreParserFactory* factory) { | 1271 PreParserFactory* factory) { |
| 1363 return PreParserExpression::Default(); | 1272 return PreParserExpression::Default(); |
| 1364 } | 1273 } |
| 1365 | 1274 |
| 1366 // Producing data during the recursive descent. | 1275 // Producing data during the recursive descent. |
| 1367 PreParserIdentifier GetSymbol(Scanner* scanner); | 1276 const AstRawString* GetNumberAsSymbol(Scanner* scanner); |
| 1368 PreParserIdentifier GetNumberAsSymbol(Scanner* scanner); | |
| 1369 | |
| 1370 static PreParserIdentifier GetNextSymbol(Scanner* scanner) { | |
| 1371 return PreParserIdentifier::Default(); | |
| 1372 } | |
| 1373 | 1277 |
| 1374 static PreParserExpression ThisExpression(Scope* scope, | 1278 static PreParserExpression ThisExpression(Scope* scope, |
| 1375 PreParserFactory* factory) { | 1279 PreParserFactory* factory) { |
| 1376 return PreParserExpression::This(); | 1280 return PreParserExpression::This(); |
| 1377 } | 1281 } |
| 1378 | 1282 |
| 1379 static PreParserExpression SuperReference(Scope* scope, | 1283 static PreParserExpression SuperReference(Scope* scope, |
| 1380 PreParserFactory* factory) { | 1284 PreParserFactory* factory) { |
| 1381 return PreParserExpression::Super(); | 1285 return PreParserExpression::Super(); |
| 1382 } | 1286 } |
| 1383 | 1287 |
| 1384 static PreParserExpression DefaultConstructor(bool call_super, Scope* scope, | 1288 static PreParserExpression DefaultConstructor(bool call_super, Scope* scope, |
| 1385 int pos, int end_pos) { | 1289 int pos, int end_pos) { |
| 1386 return PreParserExpression::Default(); | 1290 return PreParserExpression::Default(); |
| 1387 } | 1291 } |
| 1388 | 1292 |
| 1389 static PreParserExpression ExpressionFromLiteral( | 1293 static PreParserExpression ExpressionFromLiteral( |
| 1390 Token::Value token, int pos, Scanner* scanner, | 1294 Token::Value token, int pos, Scanner* scanner, |
| 1391 PreParserFactory* factory) { | 1295 PreParserFactory* factory) { |
| 1392 return PreParserExpression::Default(); | 1296 return PreParserExpression::Default(); |
| 1393 } | 1297 } |
| 1394 | 1298 |
| 1395 static PreParserExpression ExpressionFromIdentifier( | 1299 PreParserExpression ExpressionFromIdentifier(const AstRawString* name, |
| 1396 PreParserIdentifier name, int pos, Scope* scope, | 1300 int pos, Scope* scope, |
| 1397 PreParserFactory* factory) { | 1301 PreParserFactory* factory); |
| 1398 return PreParserExpression::FromIdentifier(name); | |
| 1399 } | |
| 1400 | 1302 |
| 1401 PreParserExpression ExpressionFromString(int pos, | 1303 PreParserExpression ExpressionFromString(int pos, |
| 1402 Scanner* scanner, | 1304 Scanner* scanner, |
| 1403 PreParserFactory* factory = NULL); | 1305 PreParserFactory* factory = NULL); |
| 1404 | 1306 |
| 1405 PreParserExpression GetIterator(PreParserExpression iterable, | 1307 PreParserExpression GetIterator(PreParserExpression iterable, |
| 1406 PreParserFactory* factory) { | 1308 PreParserFactory* factory) { |
| 1407 return PreParserExpression::Default(); | 1309 return PreParserExpression::Default(); |
| 1408 } | 1310 } |
| 1409 | 1311 |
| 1410 static PreParserExpressionList NewExpressionList(int size, Zone* zone) { | 1312 static PreParserExpressionList NewExpressionList(int size, Zone* zone) { |
| 1411 return PreParserExpressionList(); | 1313 return PreParserExpressionList(); |
| 1412 } | 1314 } |
| 1413 | 1315 |
| 1414 static PreParserStatementList NewStatementList(int size, Zone* zone) { | 1316 static PreParserStatementList NewStatementList(int size, Zone* zone) { |
| 1415 return PreParserStatementList(); | 1317 return PreParserStatementList(); |
| 1416 } | 1318 } |
| 1417 | 1319 |
| 1418 static PreParserExpressionList NewPropertyList(int size, Zone* zone) { | 1320 static PreParserExpressionList NewPropertyList(int size, Zone* zone) { |
| 1419 return PreParserExpressionList(); | 1321 return PreParserExpressionList(); |
| 1420 } | 1322 } |
| 1421 | 1323 |
| 1422 V8_INLINE void SkipLazyFunctionBody(PreParserIdentifier function_name, | 1324 V8_INLINE void SkipLazyFunctionBody(const AstRawString* function_name, |
| 1423 int* materialized_literal_count, | 1325 int* materialized_literal_count, |
| 1424 int* expected_property_count, bool* ok) { | 1326 int* expected_property_count, bool* ok) { |
| 1425 UNREACHABLE(); | 1327 UNREACHABLE(); |
| 1426 } | 1328 } |
| 1427 | 1329 |
| 1428 V8_INLINE PreParserStatementList | 1330 V8_INLINE PreParserStatementList |
| 1429 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, | 1331 ParseEagerFunctionBody(const AstRawString* function_name, int pos, |
| 1430 Variable* fvar, Token::Value fvar_init_op, | 1332 Variable* fvar, Token::Value fvar_init_op, |
| 1431 FunctionKind kind, bool* ok); | 1333 FunctionKind kind, bool* ok); |
| 1432 | 1334 |
| 1433 // Utility functions | 1335 // Utility functions |
| 1434 int DeclareArrowParametersFromExpression(PreParserExpression expression, | 1336 int DeclareArrowParametersFromExpression(PreParserExpression expression, |
| 1435 Scope* scope, | 1337 Scope* scope, |
| 1436 Scanner::Location* dupe_loc, | 1338 Scanner::Location* dupe_loc, |
| 1437 bool* ok) { | 1339 bool* ok) { |
| 1438 // TODO(aperez): Detect duplicated identifiers in paramlists. | 1340 // TODO(aperez): Detect duplicated identifiers in paramlists. |
| 1439 *ok = expression.IsValidArrowParamList(); | 1341 *ok = expression.IsValidArrowParamList(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1462 } | 1364 } |
| 1463 static bool IsTaggedTemplate(const PreParserExpression tag) { | 1365 static bool IsTaggedTemplate(const PreParserExpression tag) { |
| 1464 return !tag.IsNoTemplateTag(); | 1366 return !tag.IsNoTemplateTag(); |
| 1465 } | 1367 } |
| 1466 | 1368 |
| 1467 void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} | 1369 void CheckConflictingVarDeclarations(Scope* scope, bool* ok) {} |
| 1468 | 1370 |
| 1469 // Temporary glue; these functions will move to ParserBase. | 1371 // Temporary glue; these functions will move to ParserBase. |
| 1470 PreParserExpression ParseV8Intrinsic(bool* ok); | 1372 PreParserExpression ParseV8Intrinsic(bool* ok); |
| 1471 PreParserExpression ParseFunctionLiteral( | 1373 PreParserExpression ParseFunctionLiteral( |
| 1472 PreParserIdentifier name, Scanner::Location function_name_location, | 1374 const AstRawString* name, Scanner::Location function_name_location, |
| 1473 bool name_is_strict_reserved, FunctionKind kind, | 1375 bool name_is_strict_reserved, FunctionKind kind, |
| 1474 int function_token_position, FunctionLiteral::FunctionType type, | 1376 int function_token_position, FunctionLiteral::FunctionType type, |
| 1475 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1377 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
| 1476 | 1378 |
| 1477 PreParserExpression ParseClassLiteral(PreParserIdentifier name, | 1379 PreParserExpression ParseClassLiteral(const AstRawString* name, |
| 1478 Scanner::Location class_name_location, | 1380 Scanner::Location class_name_location, |
| 1479 bool name_is_strict_reserved, int pos, | 1381 bool name_is_strict_reserved, int pos, |
| 1480 bool* ok); | 1382 bool* ok); |
| 1481 | 1383 |
| 1482 private: | 1384 private: |
| 1483 PreParser* pre_parser_; | 1385 PreParser* pre_parser_; |
| 1484 }; | 1386 }; |
| 1485 | 1387 |
| 1486 | 1388 |
| 1487 // Preparsing checks a JavaScript program and emits preparse-data that helps | 1389 // Preparsing checks a JavaScript program and emits preparse-data that helps |
| 1488 // a later parsing to be faster. | 1390 // a later parsing to be faster. |
| 1489 // See preparse-data-format.h for the data format. | 1391 // See preparse-data-format.h for the data format. |
| 1490 | 1392 |
| 1491 // The PreParser checks that the syntax follows the grammar for JavaScript, | 1393 // The PreParser checks that the syntax follows the grammar for JavaScript, |
| 1492 // and collects some information about the program along the way. | 1394 // and collects some information about the program along the way. |
| 1493 // The grammar check is only performed in order to understand the program | 1395 // The grammar check is only performed in order to understand the program |
| 1494 // sufficiently to deduce some information about it, that can be used | 1396 // sufficiently to deduce some information about it, that can be used |
| 1495 // to speed up later parsing. Finding errors is not the goal of pre-parsing, | 1397 // to speed up later parsing. Finding errors is not the goal of pre-parsing, |
| 1496 // rather it is to speed up properly written and correct programs. | 1398 // rather it is to speed up properly written and correct programs. |
| 1497 // That means that contextual checks (like a label being declared where | 1399 // That means that contextual checks (like a label being declared where |
| 1498 // it is used) are generally omitted. | 1400 // it is used) are generally omitted. |
| 1499 class PreParser : public ParserBase<PreParserTraits> { | 1401 class PreParser : public ParserBase<PreParserTraits> { |
| 1500 public: | 1402 public: |
| 1501 typedef PreParserIdentifier Identifier; | |
| 1502 typedef PreParserExpression Expression; | 1403 typedef PreParserExpression Expression; |
| 1503 typedef PreParserStatement Statement; | 1404 typedef PreParserStatement Statement; |
| 1504 | 1405 |
| 1505 enum PreParseResult { | 1406 enum PreParseResult { |
| 1506 kPreParseStackOverflow, | 1407 kPreParseStackOverflow, |
| 1507 kPreParseSuccess | 1408 kPreParseSuccess |
| 1508 }; | 1409 }; |
| 1509 | 1410 |
| 1510 PreParser(Isolate* isolate, Zone* zone, Scanner* scanner, | 1411 PreParser(Isolate* isolate, Zone* zone, Scanner* scanner, |
| 1511 AstValueFactory* ast_value_factory, ParserRecorder* log, | 1412 AstValueFactory* ast_value_factory, ParserRecorder* log, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 Statement ParseDoWhileStatement(bool* ok); | 1496 Statement ParseDoWhileStatement(bool* ok); |
| 1596 Statement ParseWhileStatement(bool* ok); | 1497 Statement ParseWhileStatement(bool* ok); |
| 1597 Statement ParseForStatement(bool* ok); | 1498 Statement ParseForStatement(bool* ok); |
| 1598 Statement ParseThrowStatement(bool* ok); | 1499 Statement ParseThrowStatement(bool* ok); |
| 1599 Statement ParseTryStatement(bool* ok); | 1500 Statement ParseTryStatement(bool* ok); |
| 1600 Statement ParseDebuggerStatement(bool* ok); | 1501 Statement ParseDebuggerStatement(bool* ok); |
| 1601 Expression ParseConditionalExpression(bool accept_IN, bool* ok); | 1502 Expression ParseConditionalExpression(bool accept_IN, bool* ok); |
| 1602 Expression ParseObjectLiteral(bool* ok); | 1503 Expression ParseObjectLiteral(bool* ok); |
| 1603 Expression ParseV8Intrinsic(bool* ok); | 1504 Expression ParseV8Intrinsic(bool* ok); |
| 1604 | 1505 |
| 1605 V8_INLINE void SkipLazyFunctionBody(PreParserIdentifier function_name, | 1506 V8_INLINE void SkipLazyFunctionBody(const AstRawString* function_name, |
| 1606 int* materialized_literal_count, | 1507 int* materialized_literal_count, |
| 1607 int* expected_property_count, bool* ok); | 1508 int* expected_property_count, bool* ok); |
| 1608 V8_INLINE PreParserStatementList | 1509 V8_INLINE PreParserStatementList |
| 1609 ParseEagerFunctionBody(PreParserIdentifier function_name, int pos, | 1510 ParseEagerFunctionBody(const AstRawString* function_name, int pos, |
| 1610 Variable* fvar, Token::Value fvar_init_op, | 1511 Variable* fvar, Token::Value fvar_init_op, |
| 1611 FunctionKind kind, bool* ok); | 1512 FunctionKind kind, bool* ok); |
| 1612 | 1513 |
| 1613 Expression ParseFunctionLiteral( | 1514 Expression ParseFunctionLiteral( |
| 1614 Identifier name, Scanner::Location function_name_location, | 1515 const AstRawString* name, Scanner::Location function_name_location, |
| 1615 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, | 1516 bool name_is_strict_reserved, FunctionKind kind, int function_token_pos, |
| 1616 FunctionLiteral::FunctionType function_type, | 1517 FunctionLiteral::FunctionType function_type, |
| 1617 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); | 1518 FunctionLiteral::ArityRestriction arity_restriction, bool* ok); |
| 1618 void ParseLazyFunctionLiteralBody(bool* ok); | 1519 void ParseLazyFunctionLiteralBody(bool* ok); |
| 1619 | 1520 |
| 1620 PreParserExpression ParseClassLiteral(PreParserIdentifier name, | 1521 PreParserExpression ParseClassLiteral(const AstRawString* name, |
| 1621 Scanner::Location class_name_location, | 1522 Scanner::Location class_name_location, |
| 1622 bool name_is_strict_reserved, int pos, | 1523 bool name_is_strict_reserved, int pos, |
| 1623 bool* ok); | 1524 bool* ok); |
| 1624 | 1525 |
| 1625 bool CheckInOrOf(bool accept_OF); | 1526 bool CheckInOrOf(bool accept_OF); |
| 1626 }; | 1527 }; |
| 1627 | 1528 |
| 1628 | 1529 |
| 1629 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { | 1530 void PreParserTraits::MaterializeTemplateCallsiteLiterals() { |
| 1630 pre_parser_->function_state_->NextMaterializedLiteralIndex(); | 1531 pre_parser_->function_state_->NextMaterializedLiteralIndex(); |
| 1631 pre_parser_->function_state_->NextMaterializedLiteralIndex(); | 1532 pre_parser_->function_state_->NextMaterializedLiteralIndex(); |
| 1632 } | 1533 } |
| 1633 | 1534 |
| 1634 | 1535 |
| 1635 PreParserStatementList PreParser::ParseEagerFunctionBody( | 1536 PreParserStatementList PreParser::ParseEagerFunctionBody( |
| 1636 PreParserIdentifier function_name, int pos, Variable* fvar, | 1537 const AstRawString* function_name, int pos, Variable* fvar, |
| 1637 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { | 1538 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { |
| 1638 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 1539 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
| 1639 | 1540 |
| 1640 ParseStatementList(Token::RBRACE, ok); | 1541 ParseStatementList(Token::RBRACE, ok); |
| 1641 if (!*ok) return PreParserStatementList(); | 1542 if (!*ok) return PreParserStatementList(); |
| 1642 | 1543 |
| 1643 Expect(Token::RBRACE, ok); | 1544 Expect(Token::RBRACE, ok); |
| 1644 return PreParserStatementList(); | 1545 return PreParserStatementList(); |
| 1645 } | 1546 } |
| 1646 | 1547 |
| 1647 | 1548 |
| 1648 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( | 1549 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( |
| 1649 PreParserIdentifier function_name, int pos, Variable* fvar, | 1550 const AstRawString* function_name, int pos, Variable* fvar, |
| 1650 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { | 1551 Token::Value fvar_init_op, FunctionKind kind, bool* ok) { |
| 1651 return pre_parser_->ParseEagerFunctionBody(function_name, pos, fvar, | 1552 return pre_parser_->ParseEagerFunctionBody(function_name, pos, fvar, |
| 1652 fvar_init_op, kind, ok); | 1553 fvar_init_op, kind, ok); |
| 1653 } | 1554 } |
| 1654 | 1555 |
| 1655 | 1556 |
| 1656 template <class Traits> | 1557 template <class Traits> |
| 1657 ParserBase<Traits>::FunctionState::FunctionState( | 1558 ParserBase<Traits>::FunctionState::FunctionState( |
| 1658 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope, | 1559 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope, |
| 1659 FunctionKind kind, typename Traits::Type::Factory* factory) | 1560 FunctionKind kind, typename Traits::Type::Factory* factory) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 return Traits::ReportMessageAt(source_location, | 1609 return Traits::ReportMessageAt(source_location, |
| 1709 "unexpected_template_string"); | 1610 "unexpected_template_string"); |
| 1710 default: | 1611 default: |
| 1711 const char* name = Token::String(token); | 1612 const char* name = Token::String(token); |
| 1712 DCHECK(name != NULL); | 1613 DCHECK(name != NULL); |
| 1713 Traits::ReportMessageAt(source_location, "unexpected_token", name); | 1614 Traits::ReportMessageAt(source_location, "unexpected_token", name); |
| 1714 } | 1615 } |
| 1715 } | 1616 } |
| 1716 | 1617 |
| 1717 | 1618 |
| 1718 template<class Traits> | 1619 template <class Traits> |
| 1719 typename ParserBase<Traits>::IdentifierT ParserBase<Traits>::ParseIdentifier( | 1620 const AstRawString* ParserBase<Traits>::ParseIdentifier( |
| 1720 AllowEvalOrArgumentsAsIdentifier allow_eval_or_arguments, | 1621 AllowEvalOrArgumentsAsIdentifier allow_eval_or_arguments, bool* ok) { |
| 1721 bool* ok) { | |
| 1722 Token::Value next = Next(); | 1622 Token::Value next = Next(); |
| 1723 if (next == Token::IDENTIFIER) { | 1623 if (next == Token::IDENTIFIER) { |
| 1724 IdentifierT name = this->GetSymbol(scanner()); | 1624 const AstRawString* name = GetSymbol(scanner()); |
| 1725 if (allow_eval_or_arguments == kDontAllowEvalOrArguments && | 1625 if (allow_eval_or_arguments == kDontAllowEvalOrArguments && |
| 1726 is_strict(language_mode()) && this->IsEvalOrArguments(name)) { | 1626 is_strict(language_mode()) && this->IsEvalOrArguments(name)) { |
| 1727 ReportMessage("strict_eval_arguments"); | 1627 ReportMessage("strict_eval_arguments"); |
| 1728 *ok = false; | 1628 *ok = false; |
| 1729 } | 1629 } |
| 1730 if (name->IsArguments(ast_value_factory())) scope_->RecordArgumentsUsage(); | 1630 if (name == ast_value_factory()->arguments_string()) { |
| 1631 scope_->RecordArgumentsUsage(); |
| 1632 } |
| 1731 return name; | 1633 return name; |
| 1732 } else if (is_sloppy(language_mode()) && | 1634 } else if (is_sloppy(language_mode()) && |
| 1733 (next == Token::FUTURE_STRICT_RESERVED_WORD || | 1635 (next == Token::FUTURE_STRICT_RESERVED_WORD || |
| 1734 next == Token::LET || next == Token::STATIC || | 1636 next == Token::LET || next == Token::STATIC || |
| 1735 (next == Token::YIELD && !is_generator()))) { | 1637 (next == Token::YIELD && !is_generator()))) { |
| 1736 return this->GetSymbol(scanner()); | 1638 return GetSymbol(scanner()); |
| 1737 } else { | 1639 } else { |
| 1738 this->ReportUnexpectedToken(next); | 1640 this->ReportUnexpectedToken(next); |
| 1739 *ok = false; | 1641 *ok = false; |
| 1740 return Traits::EmptyIdentifier(); | 1642 return NULL; |
| 1741 } | 1643 } |
| 1742 } | 1644 } |
| 1743 | 1645 |
| 1744 | 1646 |
| 1745 template <class Traits> | 1647 template <class Traits> |
| 1746 typename ParserBase<Traits>::IdentifierT ParserBase< | 1648 const AstRawString* ParserBase<Traits>::ParseIdentifierOrStrictReservedWord( |
| 1747 Traits>::ParseIdentifierOrStrictReservedWord(bool* is_strict_reserved, | 1649 bool* is_strict_reserved, bool* ok) { |
| 1748 bool* ok) { | |
| 1749 Token::Value next = Next(); | 1650 Token::Value next = Next(); |
| 1750 if (next == Token::IDENTIFIER) { | 1651 if (next == Token::IDENTIFIER) { |
| 1751 *is_strict_reserved = false; | 1652 *is_strict_reserved = false; |
| 1752 } else if (next == Token::FUTURE_STRICT_RESERVED_WORD || next == Token::LET || | 1653 } else if (next == Token::FUTURE_STRICT_RESERVED_WORD || next == Token::LET || |
| 1753 next == Token::STATIC || | 1654 next == Token::STATIC || |
| 1754 (next == Token::YIELD && !this->is_generator())) { | 1655 (next == Token::YIELD && !this->is_generator())) { |
| 1755 *is_strict_reserved = true; | 1656 *is_strict_reserved = true; |
| 1756 } else { | 1657 } else { |
| 1757 ReportUnexpectedToken(next); | 1658 ReportUnexpectedToken(next); |
| 1758 *ok = false; | 1659 *ok = false; |
| 1759 return Traits::EmptyIdentifier(); | 1660 return NULL; |
| 1760 } | 1661 } |
| 1761 | 1662 |
| 1762 IdentifierT name = this->GetSymbol(scanner()); | 1663 const AstRawString* name = GetSymbol(scanner()); |
| 1763 if (name->IsArguments(ast_value_factory())) scope_->RecordArgumentsUsage(); | 1664 if (name == ast_value_factory()->arguments_string()) { |
| 1665 scope_->RecordArgumentsUsage(); |
| 1666 } |
| 1764 return name; | 1667 return name; |
| 1765 } | 1668 } |
| 1766 | 1669 |
| 1767 | 1670 |
| 1768 template <class Traits> | 1671 template <class Traits> |
| 1769 typename ParserBase<Traits>::IdentifierT | 1672 const AstRawString* ParserBase<Traits>::ParseIdentifierName(bool* ok) { |
| 1770 ParserBase<Traits>::ParseIdentifierName(bool* ok) { | |
| 1771 Token::Value next = Next(); | 1673 Token::Value next = Next(); |
| 1772 if (next != Token::IDENTIFIER && next != Token::FUTURE_RESERVED_WORD && | 1674 if (next != Token::IDENTIFIER && next != Token::FUTURE_RESERVED_WORD && |
| 1773 next != Token::LET && next != Token::STATIC && next != Token::YIELD && | 1675 next != Token::LET && next != Token::STATIC && next != Token::YIELD && |
| 1774 next != Token::FUTURE_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) { | 1676 next != Token::FUTURE_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) { |
| 1775 this->ReportUnexpectedToken(next); | 1677 this->ReportUnexpectedToken(next); |
| 1776 *ok = false; | 1678 *ok = false; |
| 1777 return Traits::EmptyIdentifier(); | 1679 return NULL; |
| 1778 } | 1680 } |
| 1779 | 1681 |
| 1780 IdentifierT name = this->GetSymbol(scanner()); | 1682 const AstRawString* name = GetSymbol(scanner()); |
| 1781 if (name->IsArguments(ast_value_factory())) scope_->RecordArgumentsUsage(); | 1683 if (name == ast_value_factory()->arguments_string()) { |
| 1684 scope_->RecordArgumentsUsage(); |
| 1685 } |
| 1782 return name; | 1686 return name; |
| 1783 } | 1687 } |
| 1784 | 1688 |
| 1785 | 1689 |
| 1786 template <class Traits> | 1690 template <class Traits> |
| 1787 typename ParserBase<Traits>::IdentifierT | 1691 const AstRawString* ParserBase<Traits>::ParseIdentifierNameOrGetOrSet( |
| 1788 ParserBase<Traits>::ParseIdentifierNameOrGetOrSet(bool* is_get, | 1692 bool* is_get, bool* is_set, bool* ok) { |
| 1789 bool* is_set, | 1693 const AstRawString* result = ParseIdentifierName(ok); |
| 1790 bool* ok) { | 1694 if (!*ok) return NULL; |
| 1791 IdentifierT result = ParseIdentifierName(ok); | |
| 1792 if (!*ok) return Traits::EmptyIdentifier(); | |
| 1793 scanner()->IsGetOrSet(is_get, is_set); | 1695 scanner()->IsGetOrSet(is_get, is_set); |
| 1794 return result; | 1696 return result; |
| 1795 } | 1697 } |
| 1796 | 1698 |
| 1797 | 1699 |
| 1798 template <class Traits> | 1700 template <class Traits> |
| 1799 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral( | 1701 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral( |
| 1800 bool seen_equal, bool* ok) { | 1702 bool seen_equal, bool* ok) { |
| 1801 int pos = peek_position(); | 1703 int pos = peek_position(); |
| 1802 if (!scanner()->ScanRegExpPattern(seen_equal)) { | 1704 if (!scanner()->ScanRegExpPattern(seen_equal)) { |
| 1803 Next(); | 1705 Next(); |
| 1804 ReportMessage("unterminated_regexp"); | 1706 ReportMessage("unterminated_regexp"); |
| 1805 *ok = false; | 1707 *ok = false; |
| 1806 return Traits::EmptyExpression(); | 1708 return Traits::EmptyExpression(); |
| 1807 } | 1709 } |
| 1808 | 1710 |
| 1809 int literal_index = function_state_->NextMaterializedLiteralIndex(); | 1711 int literal_index = function_state_->NextMaterializedLiteralIndex(); |
| 1810 | 1712 |
| 1811 IdentifierT js_pattern = this->GetNextSymbol(scanner()); | 1713 const AstRawString* js_pattern = GetNextSymbol(scanner()); |
| 1812 if (!scanner()->ScanRegExpFlags()) { | 1714 if (!scanner()->ScanRegExpFlags()) { |
| 1813 Next(); | 1715 Next(); |
| 1814 ReportMessage("malformed_regexp_flags"); | 1716 ReportMessage("malformed_regexp_flags"); |
| 1815 *ok = false; | 1717 *ok = false; |
| 1816 return Traits::EmptyExpression(); | 1718 return Traits::EmptyExpression(); |
| 1817 } | 1719 } |
| 1818 IdentifierT js_flags = this->GetNextSymbol(scanner()); | 1720 const AstRawString* js_flags = GetNextSymbol(scanner()); |
| 1819 Next(); | 1721 Next(); |
| 1820 return factory()->NewRegExpLiteral(js_pattern, js_flags, literal_index, pos); | 1722 return factory()->NewRegExpLiteral(js_pattern, js_flags, literal_index, pos); |
| 1821 } | 1723 } |
| 1822 | 1724 |
| 1823 | 1725 |
| 1824 #define CHECK_OK ok); \ | 1726 #define CHECK_OK ok); \ |
| 1825 if (!*ok) return this->EmptyExpression(); \ | 1727 if (!*ok) return this->EmptyExpression(); \ |
| 1826 ((void)0 | 1728 ((void)0 |
| 1827 #define DUMMY ) // to make indentation work | 1729 #define DUMMY ) // to make indentation work |
| 1828 #undef DUMMY | 1730 #undef DUMMY |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 Next(); | 1772 Next(); |
| 1871 result = this->ExpressionFromLiteral(token, pos, scanner(), factory()); | 1773 result = this->ExpressionFromLiteral(token, pos, scanner(), factory()); |
| 1872 break; | 1774 break; |
| 1873 | 1775 |
| 1874 case Token::IDENTIFIER: | 1776 case Token::IDENTIFIER: |
| 1875 case Token::LET: | 1777 case Token::LET: |
| 1876 case Token::STATIC: | 1778 case Token::STATIC: |
| 1877 case Token::YIELD: | 1779 case Token::YIELD: |
| 1878 case Token::FUTURE_STRICT_RESERVED_WORD: { | 1780 case Token::FUTURE_STRICT_RESERVED_WORD: { |
| 1879 // Using eval or arguments in this context is OK even in strict mode. | 1781 // Using eval or arguments in this context is OK even in strict mode. |
| 1880 IdentifierT name = ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 1782 const AstRawString* name = |
| 1783 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
| 1881 result = this->ExpressionFromIdentifier(name, pos, scope_, factory()); | 1784 result = this->ExpressionFromIdentifier(name, pos, scope_, factory()); |
| 1882 break; | 1785 break; |
| 1883 } | 1786 } |
| 1884 | 1787 |
| 1885 case Token::STRING: { | 1788 case Token::STRING: { |
| 1886 Consume(Token::STRING); | 1789 Consume(Token::STRING); |
| 1887 result = this->ExpressionFromString(pos, scanner(), factory()); | 1790 result = this->ExpressionFromString(pos, scanner(), factory()); |
| 1888 break; | 1791 break; |
| 1889 } | 1792 } |
| 1890 | 1793 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1923 break; | 1826 break; |
| 1924 | 1827 |
| 1925 case Token::CLASS: { | 1828 case Token::CLASS: { |
| 1926 Consume(Token::CLASS); | 1829 Consume(Token::CLASS); |
| 1927 if (!allow_harmony_sloppy() && is_sloppy(language_mode())) { | 1830 if (!allow_harmony_sloppy() && is_sloppy(language_mode())) { |
| 1928 ReportMessage("sloppy_lexical", NULL); | 1831 ReportMessage("sloppy_lexical", NULL); |
| 1929 *ok = false; | 1832 *ok = false; |
| 1930 break; | 1833 break; |
| 1931 } | 1834 } |
| 1932 int class_token_position = position(); | 1835 int class_token_position = position(); |
| 1933 IdentifierT name = this->EmptyIdentifier(); | 1836 const AstRawString* name = NULL; |
| 1934 bool is_strict_reserved_name = false; | 1837 bool is_strict_reserved_name = false; |
| 1935 Scanner::Location class_name_location = Scanner::Location::invalid(); | 1838 Scanner::Location class_name_location = Scanner::Location::invalid(); |
| 1936 if (peek_any_identifier()) { | 1839 if (peek_any_identifier()) { |
| 1937 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name, | 1840 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name, |
| 1938 CHECK_OK); | 1841 CHECK_OK); |
| 1939 class_name_location = scanner()->location(); | 1842 class_name_location = scanner()->location(); |
| 1940 } | 1843 } |
| 1941 result = this->ParseClassLiteral(name, class_name_location, | 1844 result = this->ParseClassLiteral(name, class_name_location, |
| 1942 is_strict_reserved_name, | 1845 is_strict_reserved_name, |
| 1943 class_token_position, CHECK_OK); | 1846 class_token_position, CHECK_OK); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2013 | 1916 |
| 2014 // Update the scope information before the pre-parsing bailout. | 1917 // Update the scope information before the pre-parsing bailout. |
| 2015 int literal_index = function_state_->NextMaterializedLiteralIndex(); | 1918 int literal_index = function_state_->NextMaterializedLiteralIndex(); |
| 2016 | 1919 |
| 2017 return factory()->NewArrayLiteral(values, literal_index, pos); | 1920 return factory()->NewArrayLiteral(values, literal_index, pos); |
| 2018 } | 1921 } |
| 2019 | 1922 |
| 2020 | 1923 |
| 2021 template <class Traits> | 1924 template <class Traits> |
| 2022 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParsePropertyName( | 1925 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParsePropertyName( |
| 2023 IdentifierT* name, bool* is_get, bool* is_set, bool* is_static, | 1926 const AstRawString** name, bool* is_get, bool* is_set, bool* is_static, |
| 2024 bool* is_computed_name, bool* ok) { | 1927 bool* is_computed_name, bool* ok) { |
| 2025 Token::Value token = peek(); | 1928 Token::Value token = peek(); |
| 2026 int pos = peek_position(); | 1929 int pos = peek_position(); |
| 2027 | 1930 |
| 2028 // For non computed property names we normalize the name a bit: | 1931 // For non computed property names we normalize the name a bit: |
| 2029 // | 1932 // |
| 2030 // "12" -> 12 | 1933 // "12" -> 12 |
| 2031 // 12.3 -> "12.3" | 1934 // 12.3 -> "12.3" |
| 2032 // 12.30 -> "12.3" | 1935 // 12.30 -> "12.3" |
| 2033 // identifier -> "identifier" | 1936 // identifier -> "identifier" |
| 2034 // | 1937 // |
| 2035 // This is important because we use the property name as a key in a hash | 1938 // This is important because we use the property name as a key in a hash |
| 2036 // table when we compute constant properties. | 1939 // table when we compute constant properties. |
| 2037 switch (token) { | 1940 switch (token) { |
| 2038 case Token::STRING: | 1941 case Token::STRING: |
| 2039 Consume(Token::STRING); | 1942 Consume(Token::STRING); |
| 2040 *name = this->GetSymbol(scanner()); | 1943 *name = GetSymbol(scanner()); |
| 2041 break; | 1944 break; |
| 2042 | 1945 |
| 2043 case Token::NUMBER: | 1946 case Token::NUMBER: |
| 2044 Consume(Token::NUMBER); | 1947 Consume(Token::NUMBER); |
| 2045 *name = this->GetNumberAsSymbol(scanner()); | 1948 *name = GetNumberAsSymbol(scanner()); |
| 2046 break; | 1949 break; |
| 2047 | 1950 |
| 2048 case Token::LBRACK: | 1951 case Token::LBRACK: |
| 2049 if (allow_harmony_computed_property_names_) { | 1952 if (allow_harmony_computed_property_names_) { |
| 2050 *is_computed_name = true; | 1953 *is_computed_name = true; |
| 2051 Consume(Token::LBRACK); | 1954 Consume(Token::LBRACK); |
| 2052 ExpressionT expression = ParseAssignmentExpression(true, CHECK_OK); | 1955 ExpressionT expression = ParseAssignmentExpression(true, CHECK_OK); |
| 2053 Expect(Token::RBRACK, CHECK_OK); | 1956 Expect(Token::RBRACK, CHECK_OK); |
| 2054 return expression; | 1957 return expression; |
| 2055 } | 1958 } |
| 2056 | 1959 |
| 2057 // Fall through. | 1960 // Fall through. |
| 2058 case Token::STATIC: | 1961 case Token::STATIC: |
| 2059 *is_static = true; | 1962 *is_static = true; |
| 2060 | 1963 |
| 2061 // Fall through. | 1964 // Fall through. |
| 2062 default: | 1965 default: |
| 2063 *name = ParseIdentifierNameOrGetOrSet(is_get, is_set, CHECK_OK); | 1966 *name = ParseIdentifierNameOrGetOrSet(is_get, is_set, CHECK_OK); |
| 2064 break; | 1967 break; |
| 2065 } | 1968 } |
| 2066 | 1969 |
| 2067 uint32_t index; | 1970 uint32_t index; |
| 2068 return this->IsArrayIndex(*name, &index) | 1971 return (*name)->AsArrayIndex(&index) |
| 2069 ? factory()->NewNumberLiteral(index, pos) | 1972 ? factory()->NewNumberLiteral(index, pos) |
| 2070 : factory()->NewStringLiteral(*name, pos); | 1973 : factory()->NewStringLiteral(*name, pos); |
| 2071 } | 1974 } |
| 2072 | 1975 |
| 2073 | 1976 |
| 2074 template <class Traits> | 1977 template <class Traits> |
| 2075 typename ParserBase<Traits>::ObjectLiteralPropertyT | 1978 typename ParserBase<Traits>::ObjectLiteralPropertyT |
| 2076 ParserBase<Traits>::ParsePropertyDefinition(ObjectLiteralCheckerBase* checker, | 1979 ParserBase<Traits>::ParsePropertyDefinition(ObjectLiteralCheckerBase* checker, |
| 2077 bool in_class, bool has_extends, | 1980 bool in_class, bool has_extends, |
| 2078 bool is_static, | 1981 bool is_static, |
| 2079 bool* is_computed_name, | 1982 bool* is_computed_name, |
| 2080 bool* has_seen_constructor, | 1983 bool* has_seen_constructor, |
| 2081 bool* ok) { | 1984 bool* ok) { |
| 2082 DCHECK(!in_class || is_static || has_seen_constructor != nullptr); | 1985 DCHECK(!in_class || is_static || has_seen_constructor != nullptr); |
| 2083 ExpressionT value = this->EmptyExpression(); | 1986 ExpressionT value = this->EmptyExpression(); |
| 2084 IdentifierT name = this->EmptyIdentifier(); | 1987 const AstRawString* name = NULL; |
| 2085 bool is_get = false; | 1988 bool is_get = false; |
| 2086 bool is_set = false; | 1989 bool is_set = false; |
| 2087 bool name_is_static = false; | 1990 bool name_is_static = false; |
| 2088 bool is_generator = allow_harmony_object_literals_ && Check(Token::MUL); | 1991 bool is_generator = allow_harmony_object_literals_ && Check(Token::MUL); |
| 2089 | 1992 |
| 2090 Token::Value name_token = peek(); | 1993 Token::Value name_token = peek(); |
| 2091 int next_pos = peek_position(); | 1994 int next_pos = peek_position(); |
| 2092 ExpressionT name_expression = ParsePropertyName( | 1995 ExpressionT name_expression = ParsePropertyName( |
| 2093 &name, &is_get, &is_set, &name_is_static, is_computed_name, | 1996 &name, &is_get, &is_set, &name_is_static, is_computed_name, |
| 2094 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 1997 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2113 // Concise Method | 2016 // Concise Method |
| 2114 if (!*is_computed_name) { | 2017 if (!*is_computed_name) { |
| 2115 checker->CheckProperty(name_token, kMethodProperty, is_static, | 2018 checker->CheckProperty(name_token, kMethodProperty, is_static, |
| 2116 is_generator, | 2019 is_generator, |
| 2117 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2020 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2118 } | 2021 } |
| 2119 | 2022 |
| 2120 FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod | 2023 FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod |
| 2121 : FunctionKind::kConciseMethod; | 2024 : FunctionKind::kConciseMethod; |
| 2122 | 2025 |
| 2123 if (in_class && !is_static && this->IsConstructor(name)) { | 2026 if (in_class && !is_static && |
| 2027 name == ast_value_factory_->constructor_string()) { |
| 2124 *has_seen_constructor = true; | 2028 *has_seen_constructor = true; |
| 2125 kind = has_extends ? FunctionKind::kSubclassConstructor | 2029 kind = has_extends ? FunctionKind::kSubclassConstructor |
| 2126 : FunctionKind::kBaseConstructor; | 2030 : FunctionKind::kBaseConstructor; |
| 2127 } | 2031 } |
| 2128 | 2032 |
| 2129 value = this->ParseFunctionLiteral( | 2033 value = this->ParseFunctionLiteral( |
| 2130 name, scanner()->location(), | 2034 name, scanner()->location(), |
| 2131 false, // reserved words are allowed here | 2035 false, // reserved words are allowed here |
| 2132 kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, | 2036 kind, RelocInfo::kNoPosition, FunctionLiteral::ANONYMOUS_EXPRESSION, |
| 2133 FunctionLiteral::NORMAL_ARITY, | 2037 FunctionLiteral::NORMAL_ARITY, |
| 2134 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2038 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2135 | 2039 |
| 2136 return factory()->NewObjectLiteralProperty(name_expression, value, | 2040 return factory()->NewObjectLiteralProperty(name_expression, value, |
| 2137 ObjectLiteralProperty::COMPUTED, | 2041 ObjectLiteralProperty::COMPUTED, |
| 2138 is_static, *is_computed_name); | 2042 is_static, *is_computed_name); |
| 2139 | 2043 |
| 2140 } else if (in_class && name_is_static && !is_static) { | 2044 } else if (in_class && name_is_static && !is_static) { |
| 2141 // static MethodDefinition | 2045 // static MethodDefinition |
| 2142 return ParsePropertyDefinition(checker, true, has_extends, true, | 2046 return ParsePropertyDefinition(checker, true, has_extends, true, |
| 2143 is_computed_name, nullptr, ok); | 2047 is_computed_name, nullptr, ok); |
| 2144 } else if (is_get || is_set) { | 2048 } else if (is_get || is_set) { |
| 2145 // Accessor | 2049 // Accessor |
| 2146 name = this->EmptyIdentifier(); | 2050 name = NULL; |
| 2147 bool dont_care = false; | 2051 bool dont_care = false; |
| 2148 name_token = peek(); | 2052 name_token = peek(); |
| 2149 | 2053 |
| 2150 name_expression = ParsePropertyName( | 2054 name_expression = ParsePropertyName( |
| 2151 &name, &dont_care, &dont_care, &dont_care, is_computed_name, | 2055 &name, &dont_care, &dont_care, &dont_care, is_computed_name, |
| 2152 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); | 2056 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); |
| 2153 | 2057 |
| 2154 if (!*is_computed_name) { | 2058 if (!*is_computed_name) { |
| 2155 checker->CheckProperty(name_token, kAccessorProperty, is_static, | 2059 checker->CheckProperty(name_token, kAccessorProperty, is_static, |
| 2156 is_generator, | 2060 is_generator, |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2622 result->AsFunctionLiteral()->set_parenthesized(); | 2526 result->AsFunctionLiteral()->set_parenthesized(); |
| 2623 } | 2527 } |
| 2624 } | 2528 } |
| 2625 result = ParseTemplateLiteral(result, pos, CHECK_OK); | 2529 result = ParseTemplateLiteral(result, pos, CHECK_OK); |
| 2626 break; | 2530 break; |
| 2627 } | 2531 } |
| 2628 | 2532 |
| 2629 case Token::PERIOD: { | 2533 case Token::PERIOD: { |
| 2630 Consume(Token::PERIOD); | 2534 Consume(Token::PERIOD); |
| 2631 int pos = position(); | 2535 int pos = position(); |
| 2632 IdentifierT name = ParseIdentifierName(CHECK_OK); | 2536 const AstRawString* name = ParseIdentifierName(CHECK_OK); |
| 2633 result = factory()->NewProperty( | 2537 result = factory()->NewProperty( |
| 2634 result, factory()->NewStringLiteral(name, pos), pos); | 2538 result, factory()->NewStringLiteral(name, pos), pos); |
| 2635 if (fni_ != NULL) this->PushLiteralName(fni_, name); | 2539 if (fni_ != NULL) this->PushLiteralName(fni_, name); |
| 2636 break; | 2540 break; |
| 2637 } | 2541 } |
| 2638 | 2542 |
| 2639 default: | 2543 default: |
| 2640 return result; | 2544 return result; |
| 2641 } | 2545 } |
| 2642 } | 2546 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2701 // The '[' Expression ']' and '.' Identifier parts are parsed by | 2605 // The '[' Expression ']' and '.' Identifier parts are parsed by |
| 2702 // ParseMemberExpressionContinuation, and the Arguments part is parsed by the | 2606 // ParseMemberExpressionContinuation, and the Arguments part is parsed by the |
| 2703 // caller. | 2607 // caller. |
| 2704 | 2608 |
| 2705 // Parse the initial primary or function expression. | 2609 // Parse the initial primary or function expression. |
| 2706 ExpressionT result = this->EmptyExpression(); | 2610 ExpressionT result = this->EmptyExpression(); |
| 2707 if (peek() == Token::FUNCTION) { | 2611 if (peek() == Token::FUNCTION) { |
| 2708 Consume(Token::FUNCTION); | 2612 Consume(Token::FUNCTION); |
| 2709 int function_token_position = position(); | 2613 int function_token_position = position(); |
| 2710 bool is_generator = Check(Token::MUL); | 2614 bool is_generator = Check(Token::MUL); |
| 2711 IdentifierT name = this->EmptyIdentifier(); | 2615 const AstRawString* name = NULL; |
| 2712 bool is_strict_reserved_name = false; | 2616 bool is_strict_reserved_name = false; |
| 2713 Scanner::Location function_name_location = Scanner::Location::invalid(); | 2617 Scanner::Location function_name_location = Scanner::Location::invalid(); |
| 2714 FunctionLiteral::FunctionType function_type = | 2618 FunctionLiteral::FunctionType function_type = |
| 2715 FunctionLiteral::ANONYMOUS_EXPRESSION; | 2619 FunctionLiteral::ANONYMOUS_EXPRESSION; |
| 2716 if (peek_any_identifier()) { | 2620 if (peek_any_identifier()) { |
| 2717 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name, | 2621 name = ParseIdentifierOrStrictReservedWord(&is_strict_reserved_name, |
| 2718 CHECK_OK); | 2622 CHECK_OK); |
| 2719 function_name_location = scanner()->location(); | 2623 function_name_location = scanner()->location(); |
| 2720 function_type = FunctionLiteral::NAMED_EXPRESSION; | 2624 function_type = FunctionLiteral::NAMED_EXPRESSION; |
| 2721 } | 2625 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2785 expression = factory()->NewProperty(expression, index, pos); | 2689 expression = factory()->NewProperty(expression, index, pos); |
| 2786 if (fni_ != NULL) { | 2690 if (fni_ != NULL) { |
| 2787 this->PushPropertyName(fni_, index); | 2691 this->PushPropertyName(fni_, index); |
| 2788 } | 2692 } |
| 2789 Expect(Token::RBRACK, CHECK_OK); | 2693 Expect(Token::RBRACK, CHECK_OK); |
| 2790 break; | 2694 break; |
| 2791 } | 2695 } |
| 2792 case Token::PERIOD: { | 2696 case Token::PERIOD: { |
| 2793 Consume(Token::PERIOD); | 2697 Consume(Token::PERIOD); |
| 2794 int pos = position(); | 2698 int pos = position(); |
| 2795 IdentifierT name = ParseIdentifierName(CHECK_OK); | 2699 const AstRawString* name = ParseIdentifierName(CHECK_OK); |
| 2796 expression = factory()->NewProperty( | 2700 expression = factory()->NewProperty( |
| 2797 expression, factory()->NewStringLiteral(name, pos), pos); | 2701 expression, factory()->NewStringLiteral(name, pos), pos); |
| 2798 if (fni_ != NULL) { | 2702 if (fni_ != NULL) { |
| 2799 this->PushLiteralName(fni_, name); | 2703 this->PushLiteralName(fni_, name); |
| 2800 } | 2704 } |
| 2801 break; | 2705 break; |
| 2802 } | 2706 } |
| 2803 default: | 2707 default: |
| 2804 return expression; | 2708 return expression; |
| 2805 } | 2709 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2845 | 2749 |
| 2846 Expect(Token::ARROW, CHECK_OK); | 2750 Expect(Token::ARROW, CHECK_OK); |
| 2847 | 2751 |
| 2848 if (peek() == Token::LBRACE) { | 2752 if (peek() == Token::LBRACE) { |
| 2849 // Multiple statemente body | 2753 // Multiple statemente body |
| 2850 Consume(Token::LBRACE); | 2754 Consume(Token::LBRACE); |
| 2851 bool is_lazily_parsed = | 2755 bool is_lazily_parsed = |
| 2852 (mode() == PARSE_LAZILY && scope_->AllowsLazyCompilation()); | 2756 (mode() == PARSE_LAZILY && scope_->AllowsLazyCompilation()); |
| 2853 if (is_lazily_parsed) { | 2757 if (is_lazily_parsed) { |
| 2854 body = this->NewStatementList(0, zone()); | 2758 body = this->NewStatementList(0, zone()); |
| 2855 this->SkipLazyFunctionBody(this->EmptyIdentifier(), | 2759 this->SkipLazyFunctionBody(NULL, &materialized_literal_count, |
| 2856 &materialized_literal_count, | |
| 2857 &expected_property_count, CHECK_OK); | 2760 &expected_property_count, CHECK_OK); |
| 2858 } else { | 2761 } else { |
| 2859 body = this->ParseEagerFunctionBody( | 2762 body = this->ParseEagerFunctionBody(NULL, RelocInfo::kNoPosition, NULL, |
| 2860 this->EmptyIdentifier(), RelocInfo::kNoPosition, NULL, | 2763 Token::INIT_VAR, kArrowFunction, |
| 2861 Token::INIT_VAR, kArrowFunction, CHECK_OK); | 2764 CHECK_OK); |
| 2862 materialized_literal_count = | 2765 materialized_literal_count = |
| 2863 function_state.materialized_literal_count(); | 2766 function_state.materialized_literal_count(); |
| 2864 expected_property_count = function_state.expected_property_count(); | 2767 expected_property_count = function_state.expected_property_count(); |
| 2865 handler_count = function_state.handler_count(); | 2768 handler_count = function_state.handler_count(); |
| 2866 } | 2769 } |
| 2867 } else { | 2770 } else { |
| 2868 // Single-expression body | 2771 // Single-expression body |
| 2869 int pos = position(); | 2772 int pos = position(); |
| 2870 parenthesized_function_ = false; | 2773 parenthesized_function_ = false; |
| 2871 ExpressionT expression = ParseAssignmentExpression(true, CHECK_OK); | 2774 ExpressionT expression = ParseAssignmentExpression(true, CHECK_OK); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2892 if (is_strict(language_mode())) { | 2795 if (is_strict(language_mode())) { |
| 2893 CheckStrictOctalLiteral(start_pos, scanner()->location().end_pos, | 2796 CheckStrictOctalLiteral(start_pos, scanner()->location().end_pos, |
| 2894 CHECK_OK); | 2797 CHECK_OK); |
| 2895 } | 2798 } |
| 2896 | 2799 |
| 2897 if (allow_harmony_scoping() && is_strict(language_mode())) | 2800 if (allow_harmony_scoping() && is_strict(language_mode())) |
| 2898 this->CheckConflictingVarDeclarations(scope, CHECK_OK); | 2801 this->CheckConflictingVarDeclarations(scope, CHECK_OK); |
| 2899 } | 2802 } |
| 2900 | 2803 |
| 2901 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( | 2804 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( |
| 2902 this->EmptyIdentifierString(), ast_value_factory(), scope, body, | 2805 ast_value_factory()->empty_string(), ast_value_factory(), scope, body, |
| 2903 materialized_literal_count, expected_property_count, handler_count, | 2806 materialized_literal_count, expected_property_count, handler_count, |
| 2904 num_parameters, FunctionLiteral::kNoDuplicateParameters, | 2807 num_parameters, FunctionLiteral::kNoDuplicateParameters, |
| 2905 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, | 2808 FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction, |
| 2906 FunctionLiteral::kNotParenthesized, FunctionKind::kArrowFunction, | 2809 FunctionLiteral::kNotParenthesized, FunctionKind::kArrowFunction, |
| 2907 start_pos); | 2810 start_pos); |
| 2908 | 2811 |
| 2909 function_literal->set_function_token_position(start_pos); | 2812 function_literal->set_function_token_position(start_pos); |
| 2910 | 2813 |
| 2911 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); | 2814 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); |
| 2912 | 2815 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3082 *ok = false; | 2985 *ok = false; |
| 3083 return; | 2986 return; |
| 3084 } | 2987 } |
| 3085 has_seen_constructor_ = true; | 2988 has_seen_constructor_ = true; |
| 3086 return; | 2989 return; |
| 3087 } | 2990 } |
| 3088 } | 2991 } |
| 3089 } } // v8::internal | 2992 } } // v8::internal |
| 3090 | 2993 |
| 3091 #endif // V8_PREPARSER_H | 2994 #endif // V8_PREPARSER_H |
| OLD | NEW |