1use crate::value::GcClosure;
2use compiler::op_code::Instructions;
3
4#[derive(Debug, Clone)]
5pub struct Frame {
6 pub cl: GcClosure,
9 pub ip: i32,
10 pub base_pointer: usize,
11 pub instructions: Vec<u8>,
12 pub initialized: Vec<bool>,
17}
18
19impl Frame {
20 pub fn new(
21 closure: GcClosure,
22 instructions: Vec<u8>,
23 base_pointer: usize,
24 num_locals: usize,
25 num_parameters: usize,
26 ) -> Self {
27 Frame {
28 cl: closure,
29 ip: -1,
30 base_pointer,
31 instructions,
32 initialized: (0..num_locals).map(|slot| slot < num_parameters).collect(),
33 }
34 }
35
36 pub fn instruction_view(&self) -> Instructions {
37 Instructions {
38 data: self.instructions.clone(),
39 }
40 }
41}