Rename interner to prototyper
This commit is contained in:
parent
a2a89ccaf2
commit
d657328487
18
src/main.rs
18
src/main.rs
@ -37,8 +37,8 @@ impl Value {
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct Object { index: u32 }
|
||||
struct Program {
|
||||
blocks: Interner<BlockData>,
|
||||
types: Interner<TypeData>,
|
||||
blocks: Prototyper<BlockData>,
|
||||
types: Prototyper<TypeData>,
|
||||
}
|
||||
struct BlockData { instructions: Vec<Instruction> }
|
||||
|
||||
@ -312,8 +312,8 @@ impl Op21 {
|
||||
impl Program {
|
||||
fn new() -> Program {
|
||||
let mut p = Self {
|
||||
blocks: Interner::<BlockData>::new(),
|
||||
types: Interner::<TypeData>::new(),
|
||||
blocks: Prototyper::<BlockData>::new(),
|
||||
types: Prototyper::<TypeData>::new(),
|
||||
};
|
||||
|
||||
let ty_null = p.type_prototype("null");
|
||||
@ -431,13 +431,13 @@ impl<'p> Heap<'p> {
|
||||
}
|
||||
}
|
||||
|
||||
struct Interner<T> {
|
||||
struct Prototyper<T> {
|
||||
by_name: HashMap<String, u32>,
|
||||
names: Vec<String>,
|
||||
values: Vec<Option<T>>
|
||||
}
|
||||
|
||||
impl<T> Interner<T> {
|
||||
impl<T> Prototyper<T> {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
by_name: HashMap::new(),
|
||||
@ -459,7 +459,7 @@ impl<T> Interner<T> {
|
||||
pub fn instantiate(&mut self, handle: u32, value: T) -> Result<(), &'static str> {
|
||||
let slot = self.values
|
||||
.get_mut(handle as usize)
|
||||
.ok_or("handle was not prototyped on this interner")?;
|
||||
.ok_or("handle was not prototyped on this prototyper")?;
|
||||
if slot.is_some() {
|
||||
return Err("can't instantiate handle twice")
|
||||
}
|
||||
@ -471,7 +471,7 @@ impl<T> Interner<T> {
|
||||
match self.values.get(handle as usize) {
|
||||
Some(Some(h)) => Ok(h),
|
||||
Some(_) => Err("handle was prototyped but not instantiated"),
|
||||
_ => Err("handle was not prototyped on this interner"),
|
||||
_ => Err("handle was not prototyped on this prototyper"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -479,7 +479,7 @@ impl<T> Interner<T> {
|
||||
match self.values.get_mut(handle as usize) {
|
||||
Some(Some(h)) => Ok(h),
|
||||
Some(_) => Err("handle was prototyped but not instantiated"),
|
||||
_ => Err("handle was not prototyped on this interner"),
|
||||
_ => Err("handle was not prototyped on this prototyper"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user