Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/ssa/codegen.dart |
| =================================================================== |
| --- sdk/lib/_internal/compiler/implementation/ssa/codegen.dart (revision 30610) |
| +++ sdk/lib/_internal/compiler/implementation/ssa/codegen.dart (working copy) |
| @@ -675,20 +675,29 @@ |
| } |
| js.Expression key = pop(); |
| List<js.SwitchClause> cases = <js.SwitchClause>[]; |
| + HSwitch switchInstruction = info.expression.end.last; |
| + List<HInstruction> inputs = switchInstruction.inputs; |
| + List<HBasicBlock> successors = switchInstruction.block.successors; |
| js.Block oldContainer = currentContainer; |
| - for (int i = 0; i < info.matchExpressions.length; i++) { |
| - for (Constant constant in info.matchExpressions[i]) { |
| - generateConstant(constant); |
| + for (int inputIndex = 1, statementIndex = 0; |
| + inputIndex < inputs.length; |
| + statementIndex++) { |
| + HBasicBlock successor = successors[inputIndex - 1]; |
| + do { |
| + visit(inputs[inputIndex]); |
| currentContainer = new js.Block.empty(); |
| cases.add(new js.Case(pop(), currentContainer)); |
| - } |
| - if (i == info.matchExpressions.length - 1) { |
| - currentContainer = new js.Block.empty(); |
| - cases.add(new js.Default(currentContainer)); |
| - } |
| - generateStatements(info.statements[i]); |
| + inputIndex++; |
| + } while (successors[inputIndex - 1] == successor); |
| + |
| + generateStatements(info.statements[statementIndex]); |
| } |
| + |
| + currentContainer = new js.Block.empty(); |
| + cases.add(new js.Default(currentContainer)); |
| + generateStatements(info.statements[info.statements.length - 1]); |
|
kasperl
2013/11/25 11:35:20
info.statements.last?
ngeoffray
2013/11/25 13:40:21
Done.
|
| + |
| currentContainer = oldContainer; |
| js.Statement result = new js.Switch(key, cases); |