1use indexmap::IndexMap;
3use mir_types::Union;
4use std::sync::Arc;
5
6#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8pub enum ScopeId {
9 Function { file: Arc<str>, name: Arc<str> },
10 Method { class: Arc<str>, method: Arc<str> },
11}
12
13#[derive(Debug)]
15pub struct TypeEnv {
16 vars: IndexMap<String, Union>,
17}
18
19impl TypeEnv {
20 pub(crate) fn new(vars: IndexMap<String, Union>) -> Self {
21 Self { vars }
22 }
23
24 pub fn get_var(&self, name: &str) -> Option<&Union> {
26 self.vars.get(name)
27 }
28
29 pub fn var_names(&self) -> impl Iterator<Item = &str> {
31 self.vars.keys().map(|s| s.as_str())
32 }
33}