Re-added symbol table infra

This commit is contained in:
greg 2018-02-26 21:43:53 -08:00
parent 92e6830979
commit fa6c2a6f45
2 changed files with 19 additions and 0 deletions

View File

@ -69,6 +69,12 @@ impl ProgrammingLanguageInterface for Schala {
} }
}; };
self.type_context.add_top_level_types(&ast);
if options.debug_symbol_table {
let text = self.type_context.debug_symbol_table();
output.add_artifact(TraceArtifact::new("symbol_table", text));
}
match self.type_context.type_check_ast(&ast) { match self.type_context.type_check_ast(&ast) {
Ok(ty) => { Ok(ty) => {
output.add_artifact(TraceArtifact::new("type_check", format!("{:?}", ty))); output.add_artifact(TraceArtifact::new("type_check", format!("{:?}", ty)));

View File

@ -50,6 +50,19 @@ impl TypeContext {
pub fn new() -> TypeContext { pub fn new() -> TypeContext {
TypeContext { bindings: HashMap::new() } TypeContext { bindings: HashMap::new() }
} }
}
impl TypeContext {
pub fn add_top_level_types(&mut self, ast: &parsing::AST) {
}
pub fn debug_symbol_table(&self) -> String {
format!("Symbols: {:?}", self.bindings)
}
}
impl TypeContext {
pub fn type_check_ast(&mut self, ast: &parsing::AST) -> TypeResult<Type> { pub fn type_check_ast(&mut self, ast: &parsing::AST) -> TypeResult<Type> {
use self::Type::*; use self::TConst::*; use self::Type::*; use self::TConst::*;
let mut ret_type = Const(Unit); let mut ret_type = Const(Unit);