From 61182a847fa6c3651e760c69aebf7bfba7f48aae Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 30 Aug 2019 19:05:01 -0700 Subject: [PATCH] Rename lookup_by_path -> lookup_by_fqsn --- schala-lang/language/src/eval.rs | 2 +- schala-lang/language/src/symbol_table.rs | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/schala-lang/language/src/eval.rs b/schala-lang/language/src/eval.rs index 2416326..d9a68c4 100644 --- a/schala-lang/language/src/eval.rs +++ b/schala-lang/language/src/eval.rs @@ -466,7 +466,7 @@ impl<'a> State<'a> { //in the values table let symbol_table = self.symbol_table_handle.borrow(); - let value = symbol_table.lookup_by_path(&fqsn!(name ; tr)); + let value = symbol_table.lookup_by_fqsn(&fqsn!(name ; tr)); Ok(match value { Some(Symbol { name, spec, .. }) => match spec { //TODO I'll need this type_name later to do a table lookup diff --git a/schala-lang/language/src/symbol_table.rs b/schala-lang/language/src/symbol_table.rs index b8edf8d..f282ce5 100644 --- a/schala-lang/language/src/symbol_table.rs +++ b/schala-lang/language/src/symbol_table.rs @@ -85,11 +85,10 @@ impl SymbolTable { } ]; let symbol_path = FullyQualifiedSymbolName(vec); - self.lookup_by_path(&symbol_path) + self.lookup_by_fqsn(&symbol_path) } - //TODO rename to lookup_by_fqsn - pub fn lookup_by_path(&self, fully_qualified_path: &FullyQualifiedSymbolName) -> Option<&Symbol> { + pub fn lookup_by_fqsn(&self, fully_qualified_path: &FullyQualifiedSymbolName) -> Option<&Symbol> { self.symbol_path_to_symbol.get(fully_qualified_path) } } @@ -301,7 +300,7 @@ mod symbol_table_tests { let mut symbol_table = SymbolTable::new(); let ast = quick_ast($source); symbol_table.add_top_level_symbols(&ast).unwrap(); - match symbol_table.lookup_by_path($single_value) { + match symbol_table.lookup_by_fqsn($single_value) { Some(_spec) => (), None => panic!(), }; @@ -373,8 +372,8 @@ mod symbol_table_tests { let mut symbol_table = SymbolTable::new(); let ast = quick_ast(source); symbol_table.add_top_level_symbols(&ast).unwrap(); - assert!(symbol_table.lookup_by_path(&fqsn!["a"; tr]).is_some()); - assert!(symbol_table.lookup_by_path(&fqsn!["some_func"; fn, "a";tr]).is_some()); + assert!(symbol_table.lookup_by_fqsn(&fqsn!["a"; tr]).is_some()); + assert!(symbol_table.lookup_by_fqsn(&fqsn!["some_func"; fn, "a";tr]).is_some()); } #[test] @@ -389,8 +388,8 @@ fn outer_func(x) { let mut symbol_table = SymbolTable::new(); let ast = quick_ast(source); symbol_table.add_top_level_symbols(&ast).unwrap(); - assert!(symbol_table.lookup_by_path(&fqsn!("outer_func"; tr)).is_some()); - assert!(symbol_table.lookup_by_path(&fqsn!("outer_func"; fn, "inner_func"; tr)).is_some()); + assert!(symbol_table.lookup_by_fqsn(&fqsn!("outer_func"; tr)).is_some()); + assert!(symbol_table.lookup_by_fqsn(&fqsn!("outer_func"; fn, "inner_func"; tr)).is_some()); } #[test] @@ -412,10 +411,10 @@ fn outer_func(x) { let ast = quick_ast(source); symbol_table.add_top_level_symbols(&ast).unwrap(); println!("{}", symbol_table.debug_symbol_table()); - assert!(symbol_table.lookup_by_path(&fqsn!("outer_func"; tr)).is_some()); - assert!(symbol_table.lookup_by_path(&fqsn!("outer_func"; fn, "inner_func"; tr)).is_some()); - assert!(symbol_table.lookup_by_path(&fqsn!("outer_func"; fn, "second_inner_func"; tr)).is_some()); - assert!(symbol_table.lookup_by_path(&fqsn!("outer_func"; fn, "second_inner_func"; fn, "another_inner_func"; tr)).is_some()); + assert!(symbol_table.lookup_by_fqsn(&fqsn!("outer_func"; tr)).is_some()); + assert!(symbol_table.lookup_by_fqsn(&fqsn!("outer_func"; fn, "inner_func"; tr)).is_some()); + assert!(symbol_table.lookup_by_fqsn(&fqsn!("outer_func"; fn, "second_inner_func"; tr)).is_some()); + assert!(symbol_table.lookup_by_fqsn(&fqsn!("outer_func"; fn, "second_inner_func"; fn, "another_inner_func"; tr)).is_some()); } #[test]