Fixed tests
but I think importing is still not working properly
This commit is contained in:
parent
86dc5eca02
commit
016d8fc900
@ -23,7 +23,6 @@ impl<'a> ASTVisitor for ScopeResolver<'a> {
|
||||
let members = self.symbol_table.lookup_children_of_fqsn(&prefix);
|
||||
for member in members.into_iter() {
|
||||
let local_name = member.0.last().unwrap().name.clone();
|
||||
println!("LOCAL NAME: {:?} and member: {:?}", local_name, member);
|
||||
self.name_scope_stack.insert(local_name.clone(), member.0);
|
||||
}
|
||||
},
|
||||
@ -80,13 +79,20 @@ impl<'a> ScopeResolver<'a> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
//TODO this is incomplete
|
||||
fn lookup_name_in_scope(&self, sym_name: &QualifiedName) -> FullyQualifiedSymbolName {
|
||||
let QualifiedName { components: vec, .. } = sym_name;
|
||||
let new_vec: Vec<ScopeSegment> = vec.iter().map(|name| {
|
||||
ScopeSegment { name: name.clone() }
|
||||
}).collect();
|
||||
FullyQualifiedSymbolName(new_vec)
|
||||
let QualifiedName { components, .. } = sym_name;
|
||||
let first_component = &components[0];
|
||||
match self.name_scope_stack.lookup(first_component) {
|
||||
None => {
|
||||
FullyQualifiedSymbolName(components.iter().map(|name| ScopeSegment { name: name.clone() }).collect())
|
||||
},
|
||||
Some(fqsn_prefix) => {
|
||||
let mut full_name = fqsn_prefix.clone();
|
||||
let rest_of_name: FQSNPrefix = components[1..].iter().map(|name| ScopeSegment { name: name.clone() }).collect();
|
||||
full_name.extend_from_slice(&rest_of_name);
|
||||
FullyQualifiedSymbolName(full_name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// this might be a variable or a pattern. if a variable, set to none
|
||||
|
@ -48,5 +48,5 @@ fn test_trie_insertion() {
|
||||
trie.insert(&fqsn!("outer"; ty, "inner"; ty, "still_inner"; tr));
|
||||
|
||||
let children = trie.get_children(&fqsn!("outer"; ty, "inner"; tr));
|
||||
assert_eq!(children.len(), 2);
|
||||
assert_eq!(children.len(), 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user