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

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

Issue 926433003: Initialize 'next' variable in async rewrite when using yield in finally blocks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | no next file » | 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 // TODO(sigurdm): Throws in catch-handlers are handled wrong. 7 // TODO(sigurdm): Throws in catch-handlers are handled wrong.
8 // TODO(sigurdm): Avoid using variables in templates. It could blow up memory 8 // TODO(sigurdm): Avoid using variables in templates. It could blow up memory
9 // use. 9 // use.
10 10
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 inits.add(makeInit(gotoName, js.number(0))); 783 inits.add(makeInit(gotoName, js.number(0)));
784 if (isAsync) { 784 if (isAsync) {
785 inits.add(makeInit(completerName, new js.New(newCompleter, []))); 785 inits.add(makeInit(completerName, new js.New(newCompleter, [])));
786 } else if (isAsyncStar) { 786 } else if (isAsyncStar) {
787 inits.add(makeInit(controllerName, 787 inits.add(makeInit(controllerName,
788 new js.Call(newController, [new js.VariableUse(helperName)]))); 788 new js.Call(newController, [new js.VariableUse(helperName)])));
789 } 789 }
790 if (hasTryBlocks) { 790 if (hasTryBlocks) {
791 inits.add(makeInit(handlerName, new js.LiteralNull())); 791 inits.add(makeInit(handlerName, new js.LiteralNull()));
792 } 792 }
793 if (hasJumpThroughFinally) { 793 if (hasJumpThroughFinally || analysis.hasYield) {
794 inits.add(makeInit(nextName, null)); 794 inits.add(makeInit(nextName, null));
795 } 795 }
796 if (analysis.hasExplicitReturns && isAsync) { 796 if (analysis.hasExplicitReturns && isAsync) {
797 inits.add(makeInit(returnValueName, null)); 797 inits.add(makeInit(returnValueName, null));
798 } 798 }
799 if (analysis.hasThis && !isSyncStar) { 799 if (analysis.hasThis && !isSyncStar) {
800 // Sync* functions must remember `this` on the level of the outer 800 // Sync* functions must remember `this` on the level of the outer
801 // function. 801 // function.
802 inits.add(makeInit(selfName, new js.This())); 802 inits.add(makeInit(selfName, new js.This()));
803 } 803 }
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 Map<js.Node, js.Node> targets = new Map<js.Node, js.Node>(); 1746 Map<js.Node, js.Node> targets = new Map<js.Node, js.Node>();
1747 List<js.Node> loopsAndSwitches = new List<js.Node>(); 1747 List<js.Node> loopsAndSwitches = new List<js.Node>();
1748 List<js.LabeledStatement> labelledStatements = 1748 List<js.LabeledStatement> labelledStatements =
1749 new List<js.LabeledStatement>(); 1749 new List<js.LabeledStatement>();
1750 Set<String> usedNames = new Set<String>(); 1750 Set<String> usedNames = new Set<String>();
1751 1751
1752 bool hasExplicitReturns = false; 1752 bool hasExplicitReturns = false;
1753 1753
1754 bool hasThis = false; 1754 bool hasThis = false;
1755 1755
1756 bool hasYield = false;
1757
1756 // The function currently being analyzed. 1758 // The function currently being analyzed.
1757 js.Fun currentFunction; 1759 js.Fun currentFunction;
1758 1760
1759 // For error messages. 1761 // For error messages.
1760 final Function unsupported; 1762 final Function unsupported;
1761 1763
1762 PreTranslationAnalysis(void this.unsupported(js.Node node)); 1764 PreTranslationAnalysis(void this.unsupported(js.Node node));
1763 1765
1764 bool visit(js.Node node) { 1766 bool visit(js.Node node) {
1765 bool containsAwait = node.accept(this); 1767 bool containsAwait = node.accept(this);
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 bool visitWhile(js.While node) { 2138 bool visitWhile(js.While node) {
2137 loopsAndSwitches.add(node); 2139 loopsAndSwitches.add(node);
2138 bool condition = visit(node.condition); 2140 bool condition = visit(node.condition);
2139 bool body = visit(node.body); 2141 bool body = visit(node.body);
2140 loopsAndSwitches.removeLast(); 2142 loopsAndSwitches.removeLast();
2141 return condition || body; 2143 return condition || body;
2142 } 2144 }
2143 2145
2144 @override 2146 @override
2145 bool visitDartYield(js.DartYield node) { 2147 bool visitDartYield(js.DartYield node) {
2148 hasYield = true;
2146 visit(node.expression); 2149 visit(node.expression);
2147 return true; 2150 return true;
2148 } 2151 }
2149 } 2152 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698