Add bytecode VM backend (compile AST to bytecodes + stack-based VM)

New execution mode: ./run vm <file.j> compiles AST to bytecodes and
runs them in a while/switch loop. Ints/floats live on the stack (no
heap allocation), ~7.7x faster than the tree-walking interpreter.

Implements: opcodes, compiler with backpatching (if/while), stack VM
with arithmetic, comparisons, variables, strings, and print/println.
Reorganizes backend into src/backend/eval/ and src/backend/bytecode/.
This commit is contained in:
Jose Luis Montañes Ojados
2026-02-18 01:01:22 +01:00
parent 2c91cbb561
commit 4442886afa
11 changed files with 776 additions and 58 deletions

6
projects/vm_simple.j Normal file
View File

@@ -0,0 +1,6 @@
x = 0
while x < 10:
x = x + 1
if x > 1000000:
println("OK")