More robust Nexus::name() method.

This version handles some error conditions.
This commit is contained in:
Stephen Williams 2014-07-18 20:16:17 -07:00
parent 6bc3f98e0a
commit cb381b3ee3
1 changed files with 17 additions and 9 deletions

View File

@ -514,16 +514,24 @@ const char* Nexus::name() const
<< obj->name() << " pin " << pin << obj->name() << " pin " << pin
<< " type=" << typeid(*obj).name() << "?" << endl; << " type=" << typeid(*obj).name() << "?" << endl;
} ostringstream tmp;
assert(sig); tmp << "nex=" << this << ends;
ostringstream tmp; const string tmps = tmp.str();
tmp << scope_path(sig->scope()) << "." << sig->name(); name_ = new char[strlen(tmps.c_str()) + 1];
if (sig->pin_count() > 1) strcpy(name_, tmps.c_str());
tmp << "<" << pin << ">"; } else {
assert(sig);
ostringstream tmp;
tmp << scope_path(sig->scope()) << "." << sig->name();
if (sig->pin_count() > 1)
tmp << "<" << pin << ">";
tmp << ends;
const string tmps = tmp.str();
name_ = new char[strlen(tmps.c_str()) + 1];
strcpy(name_, tmps.c_str());
}
const string tmps = tmp.str();
name_ = new char[strlen(tmps.c_str()) + 1];
strcpy(name_, tmps.c_str());
return name_; return name_;
} }