From 7a56b6dfc04d50c6e16a10aa0cb691e4ec80364d Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 18 Oct 2019 09:54:56 -0700 Subject: [PATCH] Add some more methods around this --- schala-lang/language/src/symbol_table.rs | 5 +++++ schala-lang/language/src/symbol_table/symbol_trie.rs | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/schala-lang/language/src/symbol_table.rs b/schala-lang/language/src/symbol_table.rs index 02faea9..7fe153a 100644 --- a/schala-lang/language/src/symbol_table.rs +++ b/schala-lang/language/src/symbol_table.rs @@ -115,12 +115,17 @@ impl SymbolTable { vec.push(ScopeSegment { name: local_name.clone(), kind: ScopeSegmentKind::Terminal }); let fully_qualified_name = FullyQualifiedSymbolName(vec); let symbol = Symbol { local_name: local_name.clone(), fully_qualified_name: fully_qualified_name.clone(), spec }; + self.symbol_trie.insert(&fully_qualified_name); self.symbol_path_to_symbol.insert(fully_qualified_name, symbol); } pub fn lookup_by_fqsn(&self, fully_qualified_path: &FullyQualifiedSymbolName) -> Option<&Symbol> { self.symbol_path_to_symbol.get(fully_qualified_path) } + + pub fn lookup_children_of_fqsn(&self, path: &FullyQualifiedSymbolName) -> Vec { + self.symbol_trie.get_children(path) + } } #[derive(Debug)] diff --git a/schala-lang/language/src/symbol_table/symbol_trie.rs b/schala-lang/language/src/symbol_table/symbol_trie.rs index 2fd9bff..47a7611 100644 --- a/schala-lang/language/src/symbol_table/symbol_trie.rs +++ b/schala-lang/language/src/symbol_table/symbol_trie.rs @@ -4,6 +4,7 @@ use super::{ScopeSegmentKind, ScopeSegment, FullyQualifiedSymbolName}; use std::hash::{Hasher, Hash}; use std::collections::hash_map::DefaultHasher; +#[derive(Debug)] pub struct SymbolTrie(Trie); impl TrieKey for FullyQualifiedSymbolName { @@ -33,7 +34,7 @@ impl SymbolTrie { Some(s) => s, None => return vec![] }; - let output: Vec = subtrie.keys().map(|fqsn| fqsn.clone()).collect(); + let output: Vec = subtrie.keys().filter(|cur_key| **cur_key != *fqsn).map(|fqsn| fqsn.clone()).collect(); output } }