OLD | NEW |
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 10 matching lines...) Expand all Loading... |
21 | 21 |
22 class ScriptCompiler; | 22 class ScriptCompiler; |
23 | 23 |
24 namespace internal { | 24 namespace internal { |
25 | 25 |
26 class ParseInfo; | 26 class ParseInfo; |
27 class ScriptData; | 27 class ScriptData; |
28 class ParserTarget; | 28 class ParserTarget; |
29 class ParserTargetScope; | 29 class ParserTargetScope; |
30 | 30 |
| 31 enum class IteratorType { kNormal, kAsync }; |
| 32 |
31 class FunctionEntry BASE_EMBEDDED { | 33 class FunctionEntry BASE_EMBEDDED { |
32 public: | 34 public: |
33 enum { | 35 enum { |
34 kStartPositionIndex, | 36 kStartPositionIndex, |
35 kEndPositionIndex, | 37 kEndPositionIndex, |
36 kNumParametersIndex, | 38 kNumParametersIndex, |
37 kFunctionLengthIndex, | 39 kFunctionLengthIndex, |
38 kLiteralCountIndex, | 40 kLiteralCountIndex, |
39 kPropertyCountIndex, | 41 kPropertyCountIndex, |
40 kFlagsIndex, | 42 kFlagsIndex, |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 Expression* current_value_; | 444 Expression* current_value_; |
443 int recursion_level_; | 445 int recursion_level_; |
444 bool* ok_; | 446 bool* ok_; |
445 | 447 |
446 DEFINE_AST_VISITOR_MEMBERS_WITHOUT_STACKOVERFLOW() | 448 DEFINE_AST_VISITOR_MEMBERS_WITHOUT_STACKOVERFLOW() |
447 }; | 449 }; |
448 | 450 |
449 // !%_IsJSReceiver(result = iterator.next()) && | 451 // !%_IsJSReceiver(result = iterator.next()) && |
450 // %ThrowIteratorResultNotAnObject(result) | 452 // %ThrowIteratorResultNotAnObject(result) |
451 Expression* BuildIteratorNextResult(Expression* iterator, Variable* result, | 453 Expression* BuildIteratorNextResult(Expression* iterator, Variable* result, |
452 int pos); | 454 IteratorType type, int pos); |
453 | 455 |
454 // Initialize the components of a for-in / for-of statement. | 456 // Initialize the components of a for-in / for-of statement. |
455 Statement* InitializeForEachStatement(ForEachStatement* stmt, | 457 Statement* InitializeForEachStatement(ForEachStatement* stmt, |
456 Expression* each, Expression* subject, | 458 Expression* each, Expression* subject, |
457 Statement* body, int each_keyword_pos); | 459 Statement* body, int each_keyword_pos); |
458 Statement* InitializeForOfStatement(ForOfStatement* stmt, Expression* each, | 460 Statement* InitializeForOfStatement(ForOfStatement* stmt, Expression* each, |
459 Expression* iterable, Statement* body, | 461 Expression* iterable, Statement* body, |
460 bool finalize, | 462 bool finalize, |
461 int next_result_pos = kNoSourcePosition); | 463 int next_result_pos = kNoSourcePosition); |
| 464 Statement* InitializeForAwaitOfStatement( |
| 465 ForEachStatement* stmt, Expression* each, Expression* iterable, |
| 466 Statement* body, bool finalize, int next_result_pos = kNoSourcePosition); |
| 467 |
462 Block* RewriteForVarInLegacy(const ForInfo& for_info); | 468 Block* RewriteForVarInLegacy(const ForInfo& for_info); |
463 void DesugarBindingInForEachStatement(ForInfo* for_info, Block** body_block, | 469 void DesugarBindingInForEachStatement(ForInfo* for_info, Block** body_block, |
464 Expression** each_variable, bool* ok); | 470 Expression** each_variable, bool* ok); |
465 Block* CreateForEachStatementTDZ(Block* init_block, const ForInfo& for_info, | 471 Block* CreateForEachStatementTDZ(Block* init_block, const ForInfo& for_info, |
466 bool* ok); | 472 bool* ok); |
467 | 473 |
468 Statement* DesugarLexicalBindingsInForStatement( | 474 Statement* DesugarLexicalBindingsInForStatement( |
469 ForStatement* loop, Statement* init, Expression* cond, Statement* next, | 475 ForStatement* loop, Statement* init, Expression* cond, Statement* next, |
470 Statement* body, Scope* inner_scope, const ForInfo& for_info, bool* ok); | 476 Statement* body, Scope* inner_scope, const ForInfo& for_info, bool* ok); |
471 | 477 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 Expression* BuildRejectPromise(Expression* value, int pos); | 635 Expression* BuildRejectPromise(Expression* value, int pos); |
630 Variable* PromiseVariable(); | 636 Variable* PromiseVariable(); |
631 | 637 |
632 // Generic AST generator for throwing errors from compiled code. | 638 // Generic AST generator for throwing errors from compiled code. |
633 Expression* NewThrowError(Runtime::FunctionId function_id, | 639 Expression* NewThrowError(Runtime::FunctionId function_id, |
634 MessageTemplate::Template message, | 640 MessageTemplate::Template message, |
635 const AstRawString* arg, int pos); | 641 const AstRawString* arg, int pos); |
636 | 642 |
637 void FinalizeIteratorUse(Scope* use_scope, Variable* completion, | 643 void FinalizeIteratorUse(Scope* use_scope, Variable* completion, |
638 Expression* condition, Variable* iter, | 644 Expression* condition, Variable* iter, |
639 Block* iterator_use, Block* result); | 645 Block* iterator_use, Block* result, |
| 646 IteratorType type); |
640 | 647 |
641 Statement* FinalizeForOfStatement(ForOfStatement* loop, Variable* completion, | 648 Statement* FinalizeForOfStatement(ForOfStatement* loop, Variable* completion, |
642 int pos); | 649 IteratorType type, int pos); |
643 void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator, | 650 void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator, |
644 Variable* input, Variable* output); | 651 Variable* input, Variable* output, IteratorType type); |
645 void BuildIteratorCloseForCompletion(Scope* scope, | 652 void BuildIteratorCloseForCompletion(Scope* scope, |
646 ZoneList<Statement*>* statements, | 653 ZoneList<Statement*>* statements, |
647 Variable* iterator, | 654 Variable* iterator, |
648 Expression* completion); | 655 Expression* completion, |
| 656 IteratorType type); |
649 Statement* CheckCallable(Variable* var, Expression* error, int pos); | 657 Statement* CheckCallable(Variable* var, Expression* error, int pos); |
650 | 658 |
651 V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos); | 659 V8_INLINE Expression* RewriteAwaitExpression(Expression* value, int pos); |
652 V8_INLINE void PrepareAsyncFunctionBody(ZoneList<Statement*>* body, | 660 V8_INLINE void PrepareAsyncFunctionBody(ZoneList<Statement*>* body, |
653 FunctionKind kind, int pos); | 661 FunctionKind kind, int pos); |
654 V8_INLINE void RewriteAsyncFunctionBody(ZoneList<Statement*>* body, | 662 V8_INLINE void RewriteAsyncFunctionBody(ZoneList<Statement*>* body, |
655 Block* block, | 663 Block* block, |
656 Expression* return_value, bool* ok); | 664 Expression* return_value, bool* ok); |
657 | 665 |
658 Expression* RewriteYieldStar(Expression* generator, Expression* expression, | 666 Expression* RewriteYieldStar(Expression* generator, Expression* expression, |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 | 1183 |
1176 private: | 1184 private: |
1177 ParserTarget** variable_; | 1185 ParserTarget** variable_; |
1178 ParserTarget* previous_; | 1186 ParserTarget* previous_; |
1179 }; | 1187 }; |
1180 | 1188 |
1181 } // namespace internal | 1189 } // namespace internal |
1182 } // namespace v8 | 1190 } // namespace v8 |
1183 | 1191 |
1184 #endif // V8_PARSING_PARSER_H_ | 1192 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |