This commit is contained in:
@@ -17,3 +17,6 @@ pub extern "C" fn scm_hash (ptr : *const u8, len : usize) -> u64 {
|
||||
let bytes = unsafe { slice::from_raw_parts (ptr, len) };
|
||||
crate::obarray::hash (str::from_utf8 (bytes).unwrap ())
|
||||
}
|
||||
|
||||
// #[unsafe(no_mangle)]
|
||||
// pub extern "C" fn scm_lookup (name : scm_)
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
use std::{ops::DerefMut, sync::{LazyLock, Mutex, RwLock}};
|
||||
use internment::Intern;
|
||||
|
||||
// mod fnv1a;
|
||||
// use fnv1a::{FNV1a, SymbolHash};
|
||||
use string_interner::{StringInterner, symbol::SymbolU32};
|
||||
// use string_interner::{StringInterner, symbol::SymbolU32};
|
||||
|
||||
pub struct Obarray (
|
||||
LazyLock <RwLock <StringInterner <string_interner::DefaultBackend>>>
|
||||
LazyLock <RwLock < <string_interner::DefaultBackend>>>
|
||||
);
|
||||
|
||||
impl Obarray {
|
||||
pub const fn new () -> Obarray {
|
||||
Obarray (LazyLock::new (|| RwLock::new (StringInterner::new ())))
|
||||
}
|
||||
}
|
||||
|
||||
impl Obarray {
|
||||
pub fn intern (&self, name : &str) -> SymbolU32 {
|
||||
let mut r = symbols.0.write ().unwrap ();
|
||||
r.deref_mut ().get_or_intern (name)
|
||||
|
||||
+8
-2
@@ -3,7 +3,7 @@
|
||||
|
||||
use std::slice;
|
||||
|
||||
use string_interner::Symbol as _;
|
||||
use internment::Intern;
|
||||
|
||||
use crate::{gc, obarray};
|
||||
|
||||
@@ -156,5 +156,11 @@ pub fn make_symbol (name : &str) -> scm_bits {
|
||||
pack_ptr (r)
|
||||
}
|
||||
|
||||
pub fn string_to_symbol (str : scm_bits) {
|
||||
pub fn make_symbol_off_heap (name : scm_bits) -> [scm_bits; 2] {
|
||||
[ tc7_symbol, name ]
|
||||
}
|
||||
|
||||
pub fn string_to_symbol (str : scm_bits) -> scm_bits {
|
||||
let r = Intern::new (make_symbol_off_heap (str));
|
||||
pack_ptr (r.as_ref () as *const scm_bits)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user