Move some VType::show methods to ::write_to_stream methods.
This commit is contained in:
parent
9ed56a6354
commit
79435924f2
|
|
@ -180,12 +180,7 @@ VTypeRecord::~VTypeRecord()
|
|||
|
||||
void VTypeRecord::show(ostream&out) const
|
||||
{
|
||||
out << "record ";
|
||||
for (size_t idx = 0 ; idx < elements_.size() ; idx += 1) {
|
||||
elements_[idx]->show(out);
|
||||
out << "; ";
|
||||
}
|
||||
out << "endrecord";
|
||||
write_to_stream(out);
|
||||
}
|
||||
|
||||
VTypeRecord::element_t::element_t(perm_string name, const VType*typ)
|
||||
|
|
@ -193,12 +188,6 @@ VTypeRecord::element_t::element_t(perm_string name, const VType*typ)
|
|||
{
|
||||
}
|
||||
|
||||
void VTypeRecord::element_t::show(ostream&out) const
|
||||
{
|
||||
out << name_ << ":";
|
||||
type_->show(out);
|
||||
}
|
||||
|
||||
VTypeDef::VTypeDef(perm_string nam, const VType*typ)
|
||||
: name_(nam), type_(typ)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -173,6 +173,8 @@ class VTypeRange : public VType {
|
|||
VTypeRange(const VType*base, int64_t max_val, int64_t min_val);
|
||||
~VTypeRange();
|
||||
|
||||
void write_to_stream(std::ostream&fd) const;
|
||||
|
||||
int emit_def(std::ostream&out, perm_string name) const;
|
||||
private:
|
||||
int emit_decl(std::ostream&out, perm_string name, bool reg_flag) const;
|
||||
|
|
@ -205,7 +207,7 @@ class VTypeRecord : public VType {
|
|||
public:
|
||||
element_t(perm_string name, const VType*type);
|
||||
|
||||
void show(std::ostream&) const;
|
||||
void write_to_stream(std::ostream&) const;
|
||||
|
||||
private:
|
||||
perm_string name_;
|
||||
|
|
@ -220,6 +222,7 @@ class VTypeRecord : public VType {
|
|||
explicit VTypeRecord(std::list<element_t*>*elements);
|
||||
~VTypeRecord();
|
||||
|
||||
void write_to_stream(std::ostream&fd) const;
|
||||
void show(std::ostream&) const;
|
||||
|
||||
int emit_def(std::ostream&out, perm_string name) const;
|
||||
|
|
|
|||
|
|
@ -37,9 +37,15 @@ void VTypeArray::write_to_stream(ostream&fd) const
|
|||
if (! ranges_.empty()) {
|
||||
assert(ranges_.size() < 2);
|
||||
fd << " (";
|
||||
ranges_[0].msb()->write_to_stream(fd);
|
||||
if (ranges_[0].msb())
|
||||
ranges_[0].msb()->write_to_stream(fd);
|
||||
else
|
||||
fd << "<>";
|
||||
fd << " downto ";
|
||||
ranges_[0].lsb()->write_to_stream(fd);
|
||||
if (ranges_[0].lsb())
|
||||
ranges_[0].lsb()->write_to_stream(fd);
|
||||
else
|
||||
fd << "<>";
|
||||
fd << ") ";
|
||||
}
|
||||
return;
|
||||
|
|
@ -48,11 +54,22 @@ void VTypeArray::write_to_stream(ostream&fd) const
|
|||
fd << "array ";
|
||||
if (! ranges_.empty()) {
|
||||
assert(ranges_.size() < 2);
|
||||
fd << "(";
|
||||
ranges_[0].msb()->write_to_stream(fd);
|
||||
fd << " downto ";
|
||||
ranges_[0].lsb()->write_to_stream(fd);
|
||||
fd << ") ";
|
||||
if (ranges_[0].is_box()) {
|
||||
fd << "(INTEGER range <>) ";
|
||||
} else {
|
||||
assert(ranges_[0].msb() && ranges_[0].lsb());
|
||||
fd << "(";
|
||||
if (ranges_[0].msb())
|
||||
ranges_[0].msb()->write_to_stream(fd);
|
||||
else
|
||||
fd << "<>";
|
||||
fd << " downto ";
|
||||
if (ranges_[0].lsb())
|
||||
ranges_[0].lsb()->write_to_stream(fd);
|
||||
else
|
||||
fd << "<>";
|
||||
fd << ") ";
|
||||
}
|
||||
}
|
||||
|
||||
fd << "of ";
|
||||
|
|
@ -71,9 +88,33 @@ void VTypePrimitive::write_to_stream(ostream&fd) const
|
|||
case STDLOGIC:
|
||||
fd << "std_logic";
|
||||
break;
|
||||
case BOOLEAN:
|
||||
fd << "boolean";
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
fd << "/* PRIMITIVE: " << type_ << " */";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void VTypeRange::write_to_stream(ostream&fd) const
|
||||
{
|
||||
fd << "range " << min_ << " to " << max_;
|
||||
}
|
||||
|
||||
void VTypeRecord::write_to_stream(ostream&fd) const
|
||||
{
|
||||
fd << "record ";
|
||||
for (size_t idx = 0 ; idx < elements_.size() ; idx += 1) {
|
||||
elements_[idx]->write_to_stream(fd);
|
||||
fd << "; ";
|
||||
}
|
||||
fd << "endrecord";
|
||||
}
|
||||
|
||||
void VTypeRecord::element_t::write_to_stream(ostream&fd) const
|
||||
{
|
||||
fd << name_ << ":";
|
||||
type_->write_to_stream(fd);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue