Changes all around - objects and GC
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user