[EE-IR] Support Local Functions
This commit introduces support for calling and referencing local functions and objects in evaluate expression on the IR backend. The primary incision is a lowering inserted after Local Declaration Lowering, that uses the intermediate data structures recorded by LDL to rewrite calls to local functions to the appropriate function in the binary, instead of predicting the compilation strategy. The required changes to the rest of the pipeline facilitate piping the required data around. The key to this transformation is that _captures by the local function_ must be introduced as _captures by the fragment function_, such that the evaluator infrastructure can find the appropriate values at run-time. This is necessary due to the strategy of compiling local functions to static functions instead of closures. Additional test coverage of stepping behavior support the corresponding changes in the Evaluator, part of the Kotlin Debugger plug-in.
This commit is contained in:
committed by
Nikita Nazarov
parent
5af9303a16
commit
4f8ef8c315
@@ -0,0 +1,38 @@
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
open class Base(i: Int)
|
||||
|
||||
class Derived(): Base(1) {
|
||||
constructor(p: Int): this() {
|
||||
val a = 2
|
||||
}
|
||||
|
||||
constructor(p1: Int, p2: Int): this()
|
||||
}
|
||||
|
||||
fun box() {
|
||||
Derived(3)
|
||||
Derived(4, 5)
|
||||
}
|
||||
|
||||
// EXPECTATIONS
|
||||
// test.kt:15 box:
|
||||
// test.kt:7 <init>: p:int=3:int
|
||||
// test.kt:6 <init>:
|
||||
// test.kt:4 <init>: i:int=1:int
|
||||
// test.kt:6 <init>:
|
||||
// test.kt:8 <init>: p:int=3:int
|
||||
// EXPECTATIONS JVM_IR
|
||||
// test.kt:9 <init>: p:int=3:int, a:int=2:int
|
||||
// EXPECTATIONS
|
||||
// test.kt:15 box:
|
||||
|
||||
// test.kt:16 box:
|
||||
// test.kt:11 <init>: p1:int=4:int, p2:int=5:int
|
||||
// test.kt:6 <init>:
|
||||
// test.kt:4 <init>: i:int=1:int
|
||||
// test.kt:6 <init>:
|
||||
// test.kt:11 <init>: p1:int=4:int, p2:int=5:int
|
||||
// test.kt:16 box:
|
||||
// test.kt:17 box:
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
|
||||
// FILE: test.kt
|
||||
class F(val a: String)
|
||||
|
||||
fun box() {
|
||||
F("foo")
|
||||
}
|
||||
|
||||
// EXPECTATIONS
|
||||
// test.kt:7 box:
|
||||
// test.kt:4 <init>: a:java.lang.String="foo":java.lang.String
|
||||
// test.kt:7 box:
|
||||
// test.kt:8 box:
|
||||
Reference in New Issue
Block a user