Mark some expressions after processing their components
when it's semantically correct Expressions: calls, 'for' loops, elvis operators It's significant for reporting 'unreachable code' correctly
This commit is contained in:
@@ -32,16 +32,16 @@ L3:
|
||||
magic(x: Int) -> <v0> INIT: in: {x=D} out: {x=D}
|
||||
w(x|<v0>) INIT: in: {x=D} out: {x=ID}
|
||||
3 mark(sum(x - 1) + x) INIT: in: {x=ID} out: {x=ID}
|
||||
mark(sum(x - 1) + x)
|
||||
mark(sum(x - 1))
|
||||
magic(sum) -> <v1> USE: in: {sum=READ, x=READ} out: {sum=READ, x=READ}
|
||||
r(sum|<v1>) -> <v2> USE: in: {x=READ} out: {sum=READ, x=READ}
|
||||
mark(x - 1)
|
||||
r(x) -> <v3>
|
||||
r(1) -> <v4>
|
||||
mark(x - 1)
|
||||
call(-, minus|<v3>, <v4>) -> <v5>
|
||||
mark(sum(x - 1))
|
||||
call(sum, invoke|<v2>, <v5>) -> <v6> USE: in: {x=READ} out: {x=READ}
|
||||
r(x) -> <v7> USE: in: {} out: {x=READ}
|
||||
mark(sum(x - 1) + x)
|
||||
call(+, plus|<v6>, <v7>) -> <v8>
|
||||
L4:
|
||||
2 <END>
|
||||
@@ -127,10 +127,10 @@ class TestOther {
|
||||
L0:
|
||||
1 <START> INIT: in: {} out: {}
|
||||
v(val x: Int = x + 1) INIT: in: {} out: {x=D}
|
||||
mark(x + 1) INIT: in: {x=D} out: {x=D}
|
||||
magic(x) -> <v0> USE: in: {x=READ} out: {x=READ}
|
||||
magic(x) -> <v0> INIT: in: {x=D} out: {x=D} USE: in: {x=READ} out: {x=READ}
|
||||
r(x|<v0>) -> <v1> USE: in: {} out: {x=READ}
|
||||
r(1) -> <v2>
|
||||
mark(x + 1)
|
||||
call(+, plus|<v1>, <v2>) -> <v3>
|
||||
w(x|<v3>) INIT: in: {x=D} out: {x=ID}
|
||||
L1:
|
||||
|
||||
@@ -15,9 +15,9 @@ L0:
|
||||
2 mark({ val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) })
|
||||
v(val b: Boolean) INIT: in: {} out: {b=D}
|
||||
mark(if (1 < 2) { b = false } else { b = true }) INIT: in: {b=D} out: {b=D}
|
||||
mark(1 < 2)
|
||||
r(1) -> <v0>
|
||||
r(2) -> <v1>
|
||||
mark(1 < 2)
|
||||
call(<, compareTo|<v0>, <v1>) -> <v2>
|
||||
jf(L2|<v2>)
|
||||
3 mark({ b = false })
|
||||
@@ -29,10 +29,10 @@ L2:
|
||||
r(true) -> <v4> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ}
|
||||
w(b|<v4>) INIT: in: {b=D} out: {b=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ}
|
||||
L3:
|
||||
2 mark(use(b)) INIT: in: {b=ID} out: {b=ID}
|
||||
error(use, No resolved call) USE: in: {b=READ} out: {b=READ}
|
||||
2 error(use, No resolved call) INIT: in: {b=ID} out: {b=ID} USE: in: {b=READ} out: {b=READ}
|
||||
r(b) -> <v5> USE: in: {} out: {b=READ}
|
||||
error(use, No resolved call)
|
||||
mark(use(b))
|
||||
magic(use(b)|<v5>) -> <v6>
|
||||
L1:
|
||||
1 <END> INIT: in: {} out: {}
|
||||
|
||||
@@ -18,22 +18,22 @@ L0:
|
||||
v(numbers: Collection<Int>) INIT: in: {} out: {numbers=D}
|
||||
magic(numbers: Collection<Int>) -> <v0> INIT: in: {numbers=D} out: {numbers=D}
|
||||
w(numbers|<v0>) INIT: in: {numbers=D} out: {numbers=ID}
|
||||
2 mark({ for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue } }) INIT: in: {numbers=ID} out: {numbers=ID}
|
||||
3 mark(for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue }) USE: in: {numbers=READ} out: {numbers=READ}
|
||||
r(numbers) -> <v1> USE: in: {} out: {numbers=READ}
|
||||
2 mark({ for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue } }) INIT: in: {numbers=ID} out: {numbers=ID} USE: in: {numbers=READ} out: {numbers=READ}
|
||||
3 r(numbers) -> <v1> USE: in: {} out: {numbers=READ}
|
||||
v(i) INIT: in: {numbers=ID} out: {i=D, numbers=ID}
|
||||
L3:
|
||||
jmp?(L2) INIT: in: {i=D, numbers=ID} out: {i=D, numbers=ID}
|
||||
L4 [loop entry point]:
|
||||
L5 [body entry point]:
|
||||
magic(numbers|<v1>) -> <v2>
|
||||
w(i|<v2>) INIT: in: {i=D, numbers=ID} out: {i=ID, numbers=ID} USE: in: {} out: {}
|
||||
4 mark({ val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue }) INIT: in: {i=ID, numbers=ID} out: {i=ID, numbers=ID}
|
||||
w(i|<v2>) INIT: in: {i=D, numbers=ID} out: {i=ID, numbers=ID}
|
||||
mark(for (i in numbers) { val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue }) INIT: in: {i=ID, numbers=ID} out: {i=ID, numbers=ID} USE: in: {} out: {}
|
||||
4 mark({ val b: Boolean if (1 < 2) { b = false } else { b = true } use(b) continue })
|
||||
v(val b: Boolean) INIT: in: {i=ID, numbers=ID} out: {b=D, i=ID, numbers=ID}
|
||||
mark(if (1 < 2) { b = false } else { b = true }) INIT: in: {b=D, i=ID, numbers=ID} out: {b=D, i=ID, numbers=ID}
|
||||
mark(1 < 2)
|
||||
r(1) -> <v3>
|
||||
r(2) -> <v4>
|
||||
mark(1 < 2)
|
||||
call(<, compareTo|<v3>, <v4>) -> <v5>
|
||||
jf(L6|<v5>)
|
||||
5 mark({ b = false })
|
||||
@@ -45,8 +45,8 @@ L6:
|
||||
r(true) -> <v7> USE: in: {b=WRITTEN_AFTER_READ} out: {b=WRITTEN_AFTER_READ}
|
||||
w(b|<v7>) INIT: in: {b=D, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=WRITTEN_AFTER_READ}
|
||||
L7:
|
||||
4 mark(use(b)) INIT: in: {b=ID, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {b=READ} out: {b=READ}
|
||||
r(b) -> <v8> USE: in: {} out: {b=READ}
|
||||
4 r(b) -> <v8> INIT: in: {b=ID, i=ID, numbers=ID} out: {b=ID, i=ID, numbers=ID} USE: in: {} out: {b=READ}
|
||||
mark(use(b))
|
||||
call(use, use|<v8>) -> <v9>
|
||||
jmp(L4 [loop entry point]) USE: in: {} out: {}
|
||||
- 3 jmp?(L4 [loop entry point])
|
||||
|
||||
Reference in New Issue
Block a user