diff --git a/schala-lang/src/typechecking.rs b/schala-lang/src/typechecking.rs index f0a19e0..4a867f1 100644 --- a/schala-lang/src/typechecking.rs +++ b/schala-lang/src/typechecking.rs @@ -11,12 +11,23 @@ use parsing; pub struct TypeContext { type_var_count: u64, bindings: HashMap, Type>, - //symbol_table: SymbolTable + symbol_table: SymbolTable } //cf. p. 150 or so of Language Implementation Patterns struct SymbolTable { + pub values: HashMap, Symbol> //TODO this will eventually have real type information +} +impl SymbolTable { + fn new() -> SymbolTable { + SymbolTable { values: HashMap::new() } + } +} + +struct Symbol { + name: Rc, + ty: Type } #[derive(Debug, PartialEq, Clone)] @@ -104,7 +115,7 @@ pub type TypeResult = Result; impl TypeContext { pub fn new() -> TypeContext { - TypeContext { bindings: HashMap::new(), type_var_count: 0 } + TypeContext { bindings: HashMap::new(), type_var_count: 0, symbol_table: SymbolTable::new() } } pub fn fresh(&mut self) -> Type { let ret = self.type_var_count; diff --git a/source_files/schala/test.schala b/source_files/schala/test.schala index 76c90ba..eab6109 100644 --- a/source_files/schala/test.schala +++ b/source_files/schala/test.schala @@ -1,5 +1,12 @@ -const a = getline() +println(a(4)) + +fn sua(x): Int { + x + 10 +} + + +//const a = getline() if a == "true" { println("You typed true")