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

Unified Diff: src/parser.cc

Issue 416033002: For-of on null or undefined is an error (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 5 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/mips64/full-codegen-mips64.cc ('k') | src/x64/full-codegen-x64.cc » ('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 43196c49e91e490b6c210d9db3ede7f851c44907..170b1f5a3523f1bc0eab16a81fef3fbc98f46f3c 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -2749,37 +2749,26 @@ void Parser::InitializeForEachStatement(ForEachStatement* stmt,
ForOfStatement* for_of = stmt->AsForOfStatement();
if (for_of != NULL) {
- Variable* iterable = scope_->DeclarationScope()->NewTemporary(
- ast_value_factory_->dot_iterable_string());
Variable* iterator = scope_->DeclarationScope()->NewTemporary(
ast_value_factory_->dot_iterator_string());
Variable* result = scope_->DeclarationScope()->NewTemporary(
ast_value_factory_->dot_result_string());
- Expression* assign_iterable;
Expression* assign_iterator;
Expression* next_result;
Expression* result_done;
Expression* assign_each;
- // var iterable = subject;
+ // var iterator = subject[Symbol.iterator]();
{
- Expression* iterable_proxy = factory()->NewVariableProxy(iterable);
- assign_iterable = factory()->NewAssignment(
- Token::ASSIGN, iterable_proxy, subject, subject->position());
- }
-
- // var iterator = iterable[Symbol.iterator]();
- {
- Expression* iterable_proxy = factory()->NewVariableProxy(iterable);
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(
- iterable_proxy, iterator_symbol_literal, pos);
+ 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(
@@ -2826,7 +2815,6 @@ void Parser::InitializeForEachStatement(ForEachStatement* stmt,
}
for_of->Initialize(each, subject, body,
- assign_iterable,
assign_iterator,
next_result,
result_done,
« no previous file with comments | « src/mips64/full-codegen-mips64.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698