Rename lookup_by_path -> lookup_by_fqsn
This commit is contained in:
parent
f6dcd7f0b8
commit
61182a847f
@ -466,7 +466,7 @@ impl<'a> State<'a> {
|
|||||||
//in the values table
|
//in the values table
|
||||||
|
|
||||||
let symbol_table = self.symbol_table_handle.borrow();
|
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 {
|
Ok(match value {
|
||||||
Some(Symbol { name, spec, .. }) => match spec {
|
Some(Symbol { name, spec, .. }) => match spec {
|
||||||
//TODO I'll need this type_name later to do a table lookup
|
//TODO I'll need this type_name later to do a table lookup
|
||||||
|
@ -85,11 +85,10 @@ impl SymbolTable {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
let symbol_path = FullyQualifiedSymbolName(vec);
|
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_fqsn(&self, fully_qualified_path: &FullyQualifiedSymbolName) -> Option<&Symbol> {
|
||||||
pub fn lookup_by_path(&self, fully_qualified_path: &FullyQualifiedSymbolName) -> Option<&Symbol> {
|
|
||||||
self.symbol_path_to_symbol.get(fully_qualified_path)
|
self.symbol_path_to_symbol.get(fully_qualified_path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,7 +300,7 @@ mod symbol_table_tests {
|
|||||||
let mut symbol_table = SymbolTable::new();
|
let mut symbol_table = SymbolTable::new();
|
||||||
let ast = quick_ast($source);
|
let ast = quick_ast($source);
|
||||||
symbol_table.add_top_level_symbols(&ast).unwrap();
|
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) => (),
|
Some(_spec) => (),
|
||||||
None => panic!(),
|
None => panic!(),
|
||||||
};
|
};
|
||||||
@ -373,8 +372,8 @@ mod symbol_table_tests {
|
|||||||
let mut symbol_table = SymbolTable::new();
|
let mut symbol_table = SymbolTable::new();
|
||||||
let ast = quick_ast(source);
|
let ast = quick_ast(source);
|
||||||
symbol_table.add_top_level_symbols(&ast).unwrap();
|
symbol_table.add_top_level_symbols(&ast).unwrap();
|
||||||
assert!(symbol_table.lookup_by_path(&fqsn!["a"; tr]).is_some());
|
assert!(symbol_table.lookup_by_fqsn(&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!["some_func"; fn, "a";tr]).is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -389,8 +388,8 @@ fn outer_func(x) {
|
|||||||
let mut symbol_table = SymbolTable::new();
|
let mut symbol_table = SymbolTable::new();
|
||||||
let ast = quick_ast(source);
|
let ast = quick_ast(source);
|
||||||
symbol_table.add_top_level_symbols(&ast).unwrap();
|
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_fqsn(&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"; fn, "inner_func"; tr)).is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -412,10 +411,10 @@ fn outer_func(x) {
|
|||||||
let ast = quick_ast(source);
|
let ast = quick_ast(source);
|
||||||
symbol_table.add_top_level_symbols(&ast).unwrap();
|
symbol_table.add_top_level_symbols(&ast).unwrap();
|
||||||
println!("{}", symbol_table.debug_symbol_table());
|
println!("{}", symbol_table.debug_symbol_table());
|
||||||
assert!(symbol_table.lookup_by_path(&fqsn!("outer_func"; tr)).is_some());
|
assert!(symbol_table.lookup_by_fqsn(&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"; 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_fqsn(&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"; fn, "second_inner_func"; fn, "another_inner_func"; tr)).is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user