Symbol table clippy
This commit is contained in:
parent
355ed3c749
commit
0c6c4ef47e
@ -230,7 +230,7 @@ impl SymbolTable {
|
||||
for statement in statements {
|
||||
let Statement { id: _, kind, location } = statement; //TODO I'm not sure if I need to do anything with this ID
|
||||
let location = *location;
|
||||
if let Err(err) = self.add_single_statement(kind, location, &scope_stack) {
|
||||
if let Err(err) = self.add_single_statement(kind, location, scope_stack) {
|
||||
errors.push(err);
|
||||
} else { // If there's an error with a name, don't recurse into subscopes of that name
|
||||
let recursive_errs = match kind {
|
||||
@ -260,10 +260,10 @@ impl SymbolTable {
|
||||
errors
|
||||
}
|
||||
|
||||
fn add_single_statement(&mut self, kind: &StatementKind, location: Location, scope_stack: &Vec<Scope>) -> Result<(), SymbolError> {
|
||||
fn add_single_statement(&mut self, kind: &StatementKind, location: Location, scope_stack: &[Scope]) -> Result<(), SymbolError> {
|
||||
match kind {
|
||||
StatementKind::Declaration(Declaration::FuncSig(signature)) => {
|
||||
let fq_function = Fqsn::from_scope_stack(scope_stack.as_ref(), signature.name.clone());
|
||||
let fq_function = Fqsn::from_scope_stack(scope_stack, signature.name.clone());
|
||||
self.fq_names.register(fq_function.clone(), NameSpec { location, kind: NameKind::Function })?;
|
||||
self.types.register(fq_function.clone(), NameSpec { location, kind: TypeKind } )?;
|
||||
|
||||
@ -274,7 +274,7 @@ impl SymbolTable {
|
||||
}
|
||||
StatementKind::Declaration(Declaration::FuncDecl(signature, ..)) => {
|
||||
let fn_name = &signature.name;
|
||||
let fq_function = Fqsn::from_scope_stack(scope_stack.as_ref(), fn_name.clone());
|
||||
let fq_function = Fqsn::from_scope_stack(scope_stack, fn_name.clone());
|
||||
self.fq_names.register(fq_function.clone(), NameSpec { location, kind: NameKind::Function })?;
|
||||
self.types.register(fq_function.clone(), NameSpec { location, kind: TypeKind } )?;
|
||||
|
||||
@ -284,11 +284,11 @@ impl SymbolTable {
|
||||
});
|
||||
},
|
||||
StatementKind::Declaration(Declaration::TypeDecl { name, .. }) => {
|
||||
let fq_type = Fqsn::from_scope_stack(scope_stack.as_ref(), name.name.clone());
|
||||
let fq_type = Fqsn::from_scope_stack(scope_stack, name.name.clone());
|
||||
self.types.register(fq_type, NameSpec { location, kind: TypeKind } )?;
|
||||
},
|
||||
StatementKind::Declaration(Declaration::Binding { name, .. }) => {
|
||||
let fq_binding = Fqsn::from_scope_stack(scope_stack.as_ref(), name.clone());
|
||||
let fq_binding = Fqsn::from_scope_stack(scope_stack, name.clone());
|
||||
self.fq_names.register(fq_binding.clone(), NameSpec { location, kind: NameKind::Binding })?;
|
||||
self.add_symbol(fq_binding, Symbol {
|
||||
local_name: name.clone(),
|
||||
@ -296,7 +296,7 @@ impl SymbolTable {
|
||||
});
|
||||
}
|
||||
StatementKind::Module(ModuleSpecifier { name, .. }) => {
|
||||
let fq_module = Fqsn::from_scope_stack(scope_stack.as_ref(), name.clone());
|
||||
let fq_module = Fqsn::from_scope_stack(scope_stack, name.clone());
|
||||
self.fq_names.register(fq_module, NameSpec { location, kind: NameKind::Module })?;
|
||||
},
|
||||
_ => (),
|
||||
|
@ -88,12 +88,12 @@ impl<'a> ASTVisitor for Resolver<'a> {
|
||||
}
|
||||
|
||||
fn qualified_name(&mut self, qualified_name: &QualifiedName) {
|
||||
let fqsn = self.lookup_name_in_scope(&qualified_name);
|
||||
let fqsn = self.lookup_name_in_scope(qualified_name);
|
||||
self.symbol_table.id_to_fqsn.insert(qualified_name.id.clone(), fqsn);
|
||||
}
|
||||
|
||||
fn named_struct(&mut self, qualified_name: &QualifiedName, _fields: &Vec<(Rc<String>, Expression)>) {
|
||||
let fqsn = self.lookup_name_in_scope(&qualified_name);
|
||||
let fqsn = self.lookup_name_in_scope(qualified_name);
|
||||
self.symbol_table.id_to_fqsn.insert(qualified_name.id.clone(), fqsn);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ impl SymbolTrie {
|
||||
Some(s) => s,
|
||||
None => return vec![]
|
||||
};
|
||||
let output: Vec<Fqsn> = subtrie.keys().filter(|cur_key| **cur_key != *fqsn).map(|fqsn| fqsn.clone()).collect();
|
||||
let output: Vec<Fqsn> = subtrie.keys().filter(|cur_key| **cur_key != *fqsn).cloned().collect();
|
||||
output
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user