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

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

Issue 1012783002: Fix renaming of exception variables on left-hand-sides. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix also the dynamic type... Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/js_ast/lib/src/nodes.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) 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:_internal/compiler/js_lib/shared/async_await_error_codes.dart' 10 import 'package:_internal/compiler/js_lib/shared/async_await_error_codes.dart'
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 742
743 @override 743 @override
744 js.Expression visitAssignment(js.Assignment node) { 744 js.Expression visitAssignment(js.Assignment node) {
745 if (!shouldTransform(node)) { 745 if (!shouldTransform(node)) {
746 return new js.Assignment.compound(visitExpression(node.leftHandSide), 746 return new js.Assignment.compound(visitExpression(node.leftHandSide),
747 node.op, visitExpression(node.value)); 747 node.op, visitExpression(node.value));
748 } 748 }
749 js.Expression leftHandSide = node.leftHandSide; 749 js.Expression leftHandSide = node.leftHandSide;
750 if (leftHandSide is js.VariableUse) { 750 if (leftHandSide is js.VariableUse) {
751 return withExpression(node.value, (js.Expression value) { 751 return withExpression(node.value, (js.Expression value) {
752 return new js.Assignment(leftHandSide, value); 752 // A non-compound [js.Assignment] has `op==null`. So it works out to
753 // use [js.Assignment.compound] for all cases.
754 // Visit the [js.VariableUse] to ensure renaming is done correctly.
755 return new js.Assignment.compound(visitExpression(leftHandSide),
756 node.op,
757 value);
753 }, store: false); 758 }, store: false);
754 } else if (leftHandSide is js.PropertyAccess) { 759 } else if (leftHandSide is js.PropertyAccess) {
755 return withExpressions([ 760 return withExpressions([
756 leftHandSide.receiver, 761 leftHandSide.receiver,
757 leftHandSide.selector, 762 leftHandSide.selector,
758 node.value 763 node.value
759 ], (evaluated) { 764 ], (evaluated) {
760 return new js.Assignment.compound( 765 return new js.Assignment.compound(
761 new js.PropertyAccess(evaluated[0], evaluated[1]), node.op, 766 new js.PropertyAccess(evaluated[0], evaluated[1]), node.op,
762 evaluated[2]); 767 evaluated[2]);
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 } 1209 }
1205 1210
1206 @override 1211 @override
1207 visitParameter(js.Parameter node) => unreachable(node); 1212 visitParameter(js.Parameter node) => unreachable(node);
1208 1213
1209 @override 1214 @override
1210 js.Expression visitPostfix(js.Postfix node) { 1215 js.Expression visitPostfix(js.Postfix node) {
1211 if (node.op == "++" || node.op == "--") { 1216 if (node.op == "++" || node.op == "--") {
1212 js.Expression argument = node.argument; 1217 js.Expression argument = node.argument;
1213 if (argument is js.VariableUse) { 1218 if (argument is js.VariableUse) {
1214 return new js.Postfix(node.op, argument); 1219 return new js.Postfix(node.op, visitExpression(argument));
1215 } else if (argument is js.PropertyAccess) { 1220 } else if (argument is js.PropertyAccess) {
1216 return withExpression2(argument.receiver, argument.selector, 1221 return withExpression2(argument.receiver, argument.selector,
1217 (receiver, selector) { 1222 (receiver, selector) {
1218 return new js.Postfix( 1223 return new js.Postfix(
1219 node.op, new js.PropertyAccess(receiver, selector)); 1224 node.op, new js.PropertyAccess(receiver, selector));
1220 }); 1225 });
1221 } else { 1226 } else {
1222 throw "Unexpected postfix ${node.op} " 1227 throw "Unexpected postfix ${node.op} "
1223 "operator argument ${node.argument}"; 1228 "operator argument ${node.argument}";
1224 } 1229 }
1225 } 1230 }
1226 return withExpression(node.argument, 1231 return withExpression(node.argument,
1227 (js.Expression argument) => new js.Postfix(node.op, argument), 1232 (js.Expression argument) => new js.Postfix(node.op, argument),
1228 store: false); 1233 store: false);
1229 } 1234 }
1230 1235
1231 @override 1236 @override
1232 js.Expression visitPrefix(js.Prefix node) { 1237 js.Expression visitPrefix(js.Prefix node) {
1233 if (node.op == "++" || node.op == "--") { 1238 if (node.op == "++" || node.op == "--") {
1234 js.Expression argument = node.argument; 1239 js.Expression argument = node.argument;
1235 if (argument is js.VariableUse) { 1240 if (argument is js.VariableUse) {
1236 return new js.Prefix(node.op, argument); 1241 return new js.Prefix(node.op, visitExpression(argument));
1237 } else if (argument is js.PropertyAccess) { 1242 } else if (argument is js.PropertyAccess) {
1238 return withExpression2(argument.receiver, argument.selector, 1243 return withExpression2(argument.receiver, argument.selector,
1239 (receiver, selector) { 1244 (receiver, selector) {
1240 return new js.Prefix( 1245 return new js.Prefix(
1241 node.op, new js.PropertyAccess(receiver, selector)); 1246 node.op, new js.PropertyAccess(receiver, selector));
1242 }); 1247 });
1243 } else { 1248 } else {
1244 throw "Unexpected prefix ${node.op} operator " 1249 throw "Unexpected prefix ${node.op} operator "
1245 "argument ${node.argument}"; 1250 "argument ${node.argument}";
1246 } 1251 }
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 beginLabel(afterFinallyLabel); 1526 beginLabel(afterFinallyLabel);
1522 } 1527 }
1523 1528
1524 @override 1529 @override
1525 visitVariableDeclaration(js.VariableDeclaration node) { 1530 visitVariableDeclaration(js.VariableDeclaration node) {
1526 unreachable(node); 1531 unreachable(node);
1527 } 1532 }
1528 1533
1529 @override 1534 @override
1530 js.Expression visitVariableDeclarationList(js.VariableDeclarationList node) { 1535 js.Expression visitVariableDeclarationList(js.VariableDeclarationList node) {
1531 List<js.Assignment> initializations = new List<js.Assignment>(); 1536 List<js.Expression> initializations = new List<js.Expression>();
1532 1537
1533 // Declaration of local variables is hoisted outside the helper but the 1538 // Declaration of local variables is hoisted outside the helper but the
1534 // initialization is done here. 1539 // initialization is done here.
1535 for (js.VariableInitialization initialization in node.declarations) { 1540 for (js.VariableInitialization initialization in node.declarations) {
1536 js.VariableDeclaration declaration = initialization.declaration; 1541 js.VariableDeclaration declaration = initialization.declaration;
1537 localVariables.add(declaration); 1542 localVariables.add(declaration);
1538 if (initialization.value != null) { 1543 if (initialization.value != null) {
1539 withExpression(initialization.value, (js.Expression value) { 1544 withExpression(initialization.value, (js.Expression value) {
1540 initializations.add( 1545 initializations.add(
1541 new js.Assignment(new js.VariableUse(declaration.name), value)); 1546 new js.Assignment(new js.VariableUse(declaration.name), value));
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 return condition || body; 2534 return condition || body;
2530 } 2535 }
2531 2536
2532 @override 2537 @override
2533 bool visitDartYield(js.DartYield node) { 2538 bool visitDartYield(js.DartYield node) {
2534 hasYield = true; 2539 hasYield = true;
2535 visit(node.expression); 2540 visit(node.expression);
2536 return true; 2541 return true;
2537 } 2542 }
2538 } 2543 }
OLDNEW
« no previous file with comments | « no previous file | pkg/js_ast/lib/src/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698