mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-17 02:45:02 +01:00
started alloc and hash
This commit is contained in:
parent
70a35e2a10
commit
1bd999bb9b
3 changed files with 40 additions and 1 deletions
39
src/alloc.rs
Normal file
39
src/alloc.rs
Normal 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 {}
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
mod alloc;
|
||||||
mod lex;
|
mod lex;
|
||||||
mod parse;
|
mod parse;
|
||||||
mod string;
|
mod string;
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
pub struct StringInterner;
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue