Fix search for class imported from another package (issue #437).

This commit is contained in:
Martin Whitaker 2020-12-23 19:16:14 +00:00
parent 71843a66f8
commit a019994513
5 changed files with 14 additions and 9 deletions

View File

@ -468,7 +468,7 @@ static void elaborate_scope_class(Design*des, NetScope*scope, PClass*pclass)
netclass_t*use_base_class = 0;
if (base_class) {
use_base_class = scope->find_class(base_class->name);
use_base_class = scope->find_class(des, base_class->name);
if (use_base_class == 0) {
cerr << pclass->get_fileline() << ": error: "
<< "Base class " << base_class->name

View File

@ -198,7 +198,7 @@ static void elaborate_sig_classes(Design*des, NetScope*scope,
{
for (map<perm_string,PClass*>::const_iterator cur = classes.begin()
; cur != classes.end() ; ++ cur) {
netclass_t*use_class = scope->find_class(cur->second->pscope_name());
netclass_t*use_class = scope->find_class(des, cur->second->pscope_name());
use_class->elaborate_sig(des, cur->second);
}
}

View File

@ -6003,7 +6003,7 @@ static void elaborate_classes(Design*des, NetScope*scope,
{
for (map<perm_string,PClass*>::const_iterator cur = classes.begin()
; cur != classes.end() ; ++ cur) {
netclass_t*use_class = scope->find_class(cur->second->pscope_name());
netclass_t*use_class = scope->find_class(des, cur->second->pscope_name());
use_class->elaborate(des, cur->second);
if (use_class->test_for_missing_initializers()) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2019 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2020 Stephen Williams (steve@icarus.com)
* Copyright (c) 2016 CERN Michele Castellana (michele.castellana@cern.ch)
*
* This source code is free software; you can redistribute it
@ -702,7 +702,7 @@ NetNet* NetScope::find_signal(perm_string key)
return 0;
}
netclass_t*NetScope::find_class(perm_string name)
netclass_t*NetScope::find_class(const Design*des, perm_string name)
{
// Special case: The scope itself is the class that we are
// looking for. This may happen for example when elaborating
@ -715,20 +715,25 @@ netclass_t*NetScope::find_class(perm_string name)
if (cur != classes_.end())
return cur->second;
// Try the imports.
NetScope*import_scope = find_import(des, name);
if (import_scope)
return import_scope->find_class(des, name);
if (up_==0 && type_==CLASS) {
assert(class_def_);
NetScope*def_parent = class_def_->definition_scope();
return def_parent->find_class(name);
return def_parent->find_class(des, name);
}
// Try looking up for the class.
if (up_!=0 && type_!=MODULE)
return up_->find_class(name);
return up_->find_class(des, name);
// Try the compilation unit.
if (unit_ != 0)
return unit_->find_class(name);
return unit_->find_class(des, name);
// Nowhere left to try...
return 0;

View File

@ -1015,7 +1015,7 @@ class NetScope : public Definitions, public Attrib {
void rem_signal(NetNet*);
NetNet* find_signal(perm_string name);
netclass_t* find_class(perm_string name);
netclass_t* find_class(const Design*des, perm_string name);
/* The unit(), parent(), and child() methods allow users of
NetScope objects to locate nearby scopes. */