From 0eccceabd909df4a00cd98fd72843c9dad69aa4e Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Fri, 26 Nov 2021 02:26:46 -0800 Subject: [PATCH] Make Func more complex --- schala-lang/src/reduced_ir/mod.rs | 2 +- schala-lang/src/symbol_table/mod.rs | 6 +++--- schala-lang/src/symbol_table/populator.rs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/schala-lang/src/reduced_ir/mod.rs b/schala-lang/src/reduced_ir/mod.rs index e45d7bf..d0204bd 100644 --- a/schala-lang/src/reduced_ir/mod.rs +++ b/schala-lang/src/reduced_ir/mod.rs @@ -339,7 +339,7 @@ impl<'a, 'b> Reducer<'a, 'b> { match symbol.spec() { Builtin(b) => Expression::Callable(Callable::Builtin(b)), - Func => Expression::Lookup(Lookup::Function(def_id.unwrap())), + Func { .. } => Expression::Lookup(Lookup::Function(def_id.unwrap())), GlobalBinding => Expression::Lookup(Lookup::GlobalVar(def_id.unwrap())), LocalVariable => Expression::Lookup(Lookup::LocalVar(def_id.unwrap())), FunctionParam(n) => Expression::Lookup(Lookup::Param(n)), diff --git a/schala-lang/src/symbol_table/mod.rs b/schala-lang/src/symbol_table/mod.rs index 7ea1382..66ea937 100644 --- a/schala-lang/src/symbol_table/mod.rs +++ b/schala-lang/src/symbol_table/mod.rs @@ -114,7 +114,7 @@ impl SymbolTable { ) -> Result<(), Vec> { let mut populator = SymbolTablePopulator { type_context, table: self }; - let errs = populator.populate_name_tables(ast); + let errs = populator.populate_definition_tables(ast); if !errs.is_empty() { return Err(errs); } @@ -212,7 +212,7 @@ impl fmt::Display for Symbol { #[derive(Debug, Clone)] pub enum SymbolSpec { Builtin(Builtin), - Func, + Func { method: Option }, DataConstructor { tag: u32, type_id: TypeId }, RecordConstructor { tag: u32, type_id: TypeId }, GlobalBinding, //Only for global variables, not for function-local ones or ones within a `let` scope context @@ -225,7 +225,7 @@ impl fmt::Display for SymbolSpec { use self::SymbolSpec::*; match self { Builtin(b) => write!(f, "Builtin: {:?}", b), - Func => write!(f, "Func"), + Func { .. } => write!(f, "Func"), DataConstructor { tag, type_id } => write!(f, "DataConstructor(tag: {}, type: {})", tag, type_id), RecordConstructor { type_id, tag, .. } => write!(f, "RecordConstructor(tag: {})( -> {})", tag, type_id), diff --git a/schala-lang/src/symbol_table/populator.rs b/schala-lang/src/symbol_table/populator.rs index fdda8c5..b3e48e8 100644 --- a/schala-lang/src/symbol_table/populator.rs +++ b/schala-lang/src/symbol_table/populator.rs @@ -32,7 +32,7 @@ impl<'a> SymbolTablePopulator<'a> { /// constants, functions, types, and modules defined within. This simultaneously /// checks for dupicate definitions (and returns errors if discovered), and sets /// up name tables that will be used by further parts of the compiler - pub fn populate_name_tables(&mut self, ast: &AST) -> Vec { + pub fn populate_definition_tables(&mut self, ast: &AST) -> Vec { let mut scope_stack = vec![]; self.add_from_scope(ast.statements.as_ref(), &mut scope_stack, false) } @@ -94,7 +94,7 @@ impl<'a> SymbolTablePopulator<'a> { .register(fq_function.clone(), NameSpec { location, kind: NameKind::Function })?; self.table.types.register(fq_function.clone(), NameSpec { location, kind: TypeKind })?; - self.add_symbol(id, fq_function, SymbolSpec::Func); + self.add_symbol(id, fq_function, SymbolSpec::Func { method: None }); } StatementKind::Declaration(Declaration::FuncDecl(signature, ..)) => { let fn_name = &signature.name; @@ -104,7 +104,7 @@ impl<'a> SymbolTablePopulator<'a> { .register(fq_function.clone(), NameSpec { location, kind: NameKind::Function })?; self.table.types.register(fq_function.clone(), NameSpec { location, kind: TypeKind })?; - self.add_symbol(id, fq_function, SymbolSpec::Func); + self.add_symbol(id, fq_function, SymbolSpec::Func { method: None }); } StatementKind::Declaration(Declaration::TypeDecl { name, .. }) => { let fq_type = Fqsn::from_scope_stack(scope_stack, name.name.clone());