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
|
void VTypeRecord::show(ostream&out) const
|
||||||
{
|
{
|
||||||
out << "record ";
|
write_to_stream(out);
|
||||||
for (size_t idx = 0 ; idx < elements_.size() ; idx += 1) {
|
|
||||||
elements_[idx]->show(out);
|
|
||||||
out << "; ";
|
|
||||||
}
|
|
||||||
out << "endrecord";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VTypeRecord::element_t::element_t(perm_string name, const VType*typ)
|
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)
|
VTypeDef::VTypeDef(perm_string nam, const VType*typ)
|
||||||
: name_(nam), type_(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(const VType*base, int64_t max_val, int64_t min_val);
|
||||||
~VTypeRange();
|
~VTypeRange();
|
||||||
|
|
||||||
|
void write_to_stream(std::ostream&fd) const;
|
||||||
|
|
||||||
int emit_def(std::ostream&out, perm_string name) const;
|
int emit_def(std::ostream&out, perm_string name) const;
|
||||||
private:
|
private:
|
||||||
int emit_decl(std::ostream&out, perm_string name, bool reg_flag) const;
|
int emit_decl(std::ostream&out, perm_string name, bool reg_flag) const;
|
||||||
|
|
@ -205,7 +207,7 @@ class VTypeRecord : public VType {
|
||||||
public:
|
public:
|
||||||
element_t(perm_string name, const VType*type);
|
element_t(perm_string name, const VType*type);
|
||||||
|
|
||||||
void show(std::ostream&) const;
|
void write_to_stream(std::ostream&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
perm_string name_;
|
perm_string name_;
|
||||||
|
|
@ -220,6 +222,7 @@ class VTypeRecord : public VType {
|
||||||
explicit VTypeRecord(std::list<element_t*>*elements);
|
explicit VTypeRecord(std::list<element_t*>*elements);
|
||||||
~VTypeRecord();
|
~VTypeRecord();
|
||||||
|
|
||||||
|
void write_to_stream(std::ostream&fd) const;
|
||||||
void show(std::ostream&) const;
|
void show(std::ostream&) const;
|
||||||
|
|
||||||
int emit_def(std::ostream&out, perm_string name) 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()) {
|
if (! ranges_.empty()) {
|
||||||
assert(ranges_.size() < 2);
|
assert(ranges_.size() < 2);
|
||||||
fd << " (";
|
fd << " (";
|
||||||
ranges_[0].msb()->write_to_stream(fd);
|
if (ranges_[0].msb())
|
||||||
|
ranges_[0].msb()->write_to_stream(fd);
|
||||||
|
else
|
||||||
|
fd << "<>";
|
||||||
fd << " downto ";
|
fd << " downto ";
|
||||||
ranges_[0].lsb()->write_to_stream(fd);
|
if (ranges_[0].lsb())
|
||||||
|
ranges_[0].lsb()->write_to_stream(fd);
|
||||||
|
else
|
||||||
|
fd << "<>";
|
||||||
fd << ") ";
|
fd << ") ";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -48,11 +54,22 @@ void VTypeArray::write_to_stream(ostream&fd) const
|
||||||
fd << "array ";
|
fd << "array ";
|
||||||
if (! ranges_.empty()) {
|
if (! ranges_.empty()) {
|
||||||
assert(ranges_.size() < 2);
|
assert(ranges_.size() < 2);
|
||||||
fd << "(";
|
if (ranges_[0].is_box()) {
|
||||||
ranges_[0].msb()->write_to_stream(fd);
|
fd << "(INTEGER range <>) ";
|
||||||
fd << " downto ";
|
} else {
|
||||||
ranges_[0].lsb()->write_to_stream(fd);
|
assert(ranges_[0].msb() && ranges_[0].lsb());
|
||||||
fd << ") ";
|
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 ";
|
fd << "of ";
|
||||||
|
|
@ -71,9 +88,33 @@ void VTypePrimitive::write_to_stream(ostream&fd) const
|
||||||
case STDLOGIC:
|
case STDLOGIC:
|
||||||
fd << "std_logic";
|
fd << "std_logic";
|
||||||
break;
|
break;
|
||||||
|
case BOOLEAN:
|
||||||
|
fd << "boolean";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
fd << "/* PRIMITIVE: " << type_ << " */";
|
fd << "/* PRIMITIVE: " << type_ << " */";
|
||||||
break;
|
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