cb7bedf860
The overall strategy is to convert the following:
switch (e) {
l_0: case e0: s_0; break;
l_1: case e1: s_1; continue l_i;
...
l_n: default: s_n; continue l_j;
}
into this:
var label;
switch (e) {
case e0: label = 0; break;
case e1: label = 1; break;
...
default: label = n; break;
}
l: while (true) {
switch (label) {
case 0: s_0; break l;
case 1: s_1; label = i; continue l;
...
case n: s_n; label = j; continue l;
}
}
BUG=http://dartbug.com/8270
R=ngeoffray@google.com
Review URL: https://codereview.chromium.org//14969004
git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22838 260f80e4-7a28-3924-810f-c04153c831b5
33 lines
701 B
Dart
33 lines
701 B
Dart
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// Test switch statement using labels.
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
void main() {
|
|
doSwitch(0, [0, 2]);
|
|
doSwitch(1, [1]);
|
|
doSwitch(2, [2]);
|
|
doSwitch(3, [3, 1]);
|
|
}
|
|
|
|
void doSwitch(int target, List expect) {
|
|
List list = [];
|
|
switch (target) {
|
|
case 0:
|
|
list.add(0);
|
|
continue case2;
|
|
case1: case 1:
|
|
list.add(1);
|
|
break;
|
|
case2: case 2:
|
|
list.add(2);
|
|
break;
|
|
case 3:
|
|
list.add(3);
|
|
continue case1;
|
|
}
|
|
Expect.listEquals(expect, list);
|
|
} |