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

Unified Diff: src/parsing/parser.cc

Issue 2135983002: Version 5.2.361.39 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@5.2
Patch Set: Created 4 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 | « include/v8-version.h ('k') | test/mjsunit/harmony/function-sent.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 1f267d34905241f59bf5f357138f72d56a83bd1a..9245872a742ba5e02ae8b022eb40f3a245c34c13 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -5956,7 +5956,10 @@ void ParserTraits::SetFunctionNameFromIdentifierRef(Expression* value,
// }
// }
//
-// output.value;
+// if (mode === kReturn) {
+// return {value: output.value, done: true};
+// }
+// output.value
// }
//
// IteratorClose(iterator) expands to the following:
@@ -6252,7 +6255,30 @@ Expression* ParserTraits::RewriteYieldStar(
}
- // output.value;
+ // if (mode === kReturn) {
+ // return {value: output.value, done: true};
+ // }
+ Statement* maybe_return_value;
+ {
+ Expression* mode_proxy = factory->NewVariableProxy(var_mode);
+ Expression* kreturn =
+ factory->NewSmiLiteral(JSGeneratorObject::kReturn, nopos);
+ Expression* condition = factory->NewCompareOperation(
+ Token::EQ_STRICT, mode_proxy, kreturn, nopos);
+
+ Expression* output_proxy = factory->NewVariableProxy(var_output);
+ Expression* literal =
+ factory->NewStringLiteral(avfactory->value_string(), nopos);
+ Expression* property = factory->NewProperty(output_proxy, literal, nopos);
+ Statement* return_value =
+ factory->NewReturnStatement(BuildIteratorResult(property, true), nopos);
+
+ maybe_return_value = factory->NewIfStatement(
+ condition, return_value, factory->NewEmptyStatement(nopos), nopos);
+ }
+
+
+ // output.value
Statement* get_value;
{
Expression* output_proxy = factory->NewVariableProxy(var_output);
@@ -6355,13 +6381,14 @@ Expression* ParserTraits::RewriteYieldStar(
// The rewriter needs to process the get_value statement only, hence we
// put the preceding statements into an init block.
- Block* do_block_ = factory->NewBlock(nullptr, 6, true, nopos);
+ Block* do_block_ = factory->NewBlock(nullptr, 7, true, nopos);
do_block_->statements()->Add(initialize_input, zone);
do_block_->statements()->Add(initialize_mode, zone);
do_block_->statements()->Add(initialize_output, zone);
do_block_->statements()->Add(get_iterator, zone);
do_block_->statements()->Add(validate_iterator, zone);
do_block_->statements()->Add(loop, zone);
+ do_block_->statements()->Add(maybe_return_value, zone);
Block* do_block = factory->NewBlock(nullptr, 2, false, nopos);
do_block->statements()->Add(do_block_, zone);
« no previous file with comments | « include/v8-version.h ('k') | test/mjsunit/harmony/function-sent.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698