From 2c2468b672d5ba6d38d82449179d749896cbd26a Mon Sep 17 00:00:00 2001 From: sergeych Date: Wed, 28 Jan 2026 22:44:15 +0300 Subject: [PATCH] Bytecode compound assign for implicit this member --- .../net/sergeych/lyng/bytecode/BytecodeCompiler.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeCompiler.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeCompiler.kt index a4adade..0149098 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeCompiler.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeCompiler.kt @@ -1006,6 +1006,19 @@ class BytecodeCompiler( updateSlotType(result, SlotType.OBJ) return CompiledValue(result, SlotType.OBJ) } + val implicitTarget = ref.target as? ImplicitThisMemberRef + if (implicitTarget != null) { + val nameId = builder.addConst(BytecodeConst.StringVal(implicitTarget.name)) + if (nameId > 0xFFFF) return compileEvalRef(ref) + val current = allocSlot() + val result = allocSlot() + val rhs = compileRef(ref.value) ?: return compileEvalRef(ref) + builder.emit(Opcode.GET_THIS_MEMBER, nameId, current) + builder.emit(objOp, current, rhs.slot, result) + builder.emit(Opcode.SET_THIS_MEMBER, nameId, result) + updateSlotType(result, SlotType.OBJ) + return CompiledValue(result, SlotType.OBJ) + } val indexTarget = ref.target as? IndexRef if (indexTarget != null) { val receiver = compileRefWithFallback(indexTarget.targetRef, null, Pos.builtIn) ?: return null