Effects: add cfg-tests on inlined lambdas
========== Introduction of Effect System: 15/18
This commit is contained in:
+145
@@ -0,0 +1,145 @@
|
||||
== myRun ==
|
||||
inline fun myRun(block: () -> Unit): Unit {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return block()
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START> INIT: in: {} out: {}
|
||||
v(block: () -> Unit) INIT: in: {} out: {}
|
||||
magic[FAKE_INITIALIZER](block: () -> Unit) -> <v0> INIT: in: {} out: {}
|
||||
w(block|<v0>) INIT: in: {} out: {}
|
||||
2 mark({ contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return block() }) INIT: in: {} out: {}
|
||||
mark({ callsInPlace(block, InvocationKind.EXACTLY_ONCE) })
|
||||
jmp?(L2)
|
||||
d({ callsInPlace(block, InvocationKind.EXACTLY_ONCE) })
|
||||
L2 [after local declaration]:
|
||||
r({ callsInPlace(block, InvocationKind.EXACTLY_ONCE) }) -> <v1>
|
||||
mark(contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) })
|
||||
call(contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }, contract|<v1>) -> <v2>
|
||||
r(block) -> <v3>
|
||||
mark(block())
|
||||
call(block(), invoke|<v3>) -> <v4>
|
||||
ret(*|<v4>) L1
|
||||
L1:
|
||||
1 <END>
|
||||
error:
|
||||
<ERROR>
|
||||
sink:
|
||||
<SINK> USE: in: {} out: {}
|
||||
=====================
|
||||
== anonymous_0 ==
|
||||
{
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
---------------------
|
||||
L3:
|
||||
3 <START> INIT: in: {} out: {}
|
||||
4 mark(callsInPlace(block, InvocationKind.EXACTLY_ONCE))
|
||||
magic[IMPLICIT_RECEIVER](callsInPlace(block, InvocationKind.EXACTLY_ONCE)) -> <v0>
|
||||
r(block) -> <v1>
|
||||
mark(InvocationKind.EXACTLY_ONCE)
|
||||
r(EXACTLY_ONCE) -> <v2>
|
||||
mark(callsInPlace(block, InvocationKind.EXACTLY_ONCE))
|
||||
call(callsInPlace(block, InvocationKind.EXACTLY_ONCE), callsInPlace|<v0>, <v1>, <v2>) -> <v3>
|
||||
L4:
|
||||
3 <END>
|
||||
error:
|
||||
<ERROR>
|
||||
sink:
|
||||
<SINK> USE: in: {} out: {}
|
||||
=====================
|
||||
== unknownRun ==
|
||||
inline fun unknownRun(block: () -> Unit) { block() }
|
||||
---------------------
|
||||
L0:
|
||||
1 <START> INIT: in: {} out: {}
|
||||
v(block: () -> Unit) INIT: in: {} out: {}
|
||||
magic[FAKE_INITIALIZER](block: () -> Unit) -> <v0> INIT: in: {} out: {}
|
||||
w(block|<v0>) INIT: in: {} out: {}
|
||||
2 mark({ block() }) INIT: in: {} out: {}
|
||||
r(block) -> <v1>
|
||||
mark(block())
|
||||
call(block(), invoke|<v1>) -> <v2>
|
||||
L1:
|
||||
1 <END>
|
||||
error:
|
||||
<ERROR>
|
||||
sink:
|
||||
<SINK> USE: in: {} out: {}
|
||||
=====================
|
||||
== foo ==
|
||||
fun foo() {
|
||||
val x: Int
|
||||
myRun {
|
||||
unknownRun { println("shouldn't change anything") }
|
||||
x = 42
|
||||
}
|
||||
println(x)
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START> INIT: in: {} out: {} USE: in: {} out: {}
|
||||
2 mark({ val x: Int myRun { unknownRun { println("shouldn't change anything") } x = 42 } println(x) })
|
||||
v(val x: Int) INIT: in: {} out: {x=D}
|
||||
mark({ unknownRun { println("shouldn't change anything") } x = 42 }) INIT: in: {x=D} out: {x=D}
|
||||
r({ unknownRun { println("shouldn't change anything") } x = 42 }) -> <v0>
|
||||
mark(myRun { unknownRun { println("shouldn't change anything") } x = 42 })
|
||||
call(myRun { unknownRun { println("shouldn't change anything") } x = 42 }, myRun|<v0>) -> <v1>
|
||||
L2 [before inlined declaration]:
|
||||
inlined({ unknownRun { println("shouldn't change anything") } x = 42 }) INIT: in: {x=ID} out: {x=ID} USE: in: {x=READ} out: {x=READ}
|
||||
L3 [after inlined declaration]:
|
||||
r(x) -> <v2> USE: in: {} out: {x=READ}
|
||||
mark(println(x))
|
||||
call(println(x), println|<v2>) -> <v3>
|
||||
L1:
|
||||
1 <END> INIT: in: {} out: {}
|
||||
error:
|
||||
<ERROR>
|
||||
sink:
|
||||
<SINK> USE: in: {} out: {}
|
||||
=====================
|
||||
== inlined anonymous_1 ==
|
||||
{
|
||||
unknownRun { println("shouldn't change anything") }
|
||||
x = 42
|
||||
}
|
||||
---------------------
|
||||
L4:
|
||||
3 <START> INIT: in: {x=D} out: {x=D}
|
||||
4 mark(unknownRun { println("shouldn't change anything") } x = 42)
|
||||
mark({ println("shouldn't change anything") })
|
||||
jmp?(L6)
|
||||
d({ println("shouldn't change anything") }) INIT: in: {x=I?} out: {x=I?} USE: in: {x=READ} out: {x=READ}
|
||||
L6 [after local declaration]:
|
||||
r({ println("shouldn't change anything") }) -> <v0> INIT: in: {x=D} out: {x=D}
|
||||
mark(unknownRun { println("shouldn't change anything") })
|
||||
call(unknownRun { println("shouldn't change anything") }, unknownRun|<v0>) -> <v1>
|
||||
r(42) -> <v2> USE: in: {x=WRITTEN_AFTER_READ} out: {x=WRITTEN_AFTER_READ}
|
||||
w(x|<v2>) INIT: in: {x=D} out: {x=ID} USE: in: {x=READ} out: {x=WRITTEN_AFTER_READ}
|
||||
L5:
|
||||
3 <END> INIT: in: {x=ID} out: {x=ID} USE: in: {x=READ} out: {x=READ}
|
||||
error:
|
||||
- <ERROR>
|
||||
sink:
|
||||
<SINK> INIT: in: {x=I?} out: {x=I?} USE: in: {x=READ} out: {x=READ}
|
||||
=====================
|
||||
== anonymous_2 ==
|
||||
{ println("shouldn't change anything") }
|
||||
---------------------
|
||||
L7:
|
||||
5 <START> INIT: in: {x=D} out: {x=D}
|
||||
6 mark(println("shouldn't change anything"))
|
||||
mark("shouldn't change anything")
|
||||
r("shouldn't change anything") -> <v0>
|
||||
mark(println("shouldn't change anything"))
|
||||
call(println("shouldn't change anything"), println|<v0>) -> <v1>
|
||||
L8:
|
||||
5 <END>
|
||||
error:
|
||||
<ERROR> INIT: in: {} out: {}
|
||||
sink:
|
||||
<SINK> INIT: in: {x=I?} out: {x=I?} USE: in: {x=READ} out: {x=READ}
|
||||
=====================
|
||||
Reference in New Issue
Block a user