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

Unified Diff: dart/frog/leg/scanner/listener.dart

Issue 9599013: Complete AST nodes for switch statement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: dart/frog/leg/scanner/listener.dart
diff --git a/dart/frog/leg/scanner/listener.dart b/dart/frog/leg/scanner/listener.dart
index 6e93383008ff32088db5cda97a32097f62d3d6e6..5b6dac4f983ada0282d0f70d25aa1ca455332b54 100644
--- a/dart/frog/leg/scanner/listener.dart
+++ b/dart/frog/leg/scanner/listener.dart
@@ -1293,11 +1293,9 @@ class NodeListener extends ElementListener {
}
void endSwitchStatement(Token switchKeyword, Token endToken) {
- popNode(); // Discard block.
+ NodeList cases = popNode();
ParenthesizedExpression expression = popNode();
- SwitchStatement node =
- new SwitchStatement(expression, switchKeyword, endToken);
- pushNode(node);
+ pushNode(new SwitchStatement(expression, cases, switchKeyword));
}
void endSwitchBlock(int caseCount, Token beginToken, Token endToken) {
@@ -1308,19 +1306,21 @@ class NodeListener extends ElementListener {
Token endToken) {
NodeList statements = makeNodeList(statementCount, null, null, null);
Expression expression = popNode();
+ Identifier label = null;
if (colon !== null) {
- popNode(); // Discard label.
+ label = popNode();
}
- pushNode(statements);
+ pushNode(new SwitchCase(label, expression, statements, caseKeyword));
}
void handleDefaultCase(Token colon, Token defaultKeyword, int statementCount,
Token endToken) {
NodeList statements = makeNodeList(statementCount, null, null, null);
+ Identifier label = null;
if (colon !== null) {
- popNode(); // Discard label.
+ label = popNode();
}
- pushNode(statements);
+ pushNode(new DefaultCase(label, statements, defaultKeyword));
}
void handleBreakStatement(bool hasTarget,

Powered by Google App Engine
This is Rietveld 408576698