Add AttrsBuidler, change Attrs struct around some
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user