Skip to main content

gc/
frame.rs

1use crate::value::GcClosure;
2use compiler::op_code::Instructions;
3
4#[derive(Debug, Clone)]
5pub struct Frame {
6    /// Borrowed closure refs. Frames do not own or free these handles; the
7    /// callee stack slot, main function root, or closure object keeps them live.
8    pub cl: GcClosure,
9    pub ip: i32,
10    pub base_pointer: usize,
11    pub instructions: Vec<u8>,
12}
13
14impl Frame {
15    pub fn new(closure: GcClosure, instructions: Vec<u8>, base_pointer: usize) -> Self {
16        Frame {
17            cl: closure,
18            ip: -1,
19            base_pointer,
20            instructions,
21        }
22    }
23
24    pub fn instruction_view(&self) -> Instructions {
25        Instructions {
26            data: self.instructions.clone(),
27        }
28    }
29}