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

Side by Side Diff: pkg/compiler/lib/src/js/rewrite_async.dart

Issue 1427593003: dart2js: Bugfix for when 'await' occurs in an initializer list. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 | pkg/pkg.status » ('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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library rewrite_async; 5 library rewrite_async;
6 6
7 import "dart:math" show max; 7 import "dart:math" show max;
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:js_runtime/shared/async_await_error_codes.dart' 10 import 'package:js_runtime/shared/async_await_error_codes.dart'
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 node.update 1016 node.update
1017 ], (List<js.Expression> transformed) { 1017 ], (List<js.Expression> transformed) {
1018 addStatement(new js.For(transformed[0], transformed[1], transformed[2], 1018 addStatement(new js.For(transformed[0], transformed[1], transformed[2],
1019 translateInBlock(node.body))); 1019 translateInBlock(node.body)));
1020 }); 1020 });
1021 insideUntranslatedBreakable = oldInsideUntranslated; 1021 insideUntranslatedBreakable = oldInsideUntranslated;
1022 return; 1022 return;
1023 } 1023 }
1024 1024
1025 if (node.init != null) { 1025 if (node.init != null) {
1026 addExpressionStatement(visitExpression(node.init)); 1026 visitExpressionIgnoreResult(node.init);
1027 } 1027 }
1028 int startLabel = newLabel("for condition"); 1028 int startLabel = newLabel("for condition");
1029 // If there is no update, continuing the loop is the same as going to the 1029 // If there is no update, continuing the loop is the same as going to the
1030 // start. 1030 // start.
1031 int continueLabel = 1031 int continueLabel =
1032 (node.update == null) ? startLabel : newLabel("for update"); 1032 (node.update == null) ? startLabel : newLabel("for update");
1033 continueLabels[node] = continueLabel; 1033 continueLabels[node] = continueLabel;
1034 int afterLabel = newLabel("after for"); 1034 int afterLabel = newLabel("after for");
1035 breakLabels[node] = afterLabel; 1035 breakLabels[node] = afterLabel;
1036 beginLabel(startLabel); 1036 beginLabel(startLabel);
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 beginLabel(afterFinallyLabel); 1546 beginLabel(afterFinallyLabel);
1547 } 1547 }
1548 1548
1549 @override 1549 @override
1550 visitVariableDeclaration(js.VariableDeclaration node) { 1550 visitVariableDeclaration(js.VariableDeclaration node) {
1551 unreachable(node); 1551 unreachable(node);
1552 } 1552 }
1553 1553
1554 @override 1554 @override
1555 js.Expression visitVariableDeclarationList(js.VariableDeclarationList node) { 1555 js.Expression visitVariableDeclarationList(js.VariableDeclarationList node) {
1556 List<js.Expression> initializations = new List<js.Expression>();
1557
1558 // Declaration of local variables is hoisted outside the helper but the
1559 // initialization is done here.
1560 for (js.VariableInitialization initialization in node.declarations) { 1556 for (js.VariableInitialization initialization in node.declarations) {
1561 js.VariableDeclaration declaration = initialization.declaration; 1557 js.VariableDeclaration declaration = initialization.declaration;
1562 localVariables.add(declaration); 1558 localVariables.add(declaration);
1563 if (initialization.value != null) { 1559 if (initialization.value != null) {
1564 withExpression(initialization.value, (js.Expression value) { 1560 withExpression(initialization.value, (js.Expression value) {
1565 initializations.add( 1561 addExpressionStatement(
1566 new js.Assignment(new js.VariableUse(declaration.name), value)); 1562 new js.Assignment(new js.VariableUse(declaration.name), value));
1567 }, store: false); 1563 }, store: false);
1568 } 1564 }
1569 } 1565 }
1570 if (initializations.isEmpty) { 1566 return js.number(0); // Dummy expression.
1571 // Dummy expression. Will be dropped by [visitExpressionIgnoreResult].
1572 return js.number(0);
1573 } else {
1574 return initializations.reduce(
1575 (js.Expression first, js.Expression second) {
1576 return new js.Binary(",", first, second);
1577 });
1578 }
1579 } 1567 }
1580 1568
1581 @override 1569 @override
1582 void visitVariableInitialization(js.VariableInitialization node) { 1570 void visitVariableInitialization(js.VariableInitialization node) {
1583 unreachable(node); 1571 unreachable(node);
1584 } 1572 }
1585 1573
1586 @override 1574 @override
1587 js.Expression visitVariableUse(js.VariableUse node) { 1575 js.Expression visitVariableUse(js.VariableUse node) {
1588 Pair<String, String> renaming = variableRenamings.lastWhere( 1576 Pair<String, String> renaming = variableRenamings.lastWhere(
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
2593 return condition || body; 2581 return condition || body;
2594 } 2582 }
2595 2583
2596 @override 2584 @override
2597 bool visitDartYield(js.DartYield node) { 2585 bool visitDartYield(js.DartYield node) {
2598 hasYield = true; 2586 hasYield = true;
2599 visit(node.expression); 2587 visit(node.expression);
2600 return true; 2588 return true;
2601 } 2589 }
2602 } 2590 }
OLDNEW
« no previous file with comments | « no previous file | pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698