| == Direction == |
| enum class Direction { |
| NORTH, SOUTH, WEST, EAST |
| } |
| --------------------- |
| L0: |
| 1 <START> INIT: in: {} out: {} |
| v(NORTH,) INIT: in: {} out: {NORTH=D} |
| magic[FAKE_INITIALIZER](NORTH,) -> <v0> INIT: in: {NORTH=D} out: {NORTH=D} |
| w(NORTH|<v0>) INIT: in: {NORTH=D} out: {NORTH=ID} |
| v(SOUTH,) INIT: in: {NORTH=ID} out: {NORTH=ID, SOUTH=D} |
| magic[FAKE_INITIALIZER](SOUTH,) -> <v1> INIT: in: {NORTH=ID, SOUTH=D} out: {NORTH=ID, SOUTH=D} |
| w(SOUTH|<v1>) INIT: in: {NORTH=ID, SOUTH=D} out: {NORTH=ID, SOUTH=ID} |
| v(WEST,) INIT: in: {NORTH=ID, SOUTH=ID} out: {NORTH=ID, SOUTH=ID, WEST=D} |
| magic[FAKE_INITIALIZER](WEST,) -> <v2> INIT: in: {NORTH=ID, SOUTH=ID, WEST=D} out: {NORTH=ID, SOUTH=ID, WEST=D} |
| w(WEST|<v2>) INIT: in: {NORTH=ID, SOUTH=ID, WEST=D} out: {NORTH=ID, SOUTH=ID, WEST=ID} |
| v(EAST) INIT: in: {NORTH=ID, SOUTH=ID, WEST=ID} out: {EAST=D, NORTH=ID, SOUTH=ID, WEST=ID} |
| magic[FAKE_INITIALIZER](EAST) -> <v3> INIT: in: {EAST=D, NORTH=ID, SOUTH=ID, WEST=ID} out: {EAST=D, NORTH=ID, SOUTH=ID, WEST=ID} |
| w(EAST|<v3>) INIT: in: {EAST=D, NORTH=ID, SOUTH=ID, WEST=ID} out: {EAST=ID, NORTH=ID, SOUTH=ID, WEST=ID} |
| L1: |
| <END> INIT: in: {EAST=ID, NORTH=ID, SOUTH=ID, WEST=ID} out: {EAST=ID, NORTH=ID, SOUTH=ID, WEST=ID} |
| error: |
| <ERROR> INIT: in: {} out: {} |
| sink: |
| <SINK> INIT: in: {EAST=I?, NORTH=I?, SOUTH=I?, WEST=I?} out: {EAST=I?, NORTH=I?, SOUTH=I?, WEST=I?} USE: in: {} out: {} |
| ===================== |
| == foo == |
| fun foo(dir: Direction): Int { |
| val res: Int |
| when (dir) { |
| Direction.NORTH -> res = 1 |
| Direction.SOUTH -> res = 2 |
| Direction.WEST -> res = 3 |
| Direction.EAST -> res = 4 |
| } |
| return res |
| } |
| --------------------- |
| L0: |
| 1 <START> INIT: in: {} out: {} |
| v(dir: Direction) INIT: in: {} out: {} |
| magic[FAKE_INITIALIZER](dir: Direction) -> <v0> INIT: in: {} out: {} |
| w(dir|<v0>) INIT: in: {} out: {} USE: in: {} out: {} |
| 2 mark({ val res: Int when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 } return res }) INIT: in: {} out: {} |
| v(val res: Int) INIT: in: {} out: {res=D} |
| mark(when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }) INIT: in: {res=D} out: {res=D} |
| r(dir) -> <v1> |
| mark(Direction.NORTH -> res = 1) |
| mark(Direction.NORTH) |
| mark(Direction.NORTH) |
| r(NORTH) -> <v2> |
| magic[EQUALS_IN_WHEN_CONDITION](Direction.NORTH|<v1>, <v2>) -> <v3> |
| jmp?(L4|<v3>) USE: in: {res=READ} out: {res=READ} |
| L3 ['when' entry body]: |
| r(1) -> <v4> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} |
| w(res|<v4>) INIT: in: {res=D} out: {res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} |
| jmp(L2) INIT: in: {res=ID} out: {res=ID} |
| L4 [next 'when' entry]: |
| mark(Direction.SOUTH -> res = 2) INIT: in: {res=D} out: {res=D} |
| mark(Direction.SOUTH) |
| mark(Direction.SOUTH) |
| r(SOUTH) -> <v5> |
| magic[EQUALS_IN_WHEN_CONDITION](Direction.SOUTH|<v1>, <v5>) -> <v6> |
| jmp?(L6|<v6>) USE: in: {res=READ} out: {res=READ} |
| L5 ['when' entry body]: |
| r(2) -> <v7> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} |
| w(res|<v7>) INIT: in: {res=D} out: {res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} |
| jmp(L2) INIT: in: {res=ID} out: {res=ID} |
| L6 [next 'when' entry]: |
| mark(Direction.WEST -> res = 3) INIT: in: {res=D} out: {res=D} |
| mark(Direction.WEST) |
| mark(Direction.WEST) |
| r(WEST) -> <v8> |
| magic[EQUALS_IN_WHEN_CONDITION](Direction.WEST|<v1>, <v8>) -> <v9> |
| jmp?(L8|<v9>) USE: in: {res=READ} out: {res=READ} |
| L7 ['when' entry body]: |
| r(3) -> <v10> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} |
| w(res|<v10>) INIT: in: {res=D} out: {res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} |
| jmp(L2) INIT: in: {res=ID} out: {res=ID} |
| L8 [next 'when' entry]: |
| mark(Direction.EAST -> res = 4) INIT: in: {res=D} out: {res=D} |
| mark(Direction.EAST) |
| mark(Direction.EAST) |
| r(EAST) -> <v11> |
| magic[EQUALS_IN_WHEN_CONDITION](Direction.EAST|<v1>, <v11>) -> <v12> |
| jmp?(L10|<v12>) USE: in: {res=READ} out: {res=READ} |
| L9 ['when' entry body]: |
| r(4) -> <v13> USE: in: {res=WRITTEN_AFTER_READ} out: {res=WRITTEN_AFTER_READ} |
| w(res|<v13>) INIT: in: {res=D} out: {res=ID} USE: in: {res=READ} out: {res=WRITTEN_AFTER_READ} |
| jmp(L2) INIT: in: {res=ID} out: {res=ID} |
| L10 [next 'when' entry]: |
| magic[EXHAUSTIVE_WHEN_ELSE](when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }) -> <v14> INIT: in: {res=D} out: {res=IED} |
| L2 [after 'when' expression]: |
| merge(when (dir) { Direction.NORTH -> res = 1 Direction.SOUTH -> res = 2 Direction.WEST -> res = 3 Direction.EAST -> res = 4 }|!<v15>, !<v16>, !<v17>, !<v18>) -> <v19> INIT: in: {res=ID} out: {res=ID} USE: in: {res=READ} out: {res=READ} |
| r(res) -> <v20> USE: in: {} out: {res=READ} |
| ret(*|<v20>) L1 |
| L1: |
| 1 <END> INIT: in: {} out: {} |
| error: |
| <ERROR> |
| sink: |
| <SINK> USE: in: {} out: {} |
| ===================== |