Files
bear/vm/types.v
T
allexanderbergmns 9b22be48a5 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>
2026-08-25 14:29:15 +02:00

57 lines
1.1 KiB
V

// 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.
struct Field {
mut:
name string
val i64
}
struct StructVal {
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
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 {
return if b { i64(1) } else { i64(0) }
}