 Chromium Code Reviews
 Chromium Code Reviews Issue 1772793002:
  Implement iterator finalization in array destructuring.  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 1772793002:
  Implement iterator finalization in array destructuring.  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| 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/allocation.h" | 8 #include "src/allocation.h" | 
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" | 
| 10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" | 
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 // Generate AST node that throws a TypeError with the given | 459 // Generate AST node that throws a TypeError with the given | 
| 460 // type. Both arguments must be non-null (in the handle sense). | 460 // type. Both arguments must be non-null (in the handle sense). | 
| 461 Expression* NewThrowTypeError(MessageTemplate::Template message, | 461 Expression* NewThrowTypeError(MessageTemplate::Template message, | 
| 462 const AstRawString* arg, int pos); | 462 const AstRawString* arg, int pos); | 
| 463 | 463 | 
| 464 // Generic AST generator for throwing errors from compiled code. | 464 // Generic AST generator for throwing errors from compiled code. | 
| 465 Expression* NewThrowError(Runtime::FunctionId function_id, | 465 Expression* NewThrowError(Runtime::FunctionId function_id, | 
| 466 MessageTemplate::Template message, | 466 MessageTemplate::Template message, | 
| 467 const AstRawString* arg, int pos); | 467 const AstRawString* arg, int pos); | 
| 468 | 468 | 
| 469 void FinalizeIteratorUse(Variable* completion, Expression* condition, | |
| 470 Variable* iter, Block* iterator_use, Block* result); | |
| 471 | |
| 469 Statement* FinalizeForOfStatement(ForOfStatement* loop, int pos); | 472 Statement* FinalizeForOfStatement(ForOfStatement* loop, int pos); | 
| 470 | 473 | 
| 471 // Reporting errors. | 474 // Reporting errors. | 
| 472 void ReportMessageAt(Scanner::Location source_location, | 475 void ReportMessageAt(Scanner::Location source_location, | 
| 473 MessageTemplate::Template message, | 476 MessageTemplate::Template message, | 
| 474 const char* arg = NULL, | 477 const char* arg = NULL, | 
| 475 ParseErrorType error_type = kSyntaxError); | 478 ParseErrorType error_type = kSyntaxError); | 
| 476 void ReportMessage(MessageTemplate::Template message, const char* arg = NULL, | 479 void ReportMessage(MessageTemplate::Template message, const char* arg = NULL, | 
| 477 ParseErrorType error_type = kSyntaxError); | 480 ParseErrorType error_type = kSyntaxError); | 
| 478 void ReportMessage(MessageTemplate::Template message, const AstRawString* arg, | 481 void ReportMessage(MessageTemplate::Template message, const AstRawString* arg, | 
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 667 Expression* RewriteYieldStar( | 670 Expression* RewriteYieldStar( | 
| 668 Expression* generator, Expression* expression, int pos); | 671 Expression* generator, Expression* expression, int pos); | 
| 669 | 672 | 
| 670 Expression* RewriteInstanceof(Expression* lhs, Expression* rhs, int pos); | 673 Expression* RewriteInstanceof(Expression* lhs, Expression* rhs, int pos); | 
| 671 | 674 | 
| 672 private: | 675 private: | 
| 673 Parser* parser_; | 676 Parser* parser_; | 
| 674 | 677 | 
| 675 void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator, | 678 void BuildIteratorClose(ZoneList<Statement*>* statements, Variable* iterator, | 
| 676 Maybe<Variable*> input, Variable* output); | 679 Maybe<Variable*> input, Variable* output); | 
| 680 | |
| 677 void BuildIteratorCloseForCompletion( | 681 void BuildIteratorCloseForCompletion( | 
| 678 ZoneList<Statement*>* statements, Variable* iterator, | 682 ZoneList<Statement*>* statements, Variable* iterator, | 
| 679 Variable* body_threw); | 683 Variable* completion); | 
| 684 | |
| 680 Statement* CheckCallable(Variable* var, Expression* error); | 685 Statement* CheckCallable(Variable* var, Expression* error); | 
| 681 }; | 686 }; | 
| 682 | 687 | 
| 683 | 688 | 
| 684 class Parser : public ParserBase<ParserTraits> { | 689 class Parser : public ParserBase<ParserTraits> { | 
| 685 public: | 690 public: | 
| 686 explicit Parser(ParseInfo* info); | 691 explicit Parser(ParseInfo* info); | 
| 687 ~Parser() { | 692 ~Parser() { | 
| 688 delete reusable_preparser_; | 693 delete reusable_preparser_; | 
| 689 reusable_preparser_ = NULL; | 694 reusable_preparser_ = NULL; | 
| 690 delete cached_parse_data_; | 695 delete cached_parse_data_; | 
| 691 cached_parse_data_ = NULL; | 696 cached_parse_data_ = NULL; | 
| 692 } | 697 } | 
| 693 | 698 | 
| 694 // Parses the source code represented by the compilation info and sets its | 699 // Parses the source code represented by the compilation info and sets its | 
| 695 // function literal. Returns false (and deallocates any allocated AST | 700 // function literal. Returns false (and deallocates any allocated AST | 
| 696 // nodes) if parsing failed. | 701 // nodes) if parsing failed. | 
| 697 static bool ParseStatic(ParseInfo* info); | 702 static bool ParseStatic(ParseInfo* info); | 
| 698 bool Parse(ParseInfo* info); | 703 bool Parse(ParseInfo* info); | 
| 699 void ParseOnBackground(ParseInfo* info); | 704 void ParseOnBackground(ParseInfo* info); | 
| 700 | 705 | 
| 701 // Handle errors detected during parsing, move statistics to Isolate, | 706 // Handle errors detected during parsing, move statistics to Isolate, | 
| 702 // internalize strings (move them to the heap). | 707 // internalize strings (move them to the heap). | 
| 703 void Internalize(Isolate* isolate, Handle<Script> script, bool error); | 708 void Internalize(Isolate* isolate, Handle<Script> script, bool error); | 
| 704 void HandleSourceURLComments(Isolate* isolate, Handle<Script> script); | 709 void HandleSourceURLComments(Isolate* isolate, Handle<Script> script); | 
| 705 | 710 | 
| 711 // Runtime encoding of different completion modes. | |
| 712 enum CompletionKind { | |
| 
adamk
2016/03/07 20:28:05
Can you make this an enum class? Otherwise you've
 
neis
2016/03/08 13:40:10
If I make it an enum class, then instead of eg NOR
 
adamk
2016/03/08 18:41:13
Oh, I forgot about that bit. The thing that bother
 | |
| 713 NORMAL = 0, | |
| 714 THROW = 1, | |
| 715 BREAK = 2, | |
| 716 CONTINUE = 4, | |
| 717 RETURN = 8, | |
| 718 ABRUPT = THROW | BREAK | CONTINUE | RETURN | |
| 
adamk
2016/03/07 20:28:05
Besides this line, do you actually use this enum a
 
neis
2016/03/08 13:40:10
Alright, changed it back to three values.
 | |
| 719 }; | |
| 720 | |
| 706 private: | 721 private: | 
| 707 friend class ParserTraits; | 722 friend class ParserTraits; | 
| 708 | 723 | 
| 709 // Limit the allowed number of local variables in a function. The hard limit | 724 // Limit the allowed number of local variables in a function. The hard limit | 
| 710 // is that offsets computed by FullCodeGenerator::StackOperand and similar | 725 // is that offsets computed by FullCodeGenerator::StackOperand and similar | 
| 711 // functions are ints, and they should not overflow. In addition, accessing | 726 // functions are ints, and they should not overflow. In addition, accessing | 
| 712 // local variables creates user-controlled constants in the generated code, | 727 // local variables creates user-controlled constants in the generated code, | 
| 713 // and we don't want too much user-controlled memory inside the code (this was | 728 // and we don't want too much user-controlled memory inside the code (this was | 
| 714 // the reason why this limit was introduced in the first place; see | 729 // the reason why this limit was introduced in the first place; see | 
| 715 // https://codereview.chromium.org/7003030/ ). | 730 // https://codereview.chromium.org/7003030/ ). | 
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 910 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); | 925 CaseClause* ParseCaseClause(bool* default_seen_ptr, bool* ok); | 
| 911 Statement* ParseSwitchStatement(ZoneList<const AstRawString*>* labels, | 926 Statement* ParseSwitchStatement(ZoneList<const AstRawString*>* labels, | 
| 912 bool* ok); | 927 bool* ok); | 
| 913 DoWhileStatement* ParseDoWhileStatement(ZoneList<const AstRawString*>* labels, | 928 DoWhileStatement* ParseDoWhileStatement(ZoneList<const AstRawString*>* labels, | 
| 914 bool* ok); | 929 bool* ok); | 
| 915 WhileStatement* ParseWhileStatement(ZoneList<const AstRawString*>* labels, | 930 WhileStatement* ParseWhileStatement(ZoneList<const AstRawString*>* labels, | 
| 916 bool* ok); | 931 bool* ok); | 
| 917 Statement* ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok); | 932 Statement* ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok); | 
| 918 Statement* ParseThrowStatement(bool* ok); | 933 Statement* ParseThrowStatement(bool* ok); | 
| 919 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); | 934 Expression* MakeCatchContext(Handle<String> id, VariableProxy* value); | 
| 935 | |
| 920 class DontCollectExpressionsInTailPositionScope; | 936 class DontCollectExpressionsInTailPositionScope; | 
| 921 class CollectExpressionsInTailPositionToListScope; | 937 class CollectExpressionsInTailPositionToListScope; | 
| 922 TryStatement* ParseTryStatement(bool* ok); | 938 TryStatement* ParseTryStatement(bool* ok); | 
| 923 DebuggerStatement* ParseDebuggerStatement(bool* ok); | 939 DebuggerStatement* ParseDebuggerStatement(bool* ok); | 
| 924 // Parse a SubStatement in strict mode, or with an extra block scope in | 940 // Parse a SubStatement in strict mode, or with an extra block scope in | 
| 925 // sloppy mode to handle | 941 // sloppy mode to handle | 
| 926 // ES#sec-functiondeclarations-in-ifstatement-statement-clauses | 942 // ES#sec-functiondeclarations-in-ifstatement-statement-clauses | 
| 927 // The legacy parameter indicates whether function declarations are | 943 // The legacy parameter indicates whether function declarations are | 
| 928 // banned by the ES2015 specification in this location, and they are being | 944 // banned by the ES2015 specification in this location, and they are being | 
| 929 // permitted here to match previous V8 behavior. | 945 // permitted here to match previous V8 behavior. | 
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1238 | 1254 | 
| 1239 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { | 1255 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { | 
| 1240 return parser_->ParseDoExpression(ok); | 1256 return parser_->ParseDoExpression(ok); | 
| 1241 } | 1257 } | 
| 1242 | 1258 | 
| 1243 | 1259 | 
| 1244 } // namespace internal | 1260 } // namespace internal | 
| 1245 } // namespace v8 | 1261 } // namespace v8 | 
| 1246 | 1262 | 
| 1247 #endif // V8_PARSING_PARSER_H_ | 1263 #endif // V8_PARSING_PARSER_H_ | 
| OLD | NEW |