Special instructions added for calls and other constructs

This commit is contained in:
Andrey Breslav
2013-12-02 17:28:38 +04:00
parent 0b575da5d3
commit 1e2eb6dfa1
20 changed files with 594 additions and 115 deletions
@@ -0,0 +1,34 @@
== Ab ==
abstract class Ab {
abstract fun getArray() : Array<Int>
}
---------------------
L0:
<START> NEXT:[<END>] PREV:[]
L1:
<END> NEXT:[<SINK>] PREV:[<START>]
error:
<ERROR> NEXT:[<SINK>] PREV:[]
sink:
<SINK> NEXT:[] PREV:[<ERROR>, <END>]
=====================
== test ==
fun test(ab: Ab) {
ab.getArray()[1]
}
---------------------
L0:
<START> NEXT:[v(ab: Ab)] PREV:[]
v(ab: Ab) NEXT:[w(ab)] PREV:[<START>]
w(ab) NEXT:[r(ab)] PREV:[v(ab: Ab)]
r(ab) NEXT:[call(getArray, getArray)] PREV:[w(ab)]
call(getArray, getArray) NEXT:[r(1)] PREV:[r(ab)]
r(1) NEXT:[call(ab.getArray()[1], get)] PREV:[call(getArray, getArray)]
call(ab.getArray()[1], get) NEXT:[<END>] PREV:[r(1)]
L1:
<END> NEXT:[<SINK>] PREV:[call(ab.getArray()[1], get)]
error:
<ERROR> NEXT:[<SINK>] PREV:[]
sink:
<SINK> NEXT:[] PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,8 @@
abstract class Ab {
abstract fun getArray() : Array<Int>
}
fun test(ab: Ab) {
ab.getArray()[1]
}
@@ -0,0 +1,47 @@
== C ==
class C {
val a: Int
get() = 1
{
$a
}
}
---------------------
L0:
<START> NEXT:[v(val a: Int get() = 1) ] PREV:[]
v(val a: Int
get() = 1) NEXT:[jmp?(L2)] PREV:[<START>]
jmp?(L2) NEXT:[r($a), d(get() = 1)] PREV:[v(val a: Int get() = 1) ]
d(get() = 1) NEXT:[<SINK>] PREV:[jmp?(L2)]
L2:
r($a) NEXT:[<END>] PREV:[jmp?(L2)]
L1:
<END> NEXT:[<SINK>] PREV:[r($a)]
error:
<ERROR> NEXT:[<SINK>] PREV:[]
sink:
<SINK> NEXT:[] PREV:[<ERROR>, <END>, d(get() = 1)]
L3:
<START> NEXT:[r(1)] PREV:[]
r(1) NEXT:[<END>] PREV:[<START>]
L4:
<END> NEXT:[<SINK>] PREV:[r(1)]
error:
<ERROR> NEXT:[<SINK>] PREV:[]
sink:
<SINK> NEXT:[] PREV:[<ERROR>, <END>]
=====================
== get_a ==
get() = 1
---------------------
L3:
<START> NEXT:[r(1)] PREV:[]
r(1) NEXT:[<END>] PREV:[<START>]
L4:
<END> NEXT:[<SINK>] PREV:[r(1)]
error:
<ERROR> NEXT:[<SINK>] PREV:[]
sink:
<SINK> NEXT:[] PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,8 @@
class C {
val a: Int
get() = 1
{
$a
}
}
@@ -0,0 +1,21 @@
== foo ==
fun foo() {
var i = 1
i++
}
---------------------
L0:
<START> NEXT:[v(var i = 1)] PREV:[]
v(var i = 1) NEXT:[r(1)] PREV:[<START>]
r(1) NEXT:[w(i)] PREV:[v(var i = 1)]
w(i) NEXT:[r(i)] PREV:[r(1)]
r(i) NEXT:[call(++, inc)] PREV:[w(i)]
call(++, inc) NEXT:[w(i)] PREV:[r(i)]
w(i) NEXT:[<END>] PREV:[call(++, inc)]
L1:
<END> NEXT:[<SINK>] PREV:[w(i)]
error:
<ERROR> NEXT:[<SINK>] PREV:[]
sink:
<SINK> NEXT:[] PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,4 @@
fun foo() {
var i = 1
i++
}
+18
View File
@@ -0,0 +1,18 @@
== foo ==
fun foo(f: () -> Unit) {
f()
}
---------------------
L0:
<START> NEXT:[v(f: () -> Unit)] PREV:[]
v(f: () -> Unit) NEXT:[w(f)] PREV:[<START>]
w(f) NEXT:[r(f)] PREV:[v(f: () -> Unit)]
r(f) NEXT:[call(f, invoke)] PREV:[w(f)]
call(f, invoke) NEXT:[<END>] PREV:[r(f)]
L1:
<END> NEXT:[<SINK>] PREV:[call(f, invoke)]
error:
<ERROR> NEXT:[<SINK>] PREV:[]
sink:
<SINK> NEXT:[] PREV:[<ERROR>, <END>]
=====================
+3
View File
@@ -0,0 +1,3 @@
fun foo(f: () -> Unit) {
f()
}
@@ -0,0 +1,23 @@
== foo ==
fun foo(x: Int) {
val (a, b) = x
a
}
---------------------
L0:
<START> NEXT:[v(x: Int)] PREV:[]
v(x: Int) NEXT:[w(x)] PREV:[<START>]
w(x) NEXT:[r(x)] PREV:[v(x: Int)]
r(x) NEXT:[v(a)] PREV:[w(x)]
v(a) NEXT:[w(a)] PREV:[r(x)]
w(a) NEXT:[v(b)] PREV:[v(a)]
v(b) NEXT:[w(b)] PREV:[w(a)]
w(b) NEXT:[r(a)] PREV:[v(b)]
r(a) NEXT:[<END>] PREV:[w(b)]
L1:
<END> NEXT:[<SINK>] PREV:[r(a)]
error:
<ERROR> NEXT:[<SINK>] PREV:[]
sink:
<SINK> NEXT:[] PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,4 @@
fun foo(x: Int) {
val (a, b) = x
a
}
@@ -0,0 +1,18 @@
== test ==
fun test(s: String?) {
s?.length
}
---------------------
L0:
<START> NEXT:[v(s: String?)] PREV:[]
v(s: String?) NEXT:[w(s)] PREV:[<START>]
w(s) NEXT:[r(s)] PREV:[v(s: String?)]
r(s) NEXT:[call(length, length)] PREV:[w(s)]
call(length, length) NEXT:[<END>] PREV:[r(s)]
L1:
<END> NEXT:[<SINK>] PREV:[call(length, length)]
error:
<ERROR> NEXT:[<SINK>] PREV:[]
sink:
<SINK> NEXT:[] PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,3 @@
fun test(s: String?) {
s?.length
}