Remove some unused things (interning, type object definition)
Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
mem::{
|
mem::{
|
||||||
gc::Gc,
|
gc::Gc,
|
||||||
intern::Intern,
|
|
||||||
ptr::ObjCell,
|
ptr::ObjCell,
|
||||||
},
|
},
|
||||||
obj::prelude::*,
|
obj::prelude::*,
|
||||||
};
|
};
|
||||||
use std::{collections::HashMap, ptr::NonNull};
|
use std::{ptr::NonNull};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct BasicGc {
|
pub struct BasicGc {
|
||||||
@@ -45,30 +44,6 @@ impl Gc for BasicGc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct BasicIntern {
|
|
||||||
strs: HashMap<String, ObjRef<Str>>,
|
|
||||||
syms: HashMap<String, Sym>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Intern for BasicIntern {
|
|
||||||
fn intern_str<G: Gc>(&mut self, gc: &mut G, s: &str) -> StrRef {
|
|
||||||
if let Some(obj_ref) = self.strs.get(s) {
|
|
||||||
*obj_ref
|
|
||||||
} else {
|
|
||||||
todo!("TODO(obj) intern strings - need attrs for Str type somehow")
|
|
||||||
//let s = Str::new(&mut ctx, s.to_string());
|
|
||||||
//ctx.gc_mut().alloc(s)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn intern_sym(&mut self, s: &str) -> Sym {
|
|
||||||
let len = self.syms.len();
|
|
||||||
*self.syms.entry(s.to_string())
|
|
||||||
.or_insert_with(|| Sym::new(len))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO object cloning
|
// TODO object cloning
|
||||||
// implementing `clone` is difficult without an ObjCtx, since Attrs has a pointer to itself. This
|
// implementing `clone` is difficult without an ObjCtx, since Attrs has a pointer to itself. This
|
||||||
// pointer would need to be updated.
|
// pointer would need to be updated.
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ pub mod gc;
|
|||||||
pub mod intern;
|
pub mod intern;
|
||||||
pub mod ptr;
|
pub mod ptr;
|
||||||
|
|
||||||
pub use basic::{BasicGc, BasicIntern};
|
pub use basic::BasicGc;
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
pub use crate::mem::{
|
pub use crate::mem::{
|
||||||
BasicGc,
|
BasicGc,
|
||||||
BasicIntern,
|
|
||||||
gc::Gc,
|
gc::Gc,
|
||||||
intern::Intern,
|
|
||||||
ptr::{DynRef, ObjRef},
|
ptr::{DynRef, ObjRef},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
use crate::obj::{attrs::AttrsBuilder, prelude::*};
|
|
||||||
use std::cell::Cell;
|
|
||||||
|
|
||||||
pub struct Ty {
|
|
||||||
marked: Cell<bool>,
|
|
||||||
attrs: ObjRef<Attrs>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Ty {
|
|
||||||
pub fn new(ctx: &mut ObjCtx) -> Self {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Obj for Ty {
|
|
||||||
fn attrs(&self) -> ObjRef<Attrs> {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn is_marked(&self) -> bool {
|
|
||||||
self.marked.get()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mark(&self) {
|
|
||||||
self.marked.set(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn unmark(&self) {
|
|
||||||
self.marked.set(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn as_any(&self) -> &dyn std::any::Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user