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

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

Issue 2664083002: [ignition] desugar async functions/generators/modules in BytecodeGenerator
Patch Set: get rid of lambdas, for better or worse.. 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
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,
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 bool is_inner_function, bool may_abort, bool* ok); 541 bool is_inner_function, bool may_abort, bool* ok);
543 542
544 Block* BuildParameterInitializationBlock( 543 Block* BuildParameterInitializationBlock(
545 const ParserFormalParameters& parameters, bool* ok); 544 const ParserFormalParameters& parameters, bool* ok);
546 Block* BuildRejectPromiseOnException(Block* block); 545 Block* BuildRejectPromiseOnException(Block* block);
547 546
548 ZoneList<Statement*>* ParseFunction( 547 ZoneList<Statement*>* ParseFunction(
549 const AstRawString* function_name, int pos, FunctionKind kind, 548 const AstRawString* function_name, int pos, FunctionKind kind,
550 FunctionLiteral::FunctionType function_type, 549 FunctionLiteral::FunctionType function_type,
551 DeclarationScope* function_scope, int* num_parameters, 550 DeclarationScope* function_scope, int* num_parameters,
552 int* function_length, bool* has_duplicate_parameters, 551 Block** parameter_init_block, int* function_length,
553 int* materialized_literal_count, int* expected_property_count, bool* ok); 552 bool* has_duplicate_parameters, int* materialized_literal_count,
553 int* expected_property_count, bool* ok);
554 554
555 void ThrowPendingError(Isolate* isolate, Handle<Script> script); 555 void ThrowPendingError(Isolate* isolate, Handle<Script> script);
556 556
557 class TemplateLiteral : public ZoneObject { 557 class TemplateLiteral : public ZoneObject {
558 public: 558 public:
559 TemplateLiteral(Zone* zone, int pos) 559 TemplateLiteral(Zone* zone, int pos)
560 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {} 560 : cooked_(8, zone), raw_(8, zone), expressions_(8, zone), pos_(pos) {}
561 561
562 const ZoneList<Expression*>* cooked() const { return &cooked_; } 562 const ZoneList<Expression*>* cooked() const { return &cooked_; }
563 const ZoneList<Expression*>* raw() const { return &raw_; } 563 const ZoneList<Expression*>* raw() const { return &raw_; }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // Rewrite expressions that are not used as patterns 620 // Rewrite expressions that are not used as patterns
621 V8_INLINE void RewriteNonPattern(bool* ok); 621 V8_INLINE void RewriteNonPattern(bool* ok);
622 622
623 V8_INLINE void QueueDestructuringAssignmentForRewriting( 623 V8_INLINE void QueueDestructuringAssignmentForRewriting(
624 Expression* assignment); 624 Expression* assignment);
625 V8_INLINE void QueueNonPatternForRewriting(Expression* expr, bool* ok); 625 V8_INLINE void QueueNonPatternForRewriting(Expression* expr, bool* ok);
626 626
627 friend class InitializerRewriter; 627 friend class InitializerRewriter;
628 void RewriteParameterInitializer(Expression* expr, Scope* scope); 628 void RewriteParameterInitializer(Expression* expr, Scope* scope);
629 629
630 Expression* BuildInitialYield(int pos, FunctionKind kind);
631 Assignment* BuildCreateJSGeneratorObject(int pos, FunctionKind kind);
632 Expression* BuildResolvePromise(Expression* value, int pos); 630 Expression* BuildResolvePromise(Expression* value, int pos);
633 Expression* BuildRejectPromise(Expression* value, int pos);
634 Variable* PromiseVariable(); 631 Variable* PromiseVariable();
635 632
636 // Generic AST generator for throwing errors from compiled code. 633 // Generic AST generator for throwing errors from compiled code.
637 Expression* NewThrowError(Runtime::FunctionId function_id, 634 Expression* NewThrowError(Runtime::FunctionId function_id,
638 MessageTemplate::Template message, 635 MessageTemplate::Template message,
639 const AstRawString* arg, int pos); 636 const AstRawString* arg, int pos);
640 637
641 void FinalizeIteratorUse(Scope* use_scope, Variable* completion, 638 void FinalizeIteratorUse(Scope* use_scope, Variable* completion,
642 Expression* condition, Variable* iter, 639 Expression* condition, Variable* iter,
643 Block* iterator_use, Block* result); 640 Block* iterator_use, Block* result);
644 641
645 Statement* FinalizeForOfStatement(ForOfStatement* loop, Variable* completion, 642 Statement* FinalizeForOfStatement(ForOfStatement* loop, Variable* completion,
646 int pos); 643 int pos);
647 void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator, 644 void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator,
648 Variable* input, Variable* output); 645 Variable* input, Variable* output);
649 void BuildIteratorCloseForCompletion(Scope* scope, 646 void BuildIteratorCloseForCompletion(Scope* scope,
650 ZoneList<Statement*>* statements, 647 ZoneList<Statement*>* statements,
651 Variable* iterator, 648 Variable* iterator,
652 Expression* completion); 649 Expression* completion);
653 Statement* CheckCallable(Variable* var, Expression* error, int pos); 650 Statement* CheckCallable(Variable* var, Expression* error, int pos);
654 651
655 V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos); 652 V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos);
656 V8_INLINE void PrepareAsyncFunctionBody(ZoneList<Statement*>* body, 653 V8_INLINE void PrepareAsyncFunctionBody(ZoneList<Statement*>* body,
657 FunctionKind kind, int pos); 654 FunctionKind kind, int pos);
658 V8_INLINE void RewriteAsyncFunctionBody(ZoneList<Statement*>* body, 655 V8_INLINE void RewriteAsyncFunctionBody(ZoneList<Statement*>* body,
659 Block* block,
660 Expression* return_value, bool* ok); 656 Expression* return_value, bool* ok);
661 657
662 Expression* RewriteYieldStar(Expression* generator, Expression* expression, 658 Expression* RewriteYieldStar(Expression* generator, Expression* expression,
663 int pos); 659 int pos);
664 660
665 void AddArrowFunctionFormalParameters(ParserFormalParameters* parameters, 661 void AddArrowFunctionFormalParameters(ParserFormalParameters* parameters,
666 Expression* params, int end_pos, 662 Expression* params, int end_pos,
667 bool* ok); 663 bool* ok);
668 void SetFunctionName(Expression* value, const AstRawString* name); 664 void SetFunctionName(Expression* value, const AstRawString* name);
669 665
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 1025
1030 V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name, 1026 V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name,
1031 ZoneList<Expression*>* args, int pos, 1027 ZoneList<Expression*>* args, int pos,
1032 bool* ok); 1028 bool* ok);
1033 1029
1034 V8_INLINE Statement* NewThrowStatement(Expression* exception, int pos) { 1030 V8_INLINE Statement* NewThrowStatement(Expression* exception, int pos) {
1035 return factory()->NewExpressionStatement( 1031 return factory()->NewExpressionStatement(
1036 factory()->NewThrow(exception, pos), pos); 1032 factory()->NewThrow(exception, pos), pos);
1037 } 1033 }
1038 1034
1039 V8_INLINE void AddParameterInitializationBlock(
1040 const ParserFormalParameters& parameters, ZoneList<Statement*>* body,
1041 bool is_async, bool* ok) {
1042 if (parameters.is_simple) return;
1043 auto* init_block = BuildParameterInitializationBlock(parameters, ok);
1044 if (!*ok) return;
1045 if (is_async) {
1046 init_block = BuildRejectPromiseOnException(init_block);
1047 }
1048 if (init_block != nullptr) body->Add(init_block, zone());
1049 }
1050
1051 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters, 1035 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters,
1052 Expression* pattern, 1036 Expression* pattern,
1053 Expression* initializer, 1037 Expression* initializer,
1054 int initializer_end_position, 1038 int initializer_end_position,
1055 bool is_rest) { 1039 bool is_rest) {
1056 parameters->UpdateArityAndFunctionLength(initializer != nullptr, is_rest); 1040 parameters->UpdateArityAndFunctionLength(initializer != nullptr, is_rest);
1057 bool is_simple = pattern->IsVariableProxy() && initializer == nullptr; 1041 bool is_simple = pattern->IsVariableProxy() && initializer == nullptr;
1058 const AstRawString* name = is_simple 1042 const AstRawString* name = is_simple
1059 ? pattern->AsVariableProxy()->raw_name() 1043 ? pattern->AsVariableProxy()->raw_name()
1060 : ast_value_factory()->empty_string(); 1044 : ast_value_factory()->empty_string();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 1176
1193 private: 1177 private:
1194 ParserTarget** variable_; 1178 ParserTarget** variable_;
1195 ParserTarget* previous_; 1179 ParserTarget* previous_;
1196 }; 1180 };
1197 1181
1198 } // namespace internal 1182 } // namespace internal
1199 } // namespace v8 1183 } // namespace v8
1200 1184
1201 #endif // V8_PARSING_PARSER_H_ 1185 #endif // V8_PARSING_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698