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

Unified Diff: lib/compiler/implementation/scanner/listener.dart

Issue 10387080: Accept more labels per switch case. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove debug-print. 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/scanner/listener.dart
diff --git a/lib/compiler/implementation/scanner/listener.dart b/lib/compiler/implementation/scanner/listener.dart
index 74dd30f0dc1b51b65e5489840bdb8bc7bd995db5..9223630ffe749f673e4bea3c4b8e5336aeedb1d6 100644
--- a/lib/compiler/implementation/scanner/listener.dart
+++ b/lib/compiler/implementation/scanner/listener.dart
@@ -165,10 +165,10 @@ class Listener {
void handleLabel(Token token) {
}
- void beginLabeledStatement(Token token) {
+ void beginLabeledStatement(Token token, int labelCount) {
}
- void endLabeledStatement() {
+ void endLabeledStatement(int labelCount) {
}
void beginLiteralMapEntry(Token token) {
@@ -251,6 +251,9 @@ class Listener {
void beginTryStatement(Token token) {
}
+ void handleCaseMatch(Token caseKeyword, Token colon) {
+ }
+
void handleCatchBlock(Token catchKeyword) {
}
@@ -404,7 +407,7 @@ class Listener {
void handleSuperExpression(Token token) {
}
- void handleSwitchCase(Token labelToken, int expressionCount,
+ void handleSwitchCase(int labelCount, int expressionCount,
Token defaultKeyword, int statementCount,
Token firstToken, Token endToken) {
}
@@ -1331,6 +1334,10 @@ class NodeListener extends ElementListener {
tryKeyword, finallyKeyword));
}
+ void handleCaseMatch(Token caseKeyword, Token colon) {
+ pushNode(new CaseMatch(caseKeyword, popNode(), colon));
+ }
+
void handleCatchBlock(Token catchKeyword) {
Block block = popNode();
NodeList formals = popNode();
@@ -1347,22 +1354,20 @@ class NodeListener extends ElementListener {
Link<Node> caseNodes = const EmptyLink<Node>();
while (caseCount > 0) {
SwitchCase switchCase = popNode();
+ Expect.isTrue(switchCase is SwitchCase);
ahe 2012/05/14 09:24:25 Please avoid assertions, an internal error has mor
Lasse Reichstein Nielsen 2012/05/14 10:34:58 Ack. Leftover debug code.
caseNodes = caseNodes.prepend(switchCase);
caseCount--;
}
pushNode(new NodeList(beginToken, caseNodes, endToken, null));
}
- void handleSwitchCase(Token labelToken, int expressionCount,
+ void handleSwitchCase(int labelCount, int caseCount,
Token defaultKeyword, int statementCount,
Token firstToken, Token endToken) {
NodeList statements = makeNodeList(statementCount, null, null, null);
- NodeList expressions = makeNodeList(expressionCount, null, null, null);
- Label label = null;
- if (labelToken !== null) {
- label = popNode();
- }
- pushNode(new SwitchCase(label, expressions, defaultKeyword, statements,
+ NodeList labelsAndCases =
+ makeNodeList(labelCount + caseCount, null, null, null);
+ pushNode(new SwitchCase(labelsAndCases, defaultKeyword, statements,
firstToken));
}
@@ -1439,10 +1444,13 @@ class NodeListener extends ElementListener {
pushNode(new Label(name, colon));
}
- void endLabeledStatement() {
+ void endLabeledStatement(int labelCount) {
Statement statement = popNode();
- Label label = popNode();
- pushNode(new LabeledStatement(label, statement));
+ while (labelCount > 0) {
+ Label label = popNode();
+ pushNode(new LabeledStatement(label, statement));
+ labelCount--;
+ }
}
void log(message) {

Powered by Google App Engine
This is Rietveld 408576698