Step 27A: remove EVAL_STMT

This commit is contained in:
Sergey Chernov 2026-02-11 21:15:43 +03:00
parent 6efdfc1964
commit ac680ceb6c
4 changed files with 2 additions and 20 deletions

View File

@ -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] 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. - [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. - [ ] Step 27: Remove interpreter opcodes and constants from bytecode runtime.
- [ ] Delete `BytecodeConst.ValueFn`, `CmdMakeValueFn`, and `MAKE_VALUE_FN`. - [ ] Delete `BytecodeConst.ValueFn`, `CmdMakeValueFn`, and `MAKE_VALUE_FN` (blocked: some lambdas still fall back to non-bytecode bodies).
- [ ] Delete `BytecodeConst.StatementVal`, `CmdEvalStmt`, and `EVAL_STMT`. - [x] Delete `BytecodeConst.StatementVal`, `CmdEvalStmt`, and `EVAL_STMT`.
- [ ] Remove `emitStatementCall`/`emitStatementEval` once unused. - [ ] Remove `emitStatementCall`/`emitStatementEval` once unused.
- [ ] Step 28: Scope as facade only. - [ ] Step 28: Scope as facade only.
- [ ] Audit bytecode execution paths for `Statement.execute` usage and remove remaining calls. - [ ] Audit bytecode execution paths for `Statement.execute` usage and remove remaining calls.

View File

@ -641,7 +641,6 @@ class BytecodeCompiler(
updateSlotType(slot, SlotType.OBJ) updateSlotType(slot, SlotType.OBJ)
return CompiledValue(slot, SlotType.OBJ) return CompiledValue(slot, SlotType.OBJ)
} }
val captureTableId = lambdaCaptureEntriesByRef[ref]?.let { captures -> val captureTableId = lambdaCaptureEntriesByRef[ref]?.let { captures ->
if (captures.isEmpty()) return@let null if (captures.isEmpty()) return@let null
val resolved = captures.map { entry -> val resolved = captures.map { entry ->

View File

@ -32,7 +32,6 @@ sealed class BytecodeConst {
data class PosVal(val pos: Pos) : BytecodeConst() data class PosVal(val pos: Pos) : BytecodeConst()
data class ObjRef(val value: Obj) : BytecodeConst() data class ObjRef(val value: Obj) : BytecodeConst()
data class Ref(val value: net.sergeych.lyng.obj.ObjRef) : 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<Boolean>) : BytecodeConst() data class ListLiteralPlan(val spreads: List<Boolean>) : BytecodeConst()
data class ValueFn( data class ValueFn(
val fn: suspend (net.sergeych.lyng.Scope) -> net.sergeych.lyng.obj.ObjRecord, val fn: suspend (net.sergeych.lyng.Scope) -> net.sergeych.lyng.obj.ObjRecord,

View File

@ -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() { class CmdMakeValueFn(internal val id: Int, internal val dst: Int) : Cmd() {
override suspend fun perform(frame: CmdFrame) { override suspend fun perform(frame: CmdFrame) {
val valueFn = frame.fn.constants.getOrNull(id) as? BytecodeConst.ValueFn val valueFn = frame.fn.constants.getOrNull(id) as? BytecodeConst.ValueFn