started alloc and hash

This commit is contained in:
nora 2021-10-05 23:10:28 +02:00
parent 70a35e2a10
commit 1bd999bb9b
3 changed files with 40 additions and 1 deletions

39
src/alloc.rs Normal file
View file

@ -0,0 +1,39 @@
use std::rc::Rc;
pub struct Alloc {
strings: table::IStrTable,
}
pub enum Object {
String(IStr),
}
/// Reference to an interned String
struct IStr {
/// This will be changed to a raw pointer once a tracing GC is implemented
data: Rc<str>,
hash: u64,
}
mod table {
use crate::alloc::IStr;
use std::collections::HashMap;
#[derive(Debug, Default)]
pub struct IStrTable {
map: HashMap<u64, IStr, StringHashBuilder>,
}
#[derive(Debug, Default)]
struct StringHashBuilder;
impl std::hash::BuildHasher for StringHashBuilder {
type Hasher = ();
fn build_hasher(&self) -> Self::Hasher {
todo!()
}
}
struct PrimitveHasher {}
}

View file

@ -1,3 +1,4 @@
mod alloc;
mod lex;
mod parse;
mod string;

View file

@ -1 +0,0 @@
pub struct StringInterner;