vhdlpp: Added VType::emit_name() that skips emission of a name if it is empty (otherwise '\' is outputted).
This commit is contained in:
parent
150fe088a6
commit
b0c79d5d1c
|
|
@ -103,6 +103,12 @@ class VType {
|
||||||
bool reg_flag;
|
bool reg_flag;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
inline void emit_name(std::ostream&out, perm_string name) const
|
||||||
|
{
|
||||||
|
if(name != empty_perm_string)
|
||||||
|
out << " \\" << name << " ";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::ostream&operator << (std::ostream&out, const VType&item)
|
inline std::ostream&operator << (std::ostream&out, const VType&item)
|
||||||
|
|
|
||||||
|
|
@ -67,26 +67,22 @@ int VTypeArray::emit_def(ostream&out, perm_string name) const
|
||||||
|
|
||||||
const VType*raw_base = cur->etype_;
|
const VType*raw_base = cur->etype_;
|
||||||
const VTypePrimitive*base = dynamic_cast<const VTypePrimitive*> (raw_base);
|
const VTypePrimitive*base = dynamic_cast<const VTypePrimitive*> (raw_base);
|
||||||
stringstream buf;
|
|
||||||
|
|
||||||
if (base) {
|
if (base) {
|
||||||
assert(dimensions() == 1);
|
assert(dimensions() == 1);
|
||||||
|
|
||||||
base->emit_def(buf, empty_perm_string);
|
base->emit_def(out, empty_perm_string);
|
||||||
if (signed_flag_)
|
if (signed_flag_)
|
||||||
buf << " signed";
|
out << " signed";
|
||||||
} else {
|
} else {
|
||||||
raw_base->emit_def(buf, empty_perm_string);
|
raw_base->emit_def(out, empty_perm_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
string tmp(buf.str());
|
|
||||||
out << tmp.substr(0, tmp.length() - 2); // drop the empty type name (\ )
|
|
||||||
|
|
||||||
if(raw_base->can_be_packed()) {
|
if(raw_base->can_be_packed()) {
|
||||||
errors += emit_dimensions(out);
|
errors += emit_dimensions(out);
|
||||||
out << " \\" << name;
|
emit_name(out, name);
|
||||||
} else {
|
} else {
|
||||||
out << "\\" << name << " ";
|
emit_name(out, name);
|
||||||
errors += emit_dimensions(out);
|
errors += emit_dimensions(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,7 +132,8 @@ int VTypeEnum::emit_def(ostream&out, perm_string name) const
|
||||||
for (size_t idx = 1 ; idx < names_.size() ; idx += 1)
|
for (size_t idx = 1 ; idx < names_.size() ; idx += 1)
|
||||||
out << ", \\" << names_[idx] << " ";
|
out << ", \\" << names_[idx] << " ";
|
||||||
|
|
||||||
out << "} \\" << name << " ";
|
out << "}";
|
||||||
|
emit_name(out, name);
|
||||||
|
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
@ -172,7 +169,7 @@ int VTypePrimitive::emit_def(ostream&out, perm_string name) const
|
||||||
{
|
{
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
errors += emit_primitive_type(out);
|
errors += emit_primitive_type(out);
|
||||||
out << " \\" << name << " ";
|
emit_name(out, name);
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,7 +194,8 @@ int VTypeRecord::emit_def(ostream&out, perm_string name) const
|
||||||
out << " \\" << element_name << " ; ";
|
out << " \\" << element_name << " ; ";
|
||||||
}
|
}
|
||||||
|
|
||||||
out << "} \\ " << name << " ";
|
out << "}";
|
||||||
|
emit_name(out, name);
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,7 +207,7 @@ int VTypeRecord::emit_def(ostream&out, perm_string name) const
|
||||||
int VTypeDef::emit_def(ostream&out, perm_string) const
|
int VTypeDef::emit_def(ostream&out, perm_string) const
|
||||||
{
|
{
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
out << "\\" << name_ << " ";
|
emit_name(out, name_);
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -222,7 +220,6 @@ int VTypeDef::emit_decl(ostream&out, perm_string name, bool reg_flag) const
|
||||||
out << "wire ";
|
out << "wire ";
|
||||||
|
|
||||||
errors += type_->emit_def(out, name);
|
errors += type_->emit_def(out, name);
|
||||||
out << " \\" << name << " ";
|
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue