Commit e95a4b33 authored by rmrf's avatar rmrf

Separate FindTemplateTypes

parent 731af1ee
...@@ -10,17 +10,18 @@ add_library (libsystemc-clang ...@@ -10,17 +10,18 @@ add_library (libsystemc-clang
FindEntryFunctions.cpp FindEntryFunctions.cpp
FindSensitivity.cpp FindSensitivity.cpp
FindWait.cpp FindWait.cpp
FindNotify.cpp FindNotify.cpp
FindSignals.cpp FindSignals.cpp
FindSimTime.cpp FindSimTime.cpp
FindConstructor.cpp FindTemplateTypes.cpp
FindConstructor.cpp
SystemCClang.cpp SystemCClang.cpp
FindNetlist.cpp FindNetlist.cpp
FindArgument.cpp FindArgument.cpp
Automata.cpp Automata.cpp
SuspensionAutomata.cpp SuspensionAutomata.cpp
SCuitable/GlobalSuspensionAutomata.cpp SCuitable/GlobalSuspensionAutomata.cpp
SCuitable/FindGPUMacro.cpp SCuitable/FindGPUMacro.cpp
#################################### ####################################
#From here the files are for the reflection database #From here the files are for the reflection database
#################################### ####################################
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "clang/AST/RecursiveASTVisitor.h" #include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/Type.h" #include "clang/AST/Type.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <set>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -24,113 +23,22 @@ public: ...@@ -24,113 +23,22 @@ public:
typedef vector<pair<string, const Type *>> argVectorType; typedef vector<pair<string, const Type *>> argVectorType;
// Constructor // Constructor
FindTemplateTypes() {} FindTemplateTypes();
/// Copy constructor /// Copy constructor
FindTemplateTypes(const FindTemplateTypes &rhs) { FindTemplateTypes(const FindTemplateTypes &rhs);
copy(rhs.template_types_.begin(), rhs.template_types_.end(), FindTemplateTypes(const FindTemplateTypes *rhs);
back_inserter(template_types_)); string getTemplateType();
} type_vector_t Enumerate(const Type *type);
bool VisitType(Type *type);
FindTemplateTypes(const FindTemplateTypes *rhs) { bool VisitIntegerLiteral(IntegerLiteral *l);
copy(rhs->template_types_.begin(), rhs->template_types_.end(), type_vector_t getTemplateArgumentsType();
back_inserter(template_types_)); void printTemplateArguments(llvm::raw_ostream &os);
} vector<string> getTemplateArguments();
size_t size();
string getTemplateType() {
string s{};
// type_vector_t::iterator
for (auto mit = template_types_.begin(); mit != template_types_.end();
++mit) {
// for ( auto const &mit: template_types_ ) {
if (mit != template_types_.begin()) {
s += "<";
}
s += mit->first;
if (mit != template_types_.begin()) {
s += ">";
}
}
return s;
}
type_vector_t Enumerate(const Type *type) {
template_types_.clear();
if (!type) {
return template_types_;
}
TraverseType(QualType(type, 0));
return template_types_;
}
bool VisitType(Type *type) {
QualType q{type->getCanonicalTypeInternal()};
// cout << "\n###### Type: " << q.getAsString() << " \n" ;
if (type->isBuiltinType()) {
template_types_.push_back(
pair<string, const Type *>(q.getAsString(), type));
return true;
}
CXXRecordDecl *p_cxx_record{type->getAsCXXRecordDecl()};
if (p_cxx_record != nullptr) {
IdentifierInfo *info{p_cxx_record->getIdentifier()};
if (info != nullptr) {
template_types_.push_back(
pair<string, const Type *>(info->getNameStart(), type));
}
}
return true;
}
bool VisitIntegerLiteral(IntegerLiteral *l) {
//_os << "\n####### IntegerLiteral: " << l->getValue().toString(10,true) <<
//"\n"; _os << "== type ptr: " << l->getType().getTypePtr() << "\n"; _os <<
//"== type name: " << l->getType().getAsString() << "\n";
template_types_.push_back(pair<string, const Type *>(
l->getValue().toString(10, true), l->getType().getTypePtr()));
return true;
}
type_vector_t getTemplateArgumentsType() { return template_types_; }
void printTemplateArguments(llvm::raw_ostream &os) {
vector<string> template_arguments;
for (auto const &mit : template_types_) {
// 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 << ", " << template_arguments.size() << " arguments, ";
for (auto const &targ : template_arguments) {
os << targ << " ";
}
}
vector<string> 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_) {
if (mit.first == "sc_in" || mit.first == "sc_out" ||
mit.first == "sc_inout") {
break;
}
template_arguments.push_back(mit.first);
}
return template_arguments;
}
size_t size() { return template_types_.size(); }
private: private:
// (string, Type*)
type_vector_t template_types_; type_vector_t template_types_;
}; };
} // namespace scpar } // namespace scpar
......
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