diff options
Diffstat (limited to 'oryxc/src/prelude.rs')
| -rw-r--r-- | oryxc/src/prelude.rs | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/oryxc/src/prelude.rs b/oryxc/src/prelude.rs index 32a123f..4e36f33 100644 --- a/oryxc/src/prelude.rs +++ b/oryxc/src/prelude.rs @@ -4,6 +4,8 @@ use std::fmt::{ Formatter, }; +use crate::hashtrie::HTrie; + #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub struct FileId(pub usize); @@ -11,14 +13,32 @@ pub struct FileId(pub usize); #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub struct SymbolId(pub u32); +#[repr(transparent)] #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub struct ScopeId(pub usize); impl ScopeId { pub const GLOBAL: Self = Self(0); + pub const INVALID: Self = Self(usize::MAX); } -#[derive(Default)] +#[derive(Debug)] +pub struct Scope { + pub parent: ScopeId, + pub symtab: HTrie<SymbolId, Symbol>, +} + +impl Scope { + pub fn new(parent: ScopeId) -> Self { + return Self { + parent, + symtab: HTrie::new(), + }; + } +} + +#[repr(u8)] +#[derive(Debug, Default)] pub enum ResolutionState { #[default] Unresolved, @@ -27,14 +47,22 @@ pub enum ResolutionState { Poisoned, } -#[derive(Default)] +#[derive(Debug)] pub struct Symbol { - pub state: ResolutionState, - pub r#type: u32, + pub state: ResolutionState, + pub kind: SymbolType, +} + +#[repr(u8)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum SymbolType { + Constant, + FuncParam, } pub enum OryxType { Integer { bits: usize, signed: bool }, + Boolean, Pointer { base: u32 }, Function { args: Vec<u32>, rets: Vec<u32> }, } |