[JVM_IR] Give temporary variable loads meaningful offsets.

Temporary variable loads in when expressions had the offsets
of the variable declaration. That leads to hacks during codegen
for line number generation.

Instead of those hacks, give the variable loads the offsets of
the context in which they occur. That avoids the codegen hacks
and fixes stepping behavior for more when expressions.
This commit is contained in:
Mads Ager
2020-08-07 14:02:40 +02:00
committed by max-kammerer
parent 413d02621b
commit 2c6b5c8847
8 changed files with 102 additions and 13 deletions
+38
View File
@@ -0,0 +1,38 @@
// FILE: test.kt
fun foo(x: Any) {
when (x) {
is Float ->
1
is Double ->
2
else ->
3
}
}
fun box() {
foo(1.2f)
foo(1.2)
foo(1)
}
// LINENUMBERS
// test.kt:15 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:6 foo
// test.kt:12 foo
// test.kt:16 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:7 foo
// test.kt:8 foo
// test.kt:12 foo
// test.kt:17 box
// test.kt:4 foo
// test.kt:5 foo
// test.kt:7 foo
// test.kt:10 foo
// test.kt:12 foo
// test.kt:18 box
+24
View File
@@ -0,0 +1,24 @@
// FILE: test.kt
fun box() {
val a: Int? = 0
when (a) {
1 -> {
1 + 1
}
2 -> {
2 + 1
}
else -> {
0 + 0
}
}
}
// LINENUMBERS
// test.kt:4 box
// test.kt:5 box
// test.kt:6 box
// test.kt:9 box
// test.kt:13 box
// test.kt:16 box