diff --git a/CHANGELOG.md b/CHANGELOG.md index d92fdf8..a762d41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ correctly parsed. - You can now annotate dml source to disable reporting of specific lints for specific files or lines, see [USAGE.md](USAGE.md) for instructions on how to use it +- Disabled the invariant check for the parameter 'size' to be set on register + objects. Will be re-enabled when constant-folding is added to the DLS. +- Fixed issue where statements under top-level in-eachs were not correctly tracked. +- Moved storage of reference->symbol mapping to on-demand timing, should significantly speed + up device analysises ## 0.9.12 - Added 'simics\_util\_vect' as a known provisional (with no DLS semantics) diff --git a/src/actions/requests.rs b/src/actions/requests.rs index ff699cb..75df0cf 100644 --- a/src/actions/requests.rs +++ b/src/actions/requests.rs @@ -8,7 +8,6 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashSet; use std::path::Path; -use std::sync::Arc; use crate::actions::hover; use crate::actions::{AnalysisProgressKind, AnalysisWaitKind, @@ -192,7 +191,6 @@ fn fp_to_symbol_refs for device in analysis.filtered_device_analysises_containing_file( &canon_path, filter.as_ref()) { - debug!("reference info is {:?}", device.reference_info.keys()); // NOTE: This ends up being the correct place to warn users // about references inside uninstantiated templates, // but we have to perform some extra work to find out we are @@ -206,12 +204,9 @@ fn fp_to_symbol_refs any_template_used = true; } } - if let Some(defs) = device.reference_info.get( - refr.loc_span()) { - for def in defs { - definitions.push(Arc::clone(def)); - } - } + + definitions.append( + &mut device.symbols_of_ref(*refr.loc_span())); } if let Some(ContextKey::Template(_)) = first_context { if !any_template_used { diff --git a/src/analysis/mod.rs b/src/analysis/mod.rs index 75caca0..9dd2155 100644 --- a/src/analysis/mod.rs +++ b/src/analysis/mod.rs @@ -376,9 +376,19 @@ pub struct SymbolStorage { pub variable_symbols: HashMap, } -// This maps non-auth symbol decls to auth decl -// and references to the symbol decl they ref -type ReferenceStorage = HashMap>; +impl SymbolStorage { + pub fn all_symbols<'a>(&'a self) -> impl Iterator { + self.template_symbols.values() + .chain(self.param_symbols.values().flat_map(|h|h.values())) + .chain(self.object_symbols.values()) + .chain(self.method_symbols.values()) + .chain(self.variable_symbols.values()) + } +} + +// This maps references to the symbol they reference, made as a lock +// because we need to incrementally fill it as requests are made +type ReferenceStorage = Arc>>>; // Analysis from the perspective of a particular DML device #[derive(Debug, Clone)] @@ -1356,7 +1366,7 @@ impl DeviceAnalysis { ReferenceMatch::Found(symbols) => for symbol in &symbols { let mut sym = symbol.lock().unwrap(); - sym.references.push(*reference.loc_span()); + sym.references.insert(*reference.loc_span()); if let Some(meth) = sym.source .as_object() .and_then(DMLObject::as_shallow) @@ -1622,7 +1632,7 @@ fn template_to_symbol(template: &Arc) -> Option { Arc::new(Mutex::new(Symbol { loc: *location, kind: DMLSymbolKind::Template, - references: vec![], + references: HashSet::default(), definitions: vec![*location], declarations: vec![*location], implementations: vec![], @@ -1659,7 +1669,7 @@ fn new_symbol_from_object(object: &DMLCompositeObject) -> SymbolRef { definitions: all_decl_defs.clone(), declarations: all_decl_defs.clone(), bases: all_decl_defs, - references: vec![], + references: HashSet::default(), implementations: vec![], source: SymbolSource::DMLObject( DMLObject::CompObject(object.key)), @@ -1679,7 +1689,7 @@ fn new_symbol_from_arg(methref: &Arc, bases, definitions, declarations, - references: vec![], + references: HashSet::default(), implementations: vec![], source: SymbolSource::MethodArg(Arc::clone(methref), arg.name().clone()), @@ -1752,7 +1762,7 @@ fn add_new_symbol_from_shallow(shallow: &DMLShallowObject, definitions, declarations, implementations: vec![], - references: vec![], + references: HashSet::default(), bases, source: SymbolSource::DMLObject( // TODO: Inefficient clone. Not terribly so, but worth @@ -1834,7 +1844,7 @@ where definitions: vec![*sym.loc_span()], declarations: vec![*sym.loc_span()], implementations: vec![], - references: vec![], + references: HashSet::default(), bases: vec![], source: SymbolSource::MethodLocal( Arc::clone(method), @@ -2028,7 +2038,68 @@ fn add_new_method_scope_symbols(method: &Arc, } } + impl DeviceAnalysis { + fn make_templates_traits(start_of_file: &ZeroSpan, + rank_maker: &mut RankMaker, + unique_templates: &HashMap< + &str, &ObjectDecl