nac3/nac3standalone/src/basic_symbol_resolver.rs

36 lines
924 B
Rust
Raw Normal View History

2021-08-19 15:30:52 +08:00
use nac3core::{
location::Location,
symbol_resolver::{SymbolResolver, SymbolValue},
toplevel::DefinitionId,
2021-08-19 15:30:52 +08:00
typecheck::{
type_inferencer::PrimitiveStore,
typedef::{Type, Unifier},
},
};
use std::collections::HashMap;
#[derive(Clone)]
pub struct Resolver {
pub id_to_type: HashMap<String, Type>,
pub id_to_def: HashMap<String, DefinitionId>,
pub class_names: HashMap<String, Type>,
}
impl SymbolResolver for Resolver {
fn get_symbol_type(&self, _: &mut Unifier, _: &PrimitiveStore, str: &str) -> Option<Type> {
self.id_to_type.get(str).cloned()
}
fn get_symbol_value(&self, _: &str) -> Option<SymbolValue> {
unimplemented!()
}
fn get_symbol_location(&self, _: &str) -> Option<Location> {
unimplemented!()
}
fn get_identifier_def(&self, id: &str) -> Option<DefinitionId> {
self.id_to_def.get(id).cloned()
}
}