mod frame; pub mod inst; use crate::obj::prelude::*; use frame::*; #[derive(Debug)] pub struct Vm { stack: Vec, frames: Vec, pc: usize, condition: bool, } impl Vm { pub fn new() -> Self { Self { stack: Default::default(), frames: vec![Default::default()], // Start with a root stack frame pc: 0, condition: false, } } pub fn stack(&self) -> &Vec { &self.stack } pub fn stack_mut(&mut self) -> &mut Vec { &mut self.stack } pub fn push(&mut self, value: ObjRef) { self.stack_mut().push(value); } pub fn pop(&mut self) -> Option { self.stack_mut().pop() } pub fn pc(&self) -> usize { self.pc } pub fn condition(&self) -> bool { self.condition } //pub fn new_local(&mut self, name: String, }