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

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

Issue 2160593002: Introduce parent ScopeState class and track the scope through the state in the parser (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 5 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/base/hashmap.h" 10 #include "src/base/hashmap.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT; 194 typedef typename Traits::Type::FunctionLiteral FunctionLiteralT;
195 typedef typename Traits::Type::Literal LiteralT; 195 typedef typename Traits::Type::Literal LiteralT;
196 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT; 196 typedef typename Traits::Type::ObjectLiteralProperty ObjectLiteralPropertyT;
197 typedef typename Traits::Type::StatementList StatementListT; 197 typedef typename Traits::Type::StatementList StatementListT;
198 typedef typename Traits::Type::ExpressionClassifier ExpressionClassifier; 198 typedef typename Traits::Type::ExpressionClassifier ExpressionClassifier;
199 199
200 ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit, 200 ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit,
201 v8::Extension* extension, AstValueFactory* ast_value_factory, 201 v8::Extension* extension, AstValueFactory* ast_value_factory,
202 ParserRecorder* log, typename Traits::Type::Parser this_object) 202 ParserRecorder* log, typename Traits::Type::Parser this_object)
203 : Traits(this_object), 203 : Traits(this_object),
204 scope_(NULL), 204 scope_state_(nullptr),
205 function_state_(NULL), 205 function_state_(nullptr),
206 extension_(extension), 206 extension_(extension),
207 fni_(NULL), 207 fni_(nullptr),
208 ast_value_factory_(ast_value_factory), 208 ast_value_factory_(ast_value_factory),
209 log_(log), 209 log_(log),
210 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly. 210 mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly.
211 parsing_module_(false), 211 parsing_module_(false),
212 stack_limit_(stack_limit), 212 stack_limit_(stack_limit),
213 zone_(zone), 213 zone_(zone),
214 scanner_(scanner), 214 scanner_(scanner),
215 stack_overflow_(false), 215 stack_overflow_(false),
216 allow_lazy_(false), 216 allow_lazy_(false),
217 allow_natives_(false), 217 allow_natives_(false),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 enum VariableDeclarationContext { 265 enum VariableDeclarationContext {
266 kStatementListItem, 266 kStatementListItem,
267 kStatement, 267 kStatement,
268 kForStatement 268 kForStatement
269 }; 269 };
270 270
271 class Checkpoint; 271 class Checkpoint;
272 class ObjectLiteralCheckerBase; 272 class ObjectLiteralCheckerBase;
273 273
274 // --------------------------------------------------------------------------- 274 // ---------------------------------------------------------------------------
275 // FunctionState and BlockState together implement the parser's scope stack. 275 // ScopeState and its subclasses implement the parser's scope stack.
276 // The parser's current scope is in scope_. BlockState and FunctionState 276 // ScopeState keeps track of the current scope, and the outer ScopeState. The
277 // constructors push on the scope stack and the destructors pop. They are also 277 // parser's scope_state_ points to the top ScopeState. ScopeState's
278 // used to hold the parser's per-function and per-block state. 278 // constructor push on the scope stack and the destructors pop. BlockState and
279 class BlockState BASE_EMBEDDED { 279 // FunctionState are used to hold additional per-block and per-function state.
280 class ScopeState BASE_EMBEDDED {
280 public: 281 public:
281 BlockState(Scope** scope_stack, Scope* scope) 282 V8_INLINE Scope* scope() const { return scope_; }
282 : scope_stack_(scope_stack), outer_scope_(*scope_stack) { 283
283 *scope_stack_ = scope; 284 protected:
285 ScopeState(ScopeState** scope_stack, Scope* scope)
286 : scope_stack_(scope_stack), outer_scope_(*scope_stack), scope_(scope) {
287 *scope_stack = this;
284 } 288 }
285 ~BlockState() { *scope_stack_ = outer_scope_; } 289 ~ScopeState() { *scope_stack_ = outer_scope_; }
290
291 Zone* zone() const { return scope_->zone(); }
286 292
287 private: 293 private:
288 Scope** scope_stack_; 294 ScopeState** scope_stack_;
289 Scope* outer_scope_; 295 ScopeState* outer_scope_;
296 Scope* scope_;
297 };
298
299 class BlockState final : public ScopeState {
300 public:
301 BlockState(ScopeState** scope_stack, Scope* scope)
302 : ScopeState(scope_stack, scope) {}
290 }; 303 };
291 304
292 struct DestructuringAssignment { 305 struct DestructuringAssignment {
293 public: 306 public:
294 DestructuringAssignment(ExpressionT expression, Scope* scope) 307 DestructuringAssignment(ExpressionT expression, Scope* scope)
295 : assignment(expression), scope(scope) {} 308 : assignment(expression), scope(scope) {}
296 309
297 ExpressionT assignment; 310 ExpressionT assignment;
298 Scope* scope; 311 Scope* scope;
299 }; 312 };
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 362
350 // We are inside a block in which tail call expressions are allowed but 363 // We are inside a block in which tail call expressions are allowed but
351 // not yet inside a return statement. 364 // not yet inside a return statement.
352 kInsideValidBlock, 365 kInsideValidBlock,
353 366
354 // Tail call expressions are not allowed in the following blocks. 367 // Tail call expressions are not allowed in the following blocks.
355 kInsideTryBlock, 368 kInsideTryBlock,
356 kInsideForInOfBody, 369 kInsideForInOfBody,
357 }; 370 };
358 371
359 class FunctionState BASE_EMBEDDED { 372 class FunctionState final : public ScopeState {
360 public: 373 public:
361 FunctionState(FunctionState** function_state_stack, Scope** scope_stack, 374 FunctionState(FunctionState** function_state_stack,
362 Scope* scope, FunctionKind kind, 375 ScopeState** scope_stack, Scope* scope, FunctionKind kind,
363 typename Traits::Type::Factory* factory); 376 typename Traits::Type::Factory* factory);
364 ~FunctionState(); 377 ~FunctionState();
365 378
366 int NextMaterializedLiteralIndex() { 379 int NextMaterializedLiteralIndex() {
367 return next_materialized_literal_index_++; 380 return next_materialized_literal_index_++;
368 } 381 }
369 int materialized_literal_count() { 382 int materialized_literal_count() {
370 return next_materialized_literal_index_; 383 return next_materialized_literal_index_;
371 } 384 }
372 385
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 void next_function_is_parenthesized(bool parenthesized) { 464 void next_function_is_parenthesized(bool parenthesized) {
452 next_function_is_parenthesized_ = parenthesized; 465 next_function_is_parenthesized_ = parenthesized;
453 } 466 }
454 467
455 bool this_function_is_parenthesized() const { 468 bool this_function_is_parenthesized() const {
456 return this_function_is_parenthesized_; 469 return this_function_is_parenthesized_;
457 } 470 }
458 471
459 private: 472 private:
460 void AddDestructuringAssignment(DestructuringAssignment pair) { 473 void AddDestructuringAssignment(DestructuringAssignment pair) {
461 destructuring_assignments_to_rewrite_.Add(pair, (*scope_stack_)->zone()); 474 destructuring_assignments_to_rewrite_.Add(pair, this->zone());
462 } 475 }
463 476
464 V8_INLINE Scope* scope() { return *scope_stack_; }
465
466 void AddNonPatternForRewriting(ExpressionT expr, bool* ok) { 477 void AddNonPatternForRewriting(ExpressionT expr, bool* ok) {
467 non_patterns_to_rewrite_.Add(expr, (*scope_stack_)->zone()); 478 non_patterns_to_rewrite_.Add(expr, this->zone());
468 if (non_patterns_to_rewrite_.length() >= 479 if (non_patterns_to_rewrite_.length() >=
469 std::numeric_limits<uint16_t>::max()) 480 std::numeric_limits<uint16_t>::max())
470 *ok = false; 481 *ok = false;
471 } 482 }
472 483
473 // Used to assign an index to each literal that needs materialization in 484 // Used to assign an index to each literal that needs materialization in
474 // the function. Includes regexp literals, and boilerplate for object and 485 // the function. Includes regexp literals, and boilerplate for object and
475 // array literals. 486 // array literals.
476 int next_materialized_literal_index_; 487 int next_materialized_literal_index_;
477 488
(...skipping 10 matching lines...) Expand all
488 Scanner::Location super_location_; 499 Scanner::Location super_location_;
489 500
490 FunctionKind kind_; 501 FunctionKind kind_;
491 // For generators, this variable may hold the generator object. It variable 502 // For generators, this variable may hold the generator object. It variable
492 // is used by yield expressions and return statements. It is not necessary 503 // is used by yield expressions and return statements. It is not necessary
493 // for generator functions to have this variable set. 504 // for generator functions to have this variable set.
494 Variable* generator_object_variable_; 505 Variable* generator_object_variable_;
495 506
496 FunctionState** function_state_stack_; 507 FunctionState** function_state_stack_;
497 FunctionState* outer_function_state_; 508 FunctionState* outer_function_state_;
498 Scope** scope_stack_;
499 Scope* outer_scope_;
500 509
501 ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_; 510 ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_;
502 TailCallExpressionList tail_call_expressions_; 511 TailCallExpressionList tail_call_expressions_;
503 ReturnExprContext return_expr_context_; 512 ReturnExprContext return_expr_context_;
504 ZoneList<ExpressionT> non_patterns_to_rewrite_; 513 ZoneList<ExpressionT> non_patterns_to_rewrite_;
505 514
506 ZoneList<typename ExpressionClassifier::Error> reported_errors_; 515 ZoneList<typename ExpressionClassifier::Error> reported_errors_;
507 516
508 typename Traits::Type::Factory* factory_; 517 typename Traits::Type::Factory* factory_;
509 518
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 static int Precedence(Token::Value token, bool accept_IN) { 817 static int Precedence(Token::Value token, bool accept_IN) {
809 if (token == Token::IN && !accept_IN) 818 if (token == Token::IN && !accept_IN)
810 return 0; // 0 precedence will terminate binary expression parsing 819 return 0; // 0 precedence will terminate binary expression parsing
811 return Token::Precedence(token); 820 return Token::Precedence(token);
812 } 821 }
813 822
814 typename Traits::Type::Factory* factory() { 823 typename Traits::Type::Factory* factory() {
815 return function_state_->factory(); 824 return function_state_->factory();
816 } 825 }
817 826
818 LanguageMode language_mode() { return scope_->language_mode(); } 827 LanguageMode language_mode() { return scope()->language_mode(); }
819 bool is_generator() const { return function_state_->is_generator(); } 828 bool is_generator() const { return function_state_->is_generator(); }
820 bool is_async_function() const { 829 bool is_async_function() const {
821 return function_state_->is_async_function(); 830 return function_state_->is_async_function();
822 } 831 }
823 bool is_resumable() const { return function_state_->is_resumable(); } 832 bool is_resumable() const { return function_state_->is_resumable(); }
824 833
825 // Report syntax errors. 834 // Report syntax errors.
826 void ReportMessage(MessageTemplate::Template message, const char* arg = NULL, 835 void ReportMessage(MessageTemplate::Template message, const char* arg = NULL,
827 ParseErrorType error_type = kSyntaxError) { 836 ParseErrorType error_type = kSyntaxError) {
828 Scanner::Location source_location = scanner()->location(); 837 Scanner::Location source_location = scanner()->location();
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 bool IsConstructor() { 1193 bool IsConstructor() {
1185 return this->scanner()->LiteralMatches("constructor", 11); 1194 return this->scanner()->LiteralMatches("constructor", 11);
1186 } 1195 }
1187 bool IsPrototype() { 1196 bool IsPrototype() {
1188 return this->scanner()->LiteralMatches("prototype", 9); 1197 return this->scanner()->LiteralMatches("prototype", 9);
1189 } 1198 }
1190 1199
1191 bool has_seen_constructor_; 1200 bool has_seen_constructor_;
1192 }; 1201 };
1193 1202
1194 Scope* scope_; // Scope stack. 1203 ModuleDescriptor* module() const { return scope()->module(); }
1204 Scope* scope() const { return scope_state_->scope(); }
1205
1206 ScopeState* scope_state_; // Scope stack.
1195 FunctionState* function_state_; // Function state stack. 1207 FunctionState* function_state_; // Function state stack.
1196 v8::Extension* extension_; 1208 v8::Extension* extension_;
1197 FuncNameInferrer* fni_; 1209 FuncNameInferrer* fni_;
1198 AstValueFactory* ast_value_factory_; // Not owned. 1210 AstValueFactory* ast_value_factory_; // Not owned.
1199 ParserRecorder* log_; 1211 ParserRecorder* log_;
1200 Mode mode_; 1212 Mode mode_;
1201 bool parsing_module_; 1213 bool parsing_module_;
1202 uintptr_t stack_limit_; 1214 uintptr_t stack_limit_;
1203 1215
1204 private: 1216 private:
1205 Zone* zone_; 1217 Zone* zone_;
1206 1218
1207 Scanner* scanner_; 1219 Scanner* scanner_;
1208 bool stack_overflow_; 1220 bool stack_overflow_;
1209 1221
1210 bool allow_lazy_; 1222 bool allow_lazy_;
1211 bool allow_natives_; 1223 bool allow_natives_;
1212 bool allow_tailcalls_; 1224 bool allow_tailcalls_;
1213 bool allow_harmony_restrictive_declarations_; 1225 bool allow_harmony_restrictive_declarations_;
1214 bool allow_harmony_do_expressions_; 1226 bool allow_harmony_do_expressions_;
1215 bool allow_harmony_for_in_; 1227 bool allow_harmony_for_in_;
1216 bool allow_harmony_function_sent_; 1228 bool allow_harmony_function_sent_;
1217 bool allow_harmony_async_await_; 1229 bool allow_harmony_async_await_;
1218 bool allow_harmony_restrictive_generators_; 1230 bool allow_harmony_restrictive_generators_;
1219 bool allow_harmony_trailing_commas_; 1231 bool allow_harmony_trailing_commas_;
1220 }; 1232 };
1221 1233
1222 template <class Traits> 1234 template <class Traits>
1223 ParserBase<Traits>::FunctionState::FunctionState( 1235 ParserBase<Traits>::FunctionState::FunctionState(
1224 FunctionState** function_state_stack, Scope** scope_stack, Scope* scope, 1236 FunctionState** function_state_stack, ScopeState** scope_stack,
1225 FunctionKind kind, typename Traits::Type::Factory* factory) 1237 Scope* scope, FunctionKind kind, typename Traits::Type::Factory* factory)
1226 : next_materialized_literal_index_(0), 1238 : ScopeState(scope_stack, scope),
1239 next_materialized_literal_index_(0),
1227 expected_property_count_(0), 1240 expected_property_count_(0),
1228 this_location_(Scanner::Location::invalid()), 1241 this_location_(Scanner::Location::invalid()),
1229 return_location_(Scanner::Location::invalid()), 1242 return_location_(Scanner::Location::invalid()),
1230 super_location_(Scanner::Location::invalid()), 1243 super_location_(Scanner::Location::invalid()),
1231 kind_(kind), 1244 kind_(kind),
1232 generator_object_variable_(NULL), 1245 generator_object_variable_(NULL),
1233 function_state_stack_(function_state_stack), 1246 function_state_stack_(function_state_stack),
1234 outer_function_state_(*function_state_stack), 1247 outer_function_state_(*function_state_stack),
1235 scope_stack_(scope_stack),
1236 outer_scope_(*scope_stack),
1237 destructuring_assignments_to_rewrite_(16, scope->zone()), 1248 destructuring_assignments_to_rewrite_(16, scope->zone()),
1238 tail_call_expressions_(scope->zone()), 1249 tail_call_expressions_(scope->zone()),
1239 return_expr_context_(ReturnExprContext::kInsideValidBlock), 1250 return_expr_context_(ReturnExprContext::kInsideValidBlock),
1240 non_patterns_to_rewrite_(0, scope->zone()), 1251 non_patterns_to_rewrite_(0, scope->zone()),
1241 reported_errors_(16, scope->zone()), 1252 reported_errors_(16, scope->zone()),
1242 factory_(factory), 1253 factory_(factory),
1243 next_function_is_parenthesized_(false), 1254 next_function_is_parenthesized_(false),
1244 this_function_is_parenthesized_(false) { 1255 this_function_is_parenthesized_(false) {
1245 *scope_stack_ = scope;
1246 *function_state_stack = this; 1256 *function_state_stack = this;
1247 if (outer_function_state_) { 1257 if (outer_function_state_) {
1248 this_function_is_parenthesized_ = 1258 this_function_is_parenthesized_ =
1249 outer_function_state_->next_function_is_parenthesized_; 1259 outer_function_state_->next_function_is_parenthesized_;
1250 outer_function_state_->next_function_is_parenthesized_ = false; 1260 outer_function_state_->next_function_is_parenthesized_ = false;
1251 } 1261 }
1252 } 1262 }
1253 1263
1254 1264
1255 template <class Traits> 1265 template <class Traits>
1256 ParserBase<Traits>::FunctionState::~FunctionState() { 1266 ParserBase<Traits>::FunctionState::~FunctionState() {
1257 *scope_stack_ = outer_scope_;
1258 *function_state_stack_ = outer_function_state_; 1267 *function_state_stack_ = outer_function_state_;
1259 } 1268 }
1260 1269
1261 template <class Traits> 1270 template <class Traits>
1262 void ParserBase<Traits>::GetUnexpectedTokenMessage( 1271 void ParserBase<Traits>::GetUnexpectedTokenMessage(
1263 Token::Value token, MessageTemplate::Template* message, 1272 Token::Value token, MessageTemplate::Template* message,
1264 Scanner::Location* location, const char** arg, 1273 Scanner::Location* location, const char** arg,
1265 MessageTemplate::Template default_) { 1274 MessageTemplate::Template default_) {
1266 *arg = nullptr; 1275 *arg = nullptr;
1267 switch (token) { 1276 switch (token) {
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 // error that we might make in the future once we know the language mode. 1372 // error that we might make in the future once we know the language mode.
1364 if (this->IsEval(name)) { 1373 if (this->IsEval(name)) {
1365 classifier->RecordStrictModeFormalParameterError( 1374 classifier->RecordStrictModeFormalParameterError(
1366 scanner()->location(), MessageTemplate::kStrictEvalArguments); 1375 scanner()->location(), MessageTemplate::kStrictEvalArguments);
1367 if (is_strict(language_mode())) { 1376 if (is_strict(language_mode())) {
1368 classifier->RecordBindingPatternError( 1377 classifier->RecordBindingPatternError(
1369 scanner()->location(), MessageTemplate::kStrictEvalArguments); 1378 scanner()->location(), MessageTemplate::kStrictEvalArguments);
1370 } 1379 }
1371 } 1380 }
1372 if (this->IsArguments(name)) { 1381 if (this->IsArguments(name)) {
1373 scope_->RecordArgumentsUsage(); 1382 scope()->RecordArgumentsUsage();
1374 classifier->RecordStrictModeFormalParameterError( 1383 classifier->RecordStrictModeFormalParameterError(
1375 scanner()->location(), MessageTemplate::kStrictEvalArguments); 1384 scanner()->location(), MessageTemplate::kStrictEvalArguments);
1376 if (is_strict(language_mode())) { 1385 if (is_strict(language_mode())) {
1377 classifier->RecordBindingPatternError( 1386 classifier->RecordBindingPatternError(
1378 scanner()->location(), MessageTemplate::kStrictEvalArguments); 1387 scanner()->location(), MessageTemplate::kStrictEvalArguments);
1379 } 1388 }
1380 } 1389 }
1381 if (this->IsAwait(name)) { 1390 if (this->IsAwait(name)) {
1382 if (is_async_function()) { 1391 if (is_async_function()) {
1383 classifier->RecordPatternError( 1392 classifier->RecordPatternError(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 } else if (next == Token::FUTURE_STRICT_RESERVED_WORD || next == Token::LET || 1440 } else if (next == Token::FUTURE_STRICT_RESERVED_WORD || next == Token::LET ||
1432 next == Token::STATIC || (next == Token::YIELD && !is_generator)) { 1441 next == Token::STATIC || (next == Token::YIELD && !is_generator)) {
1433 *is_strict_reserved = true; 1442 *is_strict_reserved = true;
1434 } else { 1443 } else {
1435 ReportUnexpectedToken(next); 1444 ReportUnexpectedToken(next);
1436 *ok = false; 1445 *ok = false;
1437 return Traits::EmptyIdentifier(); 1446 return Traits::EmptyIdentifier();
1438 } 1447 }
1439 1448
1440 IdentifierT name = this->GetSymbol(scanner()); 1449 IdentifierT name = this->GetSymbol(scanner());
1441 if (this->IsArguments(name)) scope_->RecordArgumentsUsage(); 1450 if (this->IsArguments(name)) scope()->RecordArgumentsUsage();
1442 return name; 1451 return name;
1443 } 1452 }
1444 1453
1445 template <class Traits> 1454 template <class Traits>
1446 typename ParserBase<Traits>::IdentifierT 1455 typename ParserBase<Traits>::IdentifierT
1447 ParserBase<Traits>::ParseIdentifierName(bool* ok) { 1456 ParserBase<Traits>::ParseIdentifierName(bool* ok) {
1448 Token::Value next = Next(); 1457 Token::Value next = Next();
1449 if (next != Token::IDENTIFIER && next != Token::ASYNC && 1458 if (next != Token::IDENTIFIER && next != Token::ASYNC &&
1450 next != Token::ENUM && next != Token::AWAIT && next != Token::LET && 1459 next != Token::ENUM && next != Token::AWAIT && next != Token::LET &&
1451 next != Token::STATIC && next != Token::YIELD && 1460 next != Token::STATIC && next != Token::YIELD &&
1452 next != Token::FUTURE_STRICT_RESERVED_WORD && 1461 next != Token::FUTURE_STRICT_RESERVED_WORD &&
1453 next != Token::ESCAPED_KEYWORD && 1462 next != Token::ESCAPED_KEYWORD &&
1454 next != Token::ESCAPED_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) { 1463 next != Token::ESCAPED_STRICT_RESERVED_WORD && !Token::IsKeyword(next)) {
1455 this->ReportUnexpectedToken(next); 1464 this->ReportUnexpectedToken(next);
1456 *ok = false; 1465 *ok = false;
1457 return Traits::EmptyIdentifier(); 1466 return Traits::EmptyIdentifier();
1458 } 1467 }
1459 1468
1460 IdentifierT name = this->GetSymbol(scanner()); 1469 IdentifierT name = this->GetSymbol(scanner());
1461 if (this->IsArguments(name)) scope_->RecordArgumentsUsage(); 1470 if (this->IsArguments(name)) scope()->RecordArgumentsUsage();
1462 return name; 1471 return name;
1463 } 1472 }
1464 1473
1465 1474
1466 template <class Traits> 1475 template <class Traits>
1467 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral( 1476 typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseRegExpLiteral(
1468 bool seen_equal, ExpressionClassifier* classifier, bool* ok) { 1477 bool seen_equal, ExpressionClassifier* classifier, bool* ok) {
1469 int pos = peek_position(); 1478 int pos = peek_position();
1470 if (!scanner()->ScanRegExpPattern(seen_equal)) { 1479 if (!scanner()->ScanRegExpPattern(seen_equal)) {
1471 Next(); 1480 Next();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 // '(' Expression ')' 1518 // '(' Expression ')'
1510 // TemplateLiteral 1519 // TemplateLiteral
1511 // do Block 1520 // do Block
1512 // AsyncFunctionExpression 1521 // AsyncFunctionExpression
1513 1522
1514 int beg_pos = peek_position(); 1523 int beg_pos = peek_position();
1515 switch (peek()) { 1524 switch (peek()) {
1516 case Token::THIS: { 1525 case Token::THIS: {
1517 BindingPatternUnexpectedToken(classifier); 1526 BindingPatternUnexpectedToken(classifier);
1518 Consume(Token::THIS); 1527 Consume(Token::THIS);
1519 return this->ThisExpression(scope_, factory(), beg_pos); 1528 return this->ThisExpression(scope(), factory(), beg_pos);
1520 } 1529 }
1521 1530
1522 case Token::NULL_LITERAL: 1531 case Token::NULL_LITERAL:
1523 case Token::TRUE_LITERAL: 1532 case Token::TRUE_LITERAL:
1524 case Token::FALSE_LITERAL: 1533 case Token::FALSE_LITERAL:
1525 BindingPatternUnexpectedToken(classifier); 1534 BindingPatternUnexpectedToken(classifier);
1526 return this->ExpressionFromLiteral(Next(), beg_pos, scanner(), factory()); 1535 return this->ExpressionFromLiteral(Next(), beg_pos, scanner(), factory());
1527 case Token::SMI: 1536 case Token::SMI:
1528 case Token::NUMBER: 1537 case Token::NUMBER:
1529 BindingPatternUnexpectedToken(classifier); 1538 BindingPatternUnexpectedToken(classifier);
(...skipping 12 matching lines...) Expand all
1542 case Token::IDENTIFIER: 1551 case Token::IDENTIFIER:
1543 case Token::LET: 1552 case Token::LET:
1544 case Token::STATIC: 1553 case Token::STATIC:
1545 case Token::YIELD: 1554 case Token::YIELD:
1546 case Token::AWAIT: 1555 case Token::AWAIT:
1547 case Token::ESCAPED_STRICT_RESERVED_WORD: 1556 case Token::ESCAPED_STRICT_RESERVED_WORD:
1548 case Token::FUTURE_STRICT_RESERVED_WORD: { 1557 case Token::FUTURE_STRICT_RESERVED_WORD: {
1549 // Using eval or arguments in this context is OK even in strict mode. 1558 // Using eval or arguments in this context is OK even in strict mode.
1550 IdentifierT name = ParseAndClassifyIdentifier(classifier, CHECK_OK); 1559 IdentifierT name = ParseAndClassifyIdentifier(classifier, CHECK_OK);
1551 return this->ExpressionFromIdentifier( 1560 return this->ExpressionFromIdentifier(
1552 name, beg_pos, scanner()->location().end_pos, scope_, factory()); 1561 name, beg_pos, scanner()->location().end_pos, scope(), factory());
1553 } 1562 }
1554 1563
1555 case Token::STRING: { 1564 case Token::STRING: {
1556 BindingPatternUnexpectedToken(classifier); 1565 BindingPatternUnexpectedToken(classifier);
1557 Consume(Token::STRING); 1566 Consume(Token::STRING);
1558 return this->ExpressionFromString(beg_pos, scanner(), factory()); 1567 return this->ExpressionFromString(beg_pos, scanner(), factory());
1559 } 1568 }
1560 1569
1561 case Token::ASSIGN_DIV: 1570 case Token::ASSIGN_DIV:
1562 classifier->RecordBindingPatternError( 1571 classifier->RecordBindingPatternError(
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 classifier->RecordPatternError( 1977 classifier->RecordPatternError(
1969 Scanner::Location(next_beg_pos, next_end_pos), 1978 Scanner::Location(next_beg_pos, next_end_pos),
1970 MessageTemplate::kAwaitBindingIdentifier); 1979 MessageTemplate::kAwaitBindingIdentifier);
1971 } else { 1980 } else {
1972 classifier->RecordAsyncArrowFormalParametersError( 1981 classifier->RecordAsyncArrowFormalParametersError(
1973 Scanner::Location(next_beg_pos, next_end_pos), 1982 Scanner::Location(next_beg_pos, next_end_pos),
1974 MessageTemplate::kAwaitBindingIdentifier); 1983 MessageTemplate::kAwaitBindingIdentifier);
1975 } 1984 }
1976 } 1985 }
1977 ExpressionT lhs = this->ExpressionFromIdentifier( 1986 ExpressionT lhs = this->ExpressionFromIdentifier(
1978 *name, next_beg_pos, next_end_pos, scope_, factory()); 1987 *name, next_beg_pos, next_end_pos, scope(), factory());
1979 CheckDestructuringElement(lhs, classifier, next_beg_pos, next_end_pos); 1988 CheckDestructuringElement(lhs, classifier, next_beg_pos, next_end_pos);
1980 1989
1981 if (peek() == Token::ASSIGN) { 1990 if (peek() == Token::ASSIGN) {
1982 Consume(Token::ASSIGN); 1991 Consume(Token::ASSIGN);
1983 ExpressionClassifier rhs_classifier(this); 1992 ExpressionClassifier rhs_classifier(this);
1984 ExpressionT rhs = this->ParseAssignmentExpression( 1993 ExpressionT rhs = this->ParseAssignmentExpression(
1985 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1994 true, &rhs_classifier, CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1986 Traits::RewriteNonPattern(&rhs_classifier, 1995 Traits::RewriteNonPattern(&rhs_classifier,
1987 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty)); 1996 CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
1988 classifier->Accumulate(&rhs_classifier, 1997 classifier->Accumulate(&rhs_classifier,
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier); 2284 ArrowFormalParametersUnexpectedToken(&arrow_formals_classifier);
2276 } 2285 }
2277 ExpressionT expression = this->ParseConditionalExpression( 2286 ExpressionT expression = this->ParseConditionalExpression(
2278 accept_IN, &arrow_formals_classifier, CHECK_OK); 2287 accept_IN, &arrow_formals_classifier, CHECK_OK);
2279 2288
2280 if (is_async && peek_any_identifier() && PeekAhead() == Token::ARROW) { 2289 if (is_async && peek_any_identifier() && PeekAhead() == Token::ARROW) {
2281 // async Identifier => AsyncConciseBody 2290 // async Identifier => AsyncConciseBody
2282 IdentifierT name = 2291 IdentifierT name =
2283 ParseAndClassifyIdentifier(&arrow_formals_classifier, CHECK_OK); 2292 ParseAndClassifyIdentifier(&arrow_formals_classifier, CHECK_OK);
2284 expression = this->ExpressionFromIdentifier( 2293 expression = this->ExpressionFromIdentifier(
2285 name, position(), scanner()->location().end_pos, scope_, factory()); 2294 name, position(), scanner()->location().end_pos, scope(), factory());
2286 } 2295 }
2287 2296
2288 if (peek() == Token::ARROW) { 2297 if (peek() == Token::ARROW) {
2289 Scanner::Location arrow_loc = scanner()->peek_location(); 2298 Scanner::Location arrow_loc = scanner()->peek_location();
2290 ValidateArrowFormalParameters(&arrow_formals_classifier, expression, 2299 ValidateArrowFormalParameters(&arrow_formals_classifier, expression,
2291 parenthesized_formals, is_async, CHECK_OK); 2300 parenthesized_formals, is_async, CHECK_OK);
2292 // This reads strangely, but is correct: it checks whether any 2301 // This reads strangely, but is correct: it checks whether any
2293 // sub-expression of the parameter list failed to be a valid formal 2302 // sub-expression of the parameter list failed to be a valid formal
2294 // parameter initializer. Since YieldExpressions are banned anywhere 2303 // parameter initializer. Since YieldExpressions are banned anywhere
2295 // in an arrow parameter list, this is correct. 2304 // in an arrow parameter list, this is correct.
2296 // TODO(adamk): Rename "FormalParameterInitializerError" to refer to 2305 // TODO(adamk): Rename "FormalParameterInitializerError" to refer to
2297 // "YieldExpression", which is its only use. 2306 // "YieldExpression", which is its only use.
2298 ValidateFormalParameterInitializer(&arrow_formals_classifier, ok); 2307 ValidateFormalParameterInitializer(&arrow_formals_classifier, ok);
2299 2308
2300 Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos); 2309 Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos);
2301 Scope* scope = this->NewScope(scope_, FUNCTION_SCOPE, 2310 Scope* scope = this->NewScope(this->scope(), FUNCTION_SCOPE,
2302 is_async ? FunctionKind::kAsyncArrowFunction 2311 is_async ? FunctionKind::kAsyncArrowFunction
2303 : FunctionKind::kArrowFunction); 2312 : FunctionKind::kArrowFunction);
2304 // Because the arrow's parameters were parsed in the outer scope, any 2313 // Because the arrow's parameters were parsed in the outer scope, any
2305 // usage flags that might have been triggered there need to be copied 2314 // usage flags that might have been triggered there need to be copied
2306 // to the arrow scope. 2315 // to the arrow scope.
2307 scope_->PropagateUsageFlagsToScope(scope); 2316 this->scope()->PropagateUsageFlagsToScope(scope);
2308 FormalParametersT parameters(scope); 2317 FormalParametersT parameters(scope);
2309 if (!arrow_formals_classifier.is_simple_parameter_list()) { 2318 if (!arrow_formals_classifier.is_simple_parameter_list()) {
2310 scope->SetHasNonSimpleParameters(); 2319 scope->SetHasNonSimpleParameters();
2311 parameters.is_simple = false; 2320 parameters.is_simple = false;
2312 } 2321 }
2313 2322
2314 checkpoint.Restore(&parameters.materialized_literals_count); 2323 checkpoint.Restore(&parameters.materialized_literals_count);
2315 2324
2316 scope->set_start_position(lhs_beg_pos); 2325 scope->set_start_position(lhs_beg_pos);
2317 Scanner::Location duplicate_loc = Scanner::Location::invalid(); 2326 Scanner::Location duplicate_loc = Scanner::Location::invalid();
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 // Possibly async arrow formals --- record ExpressionError just in case. 2728 // Possibly async arrow formals --- record ExpressionError just in case.
2720 ExpressionUnexpectedToken(classifier); 2729 ExpressionUnexpectedToken(classifier);
2721 classifier->RecordAsyncBindingPatternError( 2730 classifier->RecordAsyncBindingPatternError(
2722 Scanner::Location(beg_pos, scanner()->location().end_pos), 2731 Scanner::Location(beg_pos, scanner()->location().end_pos),
2723 MessageTemplate::kAwaitBindingIdentifier); 2732 MessageTemplate::kAwaitBindingIdentifier);
2724 classifier->RecordAsyncArrowFormalParametersError( 2733 classifier->RecordAsyncArrowFormalParametersError(
2725 Scanner::Location(beg_pos, scanner()->location().end_pos), 2734 Scanner::Location(beg_pos, scanner()->location().end_pos),
2726 MessageTemplate::kAwaitBindingIdentifier); 2735 MessageTemplate::kAwaitBindingIdentifier);
2727 2736
2728 return this->ExpressionFromIdentifier( 2737 return this->ExpressionFromIdentifier(
2729 name, beg_pos, scanner()->location().end_pos, scope_, factory()); 2738 name, beg_pos, scanner()->location().end_pos, scope(), factory());
2730 } 2739 }
2731 default: 2740 default:
2732 break; 2741 break;
2733 } 2742 }
2734 2743
2735 int await_pos = peek_position(); 2744 int await_pos = peek_position();
2736 Consume(Token::AWAIT); 2745 Consume(Token::AWAIT);
2737 2746
2738 ExpressionT value = ParseUnaryExpression(classifier, CHECK_OK); 2747 ExpressionT value = ParseUnaryExpression(classifier, CHECK_OK);
2739 2748
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2864 2873
2865 ArrowFormalParametersUnexpectedToken(classifier); 2874 ArrowFormalParametersUnexpectedToken(classifier);
2866 2875
2867 // Keep track of eval() calls since they disable all local variable 2876 // Keep track of eval() calls since they disable all local variable
2868 // optimizations. 2877 // optimizations.
2869 // The calls that need special treatment are the 2878 // The calls that need special treatment are the
2870 // direct eval calls. These calls are all of the form eval(...), with 2879 // direct eval calls. These calls are all of the form eval(...), with
2871 // no explicit receiver. 2880 // no explicit receiver.
2872 // These calls are marked as potentially direct eval calls. Whether 2881 // These calls are marked as potentially direct eval calls. Whether
2873 // they are actually direct calls to eval is determined at run time. 2882 // they are actually direct calls to eval is determined at run time.
2874 this->CheckPossibleEvalCall(result, scope_); 2883 this->CheckPossibleEvalCall(result, scope());
2875 2884
2876 bool is_super_call = result->IsSuperCallReference(); 2885 bool is_super_call = result->IsSuperCallReference();
2877 if (spread_pos.IsValid()) { 2886 if (spread_pos.IsValid()) {
2878 args = Traits::PrepareSpreadArguments(args); 2887 args = Traits::PrepareSpreadArguments(args);
2879 result = Traits::SpreadCall(result, args, pos); 2888 result = Traits::SpreadCall(result, args, pos);
2880 } else { 2889 } else {
2881 result = factory()->NewCall(result, args, pos); 2890 result = factory()->NewCall(result, args, pos);
2882 } 2891 }
2883 2892
2884 // Explicit calls to the super constructor using super() perform an 2893 // Explicit calls to the super constructor using super() perform an
2885 // implicit binding assignment to the 'this' variable. 2894 // implicit binding assignment to the 'this' variable.
2886 if (is_super_call) { 2895 if (is_super_call) {
2887 ExpressionT this_expr = this->ThisExpression(scope_, factory(), pos); 2896 ExpressionT this_expr = this->ThisExpression(scope(), factory(), pos);
2888 result = 2897 result =
2889 factory()->NewAssignment(Token::INIT, this_expr, result, pos); 2898 factory()->NewAssignment(Token::INIT, this_expr, result, pos);
2890 } 2899 }
2891 2900
2892 if (fni_ != NULL) fni_->RemoveLastFunction(); 2901 if (fni_ != NULL) fni_->RemoveLastFunction();
2893 break; 2902 break;
2894 } 2903 }
2895 2904
2896 case Token::PERIOD: { 2905 case Token::PERIOD: {
2897 CheckNoTailCallExpressions(classifier, CHECK_OK); 2906 CheckNoTailCallExpressions(classifier, CHECK_OK);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
3015 ExpectMetaProperty(CStrVector("sent"), "function.sent", pos, CHECK_OK); 3024 ExpectMetaProperty(CStrVector("sent"), "function.sent", pos, CHECK_OK);
3016 3025
3017 if (!is_generator()) { 3026 if (!is_generator()) {
3018 // TODO(neis): allow escaping into closures? 3027 // TODO(neis): allow escaping into closures?
3019 ReportMessageAt(scanner()->location(), 3028 ReportMessageAt(scanner()->location(),
3020 MessageTemplate::kUnexpectedFunctionSent); 3029 MessageTemplate::kUnexpectedFunctionSent);
3021 *ok = false; 3030 *ok = false;
3022 return this->EmptyExpression(); 3031 return this->EmptyExpression();
3023 } 3032 }
3024 3033
3025 return this->FunctionSentExpression(scope_, factory(), pos); 3034 return this->FunctionSentExpression(scope(), factory(), pos);
3026 } 3035 }
3027 3036
3028 bool is_generator = Check(Token::MUL); 3037 bool is_generator = Check(Token::MUL);
3029 IdentifierT name = this->EmptyIdentifier(); 3038 IdentifierT name = this->EmptyIdentifier();
3030 bool is_strict_reserved_name = false; 3039 bool is_strict_reserved_name = false;
3031 Scanner::Location function_name_location = Scanner::Location::invalid(); 3040 Scanner::Location function_name_location = Scanner::Location::invalid();
3032 FunctionLiteral::FunctionType function_type = 3041 FunctionLiteral::FunctionType function_type =
3033 FunctionLiteral::kAnonymousExpression; 3042 FunctionLiteral::kAnonymousExpression;
3034 if (peek_any_identifier()) { 3043 if (peek_any_identifier()) {
3035 name = ParseIdentifierOrStrictReservedWord( 3044 name = ParseIdentifierOrStrictReservedWord(
(...skipping 22 matching lines...) Expand all
3058 3067
3059 3068
3060 template <class Traits> 3069 template <class Traits>
3061 typename ParserBase<Traits>::ExpressionT 3070 typename ParserBase<Traits>::ExpressionT
3062 ParserBase<Traits>::ParseSuperExpression(bool is_new, 3071 ParserBase<Traits>::ParseSuperExpression(bool is_new,
3063 ExpressionClassifier* classifier, 3072 ExpressionClassifier* classifier,
3064 bool* ok) { 3073 bool* ok) {
3065 Expect(Token::SUPER, CHECK_OK); 3074 Expect(Token::SUPER, CHECK_OK);
3066 int pos = position(); 3075 int pos = position();
3067 3076
3068 Scope* scope = scope_->ReceiverScope(); 3077 Scope* scope = this->scope()->ReceiverScope();
3069 FunctionKind kind = scope->function_kind(); 3078 FunctionKind kind = scope->function_kind();
3070 if (IsConciseMethod(kind) || IsAccessorFunction(kind) || 3079 if (IsConciseMethod(kind) || IsAccessorFunction(kind) ||
3071 IsClassConstructor(kind)) { 3080 IsClassConstructor(kind)) {
3072 if (peek() == Token::PERIOD || peek() == Token::LBRACK) { 3081 if (peek() == Token::PERIOD || peek() == Token::LBRACK) {
3073 scope->RecordSuperPropertyUsage(); 3082 scope->RecordSuperPropertyUsage();
3074 return this->NewSuperPropertyReference(scope_, factory(), pos); 3083 return this->NewSuperPropertyReference(this->scope(), factory(), pos);
3075 } 3084 }
3076 // new super() is never allowed. 3085 // new super() is never allowed.
3077 // super() is only allowed in derived constructor 3086 // super() is only allowed in derived constructor
3078 if (!is_new && peek() == Token::LPAREN && IsSubclassConstructor(kind)) { 3087 if (!is_new && peek() == Token::LPAREN && IsSubclassConstructor(kind)) {
3079 // TODO(rossberg): This might not be the correct FunctionState for the 3088 // TODO(rossberg): This might not be the correct FunctionState for the
3080 // method here. 3089 // method here.
3081 function_state_->set_super_location(scanner()->location()); 3090 function_state_->set_super_location(scanner()->location());
3082 return this->NewSuperCallReference(scope_, factory(), pos); 3091 return this->NewSuperCallReference(this->scope(), factory(), pos);
3083 } 3092 }
3084 } 3093 }
3085 3094
3086 ReportMessageAt(scanner()->location(), MessageTemplate::kUnexpectedSuper); 3095 ReportMessageAt(scanner()->location(), MessageTemplate::kUnexpectedSuper);
3087 *ok = false; 3096 *ok = false;
3088 return this->EmptyExpression(); 3097 return this->EmptyExpression();
3089 } 3098 }
3090 3099
3091 template <class Traits> 3100 template <class Traits>
3092 void ParserBase<Traits>::ExpectMetaProperty(Vector<const char> property_name, 3101 void ParserBase<Traits>::ExpectMetaProperty(Vector<const char> property_name,
3093 const char* full_name, int pos, 3102 const char* full_name, int pos,
3094 bool* ok) { 3103 bool* ok) {
3095 Consume(Token::PERIOD); 3104 Consume(Token::PERIOD);
3096 ExpectContextualKeyword(property_name, CHECK_OK_CUSTOM(Void)); 3105 ExpectContextualKeyword(property_name, CHECK_OK_CUSTOM(Void));
3097 if (scanner()->literal_contains_escapes()) { 3106 if (scanner()->literal_contains_escapes()) {
3098 Traits::ReportMessageAt( 3107 Traits::ReportMessageAt(
3099 Scanner::Location(pos, scanner()->location().end_pos), 3108 Scanner::Location(pos, scanner()->location().end_pos),
3100 MessageTemplate::kInvalidEscapedMetaProperty, full_name); 3109 MessageTemplate::kInvalidEscapedMetaProperty, full_name);
3101 *ok = false; 3110 *ok = false;
3102 } 3111 }
3103 } 3112 }
3104 3113
3105 template <class Traits> 3114 template <class Traits>
3106 typename ParserBase<Traits>::ExpressionT 3115 typename ParserBase<Traits>::ExpressionT
3107 ParserBase<Traits>::ParseNewTargetExpression(bool* ok) { 3116 ParserBase<Traits>::ParseNewTargetExpression(bool* ok) {
3108 int pos = position(); 3117 int pos = position();
3109 ExpectMetaProperty(CStrVector("target"), "new.target", pos, CHECK_OK); 3118 ExpectMetaProperty(CStrVector("target"), "new.target", pos, CHECK_OK);
3110 3119
3111 if (!scope_->ReceiverScope()->is_function_scope()) { 3120 if (!scope()->ReceiverScope()->is_function_scope()) {
3112 ReportMessageAt(scanner()->location(), 3121 ReportMessageAt(scanner()->location(),
3113 MessageTemplate::kUnexpectedNewTarget); 3122 MessageTemplate::kUnexpectedNewTarget);
3114 *ok = false; 3123 *ok = false;
3115 return this->EmptyExpression(); 3124 return this->EmptyExpression();
3116 } 3125 }
3117 3126
3118 return this->NewTargetExpression(scope_, factory(), pos); 3127 return this->NewTargetExpression(scope(), factory(), pos);
3119 } 3128 }
3120 3129
3121 template <class Traits> 3130 template <class Traits>
3122 typename ParserBase<Traits>::ExpressionT 3131 typename ParserBase<Traits>::ExpressionT
3123 ParserBase<Traits>::ParseMemberExpressionContinuation( 3132 ParserBase<Traits>::ParseMemberExpressionContinuation(
3124 ExpressionT expression, bool* is_async, ExpressionClassifier* classifier, 3133 ExpressionT expression, bool* is_async, ExpressionClassifier* classifier,
3125 bool* ok) { 3134 bool* ok) {
3126 // Parses this part of MemberExpression: 3135 // Parses this part of MemberExpression:
3127 // ('[' Expression ']' | '.' Identifier | TemplateLiteral)* 3136 // ('[' Expression ']' | '.' Identifier | TemplateLiteral)*
3128 while (true) { 3137 while (true) {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
3350 3359
3351 typename Traits::Type::StatementList body; 3360 typename Traits::Type::StatementList body;
3352 int num_parameters = formal_parameters.scope->num_parameters(); 3361 int num_parameters = formal_parameters.scope->num_parameters();
3353 int materialized_literal_count = -1; 3362 int materialized_literal_count = -1;
3354 int expected_property_count = -1; 3363 int expected_property_count = -1;
3355 Scanner::Location super_loc; 3364 Scanner::Location super_loc;
3356 3365
3357 FunctionKind arrow_kind = is_async ? kAsyncArrowFunction : kArrowFunction; 3366 FunctionKind arrow_kind = is_async ? kAsyncArrowFunction : kArrowFunction;
3358 { 3367 {
3359 typename Traits::Type::Factory function_factory(ast_value_factory()); 3368 typename Traits::Type::Factory function_factory(ast_value_factory());
3360 FunctionState function_state(&function_state_, &scope_, 3369 FunctionState function_state(&function_state_, &scope_state_,
3361 formal_parameters.scope, arrow_kind, 3370 formal_parameters.scope, arrow_kind,
3362 &function_factory); 3371 &function_factory);
3363 3372
3364 function_state.SkipMaterializedLiterals( 3373 function_state.SkipMaterializedLiterals(
3365 formal_parameters.materialized_literals_count); 3374 formal_parameters.materialized_literals_count);
3366 3375
3367 this->ReindexLiterals(formal_parameters); 3376 this->ReindexLiterals(formal_parameters);
3368 3377
3369 Expect(Token::ARROW, CHECK_OK); 3378 Expect(Token::ARROW, CHECK_OK);
3370 3379
3371 if (peek() == Token::LBRACE) { 3380 if (peek() == Token::LBRACE) {
3372 // Multiple statement body 3381 // Multiple statement body
3373 Consume(Token::LBRACE); 3382 Consume(Token::LBRACE);
3374 bool is_lazily_parsed = 3383 bool is_lazily_parsed =
3375 (mode() == PARSE_LAZILY && scope_->AllowsLazyParsing()); 3384 (mode() == PARSE_LAZILY && scope()->AllowsLazyParsing());
3376 if (is_lazily_parsed) { 3385 if (is_lazily_parsed) {
3377 body = this->NewStatementList(0, zone()); 3386 body = this->NewStatementList(0, zone());
3378 this->SkipLazyFunctionBody(&materialized_literal_count, 3387 this->SkipLazyFunctionBody(&materialized_literal_count,
3379 &expected_property_count, CHECK_OK); 3388 &expected_property_count, CHECK_OK);
3380 if (formal_parameters.materialized_literals_count > 0) { 3389 if (formal_parameters.materialized_literals_count > 0) {
3381 materialized_literal_count += 3390 materialized_literal_count +=
3382 formal_parameters.materialized_literals_count; 3391 formal_parameters.materialized_literals_count;
3383 } 3392 }
3384 } else { 3393 } else {
3385 body = this->ParseEagerFunctionBody( 3394 body = this->ParseEagerFunctionBody(
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
3668 has_seen_constructor_ = true; 3677 has_seen_constructor_ = true;
3669 return; 3678 return;
3670 } 3679 }
3671 } 3680 }
3672 3681
3673 3682
3674 } // namespace internal 3683 } // namespace internal
3675 } // namespace v8 3684 } // namespace v8
3676 3685
3677 #endif // V8_PARSING_PARSER_BASE_H 3686 #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