pub struct CallFrame {
pub chunk_idx: usize,
pub ip: usize,
pub base: usize,
pub locals: Vec<Value>,
}Expand description
one call frame: the function being run, the instruction pointer into its chunk, the base slot where this frame’s locals begin, and the frame’s local slots.
the frame owns its locals vec, which drops when the frame is popped on
RETURN. 05-RESEARCH.md describes a per-frame bump arena freed wholesale on
return; in v1 the heap’s free list already reclaims slots, so the frame
owning its locals (dropped on return) is the whole of the “arena” – a
distinct bump region is not required for correctness, and adding one would
be dead weight against the free list. a richer arena stays a v2 idea.
derives Clone but not Debug – locals is a Vec<Value> and Value’s
locked derive list omits Debug.
Fields§
§chunk_idx: usizeindex into Program::chunks – which function this frame runs.
ip: usizethe instruction pointer: a byte offset into the chunk’s code.
base: usizethe value-stack index where this frame’s locals[0] conceptually sits.
the call machinery (a later commit) uses it to unwind the stack on
RETURN.
locals: Vec<Value>this frame’s local slots, indexed by GET_LOCAL / SET_LOCAL
operands. dropped when the frame is popped.