Emit class definitions after ALL scopes are scanned.

This commit is contained in:
Stephen Williams 2014-09-06 17:39:52 -07:00
parent 88e951418b
commit 8bb1d3dabe
2 changed files with 15 additions and 2 deletions

16
emit.cc
View File

@ -409,14 +409,13 @@ void NetRepeat::emit_recurse(struct target_t*tgt) const
void netclass_t::emit_scope(struct target_t*tgt) const
{
class_scope_->emit_scope(tgt);
class_scope_->emit_defs(tgt);
}
void NetScope::emit_scope(struct target_t*tgt) const
{
if (debug_emit) {
cerr << "NetScope::emit_scope: "
<< "Emit scope basename=" << basename() << endl;
<< "Emit scope " << scope_path(this) << endl;
}
tgt->scope(this);
@ -461,12 +460,20 @@ bool NetScope::emit_defs(struct target_t*tgt) const
{
bool flag = true;
if (debug_emit) {
cerr << "NetScope::emit_defs: "
<< "Emit definitions for " << scope_path(this) << endl;
}
switch (type_) {
case PACKAGE:
case MODULE:
for (map<hname_t,NetScope*>::const_iterator cur = children_.begin()
; cur != children_.end() ; ++ cur )
flag &= cur->second->emit_defs(tgt);
for (map<perm_string,netclass_t*>::const_iterator cur = classes_.begin()
; cur != classes_.end() ; ++ cur)
flag &= cur->second->emit_defs(tgt);
break;
case FUNC:
@ -485,6 +492,11 @@ bool NetScope::emit_defs(struct target_t*tgt) const
return flag;
}
bool netclass_t::emit_defs(struct target_t*tgt) const
{
return class_scope_->emit_defs(tgt);
}
int Design::emit(struct target_t*tgt) const
{
int rc = 0;

View File

@ -105,6 +105,7 @@ class netclass_t : public ivl_type_s {
void elaborate(Design*des, PClass*pclass);
void emit_scope(struct target_t*tgt) const;
bool emit_defs(struct target_t*tgt) const;
void dump_scope(ostream&fd) const;