diff --git a/vhdlpp/subprogram.cc b/vhdlpp/subprogram.cc index 56d07a599..c5b6d9ee0 100644 --- a/vhdlpp/subprogram.cc +++ b/vhdlpp/subprogram.cc @@ -308,3 +308,39 @@ void Subprogram::write_to_stream(ostream&fd) const return_type_->write_to_stream(fd); fd << ";" << endl; } + +void Subprogram::write_to_stream_body(ostream&fd) const +{ + fd << "function " << name_ << "("; + if (ports_ && ! ports_->empty()) { + list::const_iterator cur = ports_->begin(); + InterfacePort*curp = *cur; + fd << curp->name << " : "; + curp->type->write_to_stream(fd); + for (++cur ; cur != ports_->end() ; ++cur) { + curp = *cur; + fd << "; " << curp->name << " : "; + curp->type->write_to_stream(fd); + } + } + fd << ") return "; + return_type_->write_to_stream(fd); + fd << " is" << endl; + + for (map::const_iterator cur = new_variables_.begin() + ; cur != new_variables_.end() ; ++cur) { + cur->second->write_to_stream(fd); + } + + fd << "begin" << endl; + + if (statements_) { + for (list::const_iterator cur = statements_->begin() + ; cur != statements_->end() ; ++cur) { + (*cur)->write_to_stream(fd); + } + } else { + fd << "--empty body" << endl; + } + fd << "end function;" << endl; +} diff --git a/vhdlpp/subprogram.h b/vhdlpp/subprogram.h index bba9c757f..5af77244d 100644 --- a/vhdlpp/subprogram.h +++ b/vhdlpp/subprogram.h @@ -61,6 +61,7 @@ class Subprogram : public LineInfo, public ScopeBase { int emit_package(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const; + void write_to_stream_body(std::ostream&fd) const; void dump(std::ostream&fd) const; // Creates a new instance of the function that takes arguments of