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

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

Issue 2654423004: [async-functions] support await expressions in finally statements (Closed)
Patch Set: I'd like to build with -Wunused-variables locally, but how!? Created 3 years, 10 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/pattern-rewriter.cc ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_PREPARSER_H 5 #ifndef V8_PARSING_PREPARSER_H
6 #define V8_PARSING_PREPARSER_H 6 #define V8_PARSING_PREPARSER_H
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/parsing/parser-base.h" 10 #include "src/parsing/parser-base.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 explicit PreParserIdentifier(Type type) : type_(type), string_(nullptr) {} 117 explicit PreParserIdentifier(Type type) : type_(type), string_(nullptr) {}
118 Type type_; 118 Type type_;
119 // Only non-nullptr when PreParser.track_unresolved_variables_ is true. 119 // Only non-nullptr when PreParser.track_unresolved_variables_ is true.
120 const AstRawString* string_; 120 const AstRawString* string_;
121 friend class PreParserExpression; 121 friend class PreParserExpression;
122 friend class PreParser; 122 friend class PreParser;
123 friend class PreParserFactory; 123 friend class PreParserFactory;
124 }; 124 };
125 125
126 126 class PreParserStatement;
127 class PreParserExpression { 127 class PreParserExpression {
128 public: 128 public:
129 PreParserExpression() 129 PreParserExpression()
130 : code_(TypeField::encode(kEmpty)), variables_(nullptr) {} 130 : code_(TypeField::encode(kEmpty)), variables_(nullptr) {}
131 131
132 static PreParserExpression Empty() { return PreParserExpression(); } 132 static PreParserExpression Empty() { return PreParserExpression(); }
133 133
134 static PreParserExpression Default( 134 static PreParserExpression Default(
135 ZoneList<VariableProxy*>* variables = nullptr) { 135 ZoneList<VariableProxy*>* variables = nullptr) {
136 return PreParserExpression(TypeField::encode(kExpression), variables); 136 return PreParserExpression(TypeField::encode(kExpression), variables);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // and PreParser. 330 // and PreParser.
331 PreParserExpression* operator->() { return this; } 331 PreParserExpression* operator->() { return this; }
332 332
333 // More dummy implementations of things PreParser doesn't need to track: 333 // More dummy implementations of things PreParser doesn't need to track:
334 void set_index(int index) {} // For YieldExpressions 334 void set_index(int index) {} // For YieldExpressions
335 void SetShouldEagerCompile() {} 335 void SetShouldEagerCompile() {}
336 void set_should_be_used_once_hint() {} 336 void set_should_be_used_once_hint() {}
337 337
338 int position() const { return kNoSourcePosition; } 338 int position() const { return kNoSourcePosition; }
339 void set_function_token_position(int position) {} 339 void set_function_token_position(int position) {}
340 void set_parameter_init_block(PreParserStatement block);
340 341
341 private: 342 private:
342 enum Type { 343 enum Type {
343 kEmpty, 344 kEmpty,
344 kExpression, 345 kExpression,
345 kIdentifierExpression, 346 kIdentifierExpression,
346 kStringLiteralExpression, 347 kStringLiteralExpression,
347 kSpreadExpression, 348 kSpreadExpression,
348 kObjectLiteralExpression, 349 kObjectLiteralExpression,
349 kArrayLiteralExpression 350 kArrayLiteralExpression
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 kJumpStatement, 528 kJumpStatement,
528 kStringLiteralExpressionStatement, 529 kStringLiteralExpressionStatement,
529 kUseStrictExpressionStatement, 530 kUseStrictExpressionStatement,
530 kUseAsmExpressionStatement, 531 kUseAsmExpressionStatement,
531 }; 532 };
532 533
533 explicit PreParserStatement(Type code) : code_(code) {} 534 explicit PreParserStatement(Type code) : code_(code) {}
534 Type code_; 535 Type code_;
535 }; 536 };
536 537
538 V8_INLINE void PreParserExpression::set_parameter_init_block(
539 PreParserStatement block) {}
537 540
538 class PreParserFactory { 541 class PreParserFactory {
539 public: 542 public:
540 explicit PreParserFactory(AstValueFactory* ast_value_factory) 543 explicit PreParserFactory(AstValueFactory* ast_value_factory)
541 : ast_value_factory_(ast_value_factory), 544 : ast_value_factory_(ast_value_factory),
542 zone_(ast_value_factory->zone()) {} 545 zone_(ast_value_factory->zone()) {}
543 546
544 void set_zone(Zone* zone) { zone_ = zone; } 547 void set_zone(Zone* zone) { zone_ = zone; }
545 548
546 PreParserExpression NewStringLiteral(PreParserIdentifier identifier, 549 PreParserExpression NewStringLiteral(PreParserIdentifier identifier,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 return expression; 629 return expression;
627 } 630 }
628 PreParserExpression NewAssignment(Token::Value op, 631 PreParserExpression NewAssignment(Token::Value op,
629 PreParserExpression left, 632 PreParserExpression left,
630 PreParserExpression right, 633 PreParserExpression right,
631 int pos) { 634 int pos) {
632 // Identifiers need to be tracked since this might be a parameter with a 635 // Identifiers need to be tracked since this might be a parameter with a
633 // default value inside an arrow function parameter list. 636 // default value inside an arrow function parameter list.
634 return PreParserExpression::Assignment(left.variables_); 637 return PreParserExpression::Assignment(left.variables_);
635 } 638 }
636 PreParserExpression NewYield(PreParserExpression generator_object, 639 PreParserExpression NewYield(PreParserExpression expression, int pos,
637 PreParserExpression expression, int pos, 640 Yield::OnException on_exception,
638 Yield::OnException on_exception) { 641 Yield::YieldType type) {
639 return PreParserExpression::Default(); 642 return PreParserExpression::Default();
640 } 643 }
641 PreParserExpression NewConditional(PreParserExpression condition, 644 PreParserExpression NewConditional(PreParserExpression condition,
642 PreParserExpression then_expression, 645 PreParserExpression then_expression,
643 PreParserExpression else_expression, 646 PreParserExpression else_expression,
644 int pos) { 647 int pos) {
645 return PreParserExpression::Default(); 648 return PreParserExpression::Default();
646 } 649 }
647 PreParserExpression NewCountOperation(Token::Value op, 650 PreParserExpression NewCountOperation(Token::Value op,
648 bool is_prefix, 651 bool is_prefix,
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 V8_INLINE PreParserExpression 1005 V8_INLINE PreParserExpression
1003 RewriteAwaitExpression(PreParserExpression value, int pos) { 1006 RewriteAwaitExpression(PreParserExpression value, int pos) {
1004 return value; 1007 return value;
1005 } 1008 }
1006 V8_INLINE void PrepareAsyncFunctionBody(PreParserStatementList body, 1009 V8_INLINE void PrepareAsyncFunctionBody(PreParserStatementList body,
1007 FunctionKind kind, int pos) {} 1010 FunctionKind kind, int pos) {}
1008 V8_INLINE void RewriteAsyncFunctionBody(PreParserStatementList body, 1011 V8_INLINE void RewriteAsyncFunctionBody(PreParserStatementList body,
1009 PreParserStatement block, 1012 PreParserStatement block,
1010 PreParserExpression return_value, 1013 PreParserExpression return_value,
1011 bool* ok) {} 1014 bool* ok) {}
1012 V8_INLINE PreParserExpression RewriteYieldStar(PreParserExpression generator, 1015 V8_INLINE PreParserExpression RewriteYieldStar(PreParserExpression expression,
1013 PreParserExpression expression,
1014 int pos) { 1016 int pos) {
1015 return PreParserExpression::Default(); 1017 return PreParserExpression::Default();
1016 } 1018 }
1017 V8_INLINE void RewriteNonPattern(bool* ok) { ValidateExpression(ok); } 1019 V8_INLINE void RewriteNonPattern(bool* ok) { ValidateExpression(ok); }
1018 1020
1019 void DeclareAndInitializeVariables( 1021 void DeclareAndInitializeVariables(
1020 PreParserStatement block, 1022 PreParserStatement block,
1021 const DeclarationDescriptor* declaration_descriptor, 1023 const DeclarationDescriptor* declaration_descriptor,
1022 const DeclarationParsingResult::Declaration* declaration, 1024 const DeclarationParsingResult::Declaration* declaration,
1023 ZoneList<const AstRawString*>* names, bool* ok); 1025 ZoneList<const AstRawString*>* names, bool* ok);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 V8_INLINE PreParserStatement RewriteTryStatement( 1068 V8_INLINE PreParserStatement RewriteTryStatement(
1067 PreParserStatement try_block, PreParserStatement catch_block, 1069 PreParserStatement try_block, PreParserStatement catch_block,
1068 PreParserStatement finally_block, const CatchInfo& catch_info, int pos) { 1070 PreParserStatement finally_block, const CatchInfo& catch_info, int pos) {
1069 return PreParserStatement::Default(); 1071 return PreParserStatement::Default();
1070 } 1072 }
1071 1073
1072 V8_INLINE void ParseAndRewriteGeneratorFunctionBody( 1074 V8_INLINE void ParseAndRewriteGeneratorFunctionBody(
1073 int pos, FunctionKind kind, PreParserStatementList body, bool* ok) { 1075 int pos, FunctionKind kind, PreParserStatementList body, bool* ok) {
1074 ParseStatementList(body, Token::RBRACE, ok); 1076 ParseStatementList(body, Token::RBRACE, ok);
1075 } 1077 }
1076 V8_INLINE void CreateFunctionNameAssignment( 1078 V8_INLINE void CreateFunctionNameVariable(
1077 PreParserIdentifier function_name, int pos, 1079 PreParserIdentifier function_name, int pos,
1078 FunctionLiteral::FunctionType function_type, 1080 FunctionLiteral::FunctionType function_type,
1079 DeclarationScope* function_scope, PreParserStatementList result, 1081 DeclarationScope* function_scope) {}
1080 int index) {}
1081 1082
1082 V8_INLINE PreParserExpression RewriteDoExpression(PreParserStatement body, 1083 V8_INLINE PreParserExpression RewriteDoExpression(PreParserStatement body,
1083 int pos, bool* ok) { 1084 int pos, bool* ok) {
1084 return PreParserExpression::Default(); 1085 return PreParserExpression::Default();
1085 } 1086 }
1086 1087
1087 // TODO(nikolaos): The preparser currently does not keep track of labels 1088 // TODO(nikolaos): The preparser currently does not keep track of labels
1088 // and targets. 1089 // and targets.
1089 V8_INLINE PreParserStatement LookupBreakTarget(PreParserIdentifier label, 1090 V8_INLINE PreParserStatement LookupBreakTarget(PreParserIdentifier label,
1090 bool* ok) { 1091 bool* ok) {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 NewV8Intrinsic(PreParserIdentifier name, PreParserExpressionList arguments, 1525 NewV8Intrinsic(PreParserIdentifier name, PreParserExpressionList arguments,
1525 int pos, bool* ok) { 1526 int pos, bool* ok) {
1526 return PreParserExpression::Default(); 1527 return PreParserExpression::Default();
1527 } 1528 }
1528 1529
1529 V8_INLINE PreParserStatement NewThrowStatement(PreParserExpression exception, 1530 V8_INLINE PreParserStatement NewThrowStatement(PreParserExpression exception,
1530 int pos) { 1531 int pos) {
1531 return PreParserStatement::Jump(); 1532 return PreParserStatement::Jump();
1532 } 1533 }
1533 1534
1534 V8_INLINE void AddParameterInitializationBlock(
1535 const PreParserFormalParameters& parameters, PreParserStatementList body,
1536 bool is_async, bool* ok) {}
1537
1538 V8_INLINE void AddFormalParameter(PreParserFormalParameters* parameters, 1535 V8_INLINE void AddFormalParameter(PreParserFormalParameters* parameters,
1539 PreParserExpression pattern, 1536 PreParserExpression pattern,
1540 PreParserExpression initializer, 1537 PreParserExpression initializer,
1541 int initializer_end_position, 1538 int initializer_end_position,
1542 bool is_rest) { 1539 bool is_rest) {
1543 if (track_unresolved_variables_) { 1540 if (track_unresolved_variables_) {
1544 DCHECK(FLAG_lazy_inner_functions); 1541 DCHECK(FLAG_lazy_inner_functions);
1545 parameters->params.Add(new (zone()) 1542 parameters->params.Add(new (zone())
1546 PreParserFormalParameters::Parameter(pattern)); 1543 PreParserFormalParameters::Parameter(pattern));
1547 } 1544 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1651 function_state_->NextMaterializedLiteralIndex(); 1648 function_state_->NextMaterializedLiteralIndex();
1652 function_state_->NextMaterializedLiteralIndex(); 1649 function_state_->NextMaterializedLiteralIndex();
1653 } 1650 }
1654 return EmptyExpression(); 1651 return EmptyExpression();
1655 } 1652 }
1656 1653
1657 } // namespace internal 1654 } // namespace internal
1658 } // namespace v8 1655 } // namespace v8
1659 1656
1660 #endif // V8_PARSING_PREPARSER_H 1657 #endif // V8_PARSING_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parsing/pattern-rewriter.cc ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698