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

Side by Side Diff: src/parsing/parser.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/interpreter/bytecode-generator.cc ('k') | src/parsing/parser.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_PARSER_H_ 5 #ifndef V8_PARSING_PARSER_H_
6 #define V8_PARSING_PARSER_H_ 6 #define V8_PARSING_PARSER_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/base/compiler-specific.h" 10 #include "src/base/compiler-specific.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 ZoneList<CaseClause*>* cases, Scope* scope); 337 ZoneList<CaseClause*>* cases, Scope* scope);
338 void RewriteCatchPattern(CatchInfo* catch_info, bool* ok); 338 void RewriteCatchPattern(CatchInfo* catch_info, bool* ok);
339 void ValidateCatchBlock(const CatchInfo& catch_info, bool* ok); 339 void ValidateCatchBlock(const CatchInfo& catch_info, bool* ok);
340 Statement* RewriteTryStatement(Block* try_block, Block* catch_block, 340 Statement* RewriteTryStatement(Block* try_block, Block* catch_block,
341 Block* finally_block, 341 Block* finally_block,
342 const CatchInfo& catch_info, int pos); 342 const CatchInfo& catch_info, int pos);
343 343
344 void ParseAndRewriteGeneratorFunctionBody(int pos, FunctionKind kind, 344 void ParseAndRewriteGeneratorFunctionBody(int pos, FunctionKind kind,
345 ZoneList<Statement*>* body, 345 ZoneList<Statement*>* body,
346 bool* ok); 346 bool* ok);
347 void CreateFunctionNameAssignment(const AstRawString* function_name, int pos, 347 void CreateFunctionNameVariable(const AstRawString* function_name, int pos,
348 FunctionLiteral::FunctionType function_type, 348 FunctionLiteral::FunctionType function_type,
349 DeclarationScope* function_scope, 349 DeclarationScope* function_scope);
350 ZoneList<Statement*>* result, int index);
351 350
352 Statement* DeclareFunction(const AstRawString* variable_name, 351 Statement* DeclareFunction(const AstRawString* variable_name,
353 FunctionLiteral* function, VariableMode mode, 352 FunctionLiteral* function, VariableMode mode,
354 int pos, bool is_generator, bool is_async, 353 int pos, bool is_generator, bool is_async,
355 bool is_sloppy_block_function, 354 bool is_sloppy_block_function,
356 ZoneList<const AstRawString*>* names, bool* ok); 355 ZoneList<const AstRawString*>* names, bool* ok);
357 V8_INLINE Statement* DeclareClass(const AstRawString* variable_name, 356 V8_INLINE Statement* DeclareClass(const AstRawString* variable_name,
358 Expression* value, 357 Expression* value,
359 ZoneList<const AstRawString*>* names, 358 ZoneList<const AstRawString*>* names,
360 int class_token_pos, int end_pos, bool* ok); 359 int class_token_pos, int end_pos, bool* ok);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // If may_abort == true, the (pre-)parser may decide to abort skipping 534 // If may_abort == true, the (pre-)parser may decide to abort skipping
536 // in order to force the function to be eagerly parsed, after all. 535 // in order to force the function to be eagerly parsed, after all.
537 LazyParsingResult SkipFunction( 536 LazyParsingResult SkipFunction(
538 FunctionKind kind, DeclarationScope* function_scope, int* num_parameters, 537 FunctionKind kind, DeclarationScope* function_scope, int* num_parameters,
539 int* function_length, bool* has_duplicate_parameters, 538 int* function_length, bool* has_duplicate_parameters,
540 int* materialized_literal_count, int* expected_property_count, 539 int* materialized_literal_count, int* expected_property_count,
541 bool is_inner_function, bool may_abort, bool* ok); 540 bool is_inner_function, bool may_abort, bool* ok);
542 541
543 Block* BuildParameterInitializationBlock( 542 Block* BuildParameterInitializationBlock(
544 const ParserFormalParameters& parameters, bool* ok); 543 const ParserFormalParameters& parameters, bool* ok);
545 Block* BuildRejectPromiseOnException(Block* block);
546 544
547 ZoneList<Statement*>* ParseFunction( 545 ZoneList<Statement*>* ParseFunction(
548 const AstRawString* function_name, int pos, FunctionKind kind, 546 const AstRawString* function_name, int pos, FunctionKind kind,
549 FunctionLiteral::FunctionType function_type, 547 FunctionLiteral::FunctionType function_type,
550 DeclarationScope* function_scope, int* num_parameters, 548 DeclarationScope* function_scope, int* num_parameters,
551 int* function_length, bool* has_duplicate_parameters, 549 Block** parameter_init_block, int* function_length,
552 int* materialized_literal_count, int* expected_property_count, bool* ok); 550 bool* has_duplicate_parameters, int* materialized_literal_count,
551 int* expected_property_count, bool* ok);
553 552
554 void ThrowPendingError(Isolate* isolate, Handle<Script> script); 553 void ThrowPendingError(Isolate* isolate, Handle<Script> script);
555 554
556 class TemplateLiteral : public ZoneObject { 555 class TemplateLiteral : public ZoneObject {
557 public: 556 public:
558 TemplateLiteral(Zone* zone, int pos) 557 TemplateLiteral(Zone* zone, int pos)
559 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} 558 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {}
560 559
561 const ZoneList<Expression*>* cooked() const { return &cooked_; } 560 const ZoneList<Expression*>* cooked() const { return &cooked_; }
562 const ZoneList<Expression*>* raw() const { return &raw_; } 561 const ZoneList<Expression*>* raw() const { return &raw_; }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 620
622 V8_INLINE void QueueDestructuringAssignmentForRewriting( 621 V8_INLINE void QueueDestructuringAssignmentForRewriting(
623 Expression* assignment); 622 Expression* assignment);
624 V8_INLINE void QueueNonPatternForRewriting(Expression* expr, bool* ok); 623 V8_INLINE void QueueNonPatternForRewriting(Expression* expr, bool* ok);
625 624
626 friend class InitializerRewriter; 625 friend class InitializerRewriter;
627 void RewriteParameterInitializer(Expression* expr, Scope* scope); 626 void RewriteParameterInitializer(Expression* expr, Scope* scope);
628 627
629 Expression* BuildInitialYield(int pos, FunctionKind kind); 628 Expression* BuildInitialYield(int pos, FunctionKind kind);
630 Assignment* BuildCreateJSGeneratorObject(int pos, FunctionKind kind); 629 Assignment* BuildCreateJSGeneratorObject(int pos, FunctionKind kind);
631 Expression* BuildResolvePromise(Expression* value, int pos);
632 Expression* BuildRejectPromise(Expression* value, int pos);
633 Variable* PromiseVariable();
634 630
635 // Generic AST generator for throwing errors from compiled code. 631 // Generic AST generator for throwing errors from compiled code.
636 Expression* NewThrowError(Runtime::FunctionId function_id, 632 Expression* NewThrowError(Runtime::FunctionId function_id,
637 MessageTemplate::Template message, 633 MessageTemplate::Template message,
638 const AstRawString* arg, int pos); 634 const AstRawString* arg, int pos);
639 635
640 void FinalizeIteratorUse(Scope* use_scope, Variable* completion, 636 void FinalizeIteratorUse(Scope* use_scope, Variable* completion,
641 Expression* condition, Variable* iter, 637 Expression* condition, Variable* iter,
642 Block* iterator_use, Block* result); 638 Block* iterator_use, Block* result);
643 639
644 Statement* FinalizeForOfStatement(ForOfStatement* loop, Variable* completion, 640 Statement* FinalizeForOfStatement(ForOfStatement* loop, Variable* completion,
645 int pos); 641 int pos);
646 void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator, 642 void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator,
647 Variable* input, Variable* output); 643 Variable* input, Variable* output);
648 void BuildIteratorCloseForCompletion(Scope* scope, 644 void BuildIteratorCloseForCompletion(Scope* scope,
649 ZoneList<Statement*>* statements, 645 ZoneList<Statement*>* statements,
650 Variable* iterator, 646 Variable* iterator,
651 Expression* completion); 647 Expression* completion);
652 Statement* CheckCallable(Variable* var, Expression* error, int pos); 648 Statement* CheckCallable(Variable* var, Expression* error, int pos);
653 649
654 V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos); 650 // V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos);
655 V8_INLINE void PrepareAsyncFunctionBody(ZoneList<Statement*>* body, 651 V8_INLINE void PrepareAsyncFunctionBody(ZoneList<Statement*>* body,
656 FunctionKind kind, int pos); 652 FunctionKind kind, int pos);
657 V8_INLINE void RewriteAsyncFunctionBody(ZoneList<Statement*>* body, 653 V8_INLINE void RewriteAsyncFunctionBody(ZoneList<Statement*>* body,
658 Block* block, 654 Block* block,
659 Expression* return_value, bool* ok); 655 Expression* return_value, bool* ok);
660 656
661 Expression* RewriteYieldStar(Expression* generator, Expression* expression, 657 Expression* RewriteYieldStar(Expression* expression, int pos);
662 int pos);
663 658
664 void AddArrowFunctionFormalParameters(ParserFormalParameters* parameters, 659 void AddArrowFunctionFormalParameters(ParserFormalParameters* parameters,
665 Expression* params, int end_pos, 660 Expression* params, int end_pos,
666 bool* ok); 661 bool* ok);
667 void SetFunctionName(Expression* value, const AstRawString* name); 662 void SetFunctionName(Expression* value, const AstRawString* name);
668 663
669 // Helper functions for recursive descent. 664 // Helper functions for recursive descent.
670 V8_INLINE bool IsEval(const AstRawString* identifier) const { 665 V8_INLINE bool IsEval(const AstRawString* identifier) const {
671 return identifier == ast_value_factory()->eval_string(); 666 return identifier == ast_value_factory()->eval_string();
672 } 667 }
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 1009
1015 V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name, 1010 V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name,
1016 ZoneList<Expression*>* args, int pos, 1011 ZoneList<Expression*>* args, int pos,
1017 bool* ok); 1012 bool* ok);
1018 1013
1019 V8_INLINE Statement* NewThrowStatement(Expression* exception, int pos) { 1014 V8_INLINE Statement* NewThrowStatement(Expression* exception, int pos) {
1020 return factory()->NewExpressionStatement( 1015 return factory()->NewExpressionStatement(
1021 factory()->NewThrow(exception, pos), pos); 1016 factory()->NewThrow(exception, pos), pos);
1022 } 1017 }
1023 1018
1024 V8_INLINE void AddParameterInitializationBlock(
1025 const ParserFormalParameters& parameters, ZoneList<Statement*>* body,
1026 bool is_async, bool* ok) {
1027 if (parameters.is_simple) return;
1028 auto* init_block = BuildParameterInitializationBlock(parameters, ok);
1029 if (!*ok) return;
1030 if (is_async) {
1031 init_block = BuildRejectPromiseOnException(init_block);
1032 }
1033 if (init_block != nullptr) body->Add(init_block, zone());
1034 }
1035
1036 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters, 1019 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters,
1037 Expression* pattern, 1020 Expression* pattern,
1038 Expression* initializer, 1021 Expression* initializer,
1039 int initializer_end_position, 1022 int initializer_end_position,
1040 bool is_rest) { 1023 bool is_rest) {
1041 parameters->UpdateArityAndFunctionLength(initializer != nullptr, is_rest); 1024 parameters->UpdateArityAndFunctionLength(initializer != nullptr, is_rest);
1042 bool is_simple = pattern->IsVariableProxy() && initializer == nullptr; 1025 bool is_simple = pattern->IsVariableProxy() && initializer == nullptr;
1043 const AstRawString* name = is_simple 1026 const AstRawString* name = is_simple
1044 ? pattern->AsVariableProxy()->raw_name() 1027 ? pattern->AsVariableProxy()->raw_name()
1045 : ast_value_factory()->empty_string(); 1028 : ast_value_factory()->empty_string();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1177 1160
1178 private: 1161 private:
1179 ParserTarget** variable_; 1162 ParserTarget** variable_;
1180 ParserTarget* previous_; 1163 ParserTarget* previous_;
1181 }; 1164 };
1182 1165
1183 } // namespace internal 1166 } // namespace internal
1184 } // namespace v8 1167 } // namespace v8
1185 1168
1186 #endif // V8_PARSING_PARSER_H_ 1169 #endif // V8_PARSING_PARSER_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698