diff options
| author | Thomas Voss <mail@thomasvoss.com> | 2026-03-10 17:41:24 +0100 |
|---|---|---|
| committer | Thomas Voss <mail@thomasvoss.com> | 2026-03-10 17:41:24 +0100 |
| commit | 4e4232490a56bd573a40c46308e1eec8fdd7c875 (patch) | |
| tree | 62430501fd65165fd246941badd4d2540698b422 /oryxc/src/prelude.rs | |
| parent | 81d1341b34bd2a09552a08ffe9a12147c2abb6e4 (diff) | |
Begin work on symbol collection
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..c118c0d 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, Default)] pub struct Symbol { - pub state: ResolutionState, - pub r#type: u32, + pub state: ResolutionState, + pub kind: u32, +} + +#[repr(u8)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum DeclKind { + ConstDef = 0, + Param = 1, } pub enum OryxType { Integer { bits: usize, signed: bool }, + Boolean, Pointer { base: u32 }, Function { args: Vec<u32>, rets: Vec<u32> }, } |