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

Unified Diff: lib/compiler/implementation/tree/unparser.dart

Issue 10387080: Accept more labels per switch case. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: lib/compiler/implementation/tree/unparser.dart
diff --git a/lib/compiler/implementation/tree/unparser.dart b/lib/compiler/implementation/tree/unparser.dart
index 17852756cf2781af25b2609512899147492ac7cb..d48774e9a91761c6792a8cdbc9077bc6ea90d3f4 100644
--- a/lib/compiler/implementation/tree/unparser.dart
+++ b/lib/compiler/implementation/tree/unparser.dart
@@ -347,14 +347,26 @@ class Unparser implements Visitor {
}
visitSwitchCase(SwitchCase node) {
- if (node.label !== null) {
- visit(node.label);
- sb.add(': ');
+ Link<Label> labels = node.labels.nodes;
+ Link<CaseMatch> cases = node.cases.nodes;
+ // Interleave labels and cases in their original order.
+ while (!labels.isEmpty()) {
+ Label label = labels.head;
+ while (!cases.isEmpty()) {
+ CaseMatch match = cases.head;
+ if (match.colonToken.charOffset < label.colonToken.charOffset) {
+ visit(match);
+ cases = cases.tail;
+ } else {
+ break;
+ }
+ }
+ visit(label);
+ labels = labels.tail;
}
- for (Expression expression in node.expressions) {
- sb.add('case ');
- visit(expression);
- sb.add(': ');
+ while (!cases.isEmpty()) {
+ visit(cases.head);
+ cases = cases.tail;
}
if (node.isDefaultCase) {
sb.add('default:');
@@ -389,6 +401,13 @@ class Unparser implements Visitor {
}
}
+ visitCaseMatch(CaseMatch node) {
+ add(node.caseKeyword.value);
+ sb.add(" ");
+ visit(node.expression);
+ add(node.colonToken.value);
+ }
+
visitCatchBlock(CatchBlock node) {
add(node.catchKeyword.value);
sb.add(' ');

Powered by Google App Engine
This is Rietveld 408576698