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

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

Issue 994853003: Fix dart2js for switches in async code with only awaits in the key. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 | tests/compiler/dart2js/async_await_js_transform_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) 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 2394 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 bool visitReturn(js.Return node) { 2405 bool visitReturn(js.Return node) {
2406 hasExplicitReturns = true; 2406 hasExplicitReturns = true;
2407 targets[node] = currentFunction; 2407 targets[node] = currentFunction;
2408 if (node.value == null) return false; 2408 if (node.value == null) return false;
2409 return visit(node.value); 2409 return visit(node.value);
2410 } 2410 }
2411 2411
2412 @override 2412 @override
2413 bool visitSwitch(js.Switch node) { 2413 bool visitSwitch(js.Switch node) {
2414 loopsAndSwitches.add(node); 2414 loopsAndSwitches.add(node);
2415 bool result = visit(node.key); 2415 // If the key has an `await` expression, do not transform the
2416 // body of the switch.
2417 visit(node.key);
2418 bool result = false;
2416 for (js.SwitchClause clause in node.cases) { 2419 for (js.SwitchClause clause in node.cases) {
2417 if (visit(clause)) result = true; 2420 if (visit(clause)) result = true;
2418 } 2421 }
2419 loopsAndSwitches.removeLast(); 2422 loopsAndSwitches.removeLast();
2420 return result; 2423 return result;
2421 } 2424 }
2422 2425
2423 @override 2426 @override
2424 bool visitThis(js.This node) { 2427 bool visitThis(js.This node) {
2425 hasThis = true; 2428 hasThis = true;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 return condition || body; 2479 return condition || body;
2477 } 2480 }
2478 2481
2479 @override 2482 @override
2480 bool visitDartYield(js.DartYield node) { 2483 bool visitDartYield(js.DartYield node) {
2481 hasYield = true; 2484 hasYield = true;
2482 visit(node.expression); 2485 visit(node.expression);
2483 return true; 2486 return true;
2484 } 2487 }
2485 } 2488 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/async_await_js_transform_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698