diff --git a/src/main.rs b/src/main.rs index 62f5bf1..c3e3fa0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -305,28 +305,31 @@ fn main() -> Result<(), Error> { let id = unwrap_node!(x, SimpleIdentifier).unwrap(); pickle.register_declaration(&syntax_tree, id); } - // Instantiations, end-labels. - RefNode::ModuleIdentifier(x) => { + // Interface Declaration. + RefNode::InterfaceDeclaration(x) => { let id = unwrap_node!(x, SimpleIdentifier).unwrap(); - // an instantiation is potentially also a declaration (order doesn't matter) pickle.register_declaration(&syntax_tree, id); - let id = unwrap_node!(x, SimpleIdentifier).unwrap(); - pickle.register_usage(&syntax_tree, id); } - // Interface Declaration. - RefNode::InterfaceDeclaration(x) => { + // Package declarations. + RefNode::PackageDeclaration(x) => { let id = unwrap_node!(x, SimpleIdentifier).unwrap(); pickle.register_declaration(&syntax_tree, id); } - // Interface identifier. - RefNode::InterfaceIdentifier(x) => { + _ => (), + } + } + // Iterate again and check for usage + for node in &syntax_tree { + match node { + // Instantiations, end-labels. + RefNode::ModuleIdentifier(x) => { let id = unwrap_node!(x, SimpleIdentifier).unwrap(); pickle.register_usage(&syntax_tree, id); } - // Package declarations. - RefNode::PackageDeclaration(x) => { + // Interface identifier. + RefNode::InterfaceIdentifier(x) => { let id = unwrap_node!(x, SimpleIdentifier).unwrap(); - pickle.register_declaration(&syntax_tree, id); + pickle.register_usage(&syntax_tree, id); } // Package Qualifier (i.e., explicit package constants). RefNode::ClassScope(x) => { diff --git a/test/modules.sv b/test/modules.sv index d0ca5d7..1308af6 100644 --- a/test/modules.sv +++ b/test/modules.sv @@ -1,10 +1,12 @@ module module_1; module_2 i_module_2(); + module_external i_external_module(); endmodule module module_2 #(); endmodule +// Another one bites the dust. module /* test */ module_3 #()( input clk_i );