summaryrefslogtreecommitdiff
path: root/oryxc/src/prelude.rs
diff options
context:
space:
mode:
Diffstat (limited to 'oryxc/src/prelude.rs')
-rw-r--r--oryxc/src/prelude.rs38
1 files changed, 31 insertions, 7 deletions
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<usize> {
+ 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<SymbolId, Symbol>,
+ pub symtab: HashMap<SymbolId, Symbol>,
}
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<u32>, rets: Vec<u32> },
+ Function {
+ args: Box<[TypeId]>,
+ rets: Box<[TypeId]>,
+ },
+ Integer {
+ bits: usize,
+ signed: bool,
+ },
+ Pointer {
+ base: u32,
+ },
+ Type(TypeId),
}
#[derive(Clone, Copy)]