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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/language/await_regression_test.dart » ('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 (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/ast_transformer.h" 5 #include "vm/ast_transformer.h"
6 6
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/parser.h" 8 #include "vm/parser.h"
9 #include "vm/thread.h" 9 #include "vm/thread.h"
10 10
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // The temporary variables will be captured as a side effect of being 560 // The temporary variables will be captured as a side effect of being
561 // added to a scope, and the subsequent nodes that are added to the 561 // added to a scope, and the subsequent nodes that are added to the
562 // preample can access them. 562 // preample can access them.
563 for (intptr_t i = 0; i < node->num_temps(); i++) { 563 for (intptr_t i = 0; i < node->num_temps(); i++) {
564 async_temp_scope_->AddVariable(node->TempAt(i)); 564 async_temp_scope_->AddVariable(node->TempAt(i));
565 AstNode* new_init_val = Transform(node->InitializerAt(i)); 565 AstNode* new_init_val = Transform(node->InitializerAt(i));
566 preamble_->Add(new(Z) StoreLocalNode(node->token_pos(), 566 preamble_->Add(new(Z) StoreLocalNode(node->token_pos(),
567 node->TempAt(i), 567 node->TempAt(i),
568 new_init_val)); 568 new_init_val));
569 } 569 }
570 // The transformed LetNode does not have any temporary variables. 570
571 LetNode* result = new(Z) LetNode(node->token_pos()); 571 // Add all expressions but the last to the preamble. We must do
572 for (intptr_t i = 0; i < node->nodes().length(); i++) { 572 // this because subexpressions of the awaitable expression we
573 result->AddNode(Transform(node->nodes()[i])); 573 // are currently transforming may depend on each other,
574 // e.g. await foo(a++, a++). Thus we must preserve the order of the
575 // transformed subexpressions.
576 for (intptr_t i = 0; i < node->nodes().length() - 1; i++) {
577 preamble_->Add(Transform(node->nodes()[i]));
574 } 578 }
575 result_ = result; 579
580 // The last expression in the let node is the value of the node.
581 // The result of the transformed let node is this expression.
582 ASSERT(node->nodes().length() > 0);
583 const intptr_t last_node_index = node->nodes().length() - 1;
584 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.
576 } 585 }
577 586
578 587
579 void AwaitTransformer::VisitThrowNode(ThrowNode* node) { 588 void AwaitTransformer::VisitThrowNode(ThrowNode* node) {
580 AstNode* new_exception = Transform(node->exception()); 589 AstNode* new_exception = Transform(node->exception());
581 result_ = new(Z) ThrowNode(node->token_pos(), 590 result_ = new(Z) ThrowNode(node->token_pos(),
582 new_exception, 591 new_exception,
583 node->stacktrace()); 592 node->stacktrace());
584 } 593 }
585 594
586 } // namespace dart 595 } // namespace dart
OLDNEW
« 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