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

Unified Diff: runtime/vm/ast_transformer.cc

Issue 1382123003: Fix await transformation of function calls (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | tests/language/await_regression_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/ast_transformer.cc
diff --git a/runtime/vm/ast_transformer.cc b/runtime/vm/ast_transformer.cc
index b4583cf636de7d8a9156f259c6cc430e65e13772..95d8d4f37dc8ce33dab80a2117276d9731a2f5dc 100644
--- a/runtime/vm/ast_transformer.cc
+++ b/runtime/vm/ast_transformer.cc
@@ -567,12 +567,21 @@ void AwaitTransformer::VisitLetNode(LetNode* node) {
node->TempAt(i),
new_init_val));
}
- // The transformed LetNode does not have any temporary variables.
- LetNode* result = new(Z) LetNode(node->token_pos());
- for (intptr_t i = 0; i < node->nodes().length(); i++) {
- result->AddNode(Transform(node->nodes()[i]));
+
+ // Add all expressions but the last to the preamble. We must do
+ // this because subexpressions of the awaitable expression we
+ // are currently transforming may depend on each other,
+ // e.g. await foo(a++, a++). Thus we must preserve the order of the
+ // transformed subexpressions.
+ for (intptr_t i = 0; i < node->nodes().length() - 1; i++) {
+ preamble_->Add(Transform(node->nodes()[i]));
}
- result_ = result;
+
+ // The last expression in the let node is the value of the node.
+ // The result of the transformed let node is this expression.
+ ASSERT(node->nodes().length() > 0);
+ const intptr_t last_node_index = node->nodes().length() - 1;
+ result_ = Transform(node->nodes()[last_node_index]);
regis 2015/10/05 20:33:15 You could have used node->nodes().Last()
hausner 2015/10/05 21:19:43 Good idea. Will do in a later checkin.
}
« no previous file with comments | « no previous file | tests/language/await_regression_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698