From 69c215eac9ad26773b1104f3e8cef3db8fcd125b Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 20 Sep 2019 01:44:20 -0700 Subject: [PATCH] Get rid of Meta elsewhere --- schala-lang/language/src/reduced_ast.rs | 11 ++++++----- schala-lang/language/src/scope_resolution.rs | 5 ++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index 8017612..82bedf7 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -419,8 +419,9 @@ impl Pattern { fn to_subpattern(&self, symbol_table: &SymbolTable) -> Subpattern { use self::Pattern::*; match self { - TupleStruct( Meta { n: QualifiedName{ components, .. }, fqsn, .. }, inner_patterns) => { - match fqsn.as_ref().and_then(|fqsn| symbol_table.lookup_by_fqsn(&fqsn)) { + TupleStruct( Meta { n: QualifiedName{ components, id }, .. }, inner_patterns) => { + let fqsn = symbol_table.get_fqsn_from_id(&id); + match fqsn.and_then(|fqsn| symbol_table.lookup_by_fqsn(&fqsn)) { Some(symbol) => handle_symbol(Some(symbol), inner_patterns, symbol_table), None => { panic!("Symbol {:?} not found", components); @@ -433,12 +434,12 @@ impl Pattern { }, Ignored => Subpattern { tag: None, subpatterns: vec![], guard: None, bound_vars: vec![] }, Literal(lit) => lit.to_subpattern(symbol_table), - VarOrName(Meta { n: QualifiedName { components, .. }, fqsn, .. }) => { + VarOrName(Meta { n: QualifiedName { components, id }, .. }) => { // if fqsn is Some, treat this as a symbol pattern. If it's None, treat it // as a variable. println!("Calling VarOrName reduction with : {:?}", components); - - match fqsn.as_ref().and_then(|fqsn| symbol_table.lookup_by_fqsn(&fqsn)) { + let fqsn = symbol_table.get_fqsn_from_id(&id); + match fqsn.and_then(|fqsn| symbol_table.lookup_by_fqsn(&fqsn)) { Some(symbol) => handle_symbol(Some(symbol), &vec![], symbol_table), None => { let name = if components.len() == 1 { diff --git a/schala-lang/language/src/scope_resolution.rs b/schala-lang/language/src/scope_resolution.rs index 2574310..6bc31fc 100644 --- a/schala-lang/language/src/scope_resolution.rs +++ b/schala-lang/language/src/scope_resolution.rs @@ -147,8 +147,11 @@ impl<'a> ScopeResolver<'a> { /// this might be a variable or a pattern. if a variable, set to none fn qualified_name_in_pattern(&mut self, meta_qualified_name: &mut Meta, ) { let inner_name = meta_qualified_name.node(); + let ref id = inner_name.id; let fqsn = lookup_name_in_scope(inner_name); - meta_qualified_name.fqsn = if self.symbol_table.lookup_by_fqsn(&fqsn).is_some() { Some(fqsn) } else { None }; + if self.symbol_table.lookup_by_fqsn(&fqsn).is_some() { + self.symbol_table.map_id_to_fqsn(&id, fqsn); + } } }