diff --git a/bytecode_migration_plan.md b/bytecode_migration_plan.md index 7f04200..07e5649 100644 --- a/bytecode_migration_plan.md +++ b/bytecode_migration_plan.md @@ -126,8 +126,8 @@ Goal: migrate the compiler so all values live in frames/bytecode, keeping JVM te - [x] Remove `forceScopeSlots` branches once no bytecode paths depend on scope slots. - [x] Add JVM tests for captured locals and delegated locals inside lambdas on the bytecode path. - [ ] Step 27: Remove interpreter opcodes and constants from bytecode runtime. - - [ ] Delete `BytecodeConst.ValueFn`, `CmdMakeValueFn`, and `MAKE_VALUE_FN`. - - [ ] Delete `BytecodeConst.StatementVal`, `CmdEvalStmt`, and `EVAL_STMT`. + - [ ] Delete `BytecodeConst.ValueFn`, `CmdMakeValueFn`, and `MAKE_VALUE_FN` (blocked: some lambdas still fall back to non-bytecode bodies). + - [x] Delete `BytecodeConst.StatementVal`, `CmdEvalStmt`, and `EVAL_STMT`. - [ ] Remove `emitStatementCall`/`emitStatementEval` once unused. - [ ] Step 28: Scope as facade only. - [ ] Audit bytecode execution paths for `Statement.execute` usage and remove remaining calls. 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 c85c1f8..f516ae6 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeCompiler.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeCompiler.kt @@ -641,7 +641,6 @@ class BytecodeCompiler( updateSlotType(slot, SlotType.OBJ) return CompiledValue(slot, SlotType.OBJ) } - val captureTableId = lambdaCaptureEntriesByRef[ref]?.let { captures -> if (captures.isEmpty()) return@let null val resolved = captures.map { entry -> diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeConst.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeConst.kt index 61a9952..e50cba3 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeConst.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/BytecodeConst.kt @@ -32,7 +32,6 @@ sealed class BytecodeConst { data class PosVal(val pos: Pos) : BytecodeConst() data class ObjRef(val value: Obj) : BytecodeConst() data class Ref(val value: net.sergeych.lyng.obj.ObjRef) : BytecodeConst() - data class StatementVal(val statement: net.sergeych.lyng.Statement) : BytecodeConst() data class ListLiteralPlan(val spreads: List) : BytecodeConst() data class ValueFn( val fn: suspend (net.sergeych.lyng.Scope) -> net.sergeych.lyng.obj.ObjRecord, diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/CmdRuntime.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/CmdRuntime.kt index bfcf070..5c3e2a3 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/CmdRuntime.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/bytecode/CmdRuntime.kt @@ -1861,22 +1861,6 @@ class CmdEvalRef(internal val id: Int, internal val dst: Int) : Cmd() { } } -class CmdEvalStmt(internal val id: Int, internal val dst: Int) : Cmd() { - override suspend fun perform(frame: CmdFrame) { - if (frame.fn.localSlotNames.isNotEmpty()) { - frame.syncFrameToScope(useRefs = true) - } - val stmt = frame.fn.constants.getOrNull(id) as? BytecodeConst.StatementVal - ?: error("EVAL_STMT expects StatementVal at $id") - val result = stmt.statement.execute(frame.ensureScope()) - if (frame.fn.localSlotNames.isNotEmpty()) { - frame.syncScopeToFrame() - } - frame.storeObjResult(dst, result) - return - } -} - class CmdMakeValueFn(internal val id: Int, internal val dst: Int) : Cmd() { override suspend fun perform(frame: CmdFrame) { val valueFn = frame.fn.constants.getOrNull(id) as? BytecodeConst.ValueFn