Add AttrsBuidler, change Attrs struct around some

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-05-15 11:33:53 -04:00
parent f3680f29ad
commit a60471f526
6 changed files with 127 additions and 25 deletions

View File

@@ -1,12 +1,17 @@
use crate::mem::{gc::Gc, BasicGc};
use crate::{
mem::{gc::Gc, ptr::DynRef, BasicGc},
obj::Sym,
};
use std::collections::BTreeMap;
pub type DefaultGc = BasicGc;
pub struct ObjCtx<G=DefaultGc>
pub struct ObjCtx<G = DefaultGc>
where
G: Gc,
{
gc: G,
globals: BTreeMap<Sym, DynRef>,
}
impl<G> ObjCtx<G>
@@ -14,13 +19,22 @@ where
G: Gc,
{
pub fn new(gc: G) -> Self {
ObjCtx { gc }
ObjCtx { gc, globals: Default::default() }
}
pub fn gc(&self) -> &G {
&self.gc
}
pub fn gc_mut(&mut self) -> &mut G {
&mut self.gc
}
pub fn globals(&self) -> &BTreeMap<Sym, DynRef> {
&self.globals
}
pub fn globals_mut(&mut self) -> &mut BTreeMap<Sym, DynRef> {
&mut self.globals
}
}