Fix a number of TODOs
Add def -> symbol lookup table Minor syntax changes
This commit is contained in:
parent
53112c9f9d
commit
ea494bb328
@ -92,8 +92,8 @@ pub fn walk_expression<V: ASTVisitor>(v: &mut V, expr: &Expression) {
|
|||||||
walk_expression(v, f);
|
walk_expression(v, f);
|
||||||
for arg in arguments.iter() {
|
for arg in arguments.iter() {
|
||||||
match arg {
|
match arg {
|
||||||
InvocationArgument::Positional(expr) => walk_expression(v, expr),
|
InvocationArgument::Positional(expr) | InvocationArgument::Keyword { expr, .. } =>
|
||||||
InvocationArgument::Keyword { expr, .. } => walk_expression(v, expr), //TODO maybe I can combine this pattern
|
walk_expression(v, expr),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,6 +147,7 @@ pub struct SymbolTable {
|
|||||||
fqsn_to_symbol: HashMap<Fqsn, Rc<Symbol>>,
|
fqsn_to_symbol: HashMap<Fqsn, Rc<Symbol>>,
|
||||||
|
|
||||||
id_to_symbol: HashMap<ItemId, Rc<Symbol>>,
|
id_to_symbol: HashMap<ItemId, Rc<Symbol>>,
|
||||||
|
def_to_symbol: HashMap<DefId, Rc<Symbol>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SymbolTable {
|
impl SymbolTable {
|
||||||
@ -159,6 +160,7 @@ impl SymbolTable {
|
|||||||
|
|
||||||
fqsn_to_symbol: HashMap::new(),
|
fqsn_to_symbol: HashMap::new(),
|
||||||
id_to_symbol: HashMap::new(),
|
id_to_symbol: HashMap::new(),
|
||||||
|
def_to_symbol: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,9 +186,8 @@ impl SymbolTable {
|
|||||||
self.id_to_symbol.get(id).map(|s| s.as_ref())
|
self.id_to_symbol.get(id).map(|s| s.as_ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO optimize this
|
|
||||||
pub fn lookup_symbol_by_def(&self, def: &DefId) -> Option<&Symbol> {
|
pub fn lookup_symbol_by_def(&self, def: &DefId) -> Option<&Symbol> {
|
||||||
self.id_to_symbol.iter().find(|(_, sym)| sym.def_id == *def).map(|(_, sym)| sym.as_ref())
|
self.def_to_symbol.get(def).map(|s| s.as_ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@ -205,7 +206,8 @@ impl SymbolTable {
|
|||||||
let symbol = Rc::new(Symbol { fully_qualified_name: fqsn.clone(), spec, def_id });
|
let symbol = Rc::new(Symbol { fully_qualified_name: fqsn.clone(), spec, def_id });
|
||||||
self.symbol_trie.insert(&fqsn);
|
self.symbol_trie.insert(&fqsn);
|
||||||
self.fqsn_to_symbol.insert(fqsn, symbol.clone());
|
self.fqsn_to_symbol.insert(fqsn, symbol.clone());
|
||||||
self.id_to_symbol.insert(*id, symbol);
|
self.id_to_symbol.insert(*id, symbol.clone());
|
||||||
|
self.def_to_symbol.insert(def_id, symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user