Files
catscript/include/cat/backend
Minus 33a1152958 C backend: ahead-of-time compilation to a native binary
- new cat/backend/c.{h,c}: lower a compiled CAT_BYTECODE_Function to a
  self-contained C translation unit that rebuilds the bytecode and runs
  it on the catscript runtime.  The tree is emitted in pre-order with
  forward declarations; constants (int/float/text/bool) are recreated by
  the matching constructors; jumps keep their absolute targets.
- Makefile: also build libcatscript.a (all objects but main.o) so an AOT
  program links the runtime without clashing on `main`.
- main.c: `--emit-c <file>` prints the generated C; `--build <file> <out>`
  emits it, invokes the system `cc`, and produces the executable.
- tests/aot.cat + suite: the native binary's stdout must equal the
  interpreter's (arithmetic, recursion, objects, interfaces, `is`,
  concat, comparisons).  Suite 151 -> 152.

The backend is faithful by construction: it lowers the very bytecode the
interpreter runs, so native output matches the interpreter exactly
(including current language quirks, e.g. upvalues and `try`/`catch`).
2026-11-18 17:37:25 +00:00
..