Commit 279077f9 authored by rmrf's avatar rmrf

Clean up template parameters printing

parent edc9e2a4
...@@ -96,23 +96,19 @@ namespace scpar { ...@@ -96,23 +96,19 @@ namespace scpar {
return template_types_; return template_types_;
} }
void printTemplateArguments( llvm::raw_ostream &os, int tabn = 0 ) { void printTemplateArguments( llvm::raw_ostream &os ) {
vector < string > template_arguments; //{ getTemplateArguments() }; vector < string > template_arguments;
// type_vector_t::iterator
// for (auto mit = template_types_.begin(); mit != template_types_.end(); mit++) {
for ( auto const &mit: template_types_ ) { for ( auto const &mit: template_types_ ) {
for ( auto i{0}; i < tabn; ++i) { //os << "\n port type: " << mit.first << " ";
os << " "; //<< ", type ptr: " << mit.second;
} //os << "\n";
os << "- " << mit.first << ", type ptr: " << mit.second;
os << "\n";
template_arguments.push_back( mit.first ); template_arguments.push_back( mit.first );
} }
// Print the template arguments to the output stream // Print the template arguments to the output stream
os << "= "; os << ", " << template_arguments.size() << " arguments, ";
for ( auto const &targ: template_arguments ) { for ( auto const &targ: template_arguments ) {
os << targ << " "; os << targ << " ";
} }
} }
......
...@@ -53,5 +53,5 @@ void InterfaceDecl::dump(raw_ostream & os, int tabn) ...@@ -53,5 +53,5 @@ void InterfaceDecl::dump(raw_ostream & os, int tabn)
} }
os << "InterfaceDecl " << this << " '" << _name << "' FindTemplateTypes " << os << "InterfaceDecl " << this << " '" << _name << "' FindTemplateTypes " <<
_templateType; _templateType;
_templateType->printTemplateArguments(os, 1); _templateType->printTemplateArguments(os );
} }
...@@ -5,41 +5,42 @@ using namespace scpar; ...@@ -5,41 +5,42 @@ using namespace scpar;
using namespace std; using namespace std;
PortDecl::~PortDecl() { PortDecl::~PortDecl() {
if ( _templateType != nullptr ) { if ( template_type_ != nullptr ) {
delete _templateType; delete template_type_;
} }
} }
PortDecl::PortDecl():_name{"NONE"}, _templateType{nullptr} { PortDecl::PortDecl() :
port_name_{ "NONE" },
template_type_{ nullptr } {
} }
PortDecl::PortDecl(const string &name, FindTemplateTypes *tt):_name{name}, _templateType{tt} { PortDecl::PortDecl( const string &name, FindTemplateTypes *tt ) :
port_name_{ name },
template_type_{ tt } {
} }
PortDecl::PortDecl(const PortDecl &from) { PortDecl::PortDecl( const PortDecl &from ) {
_name = from._name; port_name_ = from.port_name_;
// This is necessary to allow FindPorts to go out of scope. // This is necessary to allow FindPorts to go out of scope.
_templateType = new FindTemplateTypes(*from._templateType); template_type_ = new FindTemplateTypes{ *from.template_type_ };
} }
void PortDecl::setModuleName(const string &name) { void PortDecl::setModuleName( const string &name ) {
_name = name; port_name_ = name;
} }
string PortDecl::getName() const { string PortDecl::getName() const {
return _name; return port_name_;
} }
FindTemplateTypes *PortDecl::getTemplateType() { FindTemplateTypes *PortDecl::getTemplateType() {
return _templateType; return template_type_;
} }
void PortDecl::dump(raw_ostream & os, int tabn) { void PortDecl::dump( llvm::raw_ostream & os, int tabn ) {
for ( auto i = 0; i < tabn; ++i ) { //os << "PortDecl " << this << " '" << port_name_ << "' FindTemplateTypes " << template_type_;
os << " "; os << "Port name: " << port_name_ << " ";
} template_type_->printTemplateArguments( os );
os << "PortDecl " << this << " '" << _name << "' FindTemplateTypes " <<
_templateType;
_templateType->printTemplateArguments(os, 1);
} }
...@@ -30,8 +30,8 @@ namespace scpar { ...@@ -30,8 +30,8 @@ namespace scpar {
void dump(raw_ostream &, int tabn = 0); void dump(raw_ostream &, int tabn = 0);
private: private:
string _name; string port_name_;
FindTemplateTypes *_templateType; FindTemplateTypes *template_type_;
}; };
} }
#endif #endif
...@@ -66,5 +66,5 @@ void ...@@ -66,5 +66,5 @@ void
} }
os << "Signal " << this << " '" << _name << "' FindTemplateTypes " << os << "Signal " << this << " '" << _name << "' FindTemplateTypes " <<
_sig->getTemplateTypes () << "' FieldDecl' " << _sig->getASTNode (); _sig->getTemplateTypes () << "' FieldDecl' " << _sig->getASTNode ();
_sig->getTemplateTypes ()->printTemplateArguments (os, tabn); _sig->getTemplateTypes ()->printTemplateArguments ( os );
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment