OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 #include <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace internal { | 22 namespace internal { |
23 | 23 |
24 // ---------------------------------------------------------------------------- | 24 // ---------------------------------------------------------------------------- |
25 // The CHECK_OK macro is a convenient macro to enforce error | 25 // The CHECK_OK macro is a convenient macro to enforce error |
26 // handling for functions that may fail (by returning !*ok). | 26 // handling for functions that may fail (by returning !*ok). |
27 // | 27 // |
28 // CAUTION: This macro appends extra statements after a call, | 28 // CAUTION: This macro appends extra statements after a call, |
29 // thus it must never be used where only a single statement | 29 // thus it must never be used where only a single statement |
30 // is correct (e.g. an if statement branch w/o braces)! | 30 // is correct (e.g. an if statement branch w/o braces)! |
31 | 31 |
32 #define CHECK_OK ok); \ | 32 #define CHECK_OK_VALUE(x) ok); \ |
33 if (!*ok) return Statement::Default(); \ | 33 if (!*ok) return x; \ |
34 ((void)0 | 34 ((void)0 |
35 #define DUMMY ) // to make indentation work | 35 #define DUMMY ) // to make indentation work |
36 #undef DUMMY | 36 #undef DUMMY |
37 | 37 |
38 // Used in functions where the return type is not ExpressionT. | 38 #define CHECK_OK CHECK_OK_VALUE(Statement::Default()) |
39 #define CHECK_OK_CUSTOM(x) ok); \ | 39 #define CHECK_OK_VOID CHECK_OK_VALUE(this->Void()) |
40 if (!*ok) return this->x(); \ | |
41 ((void)0 | |
42 #define DUMMY ) // to make indentation work | |
43 #undef DUMMY | |
44 | 40 |
45 PreParserIdentifier PreParser::GetSymbol() const { | 41 PreParserIdentifier PreParser::GetSymbol() const { |
46 switch (scanner()->current_token()) { | 42 switch (scanner()->current_token()) { |
47 case Token::ENUM: | 43 case Token::ENUM: |
48 return PreParserIdentifier::Enum(); | 44 return PreParserIdentifier::Enum(); |
49 case Token::AWAIT: | 45 case Token::AWAIT: |
50 return PreParserIdentifier::Await(); | 46 return PreParserIdentifier::Await(); |
51 case Token::FUTURE_STRICT_RESERVED_WORD: | 47 case Token::FUTURE_STRICT_RESERVED_WORD: |
52 return PreParserIdentifier::FutureStrictReserved(); | 48 return PreParserIdentifier::FutureStrictReserved(); |
53 case Token::LET: | 49 case Token::LET: |
(...skipping 14 matching lines...) Expand all Loading... |
68 if (scanner()->LiteralMatches("prototype", 9)) | 64 if (scanner()->LiteralMatches("prototype", 9)) |
69 return PreParserIdentifier::Prototype(); | 65 return PreParserIdentifier::Prototype(); |
70 if (scanner()->LiteralMatches("constructor", 11)) | 66 if (scanner()->LiteralMatches("constructor", 11)) |
71 return PreParserIdentifier::Constructor(); | 67 return PreParserIdentifier::Constructor(); |
72 return PreParserIdentifier::Default(); | 68 return PreParserIdentifier::Default(); |
73 } | 69 } |
74 } | 70 } |
75 | 71 |
76 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 72 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
77 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters, | 73 LanguageMode language_mode, FunctionKind kind, bool has_simple_parameters, |
78 bool parsing_module, ParserRecorder* log, Scanner::BookmarkScope* bookmark, | 74 bool parsing_module, ParserRecorder* log, bool may_abort, int* use_counts) { |
79 int* use_counts) { | |
80 parsing_module_ = parsing_module; | 75 parsing_module_ = parsing_module; |
81 log_ = log; | 76 log_ = log; |
82 use_counts_ = use_counts; | 77 use_counts_ = use_counts; |
83 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 78 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
84 DCHECK_NULL(scope_state_); | 79 DCHECK_NULL(scope_state_); |
85 DeclarationScope* top_scope = NewScriptScope(); | 80 DeclarationScope* top_scope = NewScriptScope(); |
86 FunctionState top_state(&function_state_, &scope_state_, top_scope, | 81 FunctionState top_state(&function_state_, &scope_state_, top_scope, |
87 kNormalFunction); | 82 kNormalFunction); |
88 scope()->SetLanguageMode(language_mode); | 83 scope()->SetLanguageMode(language_mode); |
89 DeclarationScope* function_scope = NewFunctionScope(kind); | 84 DeclarationScope* function_scope = NewFunctionScope(kind); |
90 if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters(); | 85 if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters(); |
91 FunctionState function_state(&function_state_, &scope_state_, function_scope, | 86 FunctionState function_state(&function_state_, &scope_state_, function_scope, |
92 kind); | 87 kind); |
93 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 88 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
94 bool ok = true; | 89 bool ok = true; |
95 int start_position = peek_position(); | 90 int start_position = peek_position(); |
96 ParseLazyFunctionLiteralBody(&ok, bookmark); | 91 LazyParsingResult result = ParseLazyFunctionLiteralBody(may_abort, &ok); |
97 use_counts_ = nullptr; | 92 use_counts_ = nullptr; |
98 if (bookmark && bookmark->HasBeenReset()) { | 93 if (result == kLazyParsingAborted) { |
99 // Do nothing, as we've just aborted scanning this function. | 94 return kPreParseAbort; |
100 } else if (stack_overflow()) { | 95 } else if (stack_overflow()) { |
101 return kPreParseStackOverflow; | 96 return kPreParseStackOverflow; |
102 } else if (!ok) { | 97 } else if (!ok) { |
103 ReportUnexpectedToken(scanner()->current_token()); | 98 ReportUnexpectedToken(scanner()->current_token()); |
104 } else { | 99 } else { |
105 DCHECK_EQ(Token::RBRACE, scanner()->peek()); | 100 DCHECK_EQ(Token::RBRACE, scanner()->peek()); |
106 if (is_strict(scope()->language_mode())) { | 101 if (is_strict(scope()->language_mode())) { |
107 int end_pos = scanner()->location().end_pos; | 102 int end_pos = scanner()->location().end_pos; |
108 CheckStrictOctalLiteral(start_position, end_pos, &ok); | 103 CheckStrictOctalLiteral(start_position, end_pos, &ok); |
109 CheckDecimalLiteralWithLeadingZero(use_counts, start_position, end_pos); | 104 CheckDecimalLiteralWithLeadingZero(use_counts, start_position, end_pos); |
110 if (!ok) return kPreParseSuccess; | |
111 } | 105 } |
112 } | 106 } |
113 return kPreParseSuccess; | 107 return kPreParseSuccess; |
114 } | 108 } |
115 | 109 |
116 | 110 |
117 // Preparsing checks a JavaScript program and emits preparse-data that helps | 111 // Preparsing checks a JavaScript program and emits preparse-data that helps |
118 // a later parsing to be faster. | 112 // a later parsing to be faster. |
119 // See preparser-data.h for the data. | 113 // See preparser-data.h for the data. |
120 | 114 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 Consume(Token::ASYNC); | 158 Consume(Token::ASYNC); |
165 return ParseAsyncFunctionDeclaration(ok); | 159 return ParseAsyncFunctionDeclaration(ok); |
166 } | 160 } |
167 /* falls through */ | 161 /* falls through */ |
168 default: | 162 default: |
169 break; | 163 break; |
170 } | 164 } |
171 return ParseStatement(kAllowLabelledFunctionStatement, ok); | 165 return ParseStatement(kAllowLabelledFunctionStatement, ok); |
172 } | 166 } |
173 | 167 |
174 | 168 PreParser::LazyParsingResult PreParser::ParseStatementList(int end_token, |
175 void PreParser::ParseStatementList(int end_token, bool* ok, | 169 bool may_abort, |
176 Scanner::BookmarkScope* bookmark) { | 170 bool* ok) { |
177 // SourceElements :: | 171 // SourceElements :: |
178 // (Statement)* <end_token> | 172 // (Statement)* <end_token> |
179 | 173 |
180 // Bookkeeping for trial parse if bookmark is set: | |
181 DCHECK_IMPLIES(bookmark, bookmark->HasBeenSet()); | |
182 bool maybe_reset = bookmark != nullptr; | |
183 int count_statements = 0; | 174 int count_statements = 0; |
184 | 175 |
185 bool directive_prologue = true; | 176 bool directive_prologue = true; |
186 while (peek() != end_token) { | 177 while (peek() != end_token) { |
187 if (directive_prologue && peek() != Token::STRING) { | 178 if (directive_prologue && peek() != Token::STRING) { |
188 directive_prologue = false; | 179 directive_prologue = false; |
189 } | 180 } |
190 bool starts_with_identifier = peek() == Token::IDENTIFIER; | 181 bool starts_with_identifier = peek() == Token::IDENTIFIER; |
191 Scanner::Location token_loc = scanner()->peek_location(); | 182 Scanner::Location token_loc = scanner()->peek_location(); |
192 Statement statement = ParseStatementListItem(CHECK_OK_CUSTOM(Void)); | 183 Statement statement = |
| 184 ParseStatementListItem(CHECK_OK_VALUE(kLazyParsingComplete)); |
193 | 185 |
194 if (directive_prologue) { | 186 if (directive_prologue) { |
195 bool use_strict_found = statement.IsUseStrictLiteral(); | 187 bool use_strict_found = statement.IsUseStrictLiteral(); |
196 | 188 |
197 if (use_strict_found) { | 189 if (use_strict_found) { |
198 scope()->SetLanguageMode( | 190 scope()->SetLanguageMode( |
199 static_cast<LanguageMode>(scope()->language_mode() | STRICT)); | 191 static_cast<LanguageMode>(scope()->language_mode() | STRICT)); |
200 } else if (!statement.IsStringLiteral()) { | 192 } else if (!statement.IsStringLiteral()) { |
201 directive_prologue = false; | 193 directive_prologue = false; |
202 } | 194 } |
203 | 195 |
204 if (use_strict_found && !scope()->HasSimpleParameters()) { | 196 if (use_strict_found && !scope()->HasSimpleParameters()) { |
205 // TC39 deemed "use strict" directives to be an error when occurring | 197 // TC39 deemed "use strict" directives to be an error when occurring |
206 // in the body of a function with non-simple parameter list, on | 198 // in the body of a function with non-simple parameter list, on |
207 // 29/7/2015. https://goo.gl/ueA7Ln | 199 // 29/7/2015. https://goo.gl/ueA7Ln |
208 ReportMessageAt(token_loc, | 200 ReportMessageAt(token_loc, |
209 MessageTemplate::kIllegalLanguageModeDirective, | 201 MessageTemplate::kIllegalLanguageModeDirective, |
210 "use strict"); | 202 "use strict"); |
211 *ok = false; | 203 *ok = false; |
212 return; | 204 return kLazyParsingComplete; |
213 } | 205 } |
214 } | 206 } |
215 | 207 |
216 // If we're allowed to reset to a bookmark, we will do so when we see a long | 208 // If we're allowed to reset to a bookmark, we will do so when we see a long |
217 // and trivial function. | 209 // and trivial function. |
218 // Our current definition of 'long and trivial' is: | 210 // Our current definition of 'long and trivial' is: |
219 // - over 200 statements | 211 // - over 200 statements |
220 // - all starting with an identifier (i.e., no if, for, while, etc.) | 212 // - all starting with an identifier (i.e., no if, for, while, etc.) |
221 if (maybe_reset && (!starts_with_identifier || | 213 if (may_abort) { |
222 ++count_statements > kLazyParseTrialLimit)) { | 214 if (!starts_with_identifier) { |
223 if (count_statements > kLazyParseTrialLimit) { | 215 may_abort = false; |
224 bookmark->Reset(); | 216 } else if (++count_statements > kLazyParseTrialLimit) { |
225 return; | 217 return kLazyParsingAborted; |
226 } | 218 } |
227 maybe_reset = false; | |
228 } | 219 } |
229 } | 220 } |
| 221 return kLazyParsingComplete; |
230 } | 222 } |
231 | 223 |
232 | 224 |
233 PreParser::Statement PreParser::ParseStatement( | 225 PreParser::Statement PreParser::ParseStatement( |
234 AllowLabelledFunctionStatement allow_function, bool* ok) { | 226 AllowLabelledFunctionStatement allow_function, bool* ok) { |
235 // Statement :: | 227 // Statement :: |
236 // EmptyStatement | 228 // EmptyStatement |
237 // ... | 229 // ... |
238 | 230 |
239 if (peek() == Token::SEMICOLON) { | 231 if (peek() == Token::SEMICOLON) { |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 (peek() == Token::LET && IsNextLetKeyword())) { | 800 (peek() == Token::LET && IsNextLetKeyword())) { |
809 int decl_count; | 801 int decl_count; |
810 bool is_lexical; | 802 bool is_lexical; |
811 bool is_binding_pattern; | 803 bool is_binding_pattern; |
812 Scanner::Location first_initializer_loc = Scanner::Location::invalid(); | 804 Scanner::Location first_initializer_loc = Scanner::Location::invalid(); |
813 Scanner::Location bindings_loc = Scanner::Location::invalid(); | 805 Scanner::Location bindings_loc = Scanner::Location::invalid(); |
814 ParseVariableDeclarations(kForStatement, &decl_count, &is_lexical, | 806 ParseVariableDeclarations(kForStatement, &decl_count, &is_lexical, |
815 &is_binding_pattern, &first_initializer_loc, | 807 &is_binding_pattern, &first_initializer_loc, |
816 &bindings_loc, CHECK_OK); | 808 &bindings_loc, CHECK_OK); |
817 if (is_lexical) has_lexical = true; | 809 if (is_lexical) has_lexical = true; |
818 if (CheckInOrOf(&mode, ok)) { | 810 if (CheckInOrOf(&mode)) { |
819 if (!*ok) return Statement::Default(); | |
820 if (decl_count != 1) { | 811 if (decl_count != 1) { |
821 ReportMessageAt(bindings_loc, | 812 ReportMessageAt(bindings_loc, |
822 MessageTemplate::kForInOfLoopMultiBindings, | 813 MessageTemplate::kForInOfLoopMultiBindings, |
823 ForEachStatement::VisitModeString(mode)); | 814 ForEachStatement::VisitModeString(mode)); |
824 *ok = false; | 815 *ok = false; |
825 return Statement::Default(); | 816 return Statement::Default(); |
826 } | 817 } |
827 if (first_initializer_loc.IsValid() && | 818 if (first_initializer_loc.IsValid() && |
828 (is_strict(language_mode()) || mode == ForEachStatement::ITERATE || | 819 (is_strict(language_mode()) || mode == ForEachStatement::ITERATE || |
829 is_lexical || is_binding_pattern || allow_harmony_for_in())) { | 820 is_lexical || is_binding_pattern || allow_harmony_for_in())) { |
(...skipping 23 matching lines...) Expand all Loading... |
853 ReturnExprContext::kInsideForInOfBody); | 844 ReturnExprContext::kInsideForInOfBody); |
854 ParseScopedStatement(true, CHECK_OK); | 845 ParseScopedStatement(true, CHECK_OK); |
855 } | 846 } |
856 return Statement::Default(); | 847 return Statement::Default(); |
857 } | 848 } |
858 } else { | 849 } else { |
859 int lhs_beg_pos = peek_position(); | 850 int lhs_beg_pos = peek_position(); |
860 ExpressionClassifier classifier(this); | 851 ExpressionClassifier classifier(this); |
861 Expression lhs = ParseExpressionCoverGrammar(false, CHECK_OK); | 852 Expression lhs = ParseExpressionCoverGrammar(false, CHECK_OK); |
862 int lhs_end_pos = scanner()->location().end_pos; | 853 int lhs_end_pos = scanner()->location().end_pos; |
863 bool is_for_each = CheckInOrOf(&mode, CHECK_OK); | 854 bool is_for_each = CheckInOrOf(&mode); |
864 bool is_destructuring = is_for_each && | 855 bool is_destructuring = is_for_each && |
865 (lhs->IsArrayLiteral() || lhs->IsObjectLiteral()); | 856 (lhs->IsArrayLiteral() || lhs->IsObjectLiteral()); |
866 | 857 |
867 if (is_destructuring) { | 858 if (is_destructuring) { |
868 ValidateAssignmentPattern(CHECK_OK); | 859 ValidateAssignmentPattern(CHECK_OK); |
869 } else { | 860 } else { |
870 ValidateExpression(CHECK_OK); | 861 ValidateExpression(CHECK_OK); |
871 } | 862 } |
872 | 863 |
873 if (is_for_each) { | 864 if (is_for_each) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1013 // 'debugger' ';' | 1004 // 'debugger' ';' |
1014 | 1005 |
1015 Expect(Token::DEBUGGER, CHECK_OK); | 1006 Expect(Token::DEBUGGER, CHECK_OK); |
1016 ExpectSemicolon(ok); | 1007 ExpectSemicolon(ok); |
1017 return Statement::Default(); | 1008 return Statement::Default(); |
1018 } | 1009 } |
1019 | 1010 |
1020 | 1011 |
1021 // Redefinition of CHECK_OK for parsing expressions. | 1012 // Redefinition of CHECK_OK for parsing expressions. |
1022 #undef CHECK_OK | 1013 #undef CHECK_OK |
1023 #define CHECK_OK ok); \ | 1014 #define CHECK_OK CHECK_OK_VALUE(Expression::Default()) |
1024 if (!*ok) return Expression::Default(); \ | |
1025 ((void)0 | |
1026 #define DUMMY ) // to make indentation work | |
1027 #undef DUMMY | |
1028 | |
1029 | 1015 |
1030 PreParser::Expression PreParser::ParseFunctionLiteral( | 1016 PreParser::Expression PreParser::ParseFunctionLiteral( |
1031 Identifier function_name, Scanner::Location function_name_location, | 1017 Identifier function_name, Scanner::Location function_name_location, |
1032 FunctionNameValidity function_name_validity, FunctionKind kind, | 1018 FunctionNameValidity function_name_validity, FunctionKind kind, |
1033 int function_token_pos, FunctionLiteral::FunctionType function_type, | 1019 int function_token_pos, FunctionLiteral::FunctionType function_type, |
1034 LanguageMode language_mode, bool* ok) { | 1020 LanguageMode language_mode, bool* ok) { |
1035 // Function :: | 1021 // Function :: |
1036 // '(' FormalParameterList? ')' '{' FunctionBody '}' | 1022 // '(' FormalParameterList? ')' '{' FunctionBody '}' |
1037 | 1023 |
1038 // Parse function body. | 1024 // Parse function body. |
(...skipping 16 matching lines...) Expand all Loading... |
1055 CheckArityRestrictions(formals.arity, kind, formals.has_rest, start_position, | 1041 CheckArityRestrictions(formals.arity, kind, formals.has_rest, start_position, |
1056 formals_end_position, CHECK_OK); | 1042 formals_end_position, CHECK_OK); |
1057 | 1043 |
1058 // See Parser::ParseFunctionLiteral for more information about lazy parsing | 1044 // See Parser::ParseFunctionLiteral for more information about lazy parsing |
1059 // and lazy compilation. | 1045 // and lazy compilation. |
1060 bool is_lazily_parsed = (outer_is_script_scope && allow_lazy() && | 1046 bool is_lazily_parsed = (outer_is_script_scope && allow_lazy() && |
1061 !function_state_->this_function_is_parenthesized()); | 1047 !function_state_->this_function_is_parenthesized()); |
1062 | 1048 |
1063 Expect(Token::LBRACE, CHECK_OK); | 1049 Expect(Token::LBRACE, CHECK_OK); |
1064 if (is_lazily_parsed) { | 1050 if (is_lazily_parsed) { |
1065 ParseLazyFunctionLiteralBody(CHECK_OK); | 1051 ParseLazyFunctionLiteralBody(false, CHECK_OK); |
1066 } else { | 1052 } else { |
1067 ParseStatementList(Token::RBRACE, CHECK_OK); | 1053 ParseStatementList(Token::RBRACE, CHECK_OK); |
1068 } | 1054 } |
1069 Expect(Token::RBRACE, CHECK_OK); | 1055 Expect(Token::RBRACE, CHECK_OK); |
1070 | 1056 |
1071 // Parsing the body may change the language mode in our scope. | 1057 // Parsing the body may change the language mode in our scope. |
1072 language_mode = function_scope->language_mode(); | 1058 language_mode = function_scope->language_mode(); |
1073 | 1059 |
1074 // Validate name and parameter names. We can do this only after parsing the | 1060 // Validate name and parameter names. We can do this only after parsing the |
1075 // function, since the function can declare itself strict. | 1061 // function, since the function can declare itself strict. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 } | 1095 } |
1110 | 1096 |
1111 ParseFunctionLiteral(name, scanner()->location(), | 1097 ParseFunctionLiteral(name, scanner()->location(), |
1112 is_strict_reserved ? kFunctionNameIsStrictReserved | 1098 is_strict_reserved ? kFunctionNameIsStrictReserved |
1113 : kFunctionNameValidityUnknown, | 1099 : kFunctionNameValidityUnknown, |
1114 FunctionKind::kAsyncFunction, pos, type, language_mode(), | 1100 FunctionKind::kAsyncFunction, pos, type, language_mode(), |
1115 CHECK_OK); | 1101 CHECK_OK); |
1116 return Expression::Default(); | 1102 return Expression::Default(); |
1117 } | 1103 } |
1118 | 1104 |
1119 void PreParser::ParseLazyFunctionLiteralBody(bool* ok, | 1105 PreParser::LazyParsingResult PreParser::ParseLazyFunctionLiteralBody( |
1120 Scanner::BookmarkScope* bookmark) { | 1106 bool may_abort, bool* ok) { |
1121 int body_start = position(); | 1107 int body_start = position(); |
1122 ParseStatementList(Token::RBRACE, ok, bookmark); | 1108 LazyParsingResult result = ParseStatementList( |
1123 if (!*ok) return; | 1109 Token::RBRACE, may_abort, CHECK_OK_VALUE(kLazyParsingComplete)); |
1124 if (bookmark && bookmark->HasBeenReset()) return; | 1110 if (result == kLazyParsingAborted) return result; |
1125 | 1111 |
1126 // Position right after terminal '}'. | 1112 // Position right after terminal '}'. |
1127 DCHECK_EQ(Token::RBRACE, scanner()->peek()); | 1113 DCHECK_EQ(Token::RBRACE, scanner()->peek()); |
1128 int body_end = scanner()->peek_location().end_pos; | 1114 int body_end = scanner()->peek_location().end_pos; |
1129 DeclarationScope* scope = this->scope()->AsDeclarationScope(); | 1115 DeclarationScope* scope = this->scope()->AsDeclarationScope(); |
1130 DCHECK(scope->is_function_scope()); | 1116 DCHECK(scope->is_function_scope()); |
1131 log_->LogFunction(body_start, body_end, | 1117 log_->LogFunction(body_start, body_end, |
1132 function_state_->materialized_literal_count(), | 1118 function_state_->materialized_literal_count(), |
1133 function_state_->expected_property_count(), language_mode(), | 1119 function_state_->expected_property_count(), language_mode(), |
1134 scope->uses_super_property(), scope->calls_eval()); | 1120 scope->uses_super_property(), scope->calls_eval()); |
| 1121 return kLazyParsingComplete; |
1135 } | 1122 } |
1136 | 1123 |
1137 PreParserExpression PreParser::ParseClassLiteral( | 1124 PreParserExpression PreParser::ParseClassLiteral( |
1138 PreParserIdentifier name, Scanner::Location class_name_location, | 1125 PreParserIdentifier name, Scanner::Location class_name_location, |
1139 bool name_is_strict_reserved, int pos, bool* ok) { | 1126 bool name_is_strict_reserved, int pos, bool* ok) { |
1140 // All parts of a ClassDeclaration and ClassExpression are strict code. | 1127 // All parts of a ClassDeclaration and ClassExpression are strict code. |
1141 if (name_is_strict_reserved) { | 1128 if (name_is_strict_reserved) { |
1142 ReportMessageAt(class_name_location, | 1129 ReportMessageAt(class_name_location, |
1143 MessageTemplate::kUnexpectedStrictReserved); | 1130 MessageTemplate::kUnexpectedStrictReserved); |
1144 *ok = false; | 1131 *ok = false; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 Expect(Token::RBRACE, CHECK_OK); | 1208 Expect(Token::RBRACE, CHECK_OK); |
1222 return PreParserExpression::Default(); | 1209 return PreParserExpression::Default(); |
1223 } | 1210 } |
1224 | 1211 |
1225 void PreParser::ParseAsyncArrowSingleExpressionBody(PreParserStatementList body, | 1212 void PreParser::ParseAsyncArrowSingleExpressionBody(PreParserStatementList body, |
1226 bool accept_IN, int pos, | 1213 bool accept_IN, int pos, |
1227 bool* ok) { | 1214 bool* ok) { |
1228 scope()->ForceContextAllocation(); | 1215 scope()->ForceContextAllocation(); |
1229 | 1216 |
1230 PreParserExpression return_value = | 1217 PreParserExpression return_value = |
1231 ParseAssignmentExpression(accept_IN, CHECK_OK_CUSTOM(Void)); | 1218 ParseAssignmentExpression(accept_IN, CHECK_OK_VOID); |
1232 | 1219 |
1233 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); | 1220 body->Add(PreParserStatement::ExpressionStatement(return_value), zone()); |
1234 } | 1221 } |
1235 | 1222 |
1236 #undef CHECK_OK | 1223 #undef CHECK_OK |
1237 #undef CHECK_OK_CUSTOM | 1224 #undef CHECK_OK_CUSTOM |
1238 | 1225 |
1239 | 1226 |
1240 } // namespace internal | 1227 } // namespace internal |
1241 } // namespace v8 | 1228 } // namespace v8 |
OLD | NEW |