Chromium Code Reviews| Index: pkg/compiler/lib/src/ssa/jump_handler.dart |
| diff --git a/pkg/compiler/lib/src/ssa/jump_handler.dart b/pkg/compiler/lib/src/ssa/jump_handler.dart |
| index d401ca8361bbe87a151b1169c284c21207fb6d61..2b9a9df18434abd7d913089c7f607f649d43ee70 100644 |
| --- a/pkg/compiler/lib/src/ssa/jump_handler.dart |
| +++ b/pkg/compiler/lib/src/ssa/jump_handler.dart |
| @@ -150,36 +150,13 @@ class TargetJumpHandler implements JumpHandler { |
| /// Special [JumpHandler] implementation used to handle continue statements |
| /// targeting switch cases. |
| -class SwitchCaseJumpHandler extends TargetJumpHandler { |
| +abstract class SwitchCaseJumpHandler extends TargetJumpHandler { |
| /// Map from switch case targets to indices used to encode the flow of the |
| /// switch case loop. |
| final Map<JumpTarget, int> targetIndexMap = new Map<JumpTarget, int>(); |
| SwitchCaseJumpHandler( |
| - GraphBuilder builder, JumpTarget target, ast.SwitchStatement node) |
| - : super(builder, target) { |
| - // The switch case indices must match those computed in |
| - // [SsaFromAstMixin.buildSwitchCaseConstants]. |
| - // Switch indices are 1-based so we can bypass the synthetic loop when no |
| - // cases match simply by branching on the index (which defaults to null). |
| - int switchIndex = 1; |
| - for (ast.SwitchCase switchCase in node.cases) { |
| - for (ast.Node labelOrCase in switchCase.labelsAndCases) { |
| - ast.Node label = labelOrCase.asLabel(); |
| - if (label != null) { |
| - LabelDefinition labelElement = |
| - builder.elements.getLabelDefinition(label); |
| - if (labelElement != null && labelElement.isContinueTarget) { |
| - JumpTarget continueTarget = labelElement.target; |
| - targetIndexMap[continueTarget] = switchIndex; |
| - assert(builder.jumpTargets[continueTarget] == null); |
| - builder.jumpTargets[continueTarget] = this; |
| - } |
| - } |
| - } |
| - switchIndex++; |
| - } |
| - } |
| + GraphBuilder builder, JumpTarget target) : super(builder, target); |
| void generateBreak([LabelDefinition label]) { |
| if (label == null) { |
| @@ -232,3 +209,34 @@ class SwitchCaseJumpHandler extends TargetJumpHandler { |
| super.close(); |
| } |
| } |
| + |
| +/// Special [JumpHandler] implementation used to handle continue statements |
| +/// targeting switch cases. |
| +class SsaSwitchCaseJumpHandler extends SwitchCaseJumpHandler { |
|
sra1
2017/01/19 23:03:47
Ssa -> Ast
They are both SSA, one from Ast, one fr
Emily Fortuna
2017/01/19 23:19:01
Done.
|
| + |
| + SsaSwitchCaseJumpHandler( |
| + GraphBuilder builder, JumpTarget target, ast.SwitchStatement node) |
| + : super(builder, target) { |
| + // The switch case indices must match those computed in |
| + // [SsaFromAstMixin.buildSwitchCaseConstants]. |
| + // Switch indices are 1-based so we can bypass the synthetic loop when no |
| + // cases match simply by branching on the index (which defaults to null). |
| + int switchIndex = 1; |
| + for (ast.SwitchCase switchCase in node.cases) { |
| + for (ast.Node labelOrCase in switchCase.labelsAndCases) { |
| + ast.Node label = labelOrCase.asLabel(); |
| + if (label != null) { |
| + LabelDefinition labelElement = |
| + builder.elements.getLabelDefinition(label); |
| + if (labelElement != null && labelElement.isContinueTarget) { |
| + JumpTarget continueTarget = labelElement.target; |
| + targetIndexMap[continueTarget] = switchIndex; |
| + assert(builder.jumpTargets[continueTarget] == null); |
| + builder.jumpTargets[continueTarget] = this; |
| + } |
| + } |
| + } |
| + switchIndex++; |
| + } |
| + } |
| +} |