Production pass: floats, GC, type checking, and tooling

Adds floats, bitwise ops, UTF-8 strings with methods, try/catch,
closures, generics validation, a compile-time type checker, a
mark-and-sweep GC, source-level debug info, constant folding, and
the repl/fmt/package-manager commands.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
allexanderbergmns
2026-08-25 14:29:15 +02:00
parent b0a4da7e2f
commit 9b22be48a5
27 changed files with 3638 additions and 166 deletions
+32 -10
View File
@@ -1,6 +1,8 @@
// types.v — core types and constants for the VuurRaaf VM.
module vm
import obj
const stack_cap = 65536
// Field is one `name: value` entry of a struct value.
@@ -15,18 +17,38 @@ mut:
fields []Field
}
// Handler records a try/catch handler pushed at runtime.
struct Closure {
entry int // code IP of the function body
}
struct Handler {
ip int // catch_ip
bp int // frame base at try point
sp int // stack pointer right after the handler record
}
struct Vm {
mut:
code []u8
strings []string
arrays [][]i64
structs []StructVal
stack []i64
sp int
bp int
ip int
trace bool
halted bool
code []u8
strings []string
arrays [][]i64
structs []StructVal
floats []f64
closures []Closure
stack []i64
sp int
bp int
ip int
trace bool
halted bool
prog_args []string
exit_code i64
did_exit bool
handlers []Handler
lines []obj.LineInfo // debug info: code offset -> source line
const_strs int // strings[0..const_strs] are bytecode constants, never collected
last_heap int // heap size at the last GC check (allocation trigger)
}
fn bool_i64(b bool) i64 {