This commit is contained in:
2024-12-06 20:04:04 -05:00
parent 620c4557e9
commit e63f652eb5
6 changed files with 27 additions and 20 deletions

View File

@@ -2,12 +2,14 @@ use std::collections::HashMap;
use super::{AddrID, IRLData, IRLFunction, IRLInstruction, IRUInstruction, Namespace, VarID};
pub struct Program {
pub struct IRLProgram {
pub fns: Vec<IRLFunction>,
pub data: Vec<IRLData>,
}
impl Program {
// NOTE: there are THREE places here where I specify size (8)
impl IRLProgram {
pub fn create(ns: &Namespace) -> Self {
let mut fns = Vec::new();
let mut data = Vec::new();

View File

@@ -53,8 +53,8 @@ impl Namespace {
pub fn get_fn(&self, id: FnID) -> &FnDef {
&self.fn_defs[id.0]
}
pub fn get_fn_var(&self, id: VarID) -> &FnDef {
&self.fn_defs[self.fn_map[&id].0]
pub fn get_fn_var(&self, id: VarID) -> Option<&FnDef> {
Some(&self.fn_defs[self.fn_map.get(&id)?.0])
}
pub fn get_type(&self, id: TypeID) -> &TypeDef {
&self.type_defs[id.0]
@@ -102,7 +102,6 @@ impl Namespace {
self.fn_defs.push(def);
self.fns.push(None);
id
}
pub fn def_type(&mut self, def: TypeDef) -> TypeID {
@@ -230,4 +229,3 @@ impl Idents {
}
}
}