Files
sdk/pkg/dart2bytecode/testcases/switch.dart
T
Alexander Markov 3abf78212c Bytecode compiler
Add dart2bytecode tool which takes Dart sources and produces
Dart bytecode. The tool uses common front-end (CFE) to parse Dart
source code and contains bytecode generator which translates
kernel AST to bytecode.

Change-Id: I90bd6e72c619cf0edc556da0640760b30e81091d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378560
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-08-08 18:08:58 +00:00

61 lines
856 B
Dart

// Copyright (c) 2024, 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.
int foo1(int x) {
int y = -1;
switch (x) {
case 1:
y = 11;
break;
case 2:
y = 22;
break;
case 3:
y = 33;
break;
}
return y;
}
int foo2(int x) {
int y;
switch (x) {
case 1:
case 2:
case 3:
y = 11;
break;
case 4:
case 5:
case 6:
y = 22;
break;
default:
y = 33;
}
return y;
}
int foo3(int x) {
int y;
switch (x) {
case 1:
case 2:
case 3:
y = 11;
continue L5;
case 4:
L5:
case 5:
case 6:
y = 22;
return 42;
default:
y = 33;
}
return y;
}
main() {}