From 232bec97a7cf83615770ab439d345dd4f59b09ff Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 26 Feb 2018 21:43:53 -0800 Subject: [PATCH] Re-added symbol table infra --- src/schala_lang/mod.rs | 6 ++++++ src/schala_lang/typechecking.rs | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/schala_lang/mod.rs b/src/schala_lang/mod.rs index bdc85d4..6eeb4eb 100644 --- a/src/schala_lang/mod.rs +++ b/src/schala_lang/mod.rs @@ -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) { Ok(ty) => { output.add_artifact(TraceArtifact::new("type_check", format!("{:?}", ty))); diff --git a/src/schala_lang/typechecking.rs b/src/schala_lang/typechecking.rs index 362c22a..0551784 100644 --- a/src/schala_lang/typechecking.rs +++ b/src/schala_lang/typechecking.rs @@ -50,6 +50,19 @@ impl TypeContext { pub fn new() -> TypeContext { 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 { use self::Type::*; use self::TConst::*; let mut ret_type = Const(Unit);