Skip to main content

lora_analyzer/
symbols.rs

1use std::fmt;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
4pub struct VarId(pub u32);
5
6impl fmt::Display for VarId {
7    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8        write!(f, "{}", self.0)
9    }
10}
11
12#[derive(Debug, Default)]
13pub struct SymbolTable {
14    next_var: u32,
15}
16
17impl SymbolTable {
18    pub fn new() -> Self {
19        Self { next_var: 0 }
20    }
21
22    pub fn new_var(&mut self) -> VarId {
23        let id = VarId(self.next_var);
24        self.next_var += 1;
25        id
26    }
27}