Pseudocode: Generate additional returns for implicit return values (lambdas, functions with expression bodies)

This commit is contained in:
Alexey Sedunov
2014-06-27 13:42:40 +04:00
parent 3e3918ab6e
commit 0a8fa404bf
21 changed files with 73 additions and 68 deletions
@@ -45,6 +45,7 @@ L0:
magic(vararg a: Any?) -> <v0> INIT: in: {a=D} out: {a=D}
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: {} out: {a=READ}
ret(*|<v1>) L1
L1:
<END>
error:
@@ -48,8 +48,9 @@ L3:
r(a) -> <v4> INIT: in: {x=ID, y=ID} out: {x=ID, y=ID} USE: in: {} out: {a=READ}
mark(use(a))
call(use(a), use|<v4>) -> <v5>
3 ret(*|<v5>) L4 INIT: in: {x=ID} out: {x=ID}
L4:
3 <END> INIT: in: {x=ID} out: {x=ID}
<END>
error:
<ERROR> INIT: in: {} out: {}
sink:
@@ -64,6 +65,7 @@ L0:
magic(vararg a: Any?) -> <v0> INIT: in: {a=D} out: {a=D}
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: {} out: {a=READ}
ret(*|<v1>) L1
L1:
<END>
error:
@@ -55,6 +55,7 @@ L0:
magic(a: Int) -> <v0> INIT: in: {a=D} out: {a=D}
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: {} out: {a=READ}
ret(*|<v1>) L1
L1:
<END>
error:
@@ -43,8 +43,9 @@ L3:
r(x) -> <v7> USE: in: {} out: {x=READ}
mark(sum(x - 1) + x)
call(sum(x - 1) + x, plus|<v6>, <v7>) -> <v8>
2 ret(*|<v8>) L4
L4:
2 <END>
<END>
error:
<ERROR> INIT: in: {} out: {}
sink:
@@ -68,6 +68,7 @@ L0:
magic(vararg a: Any?) -> <v0> INIT: in: {a=D} out: {a=D}
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: {} out: {a=READ}
ret(*|<v1>) L1
L1:
<END>
error:
@@ -38,6 +38,7 @@ L3:
r(b) -> <v2> USE: in: {} out: {b=READ}
mark(x + b)
call(x + b, plus|<v1>, <v2>) -> <v3>
ret(*|<v3>) L4
L4:
<END>
error:
@@ -79,12 +79,13 @@ L3:
3 <START>
4 mark(1)
r(1) -> <v0>
3 ret(*|<v0>) L4
L4:
3 <END> NEXT:[<SINK>]
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
<SINK> PREV:[<ERROR>, <END>]
=====================
== foo ==
fun foo(a : Boolean, b : Int) : Unit {}
@@ -4,10 +4,11 @@ fun short() = 1
L0:
1 <START>
r(1) -> <v0>
ret(*|<v0>) L1
L1:
<END> NEXT:[<SINK>]
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
<SINK> PREV:[<ERROR>, <END>]
=====================
@@ -45,12 +45,13 @@ override fun foo() = 10
L0:
1 <START>
r(10) -> <v0>
ret(*|<v0>) L1
L1:
<END> NEXT:[<SINK>]
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
<SINK> PREV:[<ERROR>, <END>]
=====================
== foo ==
fun foo(b: B) : Int {
@@ -19,12 +19,13 @@ fun component1() = 1
L0:
1 <START>
r(1) -> <v0>
ret(*|<v0>) L1
L1:
<END> NEXT:[<SINK>]
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
<SINK> PREV:[<ERROR>, <END>]
=====================
== component2 ==
fun component2() = 2
@@ -32,12 +33,13 @@ fun component2() = 2
L0:
1 <START>
r(2) -> <v0>
ret(*|<v0>) L1
L1:
<END> NEXT:[<SINK>]
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
<SINK> PREV:[<ERROR>, <END>]
=====================
== test ==
fun test(c: C) {
@@ -24,6 +24,7 @@ L0:
magic(p: PropertyMetadata) -> <v1>
w(p|<v1>)
r(0) -> <v2>
ret(*|<v2>) L1
L1:
<END> NEXT:[<SINK>]
error:
@@ -26,6 +26,7 @@ L0:
r($bar|<v1>) -> <v2>
mark("foo" + this.$bar)
call("foo" + this.$bar, plus|<v0>, <v2>) -> <v3>
ret(*|<v3>) L1
L1:
<END> NEXT:[<SINK>]
error:
@@ -17,6 +17,7 @@ L2 [after default value for parameter i]:
r(j) -> <v5>
mark(i + j)
call(i + j, plus|<v4>, <v5>) -> <v6>
ret(*|<v6>) L1
L1:
<END> NEXT:[<SINK>]
error: