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:
@@ -14,14 +14,14 @@ L0:
|
||||
2 mark({ val b: Boolean if (1 < 2) { use(b) } else { b = true } })
|
||||
v(val b: Boolean) INIT: in: {} out: {b=D}
|
||||
mark(if (1 < 2) { use(b) } 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({ use(b) })
|
||||
mark(use(b)) USE: in: {b=READ} out: {b=READ}
|
||||
3 mark({ use(b) }) USE: in: {b=READ} out: {b=READ}
|
||||
r(b) -> <v3> USE: in: {} out: {b=READ}
|
||||
mark(use(b))
|
||||
call(use, use|<v3>) -> <v4>
|
||||
2 jmp(L3) USE: in: {} out: {}
|
||||
L2:
|
||||
|
||||
@@ -39,14 +39,14 @@ L3:
|
||||
magic(x: Int) -> <v0> INIT: in: {x=D} out: {x=D}
|
||||
w(x|<v0>) INIT: in: {x=D} out: {x=ID}
|
||||
4 mark(val y = x + a use(a)) INIT: in: {x=ID} out: {x=ID}
|
||||
v(val y = x + a) INIT: in: {x=ID} out: {x=ID, y=D}
|
||||
mark(x + a) INIT: in: {x=ID, y=D} out: {x=ID, y=D} USE: in: {a=READ, x=READ} out: {a=READ, x=READ}
|
||||
r(x) -> <v1> USE: in: {a=READ} out: {a=READ, x=READ}
|
||||
v(val y = x + a) INIT: in: {x=ID} out: {x=ID, y=D} USE: in: {a=READ, x=READ} out: {a=READ, x=READ}
|
||||
r(x) -> <v1> INIT: in: {x=ID, y=D} out: {x=ID, y=D} USE: in: {a=READ} out: {a=READ, x=READ}
|
||||
r(a) -> <v2>
|
||||
mark(x + a)
|
||||
call(+, plus|<v1>, <v2>) -> <v3>
|
||||
w(y|<v3>) INIT: in: {x=ID, y=D} out: {x=ID, y=ID}
|
||||
mark(use(a)) INIT: in: {x=ID, y=ID} out: {x=ID, y=ID} USE: in: {a=READ} out: {a=READ}
|
||||
r(a) -> <v4> USE: in: {} out: {a=READ}
|
||||
w(y|<v3>) INIT: in: {x=ID, y=D} out: {x=ID, y=ID} USE: in: {a=READ} out: {a=READ}
|
||||
r(a) -> <v4> INIT: in: {x=ID, y=ID} out: {x=ID, y=ID} USE: in: {} out: {a=READ}
|
||||
mark(use(a))
|
||||
call(use, use|<v4>) -> <v5>
|
||||
L4:
|
||||
3 <END> INIT: in: {x=ID} out: {x=ID}
|
||||
|
||||
@@ -11,14 +11,14 @@ L0:
|
||||
2 mark({ var a = 1 use(a) a = 2 use(a) })
|
||||
v(var a = 1) INIT: in: {} out: {a=D}
|
||||
r(1) -> <v0> INIT: in: {a=D} out: {a=D}
|
||||
w(a|<v0>) INIT: in: {a=D} out: {a=ID}
|
||||
mark(use(a)) INIT: in: {a=ID} out: {a=ID} USE: in: {a=READ} out: {a=READ}
|
||||
r(a) -> <v1> USE: in: {a=WRITTEN_AFTER_READ} out: {a=READ}
|
||||
w(a|<v0>) INIT: in: {a=D} out: {a=ID} USE: in: {a=READ} out: {a=READ}
|
||||
r(a) -> <v1> INIT: in: {a=ID} out: {a=ID} USE: in: {a=WRITTEN_AFTER_READ} out: {a=READ}
|
||||
mark(use(a))
|
||||
call(use, use|<v1>) -> <v2>
|
||||
r(2) -> <v3> USE: in: {a=WRITTEN_AFTER_READ} out: {a=WRITTEN_AFTER_READ}
|
||||
w(a|<v3>) USE: in: {a=READ} out: {a=WRITTEN_AFTER_READ}
|
||||
mark(use(a)) USE: in: {a=READ} out: {a=READ}
|
||||
r(a) -> <v4> USE: in: {} out: {a=READ}
|
||||
mark(use(a))
|
||||
call(use, use|<v4>) -> <v5>
|
||||
L1:
|
||||
1 <END> INIT: in: {} out: {}
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -20,9 +20,9 @@ L4 [body entry point]:
|
||||
r(2) -> <v1>
|
||||
w(a|<v1>)
|
||||
L5 [condition entry point]:
|
||||
mark(a > 0)
|
||||
r(a) -> <v2>
|
||||
r(0) -> <v3>
|
||||
mark(a > 0)
|
||||
call(>, compareTo|<v2>, <v3>) -> <v4>
|
||||
jt(L2 [loop entry point]|<v4>) USE: in: {a=READ} out: {a=READ}
|
||||
L3 [loop exit point]:
|
||||
|
||||
@@ -12,10 +12,9 @@ L0:
|
||||
2 mark({ "before" for (i in 1..10) { val a = i } "after" })
|
||||
mark("before")
|
||||
r("before") -> <v0> USE: in: {} out: {}
|
||||
3 mark(for (i in 1..10) { val a = i })
|
||||
mark(1..10)
|
||||
r(1) -> <v1>
|
||||
3 r(1) -> <v1>
|
||||
r(10) -> <v2>
|
||||
mark(1..10)
|
||||
call(.., rangeTo|<v1>, <v2>) -> <v3>
|
||||
v(i) INIT: in: {} out: {i=D}
|
||||
L3:
|
||||
@@ -24,7 +23,8 @@ L4 [loop entry point]:
|
||||
L5 [body entry point]:
|
||||
magic(1..10|<v3>) -> <v4>
|
||||
w(i|<v4>) INIT: in: {i=D} out: {i=ID}
|
||||
4 mark({ val a = i }) INIT: in: {i=ID} out: {i=ID}
|
||||
mark(for (i in 1..10) { val a = i }) INIT: in: {i=ID} out: {i=ID}
|
||||
4 mark({ val a = i })
|
||||
v(val a = i) INIT: in: {i=ID} out: {a=D, i=ID}
|
||||
r(i) -> <v5> INIT: in: {a=D, i=ID} out: {a=D, i=ID}
|
||||
w(a|<v5>) INIT: in: {a=D, i=ID} out: {a=ID, i=ID}
|
||||
|
||||
@@ -43,10 +43,10 @@ L3:
|
||||
magic(x: Int) -> <v0> INIT: in: {x=D} out: {x=D}
|
||||
w(x|<v0>) INIT: in: {x=D} out: {x=ID}
|
||||
4 mark(val a = x + b) INIT: in: {x=ID} out: {x=ID}
|
||||
v(val a = x + b) INIT: in: {x=ID} out: {a=D, x=ID}
|
||||
mark(x + b) INIT: in: {a=D, x=ID} out: {a=D, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
|
||||
r(x) -> <v1> USE: in: {b=READ} out: {b=READ, x=READ}
|
||||
v(val a = x + b) INIT: in: {x=ID} out: {a=D, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
|
||||
r(x) -> <v1> INIT: in: {a=D, x=ID} out: {a=D, x=ID} USE: in: {b=READ} out: {b=READ, x=READ}
|
||||
r(b) -> <v2> USE: in: {} out: {b=READ}
|
||||
mark(x + b)
|
||||
call(+, plus|<v1>, <v2>) -> <v3>
|
||||
w(a|<v3>) INIT: in: {a=D, x=ID} out: {a=ID, x=ID}
|
||||
L4:
|
||||
|
||||
@@ -39,10 +39,10 @@ L3:
|
||||
magic(x: Int) -> <v0> INIT: in: {x=D} out: {x=D}
|
||||
w(x|<v0>) INIT: in: {x=D} out: {x=ID}
|
||||
4 mark({ val a = x + b }) INIT: in: {x=ID} out: {x=ID}
|
||||
v(val a = x + b) INIT: in: {x=ID} out: {a=D, x=ID}
|
||||
mark(x + b) INIT: in: {a=D, x=ID} out: {a=D, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
|
||||
r(x) -> <v1> USE: in: {b=READ} out: {b=READ, x=READ}
|
||||
v(val a = x + b) INIT: in: {x=ID} out: {a=D, x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
|
||||
r(x) -> <v1> INIT: in: {a=D, x=ID} out: {a=D, x=ID} USE: in: {b=READ} out: {b=READ, x=READ}
|
||||
r(b) -> <v2> USE: in: {} out: {b=READ}
|
||||
mark(x + b)
|
||||
call(+, plus|<v1>, <v2>) -> <v3>
|
||||
w(a|<v3>) INIT: in: {a=D, x=ID} out: {a=ID, x=ID}
|
||||
L4:
|
||||
|
||||
+3
-3
@@ -33,10 +33,10 @@ L3:
|
||||
3 <START> INIT: in: {} out: {}
|
||||
v(x: Int) INIT: in: {} out: {x=D}
|
||||
magic(x: Int) -> <v0> INIT: in: {x=D} out: {x=D}
|
||||
w(x|<v0>) INIT: in: {x=D} out: {x=ID}
|
||||
mark(x + b) INIT: in: {x=ID} out: {x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
|
||||
r(x) -> <v1> USE: in: {b=READ} out: {b=READ, x=READ}
|
||||
w(x|<v0>) INIT: in: {x=D} out: {x=ID} USE: in: {b=READ, x=READ} out: {b=READ, x=READ}
|
||||
r(x) -> <v1> INIT: in: {x=ID} out: {x=ID} USE: in: {b=READ} out: {b=READ, x=READ}
|
||||
r(b) -> <v2> USE: in: {} out: {b=READ}
|
||||
mark(x + b)
|
||||
call(+, plus|<v1>, <v2>) -> <v3>
|
||||
L4:
|
||||
<END>
|
||||
|
||||
@@ -12,10 +12,10 @@ L0:
|
||||
2 mark({ "before" while (true) { val a: Int } "after" })
|
||||
mark("before")
|
||||
r("before") -> <v0>
|
||||
mark(while (true) { val a: Int })
|
||||
L2 [loop entry point]:
|
||||
L5 [condition entry point]:
|
||||
r(true) -> <v1>
|
||||
mark(while (true) { val a: Int })
|
||||
L4 [body entry point]:
|
||||
3 mark({ val a: Int })
|
||||
v(val a: Int) INIT: in: {} out: {a=D}
|
||||
|
||||
Reference in New Issue
Block a user