Symbol table addition should be separate stage

This commit is contained in:
greg 2017-10-08 16:24:44 -07:00
parent b4054d7581
commit c4f0331d1a
2 changed files with 5 additions and 2 deletions

View File

@ -62,6 +62,8 @@ impl ProgrammingLanguageInterface for Schala {
}
};
self.type_context.add_symbols(&ast);
if options.debug_symbol_table {
let text = self.type_context.debug_symbol_table();
output.add_artifact(TraceArtifact::new("symbol_table", text));

View File

@ -55,6 +55,9 @@ impl TypeContext {
pub fn new() -> TypeContext {
TypeContext { symbol_table: SymbolTable::new() }
}
pub fn add_symbols(&mut self, ast: &AST) {
self.symbol_table.add_symbols(ast)
}
pub fn debug_symbol_table(&self) -> String {
format!("Symbol table:\n {:?}", self.symbol_table.map)
}
@ -81,8 +84,6 @@ impl TypeContext {
pub fn type_check(&mut self, ast: &AST) -> TypeCheckResult {
use self::ExpressionType::*;
self.symbol_table.add_symbols(ast);
for statement in ast.0.iter() {
match statement {
&Statement::Declaration(ref _decl) => {