1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#![allow(dead_code)]
use boxcar;
use dashmap::DashMap;
use crate::prelude::*;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct ScopeId(pub u32);
impl ScopeId {
pub const GLOBAL: Self = Self(0);
pub const INVAL: Self = Self(u32::MAX);
}
#[derive(Clone, Copy, Debug)]
pub struct Scope {
pub parent: ScopeId,
}
pub struct SymbolVal {}
pub struct SymbolTable {
scopes: boxcar::Vec<Scope>,
symbols: DashMap<(ScopeId, SymbolId), SymbolVal>,
}
impl SymbolTable {
pub fn new() -> Self {
return Self {
/* Initialize with the global scope */
scopes: boxcar::vec![Scope {
parent: ScopeId::INVAL,
}],
symbols: DashMap::new(),
};
}
pub fn insert(&self, scope: ScopeId, symbol: SymbolId, value: SymbolVal) {
self.symbols.insert((scope, symbol), value);
}
}
|