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

Side by Side Diff: src/parsing/parser-base.h

Issue 1841543003: [esnext] implement frontend changes for async/await proposal (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Uncomment that test Created 4 years, 7 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.cc ('k') | src/parsing/preparser.h » ('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_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_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/hashmap.h" 10 #include "src/hashmap.h"
(...skipping 11 matching lines...) Expand all
22 kFunctionNameIsStrictReserved, 22 kFunctionNameIsStrictReserved,
23 kSkipFunctionNameCheck, 23 kSkipFunctionNameCheck,
24 kFunctionNameValidityUnknown 24 kFunctionNameValidityUnknown
25 }; 25 };
26 26
27 enum AllowLabelledFunctionStatement { 27 enum AllowLabelledFunctionStatement {
28 kAllowLabelledFunctionStatement, 28 kAllowLabelledFunctionStatement,
29 kDisallowLabelledFunctionStatement, 29 kDisallowLabelledFunctionStatement,
30 }; 30 };
31 31
32 enum class FunctionBody { Normal, SingleExpression };
33
34 enum class ParseFunctionFlags {
35 kIsNormal = 0,
36 kIsGenerator = 1,
37 kIsAsync = 2,
38 kIsDefault = 4
39 };
40
41 static inline ParseFunctionFlags operator|(ParseFunctionFlags lhs,
42 ParseFunctionFlags rhs) {
43 typedef unsigned char T;
44 return static_cast<ParseFunctionFlags>(static_cast<T>(lhs) |
45 static_cast<T>(rhs));
46 }
47
48 static inline ParseFunctionFlags& operator|=(ParseFunctionFlags& lhs,
49 const ParseFunctionFlags& rhs) {
50 lhs = lhs | rhs;
51 return lhs;
52 }
53
54 static inline bool operator&(ParseFunctionFlags bitfield,
55 ParseFunctionFlags mask) {
56 typedef unsigned char T;
57 return static_cast<T>(bitfield) & static_cast<T>(mask);
58 }
59
60 enum class MethodKind {
61 Normal = 0,
62 Static = 1 << 0,
63 Generator = 1 << 1,
64 StaticGenerator = Static | Generator,
65 Async = 1 << 2,
66 StaticAsync = Static | Async,
67
68 /* Any non-ordinary method kinds */
69 SpecialMask = Generator | Async
70 };
71
72 inline bool IsValidMethodKind(MethodKind kind) {
73 return kind == MethodKind::Normal || kind == MethodKind::Static ||
74 kind == MethodKind::Generator || kind == MethodKind::StaticGenerator ||
75 kind == MethodKind::Async || kind == MethodKind::StaticAsync;
76 }
77
78 static inline MethodKind operator|(MethodKind lhs, MethodKind rhs) {
79 typedef unsigned char T;
80 return static_cast<MethodKind>(static_cast<T>(lhs) | static_cast<T>(rhs));
81 }
82
83 static inline MethodKind& operator|=(MethodKind& lhs, const MethodKind& rhs) {
84 lhs = lhs | rhs;
85 DCHECK(IsValidMethodKind(lhs));
86 return lhs;
87 }
88
89 static inline bool operator&(MethodKind bitfield, MethodKind mask) {
90 typedef unsigned char T;
91 return static_cast<T>(bitfield) & static_cast<T>(mask);
92 }
93
94 inline bool IsNormalMethod(MethodKind kind) {
95 return kind == MethodKind::Normal;
96 }
97
98 inline bool IsSpecialMethod(MethodKind kind) {
99 return kind & MethodKind::SpecialMask;
100 }
101
102 inline bool IsStaticMethod(MethodKind kind) {
103 return kind & MethodKind::Static;
104 }
105
106 inline bool IsGeneratorMethod(MethodKind kind) {
107 return kind & MethodKind::Generator;
108 }
109
110 inline bool IsAsyncMethod(MethodKind kind) { return kind & MethodKind::Async; }
111
32 struct FormalParametersBase { 112 struct FormalParametersBase {
33 explicit FormalParametersBase(Scope* scope) : scope(scope) {} 113 explicit FormalParametersBase(Scope* scope) : scope(scope) {}
34 Scope* scope; 114 Scope* scope;
35 bool has_rest = false; 115 bool has_rest = false;
36 bool is_simple = true; 116 bool is_simple = true;
37 int materialized_literals_count = 0; 117 int materialized_literals_count = 0;
38 }; 118 };
39 119
40 120
41 // Common base class shared between parser and pre-parser. Traits encapsulate 121 // Common base class shared between parser and pre-parser. Traits encapsulate
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 zone_(zone), 190 zone_(zone),
111 scanner_(scanner), 191 scanner_(scanner),
112 stack_overflow_(false), 192 stack_overflow_(false),
113 allow_lazy_(false), 193 allow_lazy_(false),
114 allow_natives_(false), 194 allow_natives_(false),
115 allow_tailcalls_(false), 195 allow_tailcalls_(false),
116 allow_harmony_restrictive_declarations_(false), 196 allow_harmony_restrictive_declarations_(false),
117 allow_harmony_do_expressions_(false), 197 allow_harmony_do_expressions_(false),
118 allow_harmony_for_in_(false), 198 allow_harmony_for_in_(false),
119 allow_harmony_function_name_(false), 199 allow_harmony_function_name_(false),
120 allow_harmony_function_sent_(false) {} 200 allow_harmony_function_sent_(false),
201 allow_harmony_async_await_(false) {}
121 202
122 #define ALLOW_ACCESSORS(name) \ 203 #define ALLOW_ACCESSORS(name) \
123 bool allow_##name() const { return allow_##name##_; } \ 204 bool allow_##name() const { return allow_##name##_; } \
124 void set_allow_##name(bool allow) { allow_##name##_ = allow; } 205 void set_allow_##name(bool allow) { allow_##name##_ = allow; }
125 206
126 #define SCANNER_ACCESSORS(name) \ 207 #define SCANNER_ACCESSORS(name) \
127 bool allow_##name() const { return scanner_->allow_##name(); } \ 208 bool allow_##name() const { return scanner_->allow_##name(); } \
128 void set_allow_##name(bool allow) { \ 209 void set_allow_##name(bool allow) { \
129 return scanner_->set_allow_##name(allow); \ 210 return scanner_->set_allow_##name(allow); \
130 } 211 }
131 212
132 ALLOW_ACCESSORS(lazy); 213 ALLOW_ACCESSORS(lazy);
133 ALLOW_ACCESSORS(natives); 214 ALLOW_ACCESSORS(natives);
134 ALLOW_ACCESSORS(tailcalls); 215 ALLOW_ACCESSORS(tailcalls);
135 ALLOW_ACCESSORS(harmony_restrictive_declarations); 216 ALLOW_ACCESSORS(harmony_restrictive_declarations);
136 ALLOW_ACCESSORS(harmony_do_expressions); 217 ALLOW_ACCESSORS(harmony_do_expressions);
137 ALLOW_ACCESSORS(harmony_for_in); 218 ALLOW_ACCESSORS(harmony_for_in);
138 ALLOW_ACCESSORS(harmony_function_name); 219 ALLOW_ACCESSORS(harmony_function_name);
139 ALLOW_ACCESSORS(harmony_function_sent); 220 ALLOW_ACCESSORS(harmony_function_sent);
221 ALLOW_ACCESSORS(harmony_async_await);
140 SCANNER_ACCESSORS(harmony_exponentiation_operator); 222 SCANNER_ACCESSORS(harmony_exponentiation_operator);
141 223
142 #undef SCANNER_ACCESSORS 224 #undef SCANNER_ACCESSORS
143 #undef ALLOW_ACCESSORS 225 #undef ALLOW_ACCESSORS
144 226
145 uintptr_t stack_limit() const { return stack_limit_; } 227 uintptr_t stack_limit() const { return stack_limit_; }
146 228
147 protected: 229 protected:
148 enum AllowRestrictedIdentifiers { 230 enum AllowRestrictedIdentifiers {
149 kAllowRestrictedIdentifiers, 231 kAllowRestrictedIdentifiers,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 this_location_ = location; 359 this_location_ = location;
278 } 360 }
279 void set_super_location(Scanner::Location location) { 361 void set_super_location(Scanner::Location location) {
280 super_location_ = location; 362 super_location_ = location;
281 } 363 }
282 void set_return_location(Scanner::Location location) { 364 void set_return_location(Scanner::Location location) {
283 return_location_ = location; 365 return_location_ = location;
284 } 366 }
285 367
286 bool is_generator() const { return IsGeneratorFunction(kind_); } 368 bool is_generator() const { return IsGeneratorFunction(kind_); }
369 bool is_async_function() const { return IsAsyncFunction(kind_); }
370 bool is_resumable() const { return is_generator() || is_async_function(); }
287 371
288 FunctionKind kind() const { return kind_; } 372 FunctionKind kind() const { return kind_; }
289 FunctionState* outer() const { return outer_function_state_; } 373 FunctionState* outer() const { return outer_function_state_; }
290 374
291 void set_generator_object_variable( 375 void set_generator_object_variable(
292 typename Traits::Type::GeneratorVariable* variable) { 376 typename Traits::Type::GeneratorVariable* variable) {
293 DCHECK(variable != NULL); 377 DCHECK(variable != NULL);
294 DCHECK(is_generator()); 378 DCHECK(is_resumable());
295 generator_object_variable_ = variable; 379 generator_object_variable_ = variable;
296 } 380 }
297 typename Traits::Type::GeneratorVariable* generator_object_variable() 381 typename Traits::Type::GeneratorVariable* generator_object_variable()
298 const { 382 const {
299 return generator_object_variable_; 383 return generator_object_variable_;
300 } 384 }
301 385
302 typename Traits::Type::Factory* factory() { return factory_; } 386 typename Traits::Type::Factory* factory() { return factory_; }
303 387
304 const List<DestructuringAssignment>& destructuring_assignments_to_rewrite() 388 const List<DestructuringAssignment>& destructuring_assignments_to_rewrite()
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 if (scanner()->HasAnyLineTerminatorBeforeNext() || 653 if (scanner()->HasAnyLineTerminatorBeforeNext() ||
570 tok == Token::RBRACE || 654 tok == Token::RBRACE ||
571 tok == Token::EOS) { 655 tok == Token::EOS) {
572 return; 656 return;
573 } 657 }
574 Expect(Token::SEMICOLON, ok); 658 Expect(Token::SEMICOLON, ok);
575 } 659 }
576 660
577 bool peek_any_identifier() { 661 bool peek_any_identifier() {
578 Token::Value next = peek(); 662 Token::Value next = peek();
579 return next == Token::IDENTIFIER || next == Token::AWAIT || 663 return next == Token::IDENTIFIER || next == Token::ENUM ||
580 next == Token::ENUM || next == Token::FUTURE_STRICT_RESERVED_WORD || 664 next == Token::AWAIT || next == Token::ASYNC ||
581 next == Token::LET || next == Token::STATIC || next == Token::YIELD; 665 next == Token::FUTURE_STRICT_RESERVED_WORD || next == Token::LET ||
666 next == Token::STATIC || next == Token::YIELD;
582 } 667 }
583 668
584 bool CheckContextualKeyword(Vector<const char> keyword) { 669 bool CheckContextualKeyword(Vector<const char> keyword) {
585 if (PeekContextualKeyword(keyword)) { 670 if (PeekContextualKeyword(keyword)) {
586 Consume(Token::IDENTIFIER); 671 Consume(Token::IDENTIFIER);
587 return true; 672 return true;
588 } 673 }
589 return false; 674 return false;
590 } 675 }
591 676
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 return 0; // 0 precedence will terminate binary expression parsing 762 return 0; // 0 precedence will terminate binary expression parsing
678 return Token::Precedence(token); 763 return Token::Precedence(token);
679 } 764 }
680 765
681 typename Traits::Type::Factory* factory() { 766 typename Traits::Type::Factory* factory() {
682 return function_state_->factory(); 767 return function_state_->factory();
683 } 768 }
684 769
685 LanguageMode language_mode() { return scope_->language_mode(); } 770 LanguageMode language_mode() { return scope_->language_mode(); }
686 bool is_generator() const { return function_state_->is_generator(); } 771 bool is_generator() const { return function_state_->is_generator(); }
772 bool is_async_function() const {
773 return function_state_->is_async_function();
774 }
775 bool is_resumable() const { return function_state_->is_resumable(); }
687 776
688 // Report syntax errors. 777 // Report syntax errors.
689 void ReportMessage(MessageTemplate::Template message, const char* arg = NULL, 778 void ReportMessage(MessageTemplate::Template message, const char* arg = NULL,
690 ParseErrorType error_type = kSyntaxError) { 779 ParseErrorType error_type = kSyntaxError) {
691 Scanner::Location source_location = scanner()->location(); 780 Scanner::Location source_location = scanner()->location();
692 Traits::ReportMessageAt(source_location, message, arg, error_type); 781 Traits::ReportMessageAt(source_location, message, arg, error_type);
693 } 782 }
694 783
695 void ReportMessageAt(Scanner::Location location, 784 void ReportMessageAt(Scanner::Location location,
696 MessageTemplate::Template message, 785 MessageTemplate::Template message,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 void ValidateFormalParameterInitializer( 822 void ValidateFormalParameterInitializer(
734 const ExpressionClassifier* classifier, bool* ok) { 823 const ExpressionClassifier* classifier, bool* ok) {
735 if (!classifier->is_valid_formal_parameter_initializer()) { 824 if (!classifier->is_valid_formal_parameter_initializer()) {
736 ReportClassifierError(classifier->formal_parameter_initializer_error()); 825 ReportClassifierError(classifier->formal_parameter_initializer_error());
737 *ok = false; 826 *ok = false;
738 } 827 }
739 } 828 }
740 829
741 void ValidateBindingPattern(const ExpressionClassifier* classifier, 830 void ValidateBindingPattern(const ExpressionClassifier* classifier,
742 bool* ok) { 831 bool* ok) {
743 if (!classifier->is_valid_binding_pattern()) { 832 if (!classifier->is_valid_binding_pattern() ||
744 ReportClassifierError(classifier->binding_pattern_error()); 833 !classifier->is_valid_async_binding_pattern()) {
834 const Scanner::Location& a = classifier->binding_pattern_error().location;
835 const Scanner::Location& b =
836 classifier->async_binding_pattern_error().location;
837 if (a.beg_pos < 0 || (b.beg_pos >= 0 && a.beg_pos > b.beg_pos)) {
838 ReportClassifierError(classifier->async_binding_pattern_error());
839 } else {
840 ReportClassifierError(classifier->binding_pattern_error());
841 }
745 *ok = false; 842 *ok = false;
746 } 843 }
747 } 844 }
748 845
749 void ValidateAssignmentPattern(const ExpressionClassifier* classifier, 846 void ValidateAssignmentPattern(const ExpressionClassifier* classifier,
750 bool* ok) { 847 bool* ok) {
751 if (!classifier->is_valid_assignment_pattern()) { 848 if (!classifier->is_valid_assignment_pattern()) {
752 ReportClassifierError(classifier->assignment_pattern_error()); 849 ReportClassifierError(classifier->assignment_pattern_error());
753 *ok = false; 850 *ok = false;
754 } 851 }
755 } 852 }
756 853
757 void ValidateFormalParameters(const ExpressionClassifier* classifier, 854 void ValidateFormalParameters(const ExpressionClassifier* classifier,
758 LanguageMode language_mode, 855 LanguageMode language_mode,
759 bool allow_duplicates, bool* ok) { 856 bool allow_duplicates, bool* ok) {
760 if (!allow_duplicates && 857 if (!allow_duplicates &&
761 !classifier->is_valid_formal_parameter_list_without_duplicates()) { 858 !classifier->is_valid_formal_parameter_list_without_duplicates()) {
762 ReportClassifierError(classifier->duplicate_formal_parameter_error()); 859 ReportClassifierError(classifier->duplicate_formal_parameter_error());
763 *ok = false; 860 *ok = false;
764 } else if (is_strict(language_mode) && 861 } else if (is_strict(language_mode) &&
765 !classifier->is_valid_strict_mode_formal_parameters()) { 862 !classifier->is_valid_strict_mode_formal_parameters()) {
766 ReportClassifierError(classifier->strict_mode_formal_parameter_error()); 863 ReportClassifierError(classifier->strict_mode_formal_parameter_error());
767 *ok = false; 864 *ok = false;
768 } 865 }
769 } 866 }
770 867
771 void ValidateArrowFormalParameters(const ExpressionClassifier* classifier, 868 void ValidateArrowFormalParameters(const ExpressionClassifier* classifier,
772 ExpressionT expr, 869 ExpressionT expr,
773 bool parenthesized_formals, bool* ok) { 870 bool parenthesized_formals, bool is_async,
871 bool* ok) {
774 if (classifier->is_valid_binding_pattern()) { 872 if (classifier->is_valid_binding_pattern()) {
775 // A simple arrow formal parameter: IDENTIFIER => BODY. 873 // A simple arrow formal parameter: IDENTIFIER => BODY.
776 if (!this->IsIdentifier(expr)) { 874 if (!this->IsIdentifier(expr)) {
777 Traits::ReportMessageAt(scanner()->location(), 875 Traits::ReportMessageAt(scanner()->location(),
778 MessageTemplate::kUnexpectedToken, 876 MessageTemplate::kUnexpectedToken,
779 Token::String(scanner()->current_token())); 877 Token::String(scanner()->current_token()));
780 *ok = false; 878 *ok = false;
781 } 879 }
782 } else if (!classifier->is_valid_arrow_formal_parameters()) { 880 } else if (!classifier->is_valid_arrow_formal_parameters()) {
783 // If after parsing the expr, we see an error but the expression is 881 // If after parsing the expr, we see an error but the expression is
784 // neither a valid binding pattern nor a valid parenthesized formal 882 // neither a valid binding pattern nor a valid parenthesized formal
785 // parameter list, show the "arrow formal parameters" error if the formals 883 // parameter list, show the "arrow formal parameters" error if the formals
786 // started with a parenthesis, and the binding pattern error otherwise. 884 // started with a parenthesis, and the binding pattern error otherwise.
787 const typename ExpressionClassifier::Error& error = 885 const typename ExpressionClassifier::Error& error =
788 parenthesized_formals ? classifier->arrow_formal_parameters_error() 886 parenthesized_formals ? classifier->arrow_formal_parameters_error()
789 : classifier->binding_pattern_error(); 887 : classifier->binding_pattern_error();
790 ReportClassifierError(error); 888 ReportClassifierError(error);
791 *ok = false; 889 *ok = false;
792 } 890 }
891 if (is_async && !classifier->is_valid_async_arrow_formal_parameters()) {
892 const typename ExpressionClassifier::Error& error =
893 classifier->async_arrow_formal_parameters_error();
894 ReportClassifierError(error);
895 *ok = false;
896 }
793 } 897 }
794 898
795 void ValidateLetPattern(const ExpressionClassifier* classifier, bool* ok) { 899 void ValidateLetPattern(const ExpressionClassifier* classifier, bool* ok) {
796 if (!classifier->is_valid_let_pattern()) { 900 if (!classifier->is_valid_let_pattern()) {
797 ReportClassifierError(classifier->let_pattern_error()); 901 ReportClassifierError(classifier->let_pattern_error());
798 *ok = false; 902 *ok = false;
799 } 903 }
800 } 904 }
801 905
802 void CheckNoTailCallExpressions(const ExpressionClassifier* classifier, 906 void CheckNoTailCallExpressions(const ExpressionClassifier* classifier,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 return ParseIdentifierOrStrictReservedWord(this->is_generator(), 960 return ParseIdentifierOrStrictReservedWord(this->is_generator(),
857 is_strict_reserved, ok); 961 is_strict_reserved, ok);
858 } 962 }
859 963
860 IdentifierT ParseIdentifierName(bool* ok); 964 IdentifierT ParseIdentifierName(bool* ok);
861 965
862 ExpressionT ParseRegExpLiteral(bool seen_equal, 966 ExpressionT ParseRegExpLiteral(bool seen_equal,
863 ExpressionClassifier* classifier, bool* ok); 967 ExpressionClassifier* classifier, bool* ok);
864 968
865 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier, 969 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier,
866 bool* ok); 970 bool* is_async, bool* ok);
971 ExpressionT ParsePrimaryExpression(ExpressionClassifier* classifier,
972 bool* ok) {
973 bool is_async;
974 return ParsePrimaryExpression(classifier, &is_async, ok);
975 }
867 ExpressionT ParseExpression(bool accept_IN, bool* ok); 976 ExpressionT ParseExpression(bool accept_IN, bool* ok);
868 ExpressionT ParseExpression(bool accept_IN, ExpressionClassifier* classifier, 977 ExpressionT ParseExpression(bool accept_IN, ExpressionClassifier* classifier,
869 bool* ok); 978 bool* ok);
870 ExpressionT ParseArrayLiteral(ExpressionClassifier* classifier, bool* ok); 979 ExpressionT ParseArrayLiteral(ExpressionClassifier* classifier, bool* ok);
871 ExpressionT ParsePropertyName(IdentifierT* name, bool* is_get, bool* is_set, 980 ExpressionT ParsePropertyName(IdentifierT* name, bool* is_get, bool* is_set,
872 bool* is_computed_name, 981 bool* is_await, bool* is_computed_name,
873 ExpressionClassifier* classifier, bool* ok); 982 ExpressionClassifier* classifier, bool* ok);
874 ExpressionT ParseObjectLiteral(ExpressionClassifier* classifier, bool* ok); 983 ExpressionT ParseObjectLiteral(ExpressionClassifier* classifier, bool* ok);
875 ObjectLiteralPropertyT ParsePropertyDefinition( 984 ObjectLiteralPropertyT ParsePropertyDefinition(
876 ObjectLiteralCheckerBase* checker, bool in_class, bool has_extends, 985 ObjectLiteralCheckerBase* checker, bool in_class, bool has_extends,
877 bool is_static, bool* is_computed_name, bool* has_seen_constructor, 986 MethodKind kind, bool* is_computed_name, bool* has_seen_constructor,
878 ExpressionClassifier* classifier, IdentifierT* name, bool* ok); 987 ExpressionClassifier* classifier, IdentifierT* name, bool* ok);
879 typename Traits::Type::ExpressionList ParseArguments( 988 typename Traits::Type::ExpressionList ParseArguments(
989 Scanner::Location* first_spread_pos, bool maybe_arrow,
990 ExpressionClassifier* classifier, bool* ok);
991 typename Traits::Type::ExpressionList ParseArguments(
880 Scanner::Location* first_spread_pos, ExpressionClassifier* classifier, 992 Scanner::Location* first_spread_pos, ExpressionClassifier* classifier,
881 bool* ok); 993 bool* ok) {
994 return ParseArguments(first_spread_pos, false, classifier, ok);
995 }
882 996
883 ExpressionT ParseAssignmentExpression(bool accept_IN, 997 ExpressionT ParseAssignmentExpression(bool accept_IN,
884 ExpressionClassifier* classifier, 998 ExpressionClassifier* classifier,
885 bool* ok); 999 bool* ok);
886 ExpressionT ParseYieldExpression(bool accept_IN, 1000 ExpressionT ParseYieldExpression(bool accept_IN,
887 ExpressionClassifier* classifier, bool* ok); 1001 ExpressionClassifier* classifier, bool* ok);
888 ExpressionT ParseTailCallExpression(ExpressionClassifier* classifier, 1002 ExpressionT ParseTailCallExpression(ExpressionClassifier* classifier,
889 bool* ok); 1003 bool* ok);
890 ExpressionT ParseConditionalExpression(bool accept_IN, 1004 ExpressionT ParseConditionalExpression(bool accept_IN,
891 ExpressionClassifier* classifier, 1005 ExpressionClassifier* classifier,
892 bool* ok); 1006 bool* ok);
893 ExpressionT ParseBinaryExpression(int prec, bool accept_IN, 1007 ExpressionT ParseBinaryExpression(int prec, bool accept_IN,
894 ExpressionClassifier* classifier, bool* ok); 1008 ExpressionClassifier* classifier, bool* ok);
895 ExpressionT ParseUnaryExpression(ExpressionClassifier* classifier, bool* ok); 1009 ExpressionT ParseUnaryExpression(ExpressionClassifier* classifier, bool* ok);
896 ExpressionT ParsePostfixExpression(ExpressionClassifier* classifier, 1010 ExpressionT ParsePostfixExpression(ExpressionClassifier* classifier,
897 bool* ok); 1011 bool* ok);
898 ExpressionT ParseLeftHandSideExpression(ExpressionClassifier* classifier, 1012 ExpressionT ParseLeftHandSideExpression(ExpressionClassifier* classifier,
899 bool* ok); 1013 bool* ok);
900 ExpressionT ParseMemberWithNewPrefixesExpression( 1014 ExpressionT ParseMemberWithNewPrefixesExpression(
901 ExpressionClassifier* classifier, bool* ok); 1015 ExpressionClassifier* classifier, bool* is_async, bool* ok);
902 ExpressionT ParseMemberExpression(ExpressionClassifier* classifier, bool* ok); 1016 ExpressionT ParseMemberExpression(ExpressionClassifier* classifier,
1017 bool* is_async, bool* ok);
903 ExpressionT ParseMemberExpressionContinuation( 1018 ExpressionT ParseMemberExpressionContinuation(
904 ExpressionT expression, ExpressionClassifier* classifier, bool* ok); 1019 ExpressionT expression, bool* is_async, ExpressionClassifier* classifier,
1020 bool* ok);
905 ExpressionT ParseArrowFunctionLiteral(bool accept_IN, 1021 ExpressionT ParseArrowFunctionLiteral(bool accept_IN,
906 const FormalParametersT& parameters, 1022 const FormalParametersT& parameters,
1023 bool is_async,
907 const ExpressionClassifier& classifier, 1024 const ExpressionClassifier& classifier,
908 bool* ok); 1025 bool* ok);
909 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, 1026 ExpressionT ParseTemplateLiteral(ExpressionT tag, int start,
910 ExpressionClassifier* classifier, bool* ok); 1027 ExpressionClassifier* classifier, bool* ok);
911 void AddTemplateExpression(ExpressionT); 1028 void AddTemplateExpression(ExpressionT);
912 ExpressionT ParseSuperExpression(bool is_new, 1029 ExpressionT ParseSuperExpression(bool is_new,
913 ExpressionClassifier* classifier, bool* ok); 1030 ExpressionClassifier* classifier, bool* ok);
914 ExpressionT ParseNewTargetExpression(bool* ok); 1031 ExpressionT ParseNewTargetExpression(bool* ok);
915 1032
916 void ParseFormalParameter(FormalParametersT* parameters, 1033 void ParseFormalParameter(FormalParametersT* parameters,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 kAccessorProperty, 1085 kAccessorProperty,
969 kValueProperty, 1086 kValueProperty,
970 kMethodProperty 1087 kMethodProperty
971 }; 1088 };
972 1089
973 class ObjectLiteralCheckerBase { 1090 class ObjectLiteralCheckerBase {
974 public: 1091 public:
975 explicit ObjectLiteralCheckerBase(ParserBase* parser) : parser_(parser) {} 1092 explicit ObjectLiteralCheckerBase(ParserBase* parser) : parser_(parser) {}
976 1093
977 virtual void CheckProperty(Token::Value property, PropertyKind type, 1094 virtual void CheckProperty(Token::Value property, PropertyKind type,
978 bool is_static, bool is_generator, bool* ok) = 0; 1095 MethodKind method_type, bool* ok) = 0;
979 1096
980 virtual ~ObjectLiteralCheckerBase() {} 1097 virtual ~ObjectLiteralCheckerBase() {}
981 1098
982 protected: 1099 protected:
983 ParserBase* parser() const { return parser_; } 1100 ParserBase* parser() const { return parser_; }
984 Scanner* scanner() const { return parser_->scanner(); } 1101 Scanner* scanner() const { return parser_->scanner(); }
985 1102
986 private: 1103 private:
987 ParserBase* parser_; 1104 ParserBase* parser_;
988 }; 1105 };
989 1106
990 // Validation per ES6 object literals. 1107 // Validation per ES6 object literals.
991 class ObjectLiteralChecker : public ObjectLiteralCheckerBase { 1108 class ObjectLiteralChecker : public ObjectLiteralCheckerBase {
992 public: 1109 public:
993 explicit ObjectLiteralChecker(ParserBase* parser) 1110 explicit ObjectLiteralChecker(ParserBase* parser)
994 : ObjectLiteralCheckerBase(parser), has_seen_proto_(false) {} 1111 : ObjectLiteralCheckerBase(parser), has_seen_proto_(false) {}
995 1112
996 void CheckProperty(Token::Value property, PropertyKind type, bool is_static, 1113 void CheckProperty(Token::Value property, PropertyKind type,
997 bool is_generator, bool* ok) override; 1114 MethodKind method_type, bool* ok) override;
998 1115
999 private: 1116 private:
1000 bool IsProto() { return this->scanner()->LiteralMatches("__proto__", 9); } 1117 bool IsProto() { return this->scanner()->LiteralMatches("__proto__", 9); }
1001 1118
1002 bool has_seen_proto_; 1119 bool has_seen_proto_;
1003 }; 1120 };
1004 1121
1005 // Validation per ES6 class literals. 1122 // Validation per ES6 class literals.
1006 class ClassLiteralChecker : public ObjectLiteralCheckerBase { 1123 class ClassLiteralChecker : public ObjectLiteralCheckerBase {
1007 public: 1124 public:
1008 explicit ClassLiteralChecker(ParserBase* parser) 1125 explicit ClassLiteralChecker(ParserBase* parser)
1009 : ObjectLiteralCheckerBase(parser), has_seen_constructor_(false) {} 1126 : ObjectLiteralCheckerBase(parser), has_seen_constructor_(false) {}
1010 1127
1011 void CheckProperty(Token::Value property, PropertyKind type, bool is_static, 1128 void CheckProperty(Token::Value property, PropertyKind type,
1012 bool is_generator, bool* ok) override; 1129 MethodKind method_type, bool* ok) override;
1013 1130
1014 private: 1131 private:
1015 bool IsConstructor() { 1132 bool IsConstructor() {
1016 return this->scanner()->LiteralMatches("constructor", 11); 1133 return this->scanner()->LiteralMatches("constructor", 11);
1017 } 1134 }
1018 bool IsPrototype() { 1135 bool IsPrototype() {
1019 return this->scanner()->LiteralMatches("prototype", 9); 1136 return this->scanner()->LiteralMatches("prototype", 9);
1020 } 1137 }
1021 1138
1022 bool has_seen_constructor_; 1139 bool has_seen_constructor_;
(...skipping 16 matching lines...) Expand all
1039 bool stack_overflow_; 1156 bool stack_overflow_;
1040 1157
1041 bool allow_lazy_; 1158 bool allow_lazy_;
1042 bool allow_natives_; 1159 bool allow_natives_;
1043 bool allow_tailcalls_; 1160 bool allow_tailcalls_;
1044 bool allow_harmony_restrictive_declarations_; 1161 bool allow_harmony_restrictive_declarations_;
1045 bool allow_harmony_do_expressions_; 1162 bool allow_harmony_do_expressions_;
1046 bool allow_harmony_for_in_; 1163 bool allow_harmony_for_in_;
1047 bool allow_harmony_function_name_; 1164 bool allow_harmony_function_name_;
1048 bool allow_harmony_function_sent_; 1165 bool allow_harmony_function_sent_;
1166 bool allow_harmony_async_await_;
1049 }; 1167 };
1050 1168
1051 template <class Traits> 1169 template <class Traits>
1052 ParserBase<Traits>::FunctionState::FunctionState( 1170 ParserBase<Traits>::FunctionState::FunctionState(
1053 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope, 1171 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope,
1054 FunctionKind kind, typename Traits::Type::Factory* factory) 1172 FunctionKind kind, typename Traits::Type::Factory* factory)
1055 : next_materialized_literal_index_(0), 1173 : next_materialized_literal_index_(0),
1056 expected_property_count_(0), 1174 expected_property_count_(0),
1057 this_location_(Scanner::Location::invalid()), 1175 this_location_(Scanner::Location::invalid()),
1058 return_location_(Scanner::Location::invalid()), 1176 return_location_(Scanner::Location::invalid()),
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 1292
1175 return result; 1293 return result;
1176 } 1294 }
1177 1295
1178 1296
1179 template <class Traits> 1297 template <class Traits>
1180 typename ParserBase<Traits>::IdentifierT 1298 typename ParserBase<Traits>::IdentifierT
1181 ParserBase<Traits>::ParseAndClassifyIdentifier(ExpressionClassifier* classifier, 1299 ParserBase<Traits>::ParseAndClassifyIdentifier(ExpressionClassifier* classifier,
1182 bool* ok) { 1300 bool* ok) {
1183 Token::Value next = Next(); 1301 Token::Value next = Next();
1184 if (next == Token::IDENTIFIER || (next == Token::AWAIT && !parsing_module_)) { 1302 if (next == Token::IDENTIFIER || next == Token::ASYNC ||
1303 (next == Token::AWAIT && !parsing_module_)) {
1185 IdentifierT name = this->GetSymbol(scanner()); 1304 IdentifierT name = this->GetSymbol(scanner());
1186 // When this function is used to read a formal parameter, we don't always 1305 // When this function is used to read a formal parameter, we don't always
1187 // know whether the function is going to be strict or sloppy. Indeed for 1306 // know whether the function is going to be strict or sloppy. Indeed for
1188 // arrow functions we don't always know that the identifier we are reading 1307 // arrow functions we don't always know that the identifier we are reading
1189 // is actually a formal parameter. Therefore besides the errors that we 1308 // is actually a formal parameter. Therefore besides the errors that we
1190 // must detect because we know we're in strict mode, we also record any 1309 // must detect because we know we're in strict mode, we also record any
1191 // error that we might make in the future once we know the language mode. 1310 // error that we might make in the future once we know the language mode.
1192 if (this->IsEval(name)) { 1311 if (this->IsEval(name)) {
1193 classifier->RecordStrictModeFormalParameterError( 1312 classifier->RecordStrictModeFormalParameterError(
1194 scanner()->location(), MessageTemplate::kStrictEvalArguments); 1313 scanner()->location(), MessageTemplate::kStrictEvalArguments);
1195 if (is_strict(language_mode())) { 1314 if (is_strict(language_mode())) {
1196 classifier->RecordBindingPatternError( 1315 classifier->RecordBindingPatternError(
1197 scanner()->location(), MessageTemplate::kStrictEvalArguments); 1316 scanner()->location(), MessageTemplate::kStrictEvalArguments);
1198 } 1317 }
1199 } 1318 }
1200 if (this->IsArguments(name)) { 1319 if (this->IsArguments(name)) {
1201 scope_->RecordArgumentsUsage(); 1320 scope_->RecordArgumentsUsage();
1202 classifier->RecordStrictModeFormalParameterError( 1321 classifier->RecordStrictModeFormalParameterError(
1203 scanner()->location(), MessageTemplate::kStrictEvalArguments); 1322 scanner()->location(), MessageTemplate::kStrictEvalArguments);
1204 if (is_strict(language_mode())) { 1323 if (is_strict(language_mode())) {
1205 classifier->RecordBindingPatternError( 1324 classifier->RecordBindingPatternError(
1206 scanner()->location(), MessageTemplate::kStrictEvalArguments); 1325 scanner()->location(), MessageTemplate::kStrictEvalArguments);
1207 } 1326 }
1208 } 1327 }
1328 if (this->IsAwait(name)) {
1329 if (is_async_function()) {
1330 classifier->RecordPatternError(
1331 scanner()->location(), MessageTemplate::kAwaitBindingIdentifier);
1332 }
1333 classifier->RecordAsyncArrowFormalParametersError(
1334 scanner()->location(), MessageTemplate::kAwaitBindingIdentifier);
1335 }
1209 1336
1210 if (classifier->duplicate_finder() != nullptr && 1337 if (classifier->duplicate_finder() != nullptr &&
1211 scanner()->FindSymbol(classifier->duplicate_finder(), 1) != 0) { 1338 scanner()->FindSymbol(classifier->duplicate_finder(), 1) != 0) {
1212 classifier->RecordDuplicateFormalParameterError(scanner()->location()); 1339 classifier->RecordDuplicateFormalParameterError(scanner()->location());
1213 } 1340 }
1214 return name; 1341 return name;
1215 } else if (is_sloppy(language_mode()) && 1342 } else if (is_sloppy(language_mode()) &&
1216 (next == Token::FUTURE_STRICT_RESERVED_WORD || 1343 (next == Token::FUTURE_STRICT_RESERVED_WORD ||
1217 next == Token::ESCAPED_STRICT_RESERVED_WORD || 1344 next == Token::ESCAPED_STRICT_RESERVED_WORD ||
1218 next == Token::LET || next == Token::STATIC || 1345 next == Token::LET || next == Token::STATIC ||
(...skipping 19 matching lines...) Expand all
1238 return Traits::EmptyIdentifier(); 1365 return Traits::EmptyIdentifier();
1239 } 1366 }
1240 } 1367 }
1241 1368
1242 1369
1243 template <class Traits> 1370 template <class Traits>
1244 typename ParserBase<Traits>::IdentifierT 1371 typename ParserBase<Traits>::IdentifierT
1245 ParserBase<Traits>::ParseIdentifierOrStrictReservedWord( 1372 ParserBase<Traits>::ParseIdentifierOrStrictReservedWord(
1246 bool is_generator, bool* is_strict_reserved, bool* ok) { 1373 bool is_generator, bool* is_strict_reserved, bool* ok) {
1247 Token::Value next = Next(); 1374 Token::Value next = Next();
1248 if (next == Token::IDENTIFIER || (next == Token::AWAIT && !parsing_module_)) { 1375 if (next == Token::IDENTIFIER || (next == Token::AWAIT && !parsing_module_) ||
1376 next == Token::ASYNC) {
1249 *is_strict_reserved = false; 1377 *is_strict_reserved = false;
1250 } else if (next == Token::FUTURE_STRICT_RESERVED_WORD || next == Token::LET || 1378 } else if (next == Token::FUTURE_STRICT_RESERVED_WORD || next == Token::LET ||
1251 next == Token::STATIC || (next == Token::YIELD && !is_generator)) { 1379 next == Token::STATIC || (next == Token::YIELD && !is_generator)) {
1252 *is_strict_reserved = true; 1380 *is_strict_reserved = true;
1253 } else { 1381 } else {
1254 ReportUnexpectedToken(next); 1382 ReportUnexpectedToken(next);
1255 *ok = false; 1383 *ok = false;
1256 return Traits::EmptyIdentifier(); 1384 return Traits::EmptyIdentifier();
1257 } 1385 }
1258 1386
1259 IdentifierT name = this->GetSymbol(scanner()); 1387 IdentifierT name = this->GetSymbol(scanner());
1260 if (this->IsArguments(name)) scope_->RecordArgumentsUsage(); 1388 if (this->IsArguments(name)) scope_->RecordArgumentsUsage();
1261 return name; 1389 return name;
1262 } 1390 }
1263 1391
1264 template <class Traits> 1392 template <class Traits>
1265 typename ParserBase<Traits>::IdentifierT 1393 typename ParserBase<Traits>::IdentifierT
1266 ParserBase<Traits>::ParseIdentifierName(bool* ok) { 1394 ParserBase<Traits>::ParseIdentifierName(bool* ok) {
1267 Token::Value next = Next(); 1395 Token::Value next = Next();
1268 if (next != Token::IDENTIFIER && next != Token::ENUM && 1396 if (next != Token::IDENTIFIER && next != Token::ASYNC &&
1269 next != Token::AWAIT && next != Token::LET && next != Token::STATIC && 1397 next != Token::ENUM && next != Token::AWAIT && next != Token::LET &&
1270 next != Token::YIELD && next != Token::FUTURE_STRICT_RESERVED_WORD && 1398 next != Token::STATIC && next != Token::YIELD &&
1399 next != Token::FUTURE_STRICT_RESERVED_WORD &&
1271 next != Token::ESCAPED_KEYWORD && 1400 next != Token::ESCAPED_KEYWORD &&
1272 next != Token::ESCAPED_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) { 1401 next != Token::ESCAPED_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) {
1273 this->ReportUnexpectedToken(next); 1402 this->ReportUnexpectedToken(next);
1274 *ok = false; 1403 *ok = false;
1275 return Traits::EmptyIdentifier(); 1404 return Traits::EmptyIdentifier();
1276 } 1405 }
1277 1406
1278 IdentifierT name = this->GetSymbol(scanner()); 1407 IdentifierT name = this->GetSymbol(scanner());
1279 if (this->IsArguments(name)) scope_->RecordArgumentsUsage(); 1408 if (this->IsArguments(name)) scope_->RecordArgumentsUsage();
1280 return name; 1409 return name;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 #define DUMMY ) // to make indentation work 1443 #define DUMMY ) // to make indentation work
1315 #undef DUMMY 1444 #undef DUMMY
1316 1445
1317 // Used in functions where the return type is not ExpressionT. 1446 // Used in functions where the return type is not ExpressionT.
1318 #define CHECK_OK_CUSTOM(x) ok); \ 1447 #define CHECK_OK_CUSTOM(x) ok); \
1319 if (!*ok) return this->x(); \ 1448 if (!*ok) return this->x(); \
1320 ((void)0 1449 ((void)0
1321 #define DUMMY ) // to make indentation work 1450 #define DUMMY ) // to make indentation work
1322 #undef DUMMY 1451 #undef DUMMY
1323 1452
1324
1325 template <class Traits> 1453 template <class Traits>
1326 typename ParserBase<Traits>::ExpressionT 1454 typename ParserBase<Traits>::ExpressionT
1327 ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, 1455 ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
1328 bool* ok) { 1456 bool* is_async, bool* ok) {
1329 // PrimaryExpression :: 1457 // PrimaryExpression ::
1330 // 'this' 1458 // 'this'
1331 // 'null' 1459 // 'null'
1332 // 'true' 1460 // 'true'
1333 // 'false' 1461 // 'false'
1334 // Identifier 1462 // Identifier
1335 // Number 1463 // Number
1336 // String 1464 // String
1337 // ArrayLiteral 1465 // ArrayLiteral
1338 // ObjectLiteral 1466 // ObjectLiteral
1339 // RegExpLiteral 1467 // RegExpLiteral
1340 // ClassLiteral 1468 // ClassLiteral
1341 // '(' Expression ')' 1469 // '(' Expression ')'
1342 // TemplateLiteral 1470 // TemplateLiteral
1343 // do Block 1471 // do Block
1472 // AsyncFunctionExpression
1344 1473
1345 int beg_pos = peek_position(); 1474 int beg_pos = peek_position();
1346 switch (peek()) { 1475 switch (peek()) {
1347 case Token::THIS: { 1476 case Token::THIS: {
1348 BindingPatternUnexpectedToken(classifier); 1477 BindingPatternUnexpectedToken(classifier);
1349 Consume(Token::THIS); 1478 Consume(Token::THIS);
1350 return this->ThisExpression(scope_, factory(), beg_pos); 1479 return this->ThisExpression(scope_, factory(), beg_pos);
1351 } 1480 }
1352 1481
1353 case Token::NULL_LITERAL: 1482 case Token::NULL_LITERAL:
1354 case Token::TRUE_LITERAL: 1483 case Token::TRUE_LITERAL:
1355 case Token::FALSE_LITERAL: 1484 case Token::FALSE_LITERAL:
1356 BindingPatternUnexpectedToken(classifier); 1485 BindingPatternUnexpectedToken(classifier);
1357 return this->ExpressionFromLiteral(Next(), beg_pos, scanner(), factory()); 1486 return this->ExpressionFromLiteral(Next(), beg_pos, scanner(), factory());
1358 case Token::SMI: 1487 case Token::SMI:
1359 case Token::NUMBER: 1488 case Token::NUMBER:
1360 BindingPatternUnexpectedToken(classifier); 1489 BindingPatternUnexpectedToken(classifier);
1361 return this->ExpressionFromLiteral(Next(), beg_pos, scanner(), factory()); 1490 return this->ExpressionFromLiteral(Next(), beg_pos, scanner(), factory());
1362 1491
1492 case Token::ASYNC:
1493 if (allow_harmony_async_await() &&
1494 !scanner()->HasAnyLineTerminatorAfterNext() &&
1495 PeekAhead() == Token::FUNCTION) {
1496 Consume(Token::ASYNC);
1497 return this->ParseAsyncFunctionExpression(CHECK_OK);
1498 }
1499 // CoverCallExpressionAndAsyncArrowHead
1500 *is_async = true;
1501 /* falls through */
1363 case Token::IDENTIFIER: 1502 case Token::IDENTIFIER:
1364 case Token::LET: 1503 case Token::LET:
1365 case Token::STATIC: 1504 case Token::STATIC:
1366 case Token::YIELD: 1505 case Token::YIELD:
1367 case Token::AWAIT: 1506 case Token::AWAIT:
1368 case Token::ESCAPED_STRICT_RESERVED_WORD: 1507 case Token::ESCAPED_STRICT_RESERVED_WORD:
1369 case Token::FUTURE_STRICT_RESERVED_WORD: { 1508 case Token::FUTURE_STRICT_RESERVED_WORD: {
1370 // Using eval or arguments in this context is OK even in strict mode. 1509 // Using eval or arguments in this context is OK even in strict mode.
1371 IdentifierT name = ParseAndClassifyIdentifier(classifier, CHECK_OK); 1510 IdentifierT name = ParseAndClassifyIdentifier(classifier, CHECK_OK);
1372 return this->ExpressionFromIdentifier( 1511 return this->ExpressionFromIdentifier(
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 1763
1625 ExpressionT result = factory()->NewArrayLiteral(values, first_spread_index, 1764 ExpressionT result = factory()->NewArrayLiteral(values, first_spread_index,
1626 literal_index, pos); 1765 literal_index, pos);
1627 if (first_spread_index >= 0) { 1766 if (first_spread_index >= 0) {
1628 result = factory()->NewRewritableExpression(result); 1767 result = factory()->NewRewritableExpression(result);
1629 Traits::QueueNonPatternForRewriting(result); 1768 Traits::QueueNonPatternForRewriting(result);
1630 } 1769 }
1631 return result; 1770 return result;
1632 } 1771 }
1633 1772
1634
1635 template <class Traits> 1773 template <class Traits>
1636 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParsePropertyName( 1774 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParsePropertyName(
1637 IdentifierT* name, bool* is_get, bool* is_set, bool* is_computed_name, 1775 IdentifierT* name, bool* is_get, bool* is_set, bool* is_await,
1638 ExpressionClassifier* classifier, bool* ok) { 1776 bool* is_computed_name, ExpressionClassifier* classifier, bool* ok) {
1639 Token::Value token = peek(); 1777 Token::Value token = peek();
1640 int pos = peek_position(); 1778 int pos = peek_position();
1641 1779
1642 // For non computed property names we normalize the name a bit: 1780 // For non computed property names we normalize the name a bit:
1643 // 1781 //
1644 // "12" -> 12 1782 // "12" -> 12
1645 // 12.3 -> "12.3" 1783 // 12.3 -> "12.3"
1646 // 12.30 -> "12.3" 1784 // 12.30 -> "12.3"
1647 // identifier -> "identifier" 1785 // identifier -> "identifier"
1648 // 1786 //
(...skipping 24 matching lines...) Expand all
1673 Traits::RewriteNonPattern(&computed_name_classifier, CHECK_OK); 1811 Traits::RewriteNonPattern(&computed_name_classifier, CHECK_OK);
1674 classifier->Accumulate(&computed_name_classifier, 1812 classifier->Accumulate(&computed_name_classifier,
1675 ExpressionClassifier::ExpressionProductions); 1813 ExpressionClassifier::ExpressionProductions);
1676 Expect(Token::RBRACK, CHECK_OK); 1814 Expect(Token::RBRACK, CHECK_OK);
1677 return expression; 1815 return expression;
1678 } 1816 }
1679 1817
1680 default: 1818 default:
1681 *name = ParseIdentifierName(CHECK_OK); 1819 *name = ParseIdentifierName(CHECK_OK);
1682 scanner()->IsGetOrSet(is_get, is_set); 1820 scanner()->IsGetOrSet(is_get, is_set);
1821 if (this->IsAwait(*name)) {
1822 *is_await = true;
1823 }
1683 break; 1824 break;
1684 } 1825 }
1685 1826
1686 uint32_t index; 1827 uint32_t index;
1687 return this->IsArrayIndex(*name, &index) 1828 return this->IsArrayIndex(*name, &index)
1688 ? factory()->NewNumberLiteral(index, pos) 1829 ? factory()->NewNumberLiteral(index, pos)
1689 : factory()->NewStringLiteral(*name, pos); 1830 : factory()->NewStringLiteral(*name, pos);
1690 } 1831 }
1691 1832
1692
1693 template <class Traits> 1833 template <class Traits>
1694 typename ParserBase<Traits>::ObjectLiteralPropertyT 1834 typename ParserBase<Traits>::ObjectLiteralPropertyT
1695 ParserBase<Traits>::ParsePropertyDefinition( 1835 ParserBase<Traits>::ParsePropertyDefinition(
1696 ObjectLiteralCheckerBase* checker, bool in_class, bool has_extends, 1836 ObjectLiteralCheckerBase* checker, bool in_class, bool has_extends,
1697 bool is_static, bool* is_computed_name, bool* has_seen_constructor, 1837 MethodKind method_kind, bool* is_computed_name, bool* has_seen_constructor,
1698 ExpressionClassifier* classifier, IdentifierT* name, bool* ok) { 1838 ExpressionClassifier* classifier, IdentifierT* name, bool* ok) {
1699 DCHECK(!in_class || is_static || has_seen_constructor != nullptr); 1839 DCHECK(!in_class || IsStaticMethod(method_kind) ||
1840 has_seen_constructor != nullptr);
1700 ExpressionT value = this->EmptyExpression(); 1841 ExpressionT value = this->EmptyExpression();
1701 bool is_get = false; 1842 bool is_get = false;
1702 bool is_set = false; 1843 bool is_set = false;
1844 bool is_await = false;
1703 bool is_generator = Check(Token::MUL); 1845 bool is_generator = Check(Token::MUL);
1846 bool is_async = false;
1847 const bool is_static = IsStaticMethod(method_kind);
1704 1848
1705 Token::Value name_token = peek(); 1849 Token::Value name_token = peek();
1850
1851 if (is_generator) {
1852 method_kind |= MethodKind::Generator;
1853 } else if (allow_harmony_async_await() && name_token == Token::ASYNC &&
1854 !scanner()->HasAnyLineTerminatorAfterNext() &&
1855 PeekAhead() != Token::LPAREN && PeekAhead()) {
1856 is_async = true;
1857 }
1858
1706 int next_beg_pos = scanner()->peek_location().beg_pos; 1859 int next_beg_pos = scanner()->peek_location().beg_pos;
1707 int next_end_pos = scanner()->peek_location().end_pos; 1860 int next_end_pos = scanner()->peek_location().end_pos;
1708 ExpressionT name_expression = 1861 ExpressionT name_expression = ParsePropertyName(
1709 ParsePropertyName(name, &is_get, &is_set, is_computed_name, classifier, 1862 name, &is_get, &is_set, &is_await, is_computed_name, classifier,
1710 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1863 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1711 1864
1712 if (fni_ != nullptr && !*is_computed_name) { 1865 if (fni_ != nullptr && !*is_computed_name) {
1713 this->PushLiteralName(fni_, *name); 1866 this->PushLiteralName(fni_, *name);
1714 } 1867 }
1715 1868
1716 if (!in_class && !is_generator) { 1869 if (!in_class && !is_generator) {
1717 DCHECK(!is_static); 1870 DCHECK(!IsStaticMethod(method_kind));
1718 1871
1719 if (peek() == Token::COLON) { 1872 if (peek() == Token::COLON) {
1720 // PropertyDefinition 1873 // PropertyDefinition
1721 // PropertyName ':' AssignmentExpression 1874 // PropertyName ':' AssignmentExpression
1722 if (!*is_computed_name) { 1875 if (!*is_computed_name) {
1723 checker->CheckProperty(name_token, kValueProperty, false, false, 1876 checker->CheckProperty(name_token, kValueProperty, MethodKind::Normal,
1724 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1877 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1725 } 1878 }
1726 Consume(Token::COLON); 1879 Consume(Token::COLON);
1727 int beg_pos = peek_position(); 1880 int beg_pos = peek_position();
1728 value = this->ParseAssignmentExpression( 1881 value = this->ParseAssignmentExpression(
1729 true, classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1882 true, classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1730 CheckDestructuringElement(value, classifier, beg_pos, 1883 CheckDestructuringElement(value, classifier, beg_pos,
1731 scanner()->location().end_pos); 1884 scanner()->location().end_pos);
1732 1885
1733 return factory()->NewObjectLiteralProperty(name_expression, value, false, 1886 return factory()->NewObjectLiteralProperty(name_expression, value,
1734 *is_computed_name); 1887 is_static, *is_computed_name);
1735 } 1888 }
1736 1889
1737 if (Token::IsIdentifier(name_token, language_mode(), this->is_generator(), 1890 if (Token::IsIdentifier(name_token, language_mode(), this->is_generator(),
1738 parsing_module_) && 1891 parsing_module_) &&
1739 (peek() == Token::COMMA || peek() == Token::RBRACE || 1892 (peek() == Token::COMMA || peek() == Token::RBRACE ||
1740 peek() == Token::ASSIGN)) { 1893 peek() == Token::ASSIGN)) {
1741 // PropertyDefinition 1894 // PropertyDefinition
1742 // IdentifierReference 1895 // IdentifierReference
1743 // CoverInitializedName 1896 // CoverInitializedName
1744 // 1897 //
1745 // CoverInitializedName 1898 // CoverInitializedName
1746 // IdentifierReference Initializer? 1899 // IdentifierReference Initializer?
1747 if (classifier->duplicate_finder() != nullptr && 1900 if (classifier->duplicate_finder() != nullptr &&
1748 scanner()->FindSymbol(classifier->duplicate_finder(), 1) != 0) { 1901 scanner()->FindSymbol(classifier->duplicate_finder(), 1) != 0) {
1749 classifier->RecordDuplicateFormalParameterError(scanner()->location()); 1902 classifier->RecordDuplicateFormalParameterError(scanner()->location());
1750 } 1903 }
1751 if (name_token == Token::LET) { 1904 if (name_token == Token::LET) {
1752 classifier->RecordLetPatternError( 1905 classifier->RecordLetPatternError(
1753 scanner()->location(), MessageTemplate::kLetInLexicalBinding); 1906 scanner()->location(), MessageTemplate::kLetInLexicalBinding);
1754 } 1907 }
1755 1908 if (is_await && is_async_function()) {
1909 classifier->RecordPatternError(
1910 Scanner::Location(next_beg_pos, next_end_pos),
1911 MessageTemplate::kAwaitBindingIdentifier);
1912 }
1756 ExpressionT lhs = this->ExpressionFromIdentifier( 1913 ExpressionT lhs = this->ExpressionFromIdentifier(
1757 *name, next_beg_pos, next_end_pos, scope_, factory()); 1914 *name, next_beg_pos, next_end_pos, scope_, factory());
1758 CheckDestructuringElement(lhs, classifier, next_beg_pos, next_end_pos); 1915 CheckDestructuringElement(lhs, classifier, next_beg_pos, next_end_pos);
1759 1916
1760 if (peek() == Token::ASSIGN) { 1917 if (peek() == Token::ASSIGN) {
1761 Consume(Token::ASSIGN); 1918 Consume(Token::ASSIGN);
1762 ExpressionClassifier rhs_classifier(this); 1919 ExpressionClassifier rhs_classifier(this);
1763 ExpressionT rhs = this->ParseAssignmentExpression( 1920 ExpressionT rhs = this->ParseAssignmentExpression(
1764 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1921 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1765 Traits::RewriteNonPattern(&rhs_classifier, 1922 Traits::RewriteNonPattern(&rhs_classifier,
1766 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1923 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1767 classifier->Accumulate(&rhs_classifier, 1924 classifier->Accumulate(&rhs_classifier,
1768 ExpressionClassifier::ExpressionProductions); 1925 ExpressionClassifier::ExpressionProductions);
1769 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs, 1926 value = factory()->NewAssignment(Token::ASSIGN, lhs, rhs,
1770 RelocInfo::kNoPosition); 1927 RelocInfo::kNoPosition);
1771 classifier->RecordCoverInitializedNameError( 1928 classifier->RecordCoverInitializedNameError(
1772 Scanner::Location(next_beg_pos, scanner()->location().end_pos), 1929 Scanner::Location(next_beg_pos, scanner()->location().end_pos),
1773 MessageTemplate::kInvalidCoverInitializedName); 1930 MessageTemplate::kInvalidCoverInitializedName);
1774 1931
1775 if (allow_harmony_function_name()) { 1932 if (allow_harmony_function_name()) {
1776 Traits::SetFunctionNameFromIdentifierRef(rhs, lhs); 1933 Traits::SetFunctionNameFromIdentifierRef(rhs, lhs);
1777 } 1934 }
1778 } else { 1935 } else {
1779 value = lhs; 1936 value = lhs;
1780 } 1937 }
1781 1938
1782 return factory()->NewObjectLiteralProperty( 1939 return factory()->NewObjectLiteralProperty(
1783 name_expression, value, ObjectLiteralProperty::COMPUTED, false, 1940 name_expression, value, ObjectLiteralProperty::COMPUTED, is_static,
1784 false); 1941 false);
1785 } 1942 }
1786 } 1943 }
1787 1944
1788 // Method definitions are never valid in patterns. 1945 // Method definitions are never valid in patterns.
1789 classifier->RecordPatternError( 1946 classifier->RecordPatternError(
1790 Scanner::Location(next_beg_pos, scanner()->location().end_pos), 1947 Scanner::Location(next_beg_pos, scanner()->location().end_pos),
1791 MessageTemplate::kInvalidDestructuringTarget); 1948 MessageTemplate::kInvalidDestructuringTarget);
1792 1949
1950 if (is_async && !IsSpecialMethod(method_kind)) {
1951 DCHECK(!is_get);
1952 DCHECK(!is_set);
1953 bool dont_care;
1954 name_expression = ParsePropertyName(
1955 name, &dont_care, &dont_care, &dont_care, is_computed_name, classifier,
1956 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1957 method_kind |= MethodKind::Async;
1958 }
1959
1793 if (is_generator || peek() == Token::LPAREN) { 1960 if (is_generator || peek() == Token::LPAREN) {
1794 // MethodDefinition 1961 // MethodDefinition
1795 // PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}' 1962 // PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}'
1796 // '*' PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}' 1963 // '*' PropertyName '(' StrictFormalParameters ')' '{' FunctionBody '}'
1797 if (!*is_computed_name) { 1964 if (!*is_computed_name) {
1798 checker->CheckProperty(name_token, kMethodProperty, is_static, 1965 checker->CheckProperty(name_token, kMethodProperty, method_kind,
1799 is_generator,
1800 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1966 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1801 } 1967 }
1802 1968
1803 FunctionKind kind = is_generator ? FunctionKind::kConciseGeneratorMethod 1969 FunctionKind kind = is_generator
1804 : FunctionKind::kConciseMethod; 1970 ? FunctionKind::kConciseGeneratorMethod
1971 : is_async ? FunctionKind::kAsyncConciseMethod
1972 : FunctionKind::kConciseMethod;
1805 1973
1806 if (in_class && !is_static && this->IsConstructor(*name)) { 1974 if (in_class && !IsStaticMethod(method_kind) &&
1975 this->IsConstructor(*name)) {
1807 *has_seen_constructor = true; 1976 *has_seen_constructor = true;
1808 kind = has_extends ? FunctionKind::kSubclassConstructor 1977 kind = has_extends ? FunctionKind::kSubclassConstructor
1809 : FunctionKind::kBaseConstructor; 1978 : FunctionKind::kBaseConstructor;
1810 } 1979 }
1811 1980
1812 value = this->ParseFunctionLiteral( 1981 value = this->ParseFunctionLiteral(
1813 *name, scanner()->location(), kSkipFunctionNameCheck, kind, 1982 *name, scanner()->location(), kSkipFunctionNameCheck, kind,
1814 RelocInfo::kNoPosition, FunctionLiteral::kAccessorOrMethod, 1983 RelocInfo::kNoPosition, FunctionLiteral::kAccessorOrMethod,
1815 language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1984 language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1816 1985
1817 return factory()->NewObjectLiteralProperty(name_expression, value, 1986 return factory()->NewObjectLiteralProperty(name_expression, value,
1818 ObjectLiteralProperty::COMPUTED, 1987 ObjectLiteralProperty::COMPUTED,
1819 is_static, *is_computed_name); 1988 is_static, *is_computed_name);
1820 } 1989 }
1821 1990
1822 if (in_class && name_token == Token::STATIC && !is_static) { 1991 if (in_class && name_token == Token::STATIC && IsNormalMethod(method_kind)) {
1823 // ClassElement (static) 1992 // ClassElement (static)
1824 // 'static' MethodDefinition 1993 // 'static' MethodDefinition
1825 *name = this->EmptyIdentifier(); 1994 *name = this->EmptyIdentifier();
1826 ObjectLiteralPropertyT property = ParsePropertyDefinition( 1995 ObjectLiteralPropertyT property = ParsePropertyDefinition(
1827 checker, true, has_extends, true, is_computed_name, nullptr, classifier, 1996 checker, true, has_extends, MethodKind::Static, is_computed_name,
1828 name, ok); 1997 nullptr, classifier, name, ok);
1829 Traits::RewriteNonPattern(classifier, ok); 1998 Traits::RewriteNonPattern(classifier, ok);
1830 return property; 1999 return property;
1831 } 2000 }
1832 2001
1833 if (is_get || is_set) { 2002 if (is_get || is_set) {
1834 // MethodDefinition (Accessors) 2003 // MethodDefinition (Accessors)
1835 // get PropertyName '(' ')' '{' FunctionBody '}' 2004 // get PropertyName '(' ')' '{' FunctionBody '}'
1836 // set PropertyName '(' PropertySetParameterList ')' '{' FunctionBody '}' 2005 // set PropertyName '(' PropertySetParameterList ')' '{' FunctionBody '}'
1837 *name = this->EmptyIdentifier(); 2006 *name = this->EmptyIdentifier();
1838 bool dont_care = false; 2007 bool dont_care = false;
1839 name_token = peek(); 2008 name_token = peek();
1840 2009
1841 name_expression = ParsePropertyName( 2010 name_expression = ParsePropertyName(
1842 name, &dont_care, &dont_care, is_computed_name, classifier, 2011 name, &dont_care, &dont_care, &dont_care, is_computed_name, classifier,
1843 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2012 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1844 2013
1845 if (!*is_computed_name) { 2014 if (!*is_computed_name) {
1846 checker->CheckProperty(name_token, kAccessorProperty, is_static, 2015 checker->CheckProperty(name_token, kAccessorProperty, method_kind,
1847 is_generator,
1848 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2016 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1849 } 2017 }
1850 2018
1851 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral( 2019 typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral(
1852 *name, scanner()->location(), kSkipFunctionNameCheck, 2020 *name, scanner()->location(), kSkipFunctionNameCheck,
1853 is_get ? FunctionKind::kGetterFunction : FunctionKind::kSetterFunction, 2021 is_get ? FunctionKind::kGetterFunction : FunctionKind::kSetterFunction,
1854 RelocInfo::kNoPosition, FunctionLiteral::kAccessorOrMethod, 2022 RelocInfo::kNoPosition, FunctionLiteral::kAccessorOrMethod,
1855 language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 2023 language_mode(), CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1856 2024
1857 // Make sure the name expression is a string since we need a Name for 2025 // Make sure the name expression is a string since we need a Name for
(...skipping 29 matching lines...) Expand all
1887 int number_of_boilerplate_properties = 0; 2055 int number_of_boilerplate_properties = 0;
1888 bool has_computed_names = false; 2056 bool has_computed_names = false;
1889 ObjectLiteralChecker checker(this); 2057 ObjectLiteralChecker checker(this);
1890 2058
1891 Expect(Token::LBRACE, CHECK_OK); 2059 Expect(Token::LBRACE, CHECK_OK);
1892 2060
1893 while (peek() != Token::RBRACE) { 2061 while (peek() != Token::RBRACE) {
1894 FuncNameInferrer::State fni_state(fni_); 2062 FuncNameInferrer::State fni_state(fni_);
1895 2063
1896 const bool in_class = false; 2064 const bool in_class = false;
1897 const bool is_static = false;
1898 const bool has_extends = false; 2065 const bool has_extends = false;
1899 bool is_computed_name = false; 2066 bool is_computed_name = false;
1900 IdentifierT name = this->EmptyIdentifier(); 2067 IdentifierT name = this->EmptyIdentifier();
1901 ObjectLiteralPropertyT property = this->ParsePropertyDefinition( 2068 ObjectLiteralPropertyT property = this->ParsePropertyDefinition(
1902 &checker, in_class, has_extends, is_static, &is_computed_name, NULL, 2069 &checker, in_class, has_extends, MethodKind::Normal, &is_computed_name,
1903 classifier, &name, CHECK_OK); 2070 NULL, classifier, &name, CHECK_OK);
1904 2071
1905 if (is_computed_name) { 2072 if (is_computed_name) {
1906 has_computed_names = true; 2073 has_computed_names = true;
1907 } 2074 }
1908 2075
1909 // Count CONSTANT or COMPUTED properties to maintain the enumeration order. 2076 // Count CONSTANT or COMPUTED properties to maintain the enumeration order.
1910 if (!has_computed_names && this->IsBoilerplateProperty(property)) { 2077 if (!has_computed_names && this->IsBoilerplateProperty(property)) {
1911 number_of_boilerplate_properties++; 2078 number_of_boilerplate_properties++;
1912 } 2079 }
1913 properties->Add(property, zone()); 2080 properties->Add(property, zone());
(...skipping 13 matching lines...) Expand all
1927 2094
1928 // Computation of literal_index must happen before pre parse bailout. 2095 // Computation of literal_index must happen before pre parse bailout.
1929 int literal_index = function_state_->NextMaterializedLiteralIndex(); 2096 int literal_index = function_state_->NextMaterializedLiteralIndex();
1930 2097
1931 return factory()->NewObjectLiteral(properties, 2098 return factory()->NewObjectLiteral(properties,
1932 literal_index, 2099 literal_index,
1933 number_of_boilerplate_properties, 2100 number_of_boilerplate_properties,
1934 pos); 2101 pos);
1935 } 2102 }
1936 2103
1937
1938 template <class Traits> 2104 template <class Traits>
1939 typename Traits::Type::ExpressionList ParserBase<Traits>::ParseArguments( 2105 typename Traits::Type::ExpressionList ParserBase<Traits>::ParseArguments(
1940 Scanner::Location* first_spread_arg_loc, ExpressionClassifier* classifier, 2106 Scanner::Location* first_spread_arg_loc, bool maybe_arrow,
1941 bool* ok) { 2107 ExpressionClassifier* classifier, bool* ok) {
1942 // Arguments :: 2108 // Arguments ::
1943 // '(' (AssignmentExpression)*[','] ')' 2109 // '(' (AssignmentExpression)*[','] ')'
1944 2110
1945 Scanner::Location spread_arg = Scanner::Location::invalid(); 2111 Scanner::Location spread_arg = Scanner::Location::invalid();
1946 typename Traits::Type::ExpressionList result = 2112 typename Traits::Type::ExpressionList result =
1947 this->NewExpressionList(4, zone_); 2113 this->NewExpressionList(4, zone_);
1948 Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList)); 2114 Expect(Token::LPAREN, CHECK_OK_CUSTOM(NullExpressionList));
1949 bool done = (peek() == Token::RPAREN); 2115 bool done = (peek() == Token::RPAREN);
1950 bool was_unspread = false; 2116 bool was_unspread = false;
1951 int unspread_sequences_count = 0; 2117 int unspread_sequences_count = 0;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 } 2153 }
1988 } 2154 }
1989 Scanner::Location location = scanner_->location(); 2155 Scanner::Location location = scanner_->location();
1990 if (Token::RPAREN != Next()) { 2156 if (Token::RPAREN != Next()) {
1991 ReportMessageAt(location, MessageTemplate::kUnterminatedArgList); 2157 ReportMessageAt(location, MessageTemplate::kUnterminatedArgList);
1992 *ok = false; 2158 *ok = false;
1993 return this->NullExpressionList(); 2159 return this->NullExpressionList();
1994 } 2160 }
1995 *first_spread_arg_loc = spread_arg; 2161 *first_spread_arg_loc = spread_arg;
1996 2162
1997 if (spread_arg.IsValid()) { 2163 if ((!maybe_arrow || peek() != Token::ARROW) && spread_arg.IsValid()) {
1998 // Unspread parameter sequences are translated into array literals in the 2164 // Unspread parameter sequences are translated into array literals in the
1999 // parser. Ensure that the number of materialized literals matches between 2165 // parser. Ensure that the number of materialized literals matches between
2000 // the parser and preparser 2166 // the parser and preparser
2001 Traits::MaterializeUnspreadArgumentsLiterals(unspread_sequences_count); 2167 Traits::MaterializeUnspreadArgumentsLiterals(unspread_sequences_count);
2002 } 2168 }
2003 2169
2004 return result; 2170 return result;
2005 } 2171 }
2006 2172
2007 // Precedence = 2 2173 // Precedence = 2
(...skipping 11 matching lines...) Expand all
2019 int lhs_beg_pos = peek_position(); 2185 int lhs_beg_pos = peek_position();
2020 2186
2021 if (peek() == Token::YIELD && is_generator()) { 2187 if (peek() == Token::YIELD && is_generator()) {
2022 return this->ParseYieldExpression(accept_IN, classifier, ok); 2188 return this->ParseYieldExpression(accept_IN, classifier, ok);
2023 } 2189 }
2024 2190
2025 FuncNameInferrer::State fni_state(fni_); 2191 FuncNameInferrer::State fni_state(fni_);
2026 ParserBase<Traits>::Checkpoint checkpoint(this); 2192 ParserBase<Traits>::Checkpoint checkpoint(this);
2027 ExpressionClassifier arrow_formals_classifier(this, 2193 ExpressionClassifier arrow_formals_classifier(this,
2028 classifier->duplicate_finder()); 2194 classifier->duplicate_finder());
2195
2196 bool is_async = allow_harmony_async_await() && peek() == Token::ASYNC &&
2197 !scanner()->HasAnyLineTerminatorAfterNext();
2198
2029 bool parenthesized_formals = peek() == Token::LPAREN; 2199 bool parenthesized_formals = peek() == Token::LPAREN;
2030 if (!parenthesized_formals) { 2200 if (!is_async && !parenthesized_formals) {
2031 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier); 2201 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier);
2032 } 2202 }
2033 ExpressionT expression = this->ParseConditionalExpression( 2203 ExpressionT expression = this->ParseConditionalExpression(
2034 accept_IN, &arrow_formals_classifier, CHECK_OK); 2204 accept_IN, &arrow_formals_classifier, CHECK_OK);
2205
2206 if (is_async && peek_any_identifier() && PeekAhead() == Token::ARROW) {
2207 // async Identifier => AsyncConciseBody
2208 IdentifierT name =
2209 ParseAndClassifyIdentifier(&arrow_formals_classifier, CHECK_OK);
2210 expression = this->ExpressionFromIdentifier(
2211 name, position(), scanner()->location().end_pos, scope_, factory());
2212 }
2213
2035 if (peek() == Token::ARROW) { 2214 if (peek() == Token::ARROW) {
2036 classifier->RecordPatternError(scanner()->peek_location(), 2215 classifier->RecordPatternError(scanner()->peek_location(),
2037 MessageTemplate::kUnexpectedToken, 2216 MessageTemplate::kUnexpectedToken,
2038 Token::String(Token::ARROW)); 2217 Token::String(Token::ARROW));
2039 ValidateArrowFormalParameters(&arrow_formals_classifier, expression, 2218 ValidateArrowFormalParameters(&arrow_formals_classifier, expression,
2040 parenthesized_formals, CHECK_OK); 2219 parenthesized_formals, is_async, CHECK_OK);
2041 // This reads strangely, but is correct: it checks whether any 2220 // This reads strangely, but is correct: it checks whether any
2042 // sub-expression of the parameter list failed to be a valid formal 2221 // sub-expression of the parameter list failed to be a valid formal
2043 // parameter initializer. Since YieldExpressions are banned anywhere 2222 // parameter initializer. Since YieldExpressions are banned anywhere
2044 // in an arrow parameter list, this is correct. 2223 // in an arrow parameter list, this is correct.
2045 // TODO(adamk): Rename "FormalParameterInitializerError" to refer to 2224 // TODO(adamk): Rename "FormalParameterInitializerError" to refer to
2046 // "YieldExpression", which is its only use. 2225 // "YieldExpression", which is its only use.
2047 ValidateFormalParameterInitializer(&arrow_formals_classifier, ok); 2226 ValidateFormalParameterInitializer(&arrow_formals_classifier, ok);
2227
2048 Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); 2228 Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos);
2049 Scope* scope = 2229 Scope* scope = this->NewScope(scope_, FUNCTION_SCOPE,
2050 this->NewScope(scope_, FUNCTION_SCOPE, FunctionKind::kArrowFunction); 2230 is_async ? FunctionKind::kAsyncArrowFunction
2231 : FunctionKind::kArrowFunction);
2051 // Because the arrow's parameters were parsed in the outer scope, any 2232 // Because the arrow's parameters were parsed in the outer scope, any
2052 // usage flags that might have been triggered there need to be copied 2233 // usage flags that might have been triggered there need to be copied
2053 // to the arrow scope. 2234 // to the arrow scope.
2054 scope_->PropagateUsageFlagsToScope(scope); 2235 scope_->PropagateUsageFlagsToScope(scope);
2055 FormalParametersT parameters(scope); 2236 FormalParametersT parameters(scope);
2056 if (!arrow_formals_classifier.is_simple_parameter_list()) { 2237 if (!arrow_formals_classifier.is_simple_parameter_list()) {
2057 scope->SetHasNonSimpleParameters(); 2238 scope->SetHasNonSimpleParameters();
2058 parameters.is_simple = false; 2239 parameters.is_simple = false;
2059 } 2240 }
2060 2241
2061 checkpoint.Restore(&parameters.materialized_literals_count); 2242 checkpoint.Restore(&parameters.materialized_literals_count);
2062 2243
2063 scope->set_start_position(lhs_beg_pos); 2244 scope->set_start_position(lhs_beg_pos);
2064 Scanner::Location duplicate_loc = Scanner::Location::invalid(); 2245 Scanner::Location duplicate_loc = Scanner::Location::invalid();
2065 this->ParseArrowFunctionFormalParameterList(&parameters, expression, loc, 2246 this->ParseArrowFunctionFormalParameterList(&parameters, expression, loc,
2066 &duplicate_loc, CHECK_OK); 2247 &duplicate_loc, CHECK_OK);
2067 if (duplicate_loc.IsValid()) { 2248 if (duplicate_loc.IsValid()) {
2068 arrow_formals_classifier.RecordDuplicateFormalParameterError( 2249 arrow_formals_classifier.RecordDuplicateFormalParameterError(
2069 duplicate_loc); 2250 duplicate_loc);
2070 } 2251 }
2071 expression = this->ParseArrowFunctionLiteral( 2252 expression = this->ParseArrowFunctionLiteral(
2072 accept_IN, parameters, arrow_formals_classifier, CHECK_OK); 2253 accept_IN, parameters, is_async, arrow_formals_classifier, CHECK_OK);
2073 2254
2074 if (fni_ != nullptr) fni_->Infer(); 2255 if (fni_ != nullptr) fni_->Infer();
2075 2256
2076 return expression; 2257 return expression;
2077 } 2258 }
2078 2259
2079 if (this->IsValidReferenceExpression(expression)) { 2260 if (this->IsValidReferenceExpression(expression)) {
2080 arrow_formals_classifier.ForgiveAssignmentPatternError(); 2261 arrow_formals_classifier.ForgiveAssignmentPatternError();
2081 } 2262 }
2082 2263
2083 // "expression" was not itself an arrow function parameter list, but it might 2264 // "expression" was not itself an arrow function parameter list, but it might
2084 // form part of one. Propagate speculative formal parameter error locations. 2265 // form part of one. Propagate speculative formal parameter error locations.
2085 // Do not merge pending non-pattern expressions yet! 2266 // Do not merge pending non-pattern expressions yet!
2086 classifier->Accumulate( 2267 classifier->Accumulate(
2087 &arrow_formals_classifier, 2268 &arrow_formals_classifier,
2088 ExpressionClassifier::StandardProductions | 2269 ExpressionClassifier::StandardProductions |
2089 ExpressionClassifier::FormalParametersProductions | 2270 ExpressionClassifier::FormalParametersProductions |
2090 ExpressionClassifier::CoverInitializedNameProduction, 2271 ExpressionClassifier::CoverInitializedNameProduction |
2272 ExpressionClassifier::AsyncArrowFormalParametersProduction |
2273 ExpressionClassifier::AsyncBindingPatternProduction,
2091 false); 2274 false);
2092 2275
2093 if (!Token::IsAssignmentOp(peek())) { 2276 if (!Token::IsAssignmentOp(peek())) {
2094 // Parsed conditional expression only (no assignment). 2277 // Parsed conditional expression only (no assignment).
2095 // Now pending non-pattern expressions must be merged. 2278 // Now pending non-pattern expressions must be merged.
2096 classifier->MergeNonPatterns(&arrow_formals_classifier); 2279 classifier->MergeNonPatterns(&arrow_formals_classifier);
2097 return expression; 2280 return expression;
2098 } 2281 }
2099 2282
2100 // Now pending non-pattern expressions must be discarded. 2283 // Now pending non-pattern expressions must be discarded.
(...skipping 21 matching lines...) Expand all
2122 } 2305 }
2123 int pos = position(); 2306 int pos = position();
2124 2307
2125 ExpressionClassifier rhs_classifier(this); 2308 ExpressionClassifier rhs_classifier(this);
2126 2309
2127 ExpressionT right = 2310 ExpressionT right =
2128 this->ParseAssignmentExpression(accept_IN, &rhs_classifier, CHECK_OK); 2311 this->ParseAssignmentExpression(accept_IN, &rhs_classifier, CHECK_OK);
2129 CheckNoTailCallExpressions(&rhs_classifier, CHECK_OK); 2312 CheckNoTailCallExpressions(&rhs_classifier, CHECK_OK);
2130 Traits::RewriteNonPattern(&rhs_classifier, CHECK_OK); 2313 Traits::RewriteNonPattern(&rhs_classifier, CHECK_OK);
2131 classifier->Accumulate( 2314 classifier->Accumulate(
2132 &rhs_classifier, ExpressionClassifier::ExpressionProductions | 2315 &rhs_classifier,
2133 ExpressionClassifier::CoverInitializedNameProduction); 2316 ExpressionClassifier::ExpressionProductions |
2317 ExpressionClassifier::CoverInitializedNameProduction |
2318 ExpressionClassifier::AsyncArrowFormalParametersProduction);
2134 2319
2135 // TODO(1231235): We try to estimate the set of properties set by 2320 // TODO(1231235): We try to estimate the set of properties set by
2136 // constructors. We define a new property whenever there is an 2321 // constructors. We define a new property whenever there is an
2137 // assignment to a property of 'this'. We should probably only add 2322 // assignment to a property of 'this'. We should probably only add
2138 // properties if we haven't seen them before. Otherwise we'll 2323 // properties if we haven't seen them before. Otherwise we'll
2139 // probably overestimate the number of properties. 2324 // probably overestimate the number of properties.
2140 if (op == Token::ASSIGN && this->IsThisProperty(expression)) { 2325 if (op == Token::ASSIGN && this->IsThisProperty(expression)) {
2141 function_state_->AddProperty(); 2326 function_state_->AddProperty();
2142 } 2327 }
2143 2328
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 // PostfixExpression 2579 // PostfixExpression
2395 // 'delete' UnaryExpression 2580 // 'delete' UnaryExpression
2396 // 'void' UnaryExpression 2581 // 'void' UnaryExpression
2397 // 'typeof' UnaryExpression 2582 // 'typeof' UnaryExpression
2398 // '++' UnaryExpression 2583 // '++' UnaryExpression
2399 // '--' UnaryExpression 2584 // '--' UnaryExpression
2400 // '+' UnaryExpression 2585 // '+' UnaryExpression
2401 // '-' UnaryExpression 2586 // '-' UnaryExpression
2402 // '~' UnaryExpression 2587 // '~' UnaryExpression
2403 // '!' UnaryExpression 2588 // '!' UnaryExpression
2589 // [+Await] AwaitExpression[?Yield]
2404 2590
2405 Token::Value op = peek(); 2591 Token::Value op = peek();
2406 if (Token::IsUnaryOp(op)) { 2592 if (Token::IsUnaryOp(op)) {
2407 BindingPatternUnexpectedToken(classifier); 2593 BindingPatternUnexpectedToken(classifier);
2408 ArrowFormalParametersUnexpectedToken(classifier); 2594 ArrowFormalParametersUnexpectedToken(classifier);
2409 2595
2410 op = Next(); 2596 op = Next();
2411 int pos = position(); 2597 int pos = position();
2412 ExpressionT expression = ParseUnaryExpression(classifier, CHECK_OK); 2598 ExpressionT expression = ParseUnaryExpression(classifier, CHECK_OK);
2413 CheckNoTailCallExpressions(classifier, CHECK_OK); 2599 CheckNoTailCallExpressions(classifier, CHECK_OK);
(...skipping 27 matching lines...) Expand all
2441 expression, beg_pos, scanner()->location().end_pos, 2627 expression, beg_pos, scanner()->location().end_pos,
2442 MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK); 2628 MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK);
2443 this->MarkExpressionAsAssigned(expression); 2629 this->MarkExpressionAsAssigned(expression);
2444 Traits::RewriteNonPattern(classifier, CHECK_OK); 2630 Traits::RewriteNonPattern(classifier, CHECK_OK);
2445 2631
2446 return factory()->NewCountOperation(op, 2632 return factory()->NewCountOperation(op,
2447 true /* prefix */, 2633 true /* prefix */,
2448 expression, 2634 expression,
2449 position()); 2635 position());
2450 2636
2637 } else if (is_async_function() && peek() == Token::AWAIT) {
2638 int beg_pos = peek_position();
2639 switch (PeekAhead()) {
2640 case Token::RPAREN:
2641 case Token::RBRACK:
2642 case Token::RBRACE:
2643 case Token::ASSIGN:
2644 case Token::COMMA: {
2645 Next();
2646 IdentifierT name = this->GetSymbol(scanner());
2647
2648 // Possibly async arrow formals --- record ExpressionError just in case.
2649 ExpressionUnexpectedToken(classifier);
2650 classifier->RecordAsyncBindingPatternError(
2651 Scanner::Location(beg_pos, scanner()->location().end_pos),
2652 MessageTemplate::kAwaitBindingIdentifier);
2653 classifier->RecordAsyncArrowFormalParametersError(
2654 Scanner::Location(beg_pos, scanner()->location().end_pos),
2655 MessageTemplate::kAwaitBindingIdentifier);
2656
2657 return this->ExpressionFromIdentifier(
2658 name, beg_pos, scanner()->location().end_pos, scope_, factory());
2659 }
2660 default:
2661 break;
2662 }
2663 Consume(Token::AWAIT);
2664
2665 ExpressionT value = ParseUnaryExpression(classifier, CHECK_OK);
2666
2667 classifier->RecordFormalParameterInitializerError(
2668 Scanner::Location(beg_pos, scanner()->location().end_pos),
2669 MessageTemplate::kAwaitExpressionFormalParameter);
2670 return Traits::RewriteAwaitExpression(value, beg_pos);
2451 } else { 2671 } else {
2452 return this->ParsePostfixExpression(classifier, ok); 2672 return this->ParsePostfixExpression(classifier, ok);
2453 } 2673 }
2454 } 2674 }
2455 2675
2456 2676
2457 template <class Traits> 2677 template <class Traits>
2458 typename ParserBase<Traits>::ExpressionT 2678 typename ParserBase<Traits>::ExpressionT
2459 ParserBase<Traits>::ParsePostfixExpression(ExpressionClassifier* classifier, 2679 ParserBase<Traits>::ParsePostfixExpression(ExpressionClassifier* classifier,
2460 bool* ok) { 2680 bool* ok) {
(...skipping 29 matching lines...) Expand all
2490 typename ParserBase<Traits>::ExpressionT 2710 typename ParserBase<Traits>::ExpressionT
2491 ParserBase<Traits>::ParseLeftHandSideExpression( 2711 ParserBase<Traits>::ParseLeftHandSideExpression(
2492 ExpressionClassifier* classifier, bool* ok) { 2712 ExpressionClassifier* classifier, bool* ok) {
2493 // LeftHandSideExpression :: 2713 // LeftHandSideExpression ::
2494 // (NewExpression | MemberExpression) ... 2714 // (NewExpression | MemberExpression) ...
2495 2715
2496 if (FLAG_harmony_explicit_tailcalls && peek() == Token::CONTINUE) { 2716 if (FLAG_harmony_explicit_tailcalls && peek() == Token::CONTINUE) {
2497 return this->ParseTailCallExpression(classifier, ok); 2717 return this->ParseTailCallExpression(classifier, ok);
2498 } 2718 }
2499 2719
2500 ExpressionT result = 2720 bool is_async = false;
2501 this->ParseMemberWithNewPrefixesExpression(classifier, CHECK_OK); 2721 ExpressionT result = this->ParseMemberWithNewPrefixesExpression(
2722 classifier, &is_async, CHECK_OK);
2502 2723
2503 while (true) { 2724 while (true) {
2504 switch (peek()) { 2725 switch (peek()) {
2505 case Token::LBRACK: { 2726 case Token::LBRACK: {
2506 CheckNoTailCallExpressions(classifier, CHECK_OK); 2727 CheckNoTailCallExpressions(classifier, CHECK_OK);
2507 Traits::RewriteNonPattern(classifier, CHECK_OK); 2728 Traits::RewriteNonPattern(classifier, CHECK_OK);
2508 BindingPatternUnexpectedToken(classifier); 2729 BindingPatternUnexpectedToken(classifier);
2509 ArrowFormalParametersUnexpectedToken(classifier); 2730 ArrowFormalParametersUnexpectedToken(classifier);
2510 Consume(Token::LBRACK); 2731 Consume(Token::LBRACK);
2511 int pos = position(); 2732 int pos = position();
2512 ExpressionT index = ParseExpression(true, classifier, CHECK_OK); 2733 ExpressionT index = ParseExpression(true, classifier, CHECK_OK);
2513 Traits::RewriteNonPattern(classifier, CHECK_OK); 2734 Traits::RewriteNonPattern(classifier, CHECK_OK);
2514 result = factory()->NewProperty(result, index, pos); 2735 result = factory()->NewProperty(result, index, pos);
2515 Expect(Token::RBRACK, CHECK_OK); 2736 Expect(Token::RBRACK, CHECK_OK);
2516 break; 2737 break;
2517 } 2738 }
2518 2739
2519 case Token::LPAREN: { 2740 case Token::LPAREN: {
2520 CheckNoTailCallExpressions(classifier, CHECK_OK); 2741 CheckNoTailCallExpressions(classifier, CHECK_OK);
2742 int pos;
2521 Traits::RewriteNonPattern(classifier, CHECK_OK); 2743 Traits::RewriteNonPattern(classifier, CHECK_OK);
2522 BindingPatternUnexpectedToken(classifier); 2744 BindingPatternUnexpectedToken(classifier);
2523 ArrowFormalParametersUnexpectedToken(classifier);
2524
2525 int pos;
2526 if (scanner()->current_token() == Token::IDENTIFIER || 2745 if (scanner()->current_token() == Token::IDENTIFIER ||
2527 scanner()->current_token() == Token::SUPER) { 2746 scanner()->current_token() == Token::SUPER ||
2747 scanner()->current_token() == Token::ASYNC) {
2528 // For call of an identifier we want to report position of 2748 // For call of an identifier we want to report position of
2529 // the identifier as position of the call in the stack trace. 2749 // the identifier as position of the call in the stack trace.
2530 pos = position(); 2750 pos = position();
2531 } else { 2751 } else {
2532 // For other kinds of calls we record position of the parenthesis as 2752 // For other kinds of calls we record position of the parenthesis as
2533 // position of the call. Note that this is extremely important for 2753 // position of the call. Note that this is extremely important for
2534 // expressions of the form function(){...}() for which call position 2754 // expressions of the form function(){...}() for which call position
2535 // should not point to the closing brace otherwise it will intersect 2755 // should not point to the closing brace otherwise it will intersect
2536 // with positions recorded for function literal and confuse debugger. 2756 // with positions recorded for function literal and confuse debugger.
2537 pos = peek_position(); 2757 pos = peek_position();
2538 // Also the trailing parenthesis are a hint that the function will 2758 // Also the trailing parenthesis are a hint that the function will
2539 // be called immediately. If we happen to have parsed a preceding 2759 // be called immediately. If we happen to have parsed a preceding
2540 // function literal eagerly, we can also compile it eagerly. 2760 // function literal eagerly, we can also compile it eagerly.
2541 if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) { 2761 if (result->IsFunctionLiteral() && mode() == PARSE_EAGERLY) {
2542 result->AsFunctionLiteral()->set_should_eager_compile(); 2762 result->AsFunctionLiteral()->set_should_eager_compile();
2543 } 2763 }
2544 } 2764 }
2545 Scanner::Location spread_pos; 2765 Scanner::Location spread_pos;
2546 typename Traits::Type::ExpressionList args = 2766 typename Traits::Type::ExpressionList args =
2547 ParseArguments(&spread_pos, classifier, CHECK_OK); 2767 ParseArguments(&spread_pos, is_async, classifier, CHECK_OK);
2768
2769 if (V8_UNLIKELY(is_async && peek() == Token::ARROW)) {
2770 if (args->length()) {
2771 // async ( Arguments ) => ...
2772 return Traits::ExpressionListToExpression(args);
2773 }
2774 // async () => ...
2775 return factory()->NewEmptyParentheses(pos);
2776 }
2777
2778 ArrowFormalParametersUnexpectedToken(classifier);
2548 2779
2549 // Keep track of eval() calls since they disable all local variable 2780 // Keep track of eval() calls since they disable all local variable
2550 // optimizations. 2781 // optimizations.
2551 // The calls that need special treatment are the 2782 // The calls that need special treatment are the
2552 // direct eval calls. These calls are all of the form eval(...), with 2783 // direct eval calls. These calls are all of the form eval(...), with
2553 // no explicit receiver. 2784 // no explicit receiver.
2554 // These calls are marked as potentially direct eval calls. Whether 2785 // These calls are marked as potentially direct eval calls. Whether
2555 // they are actually direct calls to eval is determined at run time. 2786 // they are actually direct calls to eval is determined at run time.
2556 this->CheckPossibleEvalCall(result, scope_); 2787 this->CheckPossibleEvalCall(result, scope_);
2557 2788
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2598 result = ParseTemplateLiteral(result, position(), classifier, CHECK_OK); 2829 result = ParseTemplateLiteral(result, position(), classifier, CHECK_OK);
2599 break; 2830 break;
2600 } 2831 }
2601 2832
2602 default: 2833 default:
2603 return result; 2834 return result;
2604 } 2835 }
2605 } 2836 }
2606 } 2837 }
2607 2838
2608
2609 template <class Traits> 2839 template <class Traits>
2610 typename ParserBase<Traits>::ExpressionT 2840 typename ParserBase<Traits>::ExpressionT
2611 ParserBase<Traits>::ParseMemberWithNewPrefixesExpression( 2841 ParserBase<Traits>::ParseMemberWithNewPrefixesExpression(
2612 ExpressionClassifier* classifier, bool* ok) { 2842 ExpressionClassifier* classifier, bool* is_async, bool* ok) {
2613 // NewExpression :: 2843 // NewExpression ::
2614 // ('new')+ MemberExpression 2844 // ('new')+ MemberExpression
2615 // 2845 //
2616 // NewTarget :: 2846 // NewTarget ::
2617 // 'new' '.' 'target' 2847 // 'new' '.' 'target'
2618 2848
2619 // The grammar for new expressions is pretty warped. We can have several 'new' 2849 // The grammar for new expressions is pretty warped. We can have several 'new'
2620 // keywords following each other, and then a MemberExpression. When we see '(' 2850 // keywords following each other, and then a MemberExpression. When we see '('
2621 // after the MemberExpression, it's associated with the rightmost unassociated 2851 // after the MemberExpression, it's associated with the rightmost unassociated
2622 // 'new' to create a NewExpression with arguments. However, a NewExpression 2852 // 'new' to create a NewExpression with arguments. However, a NewExpression
(...skipping 12 matching lines...) Expand all
2635 ArrowFormalParametersUnexpectedToken(classifier); 2865 ArrowFormalParametersUnexpectedToken(classifier);
2636 Consume(Token::NEW); 2866 Consume(Token::NEW);
2637 int new_pos = position(); 2867 int new_pos = position();
2638 ExpressionT result = this->EmptyExpression(); 2868 ExpressionT result = this->EmptyExpression();
2639 if (peek() == Token::SUPER) { 2869 if (peek() == Token::SUPER) {
2640 const bool is_new = true; 2870 const bool is_new = true;
2641 result = ParseSuperExpression(is_new, classifier, CHECK_OK); 2871 result = ParseSuperExpression(is_new, classifier, CHECK_OK);
2642 } else if (peek() == Token::PERIOD) { 2872 } else if (peek() == Token::PERIOD) {
2643 return ParseNewTargetExpression(CHECK_OK); 2873 return ParseNewTargetExpression(CHECK_OK);
2644 } else { 2874 } else {
2645 result = this->ParseMemberWithNewPrefixesExpression(classifier, CHECK_OK); 2875 result = this->ParseMemberWithNewPrefixesExpression(classifier, is_async,
2876 CHECK_OK);
2646 } 2877 }
2647 Traits::RewriteNonPattern(classifier, CHECK_OK); 2878 Traits::RewriteNonPattern(classifier, CHECK_OK);
2648 if (peek() == Token::LPAREN) { 2879 if (peek() == Token::LPAREN) {
2649 // NewExpression with arguments. 2880 // NewExpression with arguments.
2650 Scanner::Location spread_pos; 2881 Scanner::Location spread_pos;
2651 typename Traits::Type::ExpressionList args = 2882 typename Traits::Type::ExpressionList args =
2652 this->ParseArguments(&spread_pos, classifier, CHECK_OK); 2883 this->ParseArguments(&spread_pos, classifier, CHECK_OK);
2653 2884
2654 if (spread_pos.IsValid()) { 2885 if (spread_pos.IsValid()) {
2655 args = Traits::PrepareSpreadArguments(args); 2886 args = Traits::PrepareSpreadArguments(args);
2656 result = Traits::SpreadCallNew(result, args, new_pos); 2887 result = Traits::SpreadCallNew(result, args, new_pos);
2657 } else { 2888 } else {
2658 result = factory()->NewCallNew(result, args, new_pos); 2889 result = factory()->NewCallNew(result, args, new_pos);
2659 } 2890 }
2660 // The expression can still continue with . or [ after the arguments. 2891 // The expression can still continue with . or [ after the arguments.
2661 result = 2892 result = this->ParseMemberExpressionContinuation(result, is_async,
2662 this->ParseMemberExpressionContinuation(result, classifier, CHECK_OK); 2893 classifier, CHECK_OK);
2663 return result; 2894 return result;
2664 } 2895 }
2665 // NewExpression without arguments. 2896 // NewExpression without arguments.
2666 return factory()->NewCallNew(result, this->NewExpressionList(0, zone_), 2897 return factory()->NewCallNew(result, this->NewExpressionList(0, zone_),
2667 new_pos); 2898 new_pos);
2668 } 2899 }
2669 // No 'new' or 'super' keyword. 2900 // No 'new' or 'super' keyword.
2670 return this->ParseMemberExpression(classifier, ok); 2901 return this->ParseMemberExpression(classifier, is_async, ok);
2671 } 2902 }
2672 2903
2673
2674 template <class Traits> 2904 template <class Traits>
2675 typename ParserBase<Traits>::ExpressionT 2905 typename ParserBase<Traits>::ExpressionT
2676 ParserBase<Traits>::ParseMemberExpression(ExpressionClassifier* classifier, 2906 ParserBase<Traits>::ParseMemberExpression(ExpressionClassifier* classifier,
2677 bool* ok) { 2907 bool* is_async, bool* ok) {
2678 // MemberExpression :: 2908 // MemberExpression ::
2679 // (PrimaryExpression | FunctionLiteral | ClassLiteral) 2909 // (PrimaryExpression | FunctionLiteral | ClassLiteral)
2680 // ('[' Expression ']' | '.' Identifier | Arguments | TemplateLiteral)* 2910 // ('[' Expression ']' | '.' Identifier | Arguments | TemplateLiteral)*
2681 2911
2682 // The '[' Expression ']' and '.' Identifier parts are parsed by 2912 // The '[' Expression ']' and '.' Identifier parts are parsed by
2683 // ParseMemberExpressionContinuation, and the Arguments part is parsed by the 2913 // ParseMemberExpressionContinuation, and the Arguments part is parsed by the
2684 // caller. 2914 // caller.
2685 2915
2686 // Parse the initial primary or function expression. 2916 // Parse the initial primary or function expression.
2687 ExpressionT result = this->EmptyExpression(); 2917 ExpressionT result = this->EmptyExpression();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2724 name, function_name_location, 2954 name, function_name_location,
2725 is_strict_reserved_name ? kFunctionNameIsStrictReserved 2955 is_strict_reserved_name ? kFunctionNameIsStrictReserved
2726 : kFunctionNameValidityUnknown, 2956 : kFunctionNameValidityUnknown,
2727 is_generator ? FunctionKind::kGeneratorFunction 2957 is_generator ? FunctionKind::kGeneratorFunction
2728 : FunctionKind::kNormalFunction, 2958 : FunctionKind::kNormalFunction,
2729 function_token_position, function_type, language_mode(), CHECK_OK); 2959 function_token_position, function_type, language_mode(), CHECK_OK);
2730 } else if (peek() == Token::SUPER) { 2960 } else if (peek() == Token::SUPER) {
2731 const bool is_new = false; 2961 const bool is_new = false;
2732 result = ParseSuperExpression(is_new, classifier, CHECK_OK); 2962 result = ParseSuperExpression(is_new, classifier, CHECK_OK);
2733 } else { 2963 } else {
2734 result = ParsePrimaryExpression(classifier, CHECK_OK); 2964 result = ParsePrimaryExpression(classifier, is_async, CHECK_OK);
2735 } 2965 }
2736 2966
2737 result = ParseMemberExpressionContinuation(result, classifier, CHECK_OK); 2967 result =
2968 ParseMemberExpressionContinuation(result, is_async, classifier, CHECK_OK);
2738 return result; 2969 return result;
2739 } 2970 }
2740 2971
2741 2972
2742 template <class Traits> 2973 template <class Traits>
2743 typename ParserBase<Traits>::ExpressionT 2974 typename ParserBase<Traits>::ExpressionT
2744 ParserBase<Traits>::ParseSuperExpression(bool is_new, 2975 ParserBase<Traits>::ParseSuperExpression(bool is_new,
2745 ExpressionClassifier* classifier, 2976 ExpressionClassifier* classifier,
2746 bool* ok) { 2977 bool* ok) {
2747 Expect(Token::SUPER, CHECK_OK); 2978 Expect(Token::SUPER, CHECK_OK);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2794 if (!scope_->ReceiverScope()->is_function_scope()) { 3025 if (!scope_->ReceiverScope()->is_function_scope()) {
2795 ReportMessageAt(scanner()->location(), 3026 ReportMessageAt(scanner()->location(),
2796 MessageTemplate::kUnexpectedNewTarget); 3027 MessageTemplate::kUnexpectedNewTarget);
2797 *ok = false; 3028 *ok = false;
2798 return this->EmptyExpression(); 3029 return this->EmptyExpression();
2799 } 3030 }
2800 3031
2801 return this->NewTargetExpression(scope_, factory(), pos); 3032 return this->NewTargetExpression(scope_, factory(), pos);
2802 } 3033 }
2803 3034
2804
2805 template <class Traits> 3035 template <class Traits>
2806 typename ParserBase<Traits>::ExpressionT 3036 typename ParserBase<Traits>::ExpressionT
2807 ParserBase<Traits>::ParseMemberExpressionContinuation( 3037 ParserBase<Traits>::ParseMemberExpressionContinuation(
2808 ExpressionT expression, ExpressionClassifier* classifier, bool* ok) { 3038 ExpressionT expression, bool* is_async, ExpressionClassifier* classifier,
3039 bool* ok) {
2809 // Parses this part of MemberExpression: 3040 // Parses this part of MemberExpression:
2810 // ('[' Expression ']' | '.' Identifier | TemplateLiteral)* 3041 // ('[' Expression ']' | '.' Identifier | TemplateLiteral)*
2811 while (true) { 3042 while (true) {
2812 switch (peek()) { 3043 switch (peek()) {
2813 case Token::LBRACK: { 3044 case Token::LBRACK: {
3045 *is_async = false;
2814 Traits::RewriteNonPattern(classifier, CHECK_OK); 3046 Traits::RewriteNonPattern(classifier, CHECK_OK);
2815 BindingPatternUnexpectedToken(classifier); 3047 BindingPatternUnexpectedToken(classifier);
2816 ArrowFormalParametersUnexpectedToken(classifier); 3048 ArrowFormalParametersUnexpectedToken(classifier);
2817 3049
2818 Consume(Token::LBRACK); 3050 Consume(Token::LBRACK);
2819 int pos = position(); 3051 int pos = position();
2820 ExpressionT index = this->ParseExpression(true, classifier, CHECK_OK); 3052 ExpressionT index = this->ParseExpression(true, classifier, CHECK_OK);
2821 Traits::RewriteNonPattern(classifier, CHECK_OK); 3053 Traits::RewriteNonPattern(classifier, CHECK_OK);
2822 expression = factory()->NewProperty(expression, index, pos); 3054 expression = factory()->NewProperty(expression, index, pos);
2823 if (fni_ != NULL) { 3055 if (fni_ != NULL) {
2824 this->PushPropertyName(fni_, index); 3056 this->PushPropertyName(fni_, index);
2825 } 3057 }
2826 Expect(Token::RBRACK, CHECK_OK); 3058 Expect(Token::RBRACK, CHECK_OK);
2827 break; 3059 break;
2828 } 3060 }
2829 case Token::PERIOD: { 3061 case Token::PERIOD: {
3062 *is_async = false;
2830 Traits::RewriteNonPattern(classifier, CHECK_OK); 3063 Traits::RewriteNonPattern(classifier, CHECK_OK);
2831 BindingPatternUnexpectedToken(classifier); 3064 BindingPatternUnexpectedToken(classifier);
2832 ArrowFormalParametersUnexpectedToken(classifier); 3065 ArrowFormalParametersUnexpectedToken(classifier);
2833 3066
2834 Consume(Token::PERIOD); 3067 Consume(Token::PERIOD);
2835 int pos = position(); 3068 int pos = position();
2836 IdentifierT name = ParseIdentifierName(CHECK_OK); 3069 IdentifierT name = ParseIdentifierName(CHECK_OK);
2837 expression = factory()->NewProperty( 3070 expression = factory()->NewProperty(
2838 expression, factory()->NewStringLiteral(name, pos), pos); 3071 expression, factory()->NewStringLiteral(name, pos), pos);
2839 if (fni_ != NULL) { 3072 if (fni_ != NULL) {
2840 this->PushLiteralName(fni_, name); 3073 this->PushLiteralName(fni_, name);
2841 } 3074 }
2842 break; 3075 break;
2843 } 3076 }
2844 case Token::TEMPLATE_SPAN: 3077 case Token::TEMPLATE_SPAN:
2845 case Token::TEMPLATE_TAIL: { 3078 case Token::TEMPLATE_TAIL: {
3079 *is_async = false;
2846 Traits::RewriteNonPattern(classifier, CHECK_OK); 3080 Traits::RewriteNonPattern(classifier, CHECK_OK);
2847 BindingPatternUnexpectedToken(classifier); 3081 BindingPatternUnexpectedToken(classifier);
2848 ArrowFormalParametersUnexpectedToken(classifier); 3082 ArrowFormalParametersUnexpectedToken(classifier);
2849 int pos; 3083 int pos;
2850 if (scanner()->current_token() == Token::IDENTIFIER) { 3084 if (scanner()->current_token() == Token::IDENTIFIER) {
2851 pos = position(); 3085 pos = position();
2852 } else { 3086 } else {
2853 pos = peek_position(); 3087 pos = peek_position();
2854 if (expression->IsFunctionLiteral() && mode() == PARSE_EAGERLY) { 3088 if (expression->IsFunctionLiteral() && mode() == PARSE_EAGERLY) {
2855 // If the tag function looks like an IIFE, set_parenthesized() to 3089 // If the tag function looks like an IIFE, set_parenthesized() to
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2998 DCHECK(peek() == Token::LET); 3232 DCHECK(peek() == Token::LET);
2999 Token::Value next_next = PeekAhead(); 3233 Token::Value next_next = PeekAhead();
3000 switch (next_next) { 3234 switch (next_next) {
3001 case Token::LBRACE: 3235 case Token::LBRACE:
3002 case Token::LBRACK: 3236 case Token::LBRACK:
3003 case Token::IDENTIFIER: 3237 case Token::IDENTIFIER:
3004 case Token::STATIC: 3238 case Token::STATIC:
3005 case Token::LET: // Yes, you can do let let = ... in sloppy mode 3239 case Token::LET: // Yes, you can do let let = ... in sloppy mode
3006 case Token::YIELD: 3240 case Token::YIELD:
3007 case Token::AWAIT: 3241 case Token::AWAIT:
3242 case Token::ASYNC:
3008 return true; 3243 return true;
3009 default: 3244 default:
3010 return false; 3245 return false;
3011 } 3246 }
3012 } 3247 }
3013 3248
3014
3015 template <class Traits> 3249 template <class Traits>
3016 typename ParserBase<Traits>::ExpressionT 3250 typename ParserBase<Traits>::ExpressionT
3017 ParserBase<Traits>::ParseArrowFunctionLiteral( 3251 ParserBase<Traits>::ParseArrowFunctionLiteral(
3018 bool accept_IN, const FormalParametersT& formal_parameters, 3252 bool accept_IN, const FormalParametersT& formal_parameters, bool is_async,
3019 const ExpressionClassifier& formals_classifier, bool* ok) { 3253 const ExpressionClassifier& formals_classifier, bool* ok) {
3020 if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) { 3254 if (peek() == Token::ARROW && scanner_->HasAnyLineTerminatorBeforeNext()) {
3021 // ASI inserts `;` after arrow parameters if a line terminator is found. 3255 // ASI inserts `;` after arrow parameters if a line terminator is found.
3022 // `=> ...` is never a valid expression, so report as syntax error. 3256 // `=> ...` is never a valid expression, so report as syntax error.
3023 // If next token is not `=>`, it's a syntax error anyways. 3257 // If next token is not `=>`, it's a syntax error anyways.
3024 ReportUnexpectedTokenAt(scanner_->peek_location(), Token::ARROW); 3258 ReportUnexpectedTokenAt(scanner_->peek_location(), Token::ARROW);
3025 *ok = false; 3259 *ok = false;
3026 return this->EmptyExpression(); 3260 return this->EmptyExpression();
3027 } 3261 }
3028 3262
3029 typename Traits::Type::StatementList body; 3263 typename Traits::Type::StatementList body;
3030 int num_parameters = formal_parameters.scope->num_parameters(); 3264 int num_parameters = formal_parameters.scope->num_parameters();
3031 int materialized_literal_count = -1; 3265 int materialized_literal_count = -1;
3032 int expected_property_count = -1; 3266 int expected_property_count = -1;
3033 Scanner::Location super_loc; 3267 Scanner::Location super_loc;
3034 3268
3269 FunctionKind arrow_kind = is_async ? kAsyncArrowFunction : kArrowFunction;
3035 { 3270 {
3036 typename Traits::Type::Factory function_factory(ast_value_factory()); 3271 typename Traits::Type::Factory function_factory(ast_value_factory());
3037 FunctionState function_state(&function_state_, &scope_, 3272 FunctionState function_state(&function_state_, &scope_,
3038 formal_parameters.scope, kArrowFunction, 3273 formal_parameters.scope, arrow_kind,
3039 &function_factory); 3274 &function_factory);
3040 3275
3041 function_state.SkipMaterializedLiterals( 3276 function_state.SkipMaterializedLiterals(
3042 formal_parameters.materialized_literals_count); 3277 formal_parameters.materialized_literals_count);
3043 3278
3044 this->ReindexLiterals(formal_parameters); 3279 this->ReindexLiterals(formal_parameters);
3045 3280
3046 Expect(Token::ARROW, CHECK_OK); 3281 Expect(Token::ARROW, CHECK_OK);
3047 3282
3048 if (peek() == Token::LBRACE) { 3283 if (peek() == Token::LBRACE) {
3049 // Multiple statement body 3284 // Multiple statement body
3050 Consume(Token::LBRACE); 3285 Consume(Token::LBRACE);
3051 bool is_lazily_parsed = 3286 bool is_lazily_parsed =
3052 (mode() == PARSE_LAZILY && scope_->AllowsLazyParsing()); 3287 (mode() == PARSE_LAZILY && scope_->AllowsLazyParsing());
3053 if (is_lazily_parsed) { 3288 if (is_lazily_parsed) {
3054 body = this->NewStatementList(0, zone()); 3289 body = this->NewStatementList(0, zone());
3055 this->SkipLazyFunctionBody(&materialized_literal_count, 3290 this->SkipLazyFunctionBody(&materialized_literal_count,
3056 &expected_property_count, CHECK_OK); 3291 &expected_property_count, CHECK_OK);
3057 if (formal_parameters.materialized_literals_count > 0) { 3292 if (formal_parameters.materialized_literals_count > 0) {
3058 materialized_literal_count += 3293 materialized_literal_count +=
3059 formal_parameters.materialized_literals_count; 3294 formal_parameters.materialized_literals_count;
3060 } 3295 }
3061 } else { 3296 } else {
3062 body = this->ParseEagerFunctionBody( 3297 body = this->ParseEagerFunctionBody(
3063 this->EmptyIdentifier(), RelocInfo::kNoPosition, formal_parameters, 3298 this->EmptyIdentifier(), RelocInfo::kNoPosition, formal_parameters,
3064 kArrowFunction, FunctionLiteral::kAnonymousExpression, CHECK_OK); 3299 arrow_kind, FunctionLiteral::kAnonymousExpression, CHECK_OK);
3065 materialized_literal_count = 3300 materialized_literal_count =
3066 function_state.materialized_literal_count(); 3301 function_state.materialized_literal_count();
3067 expected_property_count = function_state.expected_property_count(); 3302 expected_property_count = function_state.expected_property_count();
3068 } 3303 }
3069 } else { 3304 } else {
3070 // Single-expression body 3305 // Single-expression body
3071 int pos = position(); 3306 int pos = position();
3072 ExpressionClassifier classifier(this); 3307 ExpressionClassifier classifier(this);
3073 DCHECK(ReturnExprContext::kInsideValidBlock == 3308 DCHECK(ReturnExprContext::kInsideValidBlock ==
3074 function_state_->return_expr_context()); 3309 function_state_->return_expr_context());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 this->CheckConflictingVarDeclarations(formal_parameters.scope, CHECK_OK); 3343 this->CheckConflictingVarDeclarations(formal_parameters.scope, CHECK_OK);
3109 3344
3110 Traits::RewriteDestructuringAssignments(); 3345 Traits::RewriteDestructuringAssignments();
3111 } 3346 }
3112 3347
3113 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( 3348 FunctionLiteralT function_literal = factory()->NewFunctionLiteral(
3114 this->EmptyIdentifierString(), formal_parameters.scope, body, 3349 this->EmptyIdentifierString(), formal_parameters.scope, body,
3115 materialized_literal_count, expected_property_count, num_parameters, 3350 materialized_literal_count, expected_property_count, num_parameters,
3116 FunctionLiteral::kNoDuplicateParameters, 3351 FunctionLiteral::kNoDuplicateParameters,
3117 FunctionLiteral::kAnonymousExpression, 3352 FunctionLiteral::kAnonymousExpression,
3118 FunctionLiteral::kShouldLazyCompile, FunctionKind::kArrowFunction, 3353 FunctionLiteral::kShouldLazyCompile, arrow_kind,
3119 formal_parameters.scope->start_position()); 3354 formal_parameters.scope->start_position());
3120 3355
3121 function_literal->set_function_token_position( 3356 function_literal->set_function_token_position(
3122 formal_parameters.scope->start_position()); 3357 formal_parameters.scope->start_position());
3123 if (super_loc.IsValid()) function_state_->set_super_location(super_loc); 3358 if (super_loc.IsValid()) function_state_->set_super_location(super_loc);
3124 3359
3125 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal); 3360 if (fni_ != NULL) this->InferFunctionName(fni_, function_literal);
3126 3361
3127 return function_literal; 3362 return function_literal;
3128 } 3363 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3277 classifier->RecordAssignmentPatternError( 3512 classifier->RecordAssignmentPatternError(
3278 Scanner::Location(begin, end), 3513 Scanner::Location(begin, end),
3279 MessageTemplate::kInvalidDestructuringTarget); 3514 MessageTemplate::kInvalidDestructuringTarget);
3280 } 3515 }
3281 } 3516 }
3282 3517
3283 3518
3284 #undef CHECK_OK 3519 #undef CHECK_OK
3285 #undef CHECK_OK_CUSTOM 3520 #undef CHECK_OK_CUSTOM
3286 3521
3287
3288 template <typename Traits> 3522 template <typename Traits>
3289 void ParserBase<Traits>::ObjectLiteralChecker::CheckProperty( 3523 void ParserBase<Traits>::ObjectLiteralChecker::CheckProperty(
3290 Token::Value property, PropertyKind type, bool is_static, bool is_generator, 3524 Token::Value property, PropertyKind type, MethodKind method_type,
3291 bool* ok) { 3525 bool* ok) {
3292 DCHECK(!is_static); 3526 DCHECK(!IsStaticMethod(method_type));
3293 DCHECK(!is_generator || type == kMethodProperty); 3527 DCHECK(!IsSpecialMethod(method_type) || type == kMethodProperty);
3294 3528
3295 if (property == Token::SMI || property == Token::NUMBER) return; 3529 if (property == Token::SMI || property == Token::NUMBER) return;
3296 3530
3297 if (type == kValueProperty && IsProto()) { 3531 if (type == kValueProperty && IsProto()) {
3298 if (has_seen_proto_) { 3532 if (has_seen_proto_) {
3299 this->parser()->ReportMessage(MessageTemplate::kDuplicateProto); 3533 this->parser()->ReportMessage(MessageTemplate::kDuplicateProto);
3300 *ok = false; 3534 *ok = false;
3301 return; 3535 return;
3302 } 3536 }
3303 has_seen_proto_ = true; 3537 has_seen_proto_ = true;
3304 return; 3538 return;
3305 } 3539 }
3306 } 3540 }
3307 3541
3308
3309 template <typename Traits> 3542 template <typename Traits>
3310 void ParserBase<Traits>::ClassLiteralChecker::CheckProperty( 3543 void ParserBase<Traits>::ClassLiteralChecker::CheckProperty(
3311 Token::Value property, PropertyKind type, bool is_static, bool is_generator, 3544 Token::Value property, PropertyKind type, MethodKind method_type,
3312 bool* ok) { 3545 bool* ok) {
3313 DCHECK(type == kMethodProperty || type == kAccessorProperty); 3546 DCHECK(type == kMethodProperty || type == kAccessorProperty);
3314 3547
3315 if (property == Token::SMI || property == Token::NUMBER) return; 3548 if (property == Token::SMI || property == Token::NUMBER) return;
3316 3549
3317 if (is_static) { 3550 if (IsStaticMethod(method_type)) {
3318 if (IsPrototype()) { 3551 if (IsPrototype()) {
3319 this->parser()->ReportMessage(MessageTemplate::kStaticPrototype); 3552 this->parser()->ReportMessage(MessageTemplate::kStaticPrototype);
3320 *ok = false; 3553 *ok = false;
3321 return; 3554 return;
3322 } 3555 }
3323 } else if (IsConstructor()) { 3556 } else if (IsConstructor()) {
3324 if (is_generator || type == kAccessorProperty) { 3557 const bool is_generator = IsGeneratorMethod(method_type);
3558 const bool is_async = IsAsyncMethod(method_type);
3559 if (is_generator || is_async || type == kAccessorProperty) {
3325 MessageTemplate::Template msg = 3560 MessageTemplate::Template msg =
3326 is_generator ? MessageTemplate::kConstructorIsGenerator 3561 is_generator ? MessageTemplate::kConstructorIsGenerator
3327 : MessageTemplate::kConstructorIsAccessor; 3562 : is_async ? MessageTemplate::kConstructorIsAsync
3563 : MessageTemplate::kConstructorIsAccessor;
3328 this->parser()->ReportMessage(msg); 3564 this->parser()->ReportMessage(msg);
3329 *ok = false; 3565 *ok = false;
3330 return; 3566 return;
3331 } 3567 }
3332 if (has_seen_constructor_) { 3568 if (has_seen_constructor_) {
3333 this->parser()->ReportMessage(MessageTemplate::kDuplicateConstructor); 3569 this->parser()->ReportMessage(MessageTemplate::kDuplicateConstructor);
3334 *ok = false; 3570 *ok = false;
3335 return; 3571 return;
3336 } 3572 }
3337 has_seen_constructor_ = true; 3573 has_seen_constructor_ = true;
3338 return; 3574 return;
3339 } 3575 }
3340 } 3576 }
3341 3577
3342 3578
3343 } // namespace internal 3579 } // namespace internal
3344 } // namespace v8 3580 } // namespace v8
3345 3581
3346 #endif // V8_PARSING_PARSER_BASE_H 3582 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698