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

Side by Side Diff: src/parser.cc

Issue 430693003: yield* calls @@iterator on iterable (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed extra flag from test Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 658
659 Expression* ParserTraits::ExpressionFromString( 659 Expression* ParserTraits::ExpressionFromString(
660 int pos, Scanner* scanner, 660 int pos, Scanner* scanner,
661 AstNodeFactory<AstConstructionVisitor>* factory) { 661 AstNodeFactory<AstConstructionVisitor>* factory) {
662 const AstRawString* symbol = GetSymbol(scanner); 662 const AstRawString* symbol = GetSymbol(scanner);
663 if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol); 663 if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol);
664 return factory->NewStringLiteral(symbol, pos); 664 return factory->NewStringLiteral(symbol, pos);
665 } 665 }
666 666
667 667
668 Expression* ParserTraits::GetIterator(
669 Expression* iterable, AstNodeFactory<AstConstructionVisitor>* factory) {
670 Expression* iterator_symbol_literal =
671 factory->NewSymbolLiteral("symbolIterator", RelocInfo::kNoPosition);
672 int pos = iterable->position();
673 Expression* prop =
674 factory->NewProperty(iterable, iterator_symbol_literal, pos);
675 Zone* zone = parser_->zone();
676 ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(0, zone);
677 return factory->NewCall(prop, args, pos);
678 }
679
680
668 Literal* ParserTraits::GetLiteralTheHole( 681 Literal* ParserTraits::GetLiteralTheHole(
669 int position, AstNodeFactory<AstConstructionVisitor>* factory) { 682 int position, AstNodeFactory<AstConstructionVisitor>* factory) {
670 return factory->NewTheHoleLiteral(RelocInfo::kNoPosition); 683 return factory->NewTheHoleLiteral(RelocInfo::kNoPosition);
671 } 684 }
672 685
673 686
674 Expression* ParserTraits::ParseV8Intrinsic(bool* ok) { 687 Expression* ParserTraits::ParseV8Intrinsic(bool* ok) {
675 return parser_->ParseV8Intrinsic(ok); 688 return parser_->ParseV8Intrinsic(ok);
676 } 689 }
677 690
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after
2766 ast_value_factory_->dot_iterator_string()); 2779 ast_value_factory_->dot_iterator_string());
2767 Variable* result = scope_->DeclarationScope()->NewTemporary( 2780 Variable* result = scope_->DeclarationScope()->NewTemporary(
2768 ast_value_factory_->dot_result_string()); 2781 ast_value_factory_->dot_result_string());
2769 2782
2770 Expression* assign_iterator; 2783 Expression* assign_iterator;
2771 Expression* next_result; 2784 Expression* next_result;
2772 Expression* result_done; 2785 Expression* result_done;
2773 Expression* assign_each; 2786 Expression* assign_each;
2774 2787
2775 // var iterator = subject[Symbol.iterator](); 2788 // var iterator = subject[Symbol.iterator]();
2776 { 2789 assign_iterator = factory()->NewAssignment(
2777 Expression* iterator_symbol_literal = 2790 Token::ASSIGN, factory()->NewVariableProxy(iterator),
2778 factory()->NewSymbolLiteral("symbolIterator", RelocInfo::kNoPosition); 2791 GetIterator(subject, factory()), RelocInfo::kNoPosition);
2779 // FIXME(wingo): Unhappily, it will be a common error that the RHS of a
2780 // for-of doesn't have a Symbol.iterator property. We should do better
2781 // than informing the user that "undefined is not a function".
2782 int pos = subject->position();
2783 Expression* iterator_property =
2784 factory()->NewProperty(subject, iterator_symbol_literal, pos);
2785 ZoneList<Expression*>* iterator_arguments =
2786 new(zone()) ZoneList<Expression*>(0, zone());
2787 Expression* iterator_call = factory()->NewCall(
2788 iterator_property, iterator_arguments, pos);
2789 Expression* iterator_proxy = factory()->NewVariableProxy(iterator);
2790 assign_iterator = factory()->NewAssignment(
2791 Token::ASSIGN, iterator_proxy, iterator_call, RelocInfo::kNoPosition);
2792 }
2793 2792
2794 // var result = iterator.next(); 2793 // var result = iterator.next();
2795 { 2794 {
2796 Expression* iterator_proxy = factory()->NewVariableProxy(iterator); 2795 Expression* iterator_proxy = factory()->NewVariableProxy(iterator);
2797 Expression* next_literal = factory()->NewStringLiteral( 2796 Expression* next_literal = factory()->NewStringLiteral(
2798 ast_value_factory_->next_string(), RelocInfo::kNoPosition); 2797 ast_value_factory_->next_string(), RelocInfo::kNoPosition);
2799 Expression* next_property = factory()->NewProperty( 2798 Expression* next_property = factory()->NewProperty(
2800 iterator_proxy, next_literal, RelocInfo::kNoPosition); 2799 iterator_proxy, next_literal, RelocInfo::kNoPosition);
2801 ZoneList<Expression*>* next_arguments = 2800 ZoneList<Expression*>* next_arguments =
2802 new(zone()) ZoneList<Expression*>(0, zone()); 2801 new(zone()) ZoneList<Expression*>(0, zone());
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after
4804 info()->SetAstValueFactory(ast_value_factory_); 4803 info()->SetAstValueFactory(ast_value_factory_);
4805 } 4804 }
4806 ast_value_factory_ = NULL; 4805 ast_value_factory_ = NULL;
4807 4806
4808 InternalizeUseCounts(); 4807 InternalizeUseCounts();
4809 4808
4810 return (result != NULL); 4809 return (result != NULL);
4811 } 4810 }
4812 4811
4813 } } // namespace v8::internal 4812 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698