fixed bug in dynamic val/var compilation
This commit is contained in:
parent
6bf99d354b
commit
529f76489b
@ -1182,10 +1182,10 @@ class Compiler(
|
||||
if (!record.visibility.isPublic) continue
|
||||
if (nameObjClass.containsKey(name)) continue
|
||||
val resolved = when (val raw = record.value) {
|
||||
is FrameSlotRef -> raw.read()
|
||||
is RecordSlotRef -> raw.read()
|
||||
is FrameSlotRef -> raw.peekValue()
|
||||
is RecordSlotRef -> raw.peekValue()
|
||||
else -> raw
|
||||
}
|
||||
} ?: continue
|
||||
when (resolved) {
|
||||
is ObjClass -> nameObjClass[name] = resolved
|
||||
is ObjInstance -> nameObjClass[name] = resolved.objClass
|
||||
|
||||
@ -60,6 +60,17 @@ class FrameSlotRef(
|
||||
return this.frame === frame && this.slot == slot
|
||||
}
|
||||
|
||||
internal fun peekValue(): Obj? {
|
||||
val bytecodeFrame = frame as? net.sergeych.lyng.bytecode.BytecodeFrame ?: return read()
|
||||
val raw = bytecodeFrame.getRawObj(slot) ?: return null
|
||||
if (raw is FrameSlotRef && raw.refersTo(bytecodeFrame, slot)) return null
|
||||
return when (raw) {
|
||||
is FrameSlotRef -> raw.peekValue()
|
||||
is RecordSlotRef -> raw.peekValue()
|
||||
else -> raw
|
||||
}
|
||||
}
|
||||
|
||||
fun write(value: Obj) {
|
||||
when (value) {
|
||||
is ObjInt -> frame.setInt(slot, value.value)
|
||||
@ -87,6 +98,15 @@ class RecordSlotRef(
|
||||
return if (direct is FrameSlotRef) direct.read() else direct
|
||||
}
|
||||
|
||||
internal fun peekValue(): Obj? {
|
||||
val direct = record.value
|
||||
return when (direct) {
|
||||
is FrameSlotRef -> direct.peekValue()
|
||||
is RecordSlotRef -> direct.peekValue()
|
||||
else -> direct
|
||||
}
|
||||
}
|
||||
|
||||
fun write(value: Obj) {
|
||||
record.value = value
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user