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

Unified Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 3003863002: [kernel] Position on switch expression (Closed)
Patch Set: ... Created 3 years, 4 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
« no previous file with comments | « no previous file | pkg/kernel/binary.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 7a84b26ef8d355126509dbfff59bdec08b7d8271..bf20af0fbd5db011776be0ddda3d9b217adc9b07 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -2858,7 +2858,19 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
@override
void endSwitchStatement(Token switchKeyword, Token endToken) {
debugEvent("SwitchStatement");
- // Do nothing. Handled by [endSwitchBlock].
+
+ List<SwitchCase> cases = pop();
+ JumpTarget target = exitBreakTarget();
+ exitSwitchScope();
+ exitLocalScope();
+ Expression expression = popForValue();
+ Statement result = new KernelSwitchStatement(expression, cases)
+ ..fileOffset = switchKeyword.charOffset;
+ if (target.hasUsers) {
+ result = new KernelLabeledStatement(result);
+ target.resolveBreaks(result);
+ }
+ exitLoopOrSwitch(result);
}
@override
@@ -2909,16 +2921,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
new ExpressionStatement(buildFallThroughError(current.fileOffset)));
}
}
- JumpTarget target = exitBreakTarget();
- exitSwitchScope();
- exitLocalScope();
- Expression expression = popForValue();
- Statement result = new KernelSwitchStatement(expression, cases);
- if (target.hasUsers) {
- result = new KernelLabeledStatement(result);
- target.resolveBreaks(result);
- }
- exitLoopOrSwitch(result);
+
+ push(cases);
}
@override
« no previous file with comments | « no previous file | pkg/kernel/binary.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698