Pseudocode: Add test for parenthesized call in selector

This commit is contained in:
Alexey Sedunov
2014-07-25 15:49:19 +04:00
parent 85bb4f9b8e
commit 2a19016d58
5 changed files with 150 additions and 0 deletions
@@ -0,0 +1,88 @@
== with ==
fun <T> with(t: T, f : T.() -> Unit) {
t.f()
}
---------------------
L0:
1 <START>
v(t: T)
magic[FAKE_INITIALIZER](t: T) -> <v0>
w(t|<v0>)
v(f : T.() -> Unit)
magic[FAKE_INITIALIZER](f : T.() -> Unit) -> <v1>
w(f|<v1>)
2 mark({ t.f() })
mark(t.f())
r(f) -> <v2>
r(t) -> <v3>
mark(f())
call(f(), invoke|<v2>, <v3>) -> <v4>
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== foo ==
val Int.foo: String.() -> Unit get() = {}
---------------------
L0:
1 <START>
v(val Int.foo: String.() -> Unit get() = {})
L1:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== bar ==
fun bar() {
with(1) {
"".(foo)()
}
}
---------------------
L0:
1 <START>
2 mark({ with(1) { "".(foo)() } })
r(1) -> <v0>
mark({ "".(foo)() })
jmp?(L2) NEXT:[r({ "".(foo)() }) -> <v1>, d({ "".(foo)() })]
d({ "".(foo)() }) NEXT:[<SINK>]
L2:
r({ "".(foo)() }) -> <v1> PREV:[jmp?(L2)]
mark(with(1) { "".(foo)() })
call(with(1) { "".(foo)() }, with|<v0>, <v1>) -> <v2>
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>, d({ "".(foo)() })]
=====================
== anonymous_0 ==
{
"".(foo)()
}
---------------------
L3:
3 <START>
4 mark("".(foo)())
mark("".(foo)())
mark((foo))
magic[IMPLICIT_RECEIVER](foo) -> <v0>
r(foo|<v0>) -> <v1>
mark("")
r("") -> <v2>
mark((foo)())
call((foo)(), invoke|<v1>, <v2>) -> <v3>
3 ret(*|<v3>) L4
L4:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,10 @@
fun <T> with(t: T, f : T.() -> Unit) {
t.f()
}
val Int.foo: String.() -> Unit get() = {}
fun bar() {
with(1) {
"".(foo)()
}
}
@@ -0,0 +1,42 @@
== with ==
fun <T> with(t: T, f : T.() -> Unit) {
t.f()
}
---------------------
<v0>: {<: T} NEW: magic[FAKE_INITIALIZER](t: T) -> <v0>
<v1>: {<: T.() -> Unit} NEW: magic[FAKE_INITIALIZER](f : T.() -> Unit) -> <v1>
t <v3>: {<: T} NEW: r(t) -> <v3>
f <v2>: {<: T.() -> Unit} NEW: r(f) -> <v2>
f() <v4>: * NEW: call(f(), invoke|<v2>, <v3>) -> <v4>
t.f() <v4>: * COPY
{ t.f() } <v4>: * COPY
=====================
== foo ==
val Int.foo: String.() -> Unit get() = {}
---------------------
=====================
== bar ==
fun bar() {
with(1) {
"".(foo)()
}
}
---------------------
1 <v0>: Int NEW: r(1) -> <v0>
{ "".(foo)() } <v1>: {<: Int.() -> Unit} NEW: r({ "".(foo)() }) -> <v1>
with(1) { "".(foo)() } <v2>: * NEW: call(with(1) { "".(foo)() }, with|<v0>, <v1>) -> <v2>
{ with(1) { "".(foo)() } } <v2>: * COPY
=====================
== anonymous_0 ==
{
"".(foo)()
}
---------------------
<v0>: Int NEW: magic[IMPLICIT_RECEIVER](foo) -> <v0>
"" <v2>: String NEW: r("") -> <v2>
foo <v1>: {<: String.() -> Unit} NEW: r(foo|<v0>) -> <v1>
(foo) <v1>: {<: String.() -> Unit} COPY
(foo)() <v3>: Unit NEW: call((foo)(), invoke|<v1>, <v2>) -> <v3>
"".(foo)() <v3>: Unit COPY
"".(foo)() <v3>: Unit COPY
=====================
@@ -409,6 +409,11 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest {
doTest("compiler/testData/cfg/expressions/nothingExpr.kt");
}
@TestMetadata("parenthesizedSelector.kt")
public void testParenthesizedSelector() throws Exception {
doTest("compiler/testData/cfg/expressions/parenthesizedSelector.kt");
}
@TestMetadata("propertySafeCall.kt")
public void testPropertySafeCall() throws Exception {
doTest("compiler/testData/cfg/expressions/propertySafeCall.kt");
@@ -411,6 +411,11 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest {
doTest("compiler/testData/cfg/expressions/nothingExpr.kt");
}
@TestMetadata("parenthesizedSelector.kt")
public void testParenthesizedSelector() throws Exception {
doTest("compiler/testData/cfg/expressions/parenthesizedSelector.kt");
}
@TestMetadata("propertySafeCall.kt")
public void testPropertySafeCall() throws Exception {
doTest("compiler/testData/cfg/expressions/propertySafeCall.kt");