Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: src/parsing/preparser.h

Issue 2179423002: [parser] Refactor parser and preparser traits (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: More changes after reviewers' comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/parser-base.h ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_PREPARSER_H 5 #ifndef V8_PARSING_PREPARSER_H
6 #define V8_PARSING_PREPARSER_H 6 #define V8_PARSING_PREPARSER_H
7 7
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/hashmap.h" 10 #include "src/base/hashmap.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 bool IsArguments() const { return type_ == kArgumentsIdentifier; } 68 bool IsArguments() const { return type_ == kArgumentsIdentifier; }
69 bool IsEvalOrArguments() const { return IsEval() || IsArguments(); } 69 bool IsEvalOrArguments() const { return IsEval() || IsArguments(); }
70 bool IsUndefined() const { return type_ == kUndefinedIdentifier; } 70 bool IsUndefined() const { return type_ == kUndefinedIdentifier; }
71 bool IsLet() const { return type_ == kLetIdentifier; } 71 bool IsLet() const { return type_ == kLetIdentifier; }
72 bool IsStatic() const { return type_ == kStaticIdentifier; } 72 bool IsStatic() const { return type_ == kStaticIdentifier; }
73 bool IsYield() const { return type_ == kYieldIdentifier; } 73 bool IsYield() const { return type_ == kYieldIdentifier; }
74 bool IsPrototype() const { return type_ == kPrototypeIdentifier; } 74 bool IsPrototype() const { return type_ == kPrototypeIdentifier; }
75 bool IsConstructor() const { return type_ == kConstructorIdentifier; } 75 bool IsConstructor() const { return type_ == kConstructorIdentifier; }
76 bool IsEnum() const { return type_ == kEnumIdentifier; } 76 bool IsEnum() const { return type_ == kEnumIdentifier; }
77 bool IsAwait() const { return type_ == kAwaitIdentifier; } 77 bool IsAwait() const { return type_ == kAwaitIdentifier; }
78 bool IsAsync() const { return type_ == kAsyncIdentifier; }
79 bool IsFutureStrictReserved() const { 78 bool IsFutureStrictReserved() const {
80 return type_ == kFutureStrictReservedIdentifier || 79 return type_ == kFutureStrictReservedIdentifier ||
81 type_ == kLetIdentifier || type_ == kStaticIdentifier || 80 type_ == kLetIdentifier || type_ == kStaticIdentifier ||
82 type_ == kYieldIdentifier; 81 type_ == kYieldIdentifier;
83 } 82 }
84 83
85 // Allow identifier->name()[->length()] to work. The preparser 84 // Allow identifier->name()[->length()] to work. The preparser
86 // does not need the actual positions/lengths of the identifiers. 85 // does not need the actual positions/lengths of the identifiers.
87 const PreParserIdentifier* operator->() const { return this; } 86 const PreParserIdentifier* operator->() const { return this; }
88 const PreParserIdentifier raw_name() const { return *this; } 87 const PreParserIdentifier raw_name() const { return *this; }
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 typedef PreParserFormalParameters FormalParameters; 614 typedef PreParserFormalParameters FormalParameters;
616 typedef PreParserStatementList StatementList; 615 typedef PreParserStatementList StatementList;
617 616
618 // For constructing objects returned by the traversing functions. 617 // For constructing objects returned by the traversing functions.
619 typedef PreParserFactory Factory; 618 typedef PreParserFactory Factory;
620 }; 619 };
621 620
622 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {} 621 explicit PreParserTraits(PreParser* pre_parser) : pre_parser_(pre_parser) {}
623 622
624 // Helper functions for recursive descent. 623 // Helper functions for recursive descent.
625 static bool IsEval(PreParserIdentifier identifier) { 624 bool IsEval(PreParserIdentifier identifier) const {
626 return identifier.IsEval(); 625 return identifier.IsEval();
627 } 626 }
628 627
629 static bool IsArguments(PreParserIdentifier identifier) { 628 bool IsArguments(PreParserIdentifier identifier) const {
630 return identifier.IsArguments(); 629 return identifier.IsArguments();
631 } 630 }
632 631
633 static bool IsAwait(PreParserIdentifier identifier) { 632 bool IsAwait(PreParserIdentifier identifier) const {
634 return identifier.IsAwait(); 633 return identifier.IsAwait();
635 } 634 }
636 635
637 static bool IsAsync(PreParserIdentifier identifier) { 636 bool IsEvalOrArguments(PreParserIdentifier identifier) const {
638 return identifier.IsAsync();
639 }
640
641 static bool IsEvalOrArguments(PreParserIdentifier identifier) {
642 return identifier.IsEvalOrArguments(); 637 return identifier.IsEvalOrArguments();
643 } 638 }
644 639
645 static bool IsUndefined(PreParserIdentifier identifier) { 640 bool IsUndefined(PreParserIdentifier identifier) const {
646 return identifier.IsUndefined(); 641 return identifier.IsUndefined();
647 } 642 }
648 643
649 static bool IsPrototype(PreParserIdentifier identifier) { 644 bool IsPrototype(PreParserIdentifier identifier) const {
650 return identifier.IsPrototype(); 645 return identifier.IsPrototype();
651 } 646 }
652 647
653 static bool IsConstructor(PreParserIdentifier identifier) { 648 bool IsConstructor(PreParserIdentifier identifier) const {
654 return identifier.IsConstructor(); 649 return identifier.IsConstructor();
655 } 650 }
656 651
657 // Returns true if the expression is of type "this.foo". 652 // Returns true if the expression is of type "this.foo".
658 static bool IsThisProperty(PreParserExpression expression) { 653 static bool IsThisProperty(PreParserExpression expression) {
659 return expression.IsThisProperty(); 654 return expression.IsThisProperty();
660 } 655 }
661 656
662 static bool IsIdentifier(PreParserExpression expression) { 657 static bool IsIdentifier(PreParserExpression expression) {
663 return expression.IsIdentifier(); 658 return expression.IsIdentifier();
664 } 659 }
665 660
666 static PreParserIdentifier AsIdentifier(PreParserExpression expression) { 661 static PreParserIdentifier AsIdentifier(PreParserExpression expression) {
667 return expression.AsIdentifier(); 662 return expression.AsIdentifier();
668 } 663 }
669 664
670 static bool IsEvalIdentifier(PreParserExpression expression) { 665 bool IsDirectEvalCall(PreParserExpression expression) const {
671 return IsIdentifier(expression) && IsEval(AsIdentifier(expression));
672 }
673
674 static bool IsDirectEvalCall(PreParserExpression expression) {
675 return expression.IsDirectEvalCall(); 666 return expression.IsDirectEvalCall();
676 } 667 }
677 668
678 static bool IsFutureStrictReserved(PreParserIdentifier identifier) { 669 bool IsFutureStrictReserved(PreParserIdentifier identifier) const {
679 return identifier.IsFutureStrictReserved(); 670 return identifier.IsFutureStrictReserved();
680 } 671 }
681 672
682 static bool IsBoilerplateProperty(PreParserExpression property) { 673 static bool IsBoilerplateProperty(PreParserExpression property) {
683 // PreParser doesn't count boilerplate properties. 674 // PreParser doesn't count boilerplate properties.
684 return false; 675 return false;
685 } 676 }
686 677
687 static bool IsArrayIndex(PreParserIdentifier string, uint32_t* index) { 678 static bool IsArrayIndex(PreParserIdentifier string, uint32_t* index) {
688 return false; 679 return false;
689 } 680 }
690 681
691 static PreParserExpression GetPropertyValue(PreParserExpression property) { 682 static PreParserExpression GetPropertyValue(PreParserExpression property) {
692 return PreParserExpression::Default(); 683 return PreParserExpression::Default();
693 } 684 }
694 685
695 // Functions for encapsulating the differences between parsing and preparsing; 686 // Functions for encapsulating the differences between parsing and preparsing;
696 // operations interleaved with the recursive descent. 687 // operations interleaved with the recursive descent.
697 static void PushLiteralName(FuncNameInferrer* fni, PreParserIdentifier id) { 688 static void PushLiteralName(FuncNameInferrer* fni, PreParserIdentifier id) {
698 // PreParser should not use FuncNameInferrer. 689 // PreParser should not use FuncNameInferrer.
699 UNREACHABLE(); 690 UNREACHABLE();
700 } 691 }
701 692
702 static void PushPropertyName(FuncNameInferrer* fni, 693 void PushPropertyName(FuncNameInferrer* fni, PreParserExpression expression) {
703 PreParserExpression expression) {
704 // PreParser should not use FuncNameInferrer. 694 // PreParser should not use FuncNameInferrer.
705 UNREACHABLE(); 695 UNREACHABLE();
706 } 696 }
707 697
708 static void InferFunctionName(FuncNameInferrer* fni, 698 static void InferFunctionName(FuncNameInferrer* fni,
709 PreParserExpression expression) { 699 PreParserExpression expression) {
710 // PreParser should not use FuncNameInferrer. 700 // PreParser should not use FuncNameInferrer.
711 UNREACHABLE(); 701 UNREACHABLE();
712 } 702 }
713 703
714 static void CheckAssigningFunctionLiteralToProperty( 704 static void CheckAssigningFunctionLiteralToProperty(
715 PreParserExpression left, PreParserExpression right) {} 705 PreParserExpression left, PreParserExpression right) {}
716 706
717 static PreParserExpression MarkExpressionAsAssigned( 707 static PreParserExpression MarkExpressionAsAssigned(
718 PreParserExpression expression) { 708 PreParserExpression expression) {
719 // TODO(marja): To be able to produce the same errors, the preparser needs 709 // TODO(marja): To be able to produce the same errors, the preparser needs
720 // to start tracking which expressions are variables and which are assigned. 710 // to start tracking which expressions are variables and which are assigned.
721 return expression; 711 return expression;
722 } 712 }
723 713
724 bool ShortcutNumericLiteralBinaryExpression(PreParserExpression* x, 714 bool ShortcutNumericLiteralBinaryExpression(PreParserExpression* x,
725 PreParserExpression y, 715 PreParserExpression y,
726 Token::Value op, 716 Token::Value op, int pos,
727 int pos,
728 PreParserFactory* factory) { 717 PreParserFactory* factory) {
729 return false; 718 return false;
730 } 719 }
731 720
732 PreParserExpression BuildUnaryExpression(PreParserExpression expression, 721 PreParserExpression BuildUnaryExpression(PreParserExpression expression,
733 Token::Value op, int pos, 722 Token::Value op, int pos,
734 PreParserFactory* factory) { 723 PreParserFactory* factory) {
735 return PreParserExpression::Default(); 724 return PreParserExpression::Default();
736 } 725 }
737 726
738 PreParserExpression BuildIteratorResult(PreParserExpression value, 727 PreParserExpression BuildIteratorResult(PreParserExpression value,
739 bool done) { 728 bool done) {
740 return PreParserExpression::Default(); 729 return PreParserExpression::Default();
741 } 730 }
731
742 PreParserExpression NewThrowReferenceError(MessageTemplate::Template message, 732 PreParserExpression NewThrowReferenceError(MessageTemplate::Template message,
743 int pos) { 733 int pos) {
744 return PreParserExpression::Default(); 734 return PreParserExpression::Default();
745 } 735 }
736
746 PreParserExpression NewThrowSyntaxError(MessageTemplate::Template message, 737 PreParserExpression NewThrowSyntaxError(MessageTemplate::Template message,
747 Handle<Object> arg, int pos) { 738 PreParserIdentifier arg, int pos) {
748 return PreParserExpression::Default();
749 }
750 PreParserExpression NewThrowTypeError(MessageTemplate::Template message,
751 Handle<Object> arg, int pos) {
752 return PreParserExpression::Default(); 739 return PreParserExpression::Default();
753 } 740 }
754 741
742 PreParserExpression NewThrowTypeError(MessageTemplate::Template message,
743 PreParserIdentifier arg, int pos) {
744 return PreParserExpression::Default();
745 }
746
755 // Reporting errors. 747 // Reporting errors.
756 void ReportMessageAt(Scanner::Location location, 748 void ReportMessageAt(Scanner::Location location,
757 MessageTemplate::Template message, 749 MessageTemplate::Template message,
758 const char* arg = NULL, 750 const char* arg = NULL,
759 ParseErrorType error_type = kSyntaxError); 751 ParseErrorType error_type = kSyntaxError);
760 void ReportMessageAt(int start_pos, int end_pos, 752 void ReportMessageAt(Scanner::Location location,
761 MessageTemplate::Template message, 753 MessageTemplate::Template message,
762 const char* arg = NULL, 754 const AstRawString* arg,
763 ParseErrorType error_type = kSyntaxError); 755 ParseErrorType error_type = kSyntaxError);
764 756
765 // A dummy function, just useful as an argument to CHECK_OK_CUSTOM. 757 // A dummy function, just useful as an argument to CHECK_OK_CUSTOM.
766 static void Void() {} 758 static void Void() {}
767 759
768 // "null" return type creators. 760 // "null" return type creators.
769 static PreParserIdentifier EmptyIdentifier() { 761 static PreParserIdentifier EmptyIdentifier() {
770 return PreParserIdentifier::Default(); 762 return PreParserIdentifier::Default();
771 } 763 }
772 static PreParserIdentifier EmptyIdentifierString() { 764 static PreParserIdentifier EmptyIdentifierString() {
773 return PreParserIdentifier::Default(); 765 return PreParserIdentifier::Default();
774 } 766 }
775 static PreParserExpression EmptyExpression() { 767 static PreParserExpression EmptyExpression() {
776 return PreParserExpression::Default(); 768 return PreParserExpression::Default();
777 } 769 }
778 static PreParserExpression EmptyLiteral() { 770 static PreParserExpression EmptyLiteral() {
779 return PreParserExpression::Default(); 771 return PreParserExpression::Default();
780 } 772 }
781 static PreParserExpression EmptyObjectLiteralProperty() { 773 static PreParserExpression EmptyObjectLiteralProperty() {
782 return PreParserExpression::Default(); 774 return PreParserExpression::Default();
783 } 775 }
784 static PreParserExpression EmptyFunctionLiteral() { 776 static PreParserExpression EmptyFunctionLiteral() {
785 return PreParserExpression::Default(); 777 return PreParserExpression::Default();
786 } 778 }
787 static PreParserExpressionList NullExpressionList() { 779 static PreParserExpressionList NullExpressionList() {
788 return PreParserExpressionList(); 780 return PreParserExpressionList();
789 } 781 }
790 782
791 // Odd-ball literal creators. 783 // Odd-ball literal creators.
792 static PreParserExpression GetLiteralTheHole(int position, 784 PreParserExpression GetLiteralTheHole(int position,
793 PreParserFactory* factory) { 785 PreParserFactory* factory) const {
794 return PreParserExpression::Default(); 786 return PreParserExpression::Default();
795 } 787 }
796 788
797 // Producing data during the recursive descent. 789 // Producing data during the recursive descent.
798 PreParserIdentifier GetSymbol(Scanner* scanner); 790 PreParserIdentifier GetSymbol(Scanner* scanner);
799 PreParserIdentifier GetNumberAsSymbol(Scanner* scanner); 791 PreParserIdentifier GetNumberAsSymbol(Scanner* scanner) {
800
801 static PreParserIdentifier GetNextSymbol(Scanner* scanner) {
802 return PreParserIdentifier::Default(); 792 return PreParserIdentifier::Default();
803 } 793 }
804 794
805 static PreParserExpression ThisExpression(int pos) { 795 PreParserIdentifier GetNextSymbol(Scanner* scanner) const {
796 return PreParserIdentifier::Default();
797 }
798
799 PreParserExpression ThisExpression(int pos = kNoSourcePosition) const {
806 return PreParserExpression::This(); 800 return PreParserExpression::This();
807 } 801 }
808 802
809 static PreParserExpression NewSuperPropertyReference( 803 PreParserExpression NewSuperPropertyReference(PreParserFactory* factory,
810 PreParserFactory* factory, int pos) { 804 int pos) const {
811 return PreParserExpression::Default(); 805 return PreParserExpression::Default();
812 } 806 }
813 807
814 static PreParserExpression NewSuperCallReference(PreParserFactory* factory, 808 PreParserExpression NewSuperCallReference(PreParserFactory* factory,
815 int pos) { 809 int pos) const {
816 return PreParserExpression::SuperCallReference(); 810 return PreParserExpression::SuperCallReference();
817 } 811 }
818 812
819 static PreParserExpression NewTargetExpression(int pos) { 813 PreParserExpression NewTargetExpression(int pos) const {
820 return PreParserExpression::Default(); 814 return PreParserExpression::Default();
821 } 815 }
822 816
823 static PreParserExpression FunctionSentExpression(PreParserFactory* factory, 817 PreParserExpression FunctionSentExpression(PreParserFactory* factory,
824 int pos) { 818 int pos) const {
825 return PreParserExpression::Default(); 819 return PreParserExpression::Default();
826 } 820 }
827 821
828 static PreParserExpression ExpressionFromLiteral( 822 PreParserExpression ExpressionFromLiteral(Token::Value token, int pos,
829 Token::Value token, int pos, Scanner* scanner, 823 Scanner* scanner,
830 PreParserFactory* factory) { 824 PreParserFactory* factory) const {
831 return PreParserExpression::Default(); 825 return PreParserExpression::Default();
832 } 826 }
833 827
834 static PreParserExpression ExpressionFromIdentifier( 828 PreParserExpression ExpressionFromIdentifier(
835 PreParserIdentifier name, int start_position, int end_position, 829 PreParserIdentifier name, int start_position, int end_position,
836 InferName = InferName::kYes) { 830 InferName = InferName::kYes) const {
837 return PreParserExpression::FromIdentifier(name); 831 return PreParserExpression::FromIdentifier(name);
838 } 832 }
839 833
840 PreParserExpression ExpressionFromString(int pos, 834 PreParserExpression ExpressionFromString(int pos, Scanner* scanner,
841 Scanner* scanner, 835 PreParserFactory* factory);
842 PreParserFactory* factory = NULL);
843 836
844 PreParserExpression GetIterator(PreParserExpression iterable, 837 PreParserExpression GetIterator(PreParserExpression iterable,
845 PreParserFactory* factory, int pos) { 838 PreParserFactory* factory, int pos) {
846 return PreParserExpression::Default(); 839 return PreParserExpression::Default();
847 } 840 }
848 841
849 static PreParserExpressionList NewExpressionList(int size, Zone* zone) { 842 PreParserExpressionList NewExpressionList(int size, Zone* zone) const {
850 return PreParserExpressionList(); 843 return PreParserExpressionList();
851 } 844 }
852 845
853 static PreParserStatementList NewStatementList(int size, Zone* zone) { 846 PreParserStatementList NewStatementList(int size, Zone* zone) const {
854 return PreParserStatementList(); 847 return PreParserStatementList();
855 } 848 }
856 849
857 static PreParserExpressionList NewPropertyList(int size, Zone* zone) { 850 PreParserExpressionList NewPropertyList(int size, Zone* zone) const {
858 return PreParserExpressionList(); 851 return PreParserExpressionList();
859 } 852 }
860 853
861 static void AddParameterInitializationBlock( 854 void AddParameterInitializationBlock(
862 const PreParserFormalParameters& parameters, PreParserStatementList list, 855 const PreParserFormalParameters& parameters, PreParserStatementList list,
863 bool is_async, bool* ok) {} 856 bool is_async, bool* ok) const {}
864 857
865 V8_INLINE void SkipLazyFunctionBody(int* materialized_literal_count, 858 V8_INLINE void SkipLazyFunctionBody(
866 int* expected_property_count, bool* ok) { 859 int* materialized_literal_count, int* expected_property_count, bool* ok,
860 Scanner::BookmarkScope* bookmark = nullptr) {
867 UNREACHABLE(); 861 UNREACHABLE();
868 } 862 }
869 863
870 V8_INLINE PreParserStatementList ParseEagerFunctionBody( 864 V8_INLINE PreParserStatementList ParseEagerFunctionBody(
871 PreParserIdentifier function_name, int pos, 865 PreParserIdentifier name, int pos,
872 const PreParserFormalParameters& parameters, FunctionKind kind, 866 const PreParserFormalParameters& parameters, FunctionKind kind,
873 FunctionLiteral::FunctionType function_type, bool* ok); 867 FunctionLiteral::FunctionType function_type, bool* ok);
874 868
875 V8_INLINE void ParseArrowFunctionFormalParameterList( 869 V8_INLINE void ParseArrowFunctionFormalParameterList(
876 PreParserFormalParameters* parameters, PreParserExpression expression, 870 PreParserFormalParameters* parameters, PreParserExpression expression,
877 const Scanner::Location& params_loc, Scanner::Location* duplicate_loc, 871 const Scanner::Location& params_loc, Scanner::Location* duplicate_loc,
878 const Scope::Snapshot& scope_snapshot, bool* ok); 872 const Scope::Snapshot& scope_snapshot, bool* ok);
879 873
880 void ParseAsyncArrowSingleExpressionBody( 874 void ParseAsyncArrowSingleExpressionBody(
881 PreParserStatementList body, bool accept_IN, 875 PreParserStatementList body, bool accept_IN,
882 Type::ExpressionClassifier* classifier, int pos, bool* ok); 876 Type::ExpressionClassifier* classifier, int pos, bool* ok);
883 877
884 V8_INLINE PreParserExpression ParseAsyncFunctionExpression(bool* ok); 878 V8_INLINE PreParserExpression ParseAsyncFunctionExpression(bool* ok);
885 879
886 void ReindexLiterals(const PreParserFormalParameters& paramaters) {} 880 void ReindexLiterals(const PreParserFormalParameters& parameters) {}
887 881
888 struct TemplateLiteralState {}; 882 struct TemplateLiteralState {};
889 883
890 TemplateLiteralState OpenTemplateLiteral(int pos) { 884 TemplateLiteralState OpenTemplateLiteral(int pos) {
891 return TemplateLiteralState(); 885 return TemplateLiteralState();
892 } 886 }
893 void AddTemplateSpan(TemplateLiteralState*, bool) {} 887 void AddTemplateSpan(TemplateLiteralState* state, bool tail) {}
894 void AddTemplateExpression(TemplateLiteralState*, PreParserExpression) {} 888 void AddTemplateExpression(TemplateLiteralState* state,
895 PreParserExpression CloseTemplateLiteral(TemplateLiteralState*, int, 889 PreParserExpression expression) {}
896 PreParserExpression tag) { 890 V8_INLINE PreParserExpression CloseTemplateLiteral(
897 if (IsTaggedTemplate(tag)) { 891 TemplateLiteralState* state, int start, PreParserExpression tag);
898 // Emulate generation of array literals for tag callsite
899 // 1st is array of cooked strings, second is array of raw strings
900 MaterializeTemplateCallsiteLiterals();
901 }
902 return EmptyExpression();
903 }
904 inline void MaterializeTemplateCallsiteLiterals();
905 PreParserExpression NoTemplateTag() { 892 PreParserExpression NoTemplateTag() {
906 return PreParserExpression::NoTemplateTag(); 893 return PreParserExpression::NoTemplateTag();
907 } 894 }
908 static bool IsTaggedTemplate(const PreParserExpression tag) { 895 static bool IsTaggedTemplate(const PreParserExpression tag) {
909 return !tag.IsNoTemplateTag(); 896 return !tag.IsNoTemplateTag();
910 } 897 }
911 898
912 void AddFormalParameter(PreParserFormalParameters* parameters, 899 void AddFormalParameter(PreParserFormalParameters* parameters,
913 PreParserExpression pattern, 900 PreParserExpression pattern,
914 PreParserExpression initializer, 901 PreParserExpression initializer,
(...skipping 19 matching lines...) Expand all
934 int function_token_position, FunctionLiteral::FunctionType type, 921 int function_token_position, FunctionLiteral::FunctionType type,
935 LanguageMode language_mode, bool* ok); 922 LanguageMode language_mode, bool* ok);
936 923
937 PreParserExpression ParseClassLiteral(Type::ExpressionClassifier* classifier, 924 PreParserExpression ParseClassLiteral(Type::ExpressionClassifier* classifier,
938 PreParserIdentifier name, 925 PreParserIdentifier name,
939 Scanner::Location class_name_location, 926 Scanner::Location class_name_location,
940 bool name_is_strict_reserved, int pos, 927 bool name_is_strict_reserved, int pos,
941 bool* ok); 928 bool* ok);
942 929
943 V8_INLINE void MarkCollectedTailCallExpressions() {} 930 V8_INLINE void MarkCollectedTailCallExpressions() {}
944 V8_INLINE void MarkTailPosition(PreParserExpression) {} 931 V8_INLINE void MarkTailPosition(PreParserExpression expression) {}
945 932
946 PreParserExpressionList PrepareSpreadArguments(PreParserExpressionList list) { 933 PreParserExpressionList PrepareSpreadArguments(PreParserExpressionList list) {
947 return list; 934 return list;
948 } 935 }
949 936
950 inline void MaterializeUnspreadArgumentsLiterals(int count); 937 inline void MaterializeUnspreadArgumentsLiterals(int count);
951 938
952 inline PreParserExpression SpreadCall(PreParserExpression function, 939 inline PreParserExpression SpreadCall(PreParserExpression function,
953 PreParserExpressionList args, int pos); 940 PreParserExpressionList args, int pos);
954 941
(...skipping 11 matching lines...) Expand all
966 inline PreParserExpression RewriteExponentiation(PreParserExpression left, 953 inline PreParserExpression RewriteExponentiation(PreParserExpression left,
967 PreParserExpression right, 954 PreParserExpression right,
968 int pos) { 955 int pos) {
969 return left; 956 return left;
970 } 957 }
971 inline PreParserExpression RewriteAssignExponentiation( 958 inline PreParserExpression RewriteAssignExponentiation(
972 PreParserExpression left, PreParserExpression right, int pos) { 959 PreParserExpression left, PreParserExpression right, int pos) {
973 return left; 960 return left;
974 } 961 }
975 962
976 inline void QueueDestructuringAssignmentForRewriting(PreParserExpression) {} 963 inline void QueueDestructuringAssignmentForRewriting(
977 inline void QueueNonPatternForRewriting(PreParserExpression, bool* ok) {} 964 PreParserExpression assignment) {}
965 inline void QueueNonPatternForRewriting(PreParserExpression expr, bool* ok) {}
978 966
979 void SetFunctionNameFromPropertyName(PreParserExpression, 967 void SetFunctionNameFromPropertyName(PreParserExpression property,
980 PreParserIdentifier) {} 968 PreParserIdentifier name) {}
981 void SetFunctionNameFromIdentifierRef(PreParserExpression, 969 void SetFunctionNameFromIdentifierRef(PreParserExpression value,
982 PreParserExpression) {} 970 PreParserExpression identifier) {}
983 971
984 inline void RewriteNonPattern(Type::ExpressionClassifier* classifier, 972 inline void RewriteNonPattern(Type::ExpressionClassifier* classifier,
985 bool* ok); 973 bool* ok);
986 974
987 inline PreParserExpression RewriteAwaitExpression(PreParserExpression value, 975 inline PreParserExpression RewriteAwaitExpression(PreParserExpression value,
988 int pos); 976 int pos);
989 977
990 V8_INLINE ZoneList<typename Type::ExpressionClassifier::Error>* 978 V8_INLINE ZoneList<typename Type::ExpressionClassifier::Error>*
991 GetReportedErrorList() const; 979 GetReportedErrorList() const;
992 V8_INLINE Zone* zone() const; 980 V8_INLINE Zone* zone() const;
993 V8_INLINE ZoneList<PreParserExpression>* GetNonPatternList() const; 981 V8_INLINE ZoneList<PreParserExpression>* GetNonPatternList() const;
994 982
995 inline PreParserExpression RewriteYieldStar( 983 inline PreParserExpression RewriteYieldStar(PreParserExpression generator,
996 PreParserExpression generator, PreParserExpression expr, int pos); 984 PreParserExpression expression,
985 int pos);
997 986
998 private: 987 private:
999 PreParser* pre_parser_; 988 PreParser* pre_parser_;
1000 }; 989 };
1001 990
1002 991
1003 // Preparsing checks a JavaScript program and emits preparse-data that helps 992 // Preparsing checks a JavaScript program and emits preparse-data that helps
1004 // a later parsing to be faster. 993 // a later parsing to be faster.
1005 // See preparse-data-format.h for the data format. 994 // See preparse-data-format.h for the data format.
1006 995
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 Statement ParseWhileStatement(bool* ok); 1118 Statement ParseWhileStatement(bool* ok);
1130 Statement ParseForStatement(bool* ok); 1119 Statement ParseForStatement(bool* ok);
1131 Statement ParseThrowStatement(bool* ok); 1120 Statement ParseThrowStatement(bool* ok);
1132 Statement ParseTryStatement(bool* ok); 1121 Statement ParseTryStatement(bool* ok);
1133 Statement ParseDebuggerStatement(bool* ok); 1122 Statement ParseDebuggerStatement(bool* ok);
1134 Expression ParseConditionalExpression(bool accept_IN, bool* ok); 1123 Expression ParseConditionalExpression(bool accept_IN, bool* ok);
1135 Expression ParseObjectLiteral(bool* ok); 1124 Expression ParseObjectLiteral(bool* ok);
1136 Expression ParseV8Intrinsic(bool* ok); 1125 Expression ParseV8Intrinsic(bool* ok);
1137 Expression ParseDoExpression(bool* ok); 1126 Expression ParseDoExpression(bool* ok);
1138 1127
1139 V8_INLINE void SkipLazyFunctionBody(int* materialized_literal_count,
1140 int* expected_property_count, bool* ok);
1141 V8_INLINE PreParserStatementList ParseEagerFunctionBody( 1128 V8_INLINE PreParserStatementList ParseEagerFunctionBody(
1142 PreParserIdentifier function_name, int pos, 1129 PreParserIdentifier function_name, int pos,
1143 const PreParserFormalParameters& parameters, FunctionKind kind, 1130 const PreParserFormalParameters& parameters, FunctionKind kind,
1144 FunctionLiteral::FunctionType function_type, bool* ok); 1131 FunctionLiteral::FunctionType function_type, bool* ok);
1145 1132
1146 Expression ParseFunctionLiteral( 1133 Expression ParseFunctionLiteral(
1147 Identifier name, Scanner::Location function_name_location, 1134 Identifier name, Scanner::Location function_name_location,
1148 FunctionNameValidity function_name_validity, FunctionKind kind, 1135 FunctionNameValidity function_name_validity, FunctionKind kind,
1149 int function_token_pos, FunctionLiteral::FunctionType function_type, 1136 int function_token_pos, FunctionLiteral::FunctionType function_type,
1150 LanguageMode language_mode, bool* ok); 1137 LanguageMode language_mode, bool* ok);
1151 void ParseLazyFunctionLiteralBody(bool* ok, 1138 void ParseLazyFunctionLiteralBody(bool* ok,
1152 Scanner::BookmarkScope* bookmark = nullptr); 1139 Scanner::BookmarkScope* bookmark = nullptr);
1153 1140
1154 PreParserExpression ParseClassLiteral(ExpressionClassifier* classifier, 1141 PreParserExpression ParseClassLiteral(ExpressionClassifier* classifier,
1155 PreParserIdentifier name, 1142 PreParserIdentifier name,
1156 Scanner::Location class_name_location, 1143 Scanner::Location class_name_location,
1157 bool name_is_strict_reserved, int pos, 1144 bool name_is_strict_reserved, int pos,
1158 bool* ok); 1145 bool* ok);
1159 1146
1160 int* use_counts_; 1147 int* use_counts_;
1161 }; 1148 };
1162 1149
1163 1150
1164 void PreParserTraits::MaterializeTemplateCallsiteLiterals() {
1165 pre_parser_->function_state_->NextMaterializedLiteralIndex();
1166 pre_parser_->function_state_->NextMaterializedLiteralIndex();
1167 }
1168
1169
1170 void PreParserTraits::MaterializeUnspreadArgumentsLiterals(int count) { 1151 void PreParserTraits::MaterializeUnspreadArgumentsLiterals(int count) {
1171 for (int i = 0; i < count; ++i) { 1152 for (int i = 0; i < count; ++i) {
1172 pre_parser_->function_state_->NextMaterializedLiteralIndex(); 1153 pre_parser_->function_state_->NextMaterializedLiteralIndex();
1173 } 1154 }
1174 } 1155 }
1175 1156
1176 1157
1177 PreParserExpression PreParserTraits::SpreadCall(PreParserExpression function, 1158 PreParserExpression PreParserTraits::SpreadCall(PreParserExpression function,
1178 PreParserExpressionList args, 1159 PreParserExpressionList args,
1179 int pos) { 1160 int pos) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 1236
1256 1237
1257 PreParserStatementList PreParserTraits::ParseEagerFunctionBody( 1238 PreParserStatementList PreParserTraits::ParseEagerFunctionBody(
1258 PreParserIdentifier function_name, int pos, 1239 PreParserIdentifier function_name, int pos,
1259 const PreParserFormalParameters& parameters, FunctionKind kind, 1240 const PreParserFormalParameters& parameters, FunctionKind kind,
1260 FunctionLiteral::FunctionType function_type, bool* ok) { 1241 FunctionLiteral::FunctionType function_type, bool* ok) {
1261 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters, 1242 return pre_parser_->ParseEagerFunctionBody(function_name, pos, parameters,
1262 kind, function_type, ok); 1243 kind, function_type, ok);
1263 } 1244 }
1264 1245
1246 PreParserExpression PreParserTraits::CloseTemplateLiteral(
1247 TemplateLiteralState* state, int start, PreParserExpression tag) {
1248 if (IsTaggedTemplate(tag)) {
1249 // Emulate generation of array literals for tag callsite
1250 // 1st is array of cooked strings, second is array of raw strings
1251 pre_parser_->function_state_->NextMaterializedLiteralIndex();
1252 pre_parser_->function_state_->NextMaterializedLiteralIndex();
1253 }
1254 return EmptyExpression();
1255 }
1256
1265 } // namespace internal 1257 } // namespace internal
1266 } // namespace v8 1258 } // namespace v8
1267 1259
1268 #endif // V8_PARSING_PREPARSER_H 1260 #endif // V8_PARSING_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parsing/parser-base.h ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698