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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index ead37b0a2cf155e32b1bf590a22e3f4c48339ce9..a3970db20640bca0515556ec0bc31b2724807340 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -665,6 +665,19 @@ Expression* ParserTraits::ExpressionFromString(
}
+Expression* ParserTraits::GetIterator(
+ Expression* iterable, AstNodeFactory<AstConstructionVisitor>* factory) {
+ Expression* iterator_symbol_literal =
+ factory->NewSymbolLiteral("symbolIterator", RelocInfo::kNoPosition);
+ int pos = iterable->position();
+ Expression* prop =
+ factory->NewProperty(iterable, iterator_symbol_literal, pos);
+ Zone* zone = parser_->zone();
+ ZoneList<Expression*>* args = new (zone) ZoneList<Expression*>(0, zone);
+ return factory->NewCall(prop, args, pos);
+}
+
+
Literal* ParserTraits::GetLiteralTheHole(
int position, AstNodeFactory<AstConstructionVisitor>* factory) {
return factory->NewTheHoleLiteral(RelocInfo::kNoPosition);
@@ -2773,23 +2786,9 @@ void Parser::InitializeForEachStatement(ForEachStatement* stmt,
Expression* assign_each;
// var iterator = subject[Symbol.iterator]();
- {
- Expression* iterator_symbol_literal =
- factory()->NewSymbolLiteral("symbolIterator", RelocInfo::kNoPosition);
- // FIXME(wingo): Unhappily, it will be a common error that the RHS of a
- // for-of doesn't have a Symbol.iterator property. We should do better
- // than informing the user that "undefined is not a function".
- int pos = subject->position();
- Expression* iterator_property =
- factory()->NewProperty(subject, iterator_symbol_literal, pos);
- ZoneList<Expression*>* iterator_arguments =
- new(zone()) ZoneList<Expression*>(0, zone());
- Expression* iterator_call = factory()->NewCall(
- iterator_property, iterator_arguments, pos);
- Expression* iterator_proxy = factory()->NewVariableProxy(iterator);
- assign_iterator = factory()->NewAssignment(
- Token::ASSIGN, iterator_proxy, iterator_call, RelocInfo::kNoPosition);
- }
+ assign_iterator = factory()->NewAssignment(
+ Token::ASSIGN, factory()->NewVariableProxy(iterator),
+ GetIterator(subject, factory()), RelocInfo::kNoPosition);
// var result = iterator.next();
{
« 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