Emit port declarations

This commit is contained in:
Nick Gasson 2008-06-09 16:37:05 +01:00
parent 3106fe0ed6
commit 1fb01d4d98
2 changed files with 12 additions and 5 deletions

View File

@ -27,16 +27,19 @@
template <class T> template <class T>
void emit_children(std::ofstream &of, void emit_children(std::ofstream &of,
const std::list<T*> &children, const std::list<T*> &children,
int level) int level, const char *delim="")
{ {
// Don't indent if there are no children // Don't indent if there are no children
if (children.size() == 0) if (children.size() == 0)
newline(of, level); newline(of, level);
else { else {
typename std::list<T*>::const_iterator it; typename std::list<T*>::const_iterator it;
int sz = children.size();
for (it = children.begin(); it != children.end(); ++it) { for (it = children.begin(); it != children.end(); ++it) {
newline(of, indent(level)); newline(of, indent(level));
(*it)->emit(of, indent(level)); (*it)->emit(of, indent(level));
if (--sz > 0)
of << delim;
} }
newline(of, level); newline(of, level);
} }

View File

@ -85,8 +85,14 @@ void vhdl_entity::emit(std::ofstream &of, int level) const
emit_comment(of, level); emit_comment(of, level);
of << "entity " << name_ << " is"; of << "entity " << name_ << " is";
// ...ports...
// newline(indent(level)); if (ports_.size() > 0) {
newline(of, indent(level));
of << "port (";
emit_children<vhdl_decl>(of, ports_, indent(level), ";");
of << ");";
}
newline(of, level); newline(of, level);
of << "end entity; "; of << "end entity; ";
blank_line(of, level); // Extra blank line after entities blank_line(of, level); // Extra blank line after entities
@ -332,8 +338,6 @@ void vhdl_port_decl::emit(std::ofstream &of, int level) const
} }
type_->emit(of, level); type_->emit(of, level);
of << ";";
emit_comment(of, level, true);
} }
void vhdl_var_decl::emit(std::ofstream &of, int level) const void vhdl_var_decl::emit(std::ofstream &of, int level) const