Changes all around - objects and GC

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-05-16 18:46:09 -04:00
parent a15dde0fc2
commit d5cf39108b
15 changed files with 223 additions and 203 deletions

View File

@@ -1,17 +1,26 @@
use crate::obj::prelude::*;
use std::collections::BTreeMap;
use crate::{
obj::prelude::*,
vm::op::Op,
};
use std::rc::Rc;
#[derive(Default)]
pub struct Frame {
stack: Vec<DynRef>,
ip: usize,
return_value: Option<DynRef>,
locals: BTreeMap<Sym, DynRef>,
locals: Ns,
ops: Rc<Vec<Op>>,
}
impl Frame {
pub fn new() -> Self {
Default::default()
pub fn new(ops: Rc<Vec<Op>>) -> Self {
Frame {
stack: Default::default(),
ip: 0,
return_value: None,
locals: Default::default(),
ops,
}
}
pub fn push(&mut self, obj_ref: DynRef) {
@@ -45,5 +54,9 @@ impl Frame {
pub fn set_local(&mut self, sym: Sym, obj_ref: DynRef) -> Option<DynRef> {
self.locals.insert(sym, obj_ref)
}
pub fn ops(&self) -> &Rc<Vec<Op>> {
&self.ops
}
}