From db11ea02d777a33fedb6af4ee056e85f52fbb008 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 17 Mar 2026 19:56:03 +0100 Subject: Lots of code simplification --- oryxc/src/prelude.rs | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'oryxc/src/prelude.rs') diff --git a/oryxc/src/prelude.rs b/oryxc/src/prelude.rs index 0d1fc15..5628c87 100644 --- a/oryxc/src/prelude.rs +++ b/oryxc/src/prelude.rs @@ -1,11 +1,10 @@ +use std::collections::HashMap; use std::fmt::{ self, Debug, Formatter, }; -use crate::hashtrie::HTrie; - macro_rules! mkidtype { ($name:ident) => { #[repr(transparent)] @@ -38,17 +37,33 @@ impl ScopeId { pub const GLOBAL: Self = Self(0); } +impl TypeId { + const MVMSK: u32 = 1 << 31; + + pub fn to_mvindex(&self) -> Option { + return if self.0 & Self::MVMSK != 0 { + Some((self.0 & !Self::MVMSK) as usize) + } else { + None + }; + } + + pub fn from_mvindex(i: usize) -> Self { + return Self(i as u32 & Self::MVMSK); + } +} + #[derive(Debug)] pub struct Scope { pub parent: ScopeId, - pub symtab: HTrie, + pub symtab: HashMap, } impl Scope { pub fn new(parent: ScopeId) -> Self { return Self { parent, - symtab: HTrie::new(), + symtab: HashMap::new(), }; } } @@ -77,10 +92,19 @@ pub enum SymbolType { } pub enum OryxType { - Integer { bits: usize, signed: bool }, Boolean, - Pointer { base: u32 }, - Function { args: Vec, rets: Vec }, + Function { + args: Box<[TypeId]>, + rets: Box<[TypeId]>, + }, + Integer { + bits: usize, + signed: bool, + }, + Pointer { + base: u32, + }, + Type(TypeId), } #[derive(Clone, Copy)] -- cgit v1.2.3