Support qualified this refs in bytecode
This commit is contained in:
parent
7850d5fbde
commit
f0dc0d2396
@ -43,6 +43,16 @@ Goal: migrate the compiler so all values live in frames/bytecode, keeping JVM te
|
|||||||
- [x] Fix post-inc return value for object slots stored in scope frames.
|
- [x] Fix post-inc return value for object slots stored in scope frames.
|
||||||
- [x] Handle optional receivers for member assign-ops and inc/dec without evaluating operands on null.
|
- [x] Handle optional receivers for member assign-ops and inc/dec without evaluating operands on null.
|
||||||
- [x] Support class-scope and index optional inc/dec paths in bytecode.
|
- [x] Support class-scope and index optional inc/dec paths in bytecode.
|
||||||
|
- [x] Step 13: Qualified `this` value refs in bytecode.
|
||||||
|
- [x] Compile `QualifiedThisRef` (`this@Type`) via `LOAD_THIS_VARIANT`.
|
||||||
|
- [x] Add a JVM test that evaluates `this@Type` as a value inside nested classes.
|
||||||
|
- [ ] Step 14: Fast local ref reads in bytecode.
|
||||||
|
- [ ] Support `FastLocalVarRef` reads with the same slot resolution as `LocalVarRef`.
|
||||||
|
- [ ] If `BoundLocalVarRef` is still emitted, map it to a direct slot read instead of failing.
|
||||||
|
- [ ] Add a JVM test that exercises fast-local reads in a bytecode-compiled function.
|
||||||
|
- [ ] Step 15: Class-scope `?=` in bytecode.
|
||||||
|
- [ ] Handle `C.x ?= v` and `C?.x ?= v` for class-scope members without falling back.
|
||||||
|
- [ ] Add a JVM test for class-scope `?=` on static vars.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
|||||||
@ -397,6 +397,7 @@ class BytecodeCompiler(
|
|||||||
is ImplicitThisMethodCallRef -> compileImplicitThisMethodCall(ref)
|
is ImplicitThisMethodCallRef -> compileImplicitThisMethodCall(ref)
|
||||||
is QualifiedThisMethodSlotCallRef -> compileQualifiedThisMethodSlotCall(ref)
|
is QualifiedThisMethodSlotCallRef -> compileQualifiedThisMethodSlotCall(ref)
|
||||||
is IndexRef -> compileIndexRef(ref)
|
is IndexRef -> compileIndexRef(ref)
|
||||||
|
is QualifiedThisRef -> compileThisVariantRef(ref.typeName)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5422,6 +5423,7 @@ class BytecodeCompiler(
|
|||||||
} ?: nameObjClass[ref.name]
|
} ?: nameObjClass[ref.name]
|
||||||
?: resolveTypeNameClass(ref.name)
|
?: resolveTypeNameClass(ref.name)
|
||||||
}
|
}
|
||||||
|
is QualifiedThisRef -> resolveTypeNameClass(ref.typeName)
|
||||||
is ListLiteralRef -> ObjList.type
|
is ListLiteralRef -> ObjList.type
|
||||||
is MapLiteralRef -> ObjMap.type
|
is MapLiteralRef -> ObjMap.type
|
||||||
is RangeRef -> ObjRange.type
|
is RangeRef -> ObjRange.type
|
||||||
@ -5487,6 +5489,7 @@ class BytecodeCompiler(
|
|||||||
return when (ref) {
|
return when (ref) {
|
||||||
is LocalSlotRef -> nameObjClass[ref.name] ?: resolveTypeNameClass(ref.name)
|
is LocalSlotRef -> nameObjClass[ref.name] ?: resolveTypeNameClass(ref.name)
|
||||||
is LocalVarRef -> nameObjClass[ref.name] ?: resolveTypeNameClass(ref.name)
|
is LocalVarRef -> nameObjClass[ref.name] ?: resolveTypeNameClass(ref.name)
|
||||||
|
is QualifiedThisRef -> resolveTypeNameClass(ref.typeName)
|
||||||
is ListLiteralRef -> ObjList.type
|
is ListLiteralRef -> ObjList.type
|
||||||
is MapLiteralRef -> ObjMap.type
|
is MapLiteralRef -> ObjMap.type
|
||||||
is RangeRef -> ObjRange.type
|
is RangeRef -> ObjRange.type
|
||||||
|
|||||||
@ -140,4 +140,18 @@ class BytecodeRecentOpsTest {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun qualifiedThisValueRef() = runTest {
|
||||||
|
eval(
|
||||||
|
"""
|
||||||
|
class T(val v) {
|
||||||
|
fun get() {
|
||||||
|
this@T.v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertEquals(7, T(7).get())
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user