Changes all around - objects and GC
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,40 +1,31 @@
|
||||
use crate::{
|
||||
mem::{gc::Gc, ptr::DynRef, BasicGc},
|
||||
obj::Sym,
|
||||
mem::{gc::Gc, BasicGc},
|
||||
obj::prelude::*,
|
||||
};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub type DefaultGc = BasicGc;
|
||||
|
||||
pub struct ObjCtx<G = DefaultGc>
|
||||
pub struct ObjCtx<'g, 'n, G>
|
||||
where
|
||||
G: Gc,
|
||||
G: Gc + 'g,
|
||||
{
|
||||
gc: G,
|
||||
globals: BTreeMap<Sym, DynRef>,
|
||||
gc: &'g mut G,
|
||||
ns: &'n mut Ns,
|
||||
}
|
||||
|
||||
impl<G> ObjCtx<G>
|
||||
impl<'g, 'n, G> ObjCtx<'g, 'n, G>
|
||||
where
|
||||
G: Gc,
|
||||
G: Gc + 'g,
|
||||
{
|
||||
pub fn new(gc: G) -> Self {
|
||||
ObjCtx { gc, globals: Default::default() }
|
||||
pub fn new(gc: &'g mut G, ns: &'n mut Ns) -> Self {
|
||||
ObjCtx { gc, ns }
|
||||
}
|
||||
|
||||
pub fn gc(&self) -> &G {
|
||||
&self.gc
|
||||
pub fn gc_mut(&'g mut self) -> &'g mut 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
|
||||
pub fn ns_mut(&'n mut self) -> &'n mut Ns {
|
||||
self.ns
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user