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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart

Issue 1575593002: dart2js cps: Name labels uniquely within each method, not globally. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Typo Created 4 years, 11 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
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 library tree_ir_nodes; 5 library tree_ir_nodes;
6 6
7 import '../constants/values.dart' as values; 7 import '../constants/values.dart' as values;
8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; 8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType;
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../io/source_information.dart' show SourceInformation; 10 import '../io/source_information.dart' show SourceInformation;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 Statement get next; 60 Statement get next;
61 void set next(Statement s); 61 void set next(Statement s);
62 accept(StatementVisitor v); 62 accept(StatementVisitor v);
63 accept1(StatementVisitor1 v, arg); 63 accept1(StatementVisitor1 v, arg);
64 } 64 }
65 65
66 /** 66 /**
67 * Labels name [LabeledStatement]s. 67 * Labels name [LabeledStatement]s.
68 */ 68 */
69 class Label { 69 class Label {
70 // A counter used to generate names. The counter is reset to 0 for each
71 // function emitted.
72 static int counter = 0;
73 static String _newName() => 'L${counter++}';
74
75 String cachedName;
76
77 String get name {
78 if (cachedName == null) cachedName = _newName();
79 return cachedName;
80 }
81
82 /// Number of [Break] or [Continue] statements that target this label. 70 /// Number of [Break] or [Continue] statements that target this label.
83 /// The [Break] constructor will increment this automatically, but the 71 /// The [Break] constructor will increment this automatically, but the
84 /// counter must be decremented by hand when a [Break] becomes orphaned. 72 /// counter must be decremented by hand when a [Break] becomes orphaned.
85 int useCount = 0; 73 int useCount = 0;
86 74
87 /// The [LabeledStatement] or [WhileTrue] binding this label. 75 /// The [LabeledStatement] or [WhileTrue] binding this label.
88 JumpTarget binding; 76 JumpTarget binding;
89 } 77 }
90 78
91 /** 79 /**
(...skipping 1554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 1634
1647 /// Number of uses of the current fallthrough target. 1635 /// Number of uses of the current fallthrough target.
1648 int get useCount => _stack.last.useCount; 1636 int get useCount => _stack.last.useCount;
1649 1637
1650 /// Indicate that a statement will fall through to the current fallthrough 1638 /// Indicate that a statement will fall through to the current fallthrough
1651 /// target. 1639 /// target.
1652 void use() { 1640 void use() {
1653 ++_stack.last.useCount; 1641 ++_stack.last.useCount;
1654 } 1642 }
1655 } 1643 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698