Sergej Jaskiewicz
|
55ae6d1f3e
|
[JS IR] Optimize pattern-matching of enums into comparing their ordinals
For this code:
```
enum class Season {
WINTER,
SPRING,
SUMMER,
AUTUMN
}
fun bar1(x : Season) : String {
return when (x) {
Season.WINTER, Season.SPRING -> "winter_spring"
Season.SUMMER -> "summer"
else -> "autumn"
}
}
```
previously we generated this:
```
function foo(x) {
var tmp0_subject = x;
return (tmp0_subject.equals(Season_WINTER_getInstance())
? true
: tmp0_subject.equals(Season_SPRING_getInstance()))
? 'winter_spring'
: tmp0_subject.equals(Season_SUMMER_getInstance())
? 'summer'
: 'autumn';
}
```
And now we generated this:
```
function bar2(x) {
var tmp0_subject = x;
var tmp0 = tmp0_subject._get_ordinal__0_k$();
var tmp;
switch (tmp0) {
case 0:
case 1:
tmp = 'winter_spring';
break;
case 2:
tmp = 'summer';
break;
case 3:
tmp = 'autumn';
break;
default:
noWhenBranchMatchedException();
break;
}
return tmp;
}
```
|
2021-10-14 11:44:01 +00:00 |
|
Mikhail Glukhikh
|
94fe79578e
|
[FIR2IR] Generate unconditional branch in exhaustive whens
|
2020-03-20 11:55:34 +03:00 |
|
Mark Punzalan
|
9df2f69f09
|
[FIR] Disable failing blackbox codegen tests for FIR.
|
2019-11-19 11:00:09 +03:00 |
|
Svyatoslav Kuzmich
|
625983b28a
|
[JS IR BE] Enum class lowering
|
2018-07-23 15:08:18 +03:00 |
|
Anton Bannykh
|
96355e2732
|
JS IR: mute codegen box tests automatically
|
2018-06-09 19:15:38 +03:00 |
|
Alexey Andreev
|
89db4dfe79
|
JS: translate when against enum to JsSwitch when possible
|
2017-11-17 11:07:41 +03:00 |
|
Alexander Udalov
|
20e36438e2
|
Move some tests from boxWithStdlib/ to box/
Move those tests which do not require neither stdlib nor reflect
|
2016-03-09 10:25:38 +03:00 |
|