diff --git a/bytecode_migration_plan.md b/bytecode_migration_plan.md index e3ba613..8c470c8 100644 --- a/bytecode_migration_plan.md +++ b/bytecode_migration_plan.md @@ -29,9 +29,9 @@ Goal: migrate the compiler so all values live in frames/bytecode, keeping JVM te - [x] Support `ClassScopeMemberRef` without scope-map fallback. - [x] Step 8: ObjDynamic member access in bytecode. - [x] Allow dynamic receiver field/method lookup without falling back to interpreter. -- [ ] Step 9: Module-level bytecode execution. - - [ ] Compile `Script` bodies to bytecode instead of interpreting at module scope. - - [ ] Keep import/module slot seeding in frame-only flow. +- [x] Step 9: Module-level bytecode execution. + - [x] Compile `Script` bodies to bytecode instead of interpreting at module scope. + - [x] Keep import/module slot seeding in frame-only flow. ## Notes diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt index e771dff..e0b155b 100644 --- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt +++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt @@ -1526,25 +1526,24 @@ class Compiler( resolutionScriptDepth == 1 && statements.none { containsUnsupportedForBytecode(it) } && statements.none { containsDelegatedRefs(it) } - val finalStatements = if (wrapScriptBytecode) { + val (finalStatements, moduleBytecode) = if (wrapScriptBytecode) { val unwrapped = statements.map { unwrapBytecodeDeep(it) } val block = InlineBlockStatement(unwrapped, start) - listOf( - BytecodeStatement.wrap( - block, - "