From 89a93d59c7bdb8781681b8e431e8fc1b3be96c6e Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Fri, 26 Nov 2021 03:41:12 -0800 Subject: [PATCH] Some refactoring --- schala-lang/src/symbol_table/populator.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/schala-lang/src/symbol_table/populator.rs b/schala-lang/src/symbol_table/populator.rs index b3e48e8..bed4ee0 100644 --- a/schala-lang/src/symbol_table/populator.rs +++ b/schala-lang/src/symbol_table/populator.rs @@ -51,24 +51,34 @@ impl<'a> SymbolTablePopulator<'a> { if let Err(err) = self.add_single_statement(id, kind, location, scope_stack, function_scope) { errors.push(err); } else { + let decl = match kind { + StatementKind::Declaration(decl) => decl, + _ => continue, + }; // If there's an error with a name, don't recurse into subscopes of that name - let recursive_errs = match kind { - StatementKind::Declaration(Declaration::FuncDecl(signature, body)) => { + let recursive_errs = match decl { + Declaration::FuncDecl(signature, body) => { let new_scope = ScopeSegment::Name(signature.name.clone()); scope_stack.push(new_scope); let output = self.add_from_scope(body.as_ref(), scope_stack, true); scope_stack.pop(); output } - StatementKind::Declaration(Declaration::Module { name, items }) => { + Declaration::Module { name, items } => { let new_scope = ScopeSegment::Name(name.clone()); scope_stack.push(new_scope); let output = self.add_from_scope(items.as_ref(), scope_stack, false); scope_stack.pop(); output } - StatementKind::Declaration(Declaration::TypeDecl { name, body, mutable }) => + Declaration::TypeDecl { name, body, mutable } => self.add_type_members(name, body, mutable, location, scope_stack), + + /* + Declaration::Impl { type_name, body, .. } => { + + }, + */ _ => vec![], }; errors.extend(recursive_errs.into_iter());