From 279077f96b75e877dd357e93bafd9ebc2c07929f Mon Sep 17 00:00:00 2001 From: rmrf Date: Sat, 29 Dec 2018 11:49:02 -0500 Subject: [PATCH] Clean up template parameters printing --- src/FindTemplateTypes.h | 18 +++++++----------- src/InterfaceDecl.cpp | 2 +- src/PortDecl.cpp | 37 +++++++++++++++++++------------------ src/PortDecl.h | 4 ++-- src/Signal.cpp | 2 +- 5 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/FindTemplateTypes.h b/src/FindTemplateTypes.h index 0e0e3be..fcb2bc9 100644 --- a/src/FindTemplateTypes.h +++ b/src/FindTemplateTypes.h @@ -96,23 +96,19 @@ namespace scpar { return template_types_; } - void printTemplateArguments( llvm::raw_ostream &os, int tabn = 0 ) { - vector < string > template_arguments; //{ getTemplateArguments() }; - // type_vector_t::iterator - // for (auto mit = template_types_.begin(); mit != template_types_.end(); mit++) { + void printTemplateArguments( llvm::raw_ostream &os ) { + vector < string > template_arguments; for ( auto const &mit: template_types_ ) { - for ( auto i{0}; i < tabn; ++i) { - os << " "; - } - os << "- " << mit.first << ", type ptr: " << mit.second; - os << "\n"; + //os << "\n port type: " << mit.first << " "; + //<< ", type ptr: " << mit.second; + //os << "\n"; template_arguments.push_back( mit.first ); } // Print the template arguments to the output stream - os << "= "; + os << ", " << template_arguments.size() << " arguments, "; for ( auto const &targ: template_arguments ) { - os << targ << " "; + os << targ << " "; } } diff --git a/src/InterfaceDecl.cpp b/src/InterfaceDecl.cpp index a3b10df..52693b2 100644 --- a/src/InterfaceDecl.cpp +++ b/src/InterfaceDecl.cpp @@ -53,5 +53,5 @@ void InterfaceDecl::dump(raw_ostream & os, int tabn) } os << "InterfaceDecl " << this << " '" << _name << "' FindTemplateTypes " << _templateType; - _templateType->printTemplateArguments(os, 1); + _templateType->printTemplateArguments(os ); } diff --git a/src/PortDecl.cpp b/src/PortDecl.cpp index ece2566..13e286e 100644 --- a/src/PortDecl.cpp +++ b/src/PortDecl.cpp @@ -5,41 +5,42 @@ using namespace scpar; using namespace std; PortDecl::~PortDecl() { - if ( _templateType != nullptr ) { - delete _templateType; + if ( template_type_ != nullptr ) { + 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) { - _name = from._name; +PortDecl::PortDecl( const PortDecl &from ) { + port_name_ = from.port_name_; // 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) { - _name = name; +void PortDecl::setModuleName( const string &name ) { + port_name_ = name; } string PortDecl::getName() const { - return _name; + return port_name_; } FindTemplateTypes *PortDecl::getTemplateType() { - return _templateType; + return template_type_; } -void PortDecl::dump(raw_ostream & os, int tabn) { - for ( auto i = 0; i < tabn; ++i ) { - os << " "; - } - os << "PortDecl " << this << " '" << _name << "' FindTemplateTypes " << - _templateType; - _templateType->printTemplateArguments(os, 1); +void PortDecl::dump( llvm::raw_ostream & os, int tabn ) { + //os << "PortDecl " << this << " '" << port_name_ << "' FindTemplateTypes " << template_type_; + os << "Port name: " << port_name_ << " "; + template_type_->printTemplateArguments( os ); } diff --git a/src/PortDecl.h b/src/PortDecl.h index 5834e0b..04d00cf 100644 --- a/src/PortDecl.h +++ b/src/PortDecl.h @@ -30,8 +30,8 @@ namespace scpar { void dump(raw_ostream &, int tabn = 0); private: - string _name; - FindTemplateTypes *_templateType; + string port_name_; + FindTemplateTypes *template_type_; }; } #endif diff --git a/src/Signal.cpp b/src/Signal.cpp index 83365ff..7a1a41f 100644 --- a/src/Signal.cpp +++ b/src/Signal.cpp @@ -66,5 +66,5 @@ void } os << "Signal " << this << " '" << _name << "' FindTemplateTypes " << _sig->getTemplateTypes () << "' FieldDecl' " << _sig->getASTNode (); - _sig->getTemplateTypes ()->printTemplateArguments (os, tabn); + _sig->getTemplateTypes ()->printTemplateArguments ( os ); } -- GitLab