Symbol table addition should be separate stage
This commit is contained in:
parent
b4054d7581
commit
c4f0331d1a
@ -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));
|
||||
|
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user