A second backend that lowers each bytecode instruction to a machine-code
call into a runtime helper, with control flow as real branches.
- cat/backend/x86_64_glue.c: one helper per opcode, mirroring cat/vm.c
exactly (frame lifecycle, arith, cmp, attr/idx, call/callmethod, is,
next/fornext, try/raise). Helpers use the SysV convention (f in rdi,
a/b/c in rsi/rdx/rcx) and return 0/1/-1.
- cat/backend/x86_64.c: emits AT&T assembly (one labelled block per
instruction, one call per helper, real jumps for JUMP/JUMPIF/JUMPIFNOT/
FORNEXT/RETURN, an .Lonerror block that resumes try handlers), plus a
small generated _main.c that rebuilds the bytecode and boots the VM.
Builds with as + cc linked against libcatscript.a.
- generators are not lowered: their prototype carries no nat_entry, so
the VM runs them (their bytecode is rebuilt by the generated main), and
the emitted code simply falls back to the interpreter.
- cat_vm_exec_closure dispatches to a prototype's nat_entry when present.
- tests: native-vs-interpreter equivalence check. Suite 155 -> 156.
Verified: hello, control, classes, generators, arith, errors, text, oop,
slots, reflect, toml, files, ffi all match the interpreter natively.
Extend the ownership discipline to the VM's global table and the
non-container value producers:
- cat_vm_set_global_owned: takes ownership of a freshly-created value
(used for the native-registered globals and the `module` table).
- cat_vm_free releases the saved `module` stack entries and the globals
table (which cascades: each stored value drops its reference).
- module enter/leave retains the saved `module` while it is off-global.
- stdlib/ffi/file build their tables with owned values and drop the
transient reference after a store.
Suite stays 130 green.
`module` is now a global table describing the unit that is executing:
`name` (basename of the file), `path` and `dir` (when loaded from a
file). It is mutable like any table, so a unit can tag itself.
- module.{h,c}: cat_module_table(name, path), plus a small enter/leave
stack (cat_module_enter/leave) that swaps `module` for the duration
of an import and restores the caller's afterwards.
- vm.h: the enter/leave stack lives on the VM (self-contained, no
globals shared between VMs).
- stdlib: installs an initial `module` (name "main"); dofile/use now
enter the imported unit and leave after it returns.
- main.c: the CLI enters the script's basename/path before running it.
- tests/module.cat + tests/module_lib.cat: name/dir/mutation + the
swap-and-restore around `use` (105 total, all green).
- Modelo de objetos Cat_Value + vtable (interfaces abstratas)
- VM de bytecode, sem GIL (VM por-thread, nativas como valores)
- Stdlib com TOML embutido (toml_parse/toml_encode)
- Família de arquivos: AbstractFile (abstrata), File::open, StringIO, BytesIO
- Front-end (lexer/parser/checker/compiler) implementado em catscript
- cpk (cat package manager) como primeiro programa; manifest package.toml
- Type hints advisory, inclusive DynSized() e sentinel_sized<...>
- 25/25 testes passando (make test)