2021-08-19 15:30:52 +08:00
|
|
|
use nac3core::{
|
|
|
|
location::Location,
|
|
|
|
symbol_resolver::{SymbolResolver, SymbolValue},
|
2021-08-24 17:14:34 +08:00
|
|
|
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()
|
|
|
|
}
|
2021-09-06 19:23:04 +08:00
|
|
|
|
|
|
|
fn add_id_def(&mut self, _: String, _: DefinitionId) {
|
|
|
|
unimplemented!();
|
|
|
|
}
|
2021-08-19 15:30:52 +08:00
|
|
|
}
|