This repository has been archived on 2020-09-15. You can view files and clone it, but cannot push or open issues or pull requests.
Files
not-python-old.2020-08-27/src/obj/ctx.rs

41 lines
669 B
Rust
Raw Normal View History

use crate::{
mem::{gc::Gc, ptr::DynRef, BasicGc},
obj::Sym,
};
use std::collections::BTreeMap;
pub type DefaultGc = BasicGc;
pub struct ObjCtx<G = DefaultGc>
where
G: Gc,
{
gc: G,
globals: BTreeMap<Sym, DynRef>,
}
impl<G> ObjCtx<G>
where
G: Gc,
{
pub fn new(gc: G) -> Self {
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
}
}