systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
FindTLMInterfaces.cpp
Go to the documentation of this file.
1#include "FindTLMInterfaces.h"
2#include "FindTemplateTypes.h"
3using namespace systemc_clang;
4
5FindTLMInterfaces::FindTLMInterfaces(CXXRecordDecl *d, llvm::raw_ostream &os)
6 : _os(os) {
7 TraverseDecl(d);
8}
9
13
17
21
23 QualType q = fd->getType();
24 string fname;
25
26 if (IdentifierInfo *info = fd->getIdentifier()) {
27 fname = info->getNameStart();
28 }
29
30 const Type *tp = q.getTypePtr();
32
33 te->Enumerate(tp);
34
35 FindTemplateTypes::type_vector_t args = te->getTemplateArgumentsType();
36 FindTemplateTypes::argVectorType::iterator ait = args.begin();
37 if (args.size() == 0) {
38 return true;
39 }
40
41 // There could be more than one type though. Are you only referring to the
42 // first one?
43 string template_type_name{ait->getTypeName()};
44 if (template_type_name == "sc_fifo_in") {
45 _inInterfaces.insert(kvType(fname, te));
46 }
47
48 else if (template_type_name == "sc_fifo_out") {
49 _outInterfaces.insert(kvType(fname, te));
50 }
51
52 else if (template_type_name == "sc_fifo_inout") {
53 _inoutInterfaces.insert(kvType(fname, te));
54 }
55
56 else {
58 }
59
60 return true;
61}
62
64 _os << "\n================= Find Interfaces ================\n";
65 _os << "\n:> Number of input Interfaces: " << _inInterfaces.size();
66 for (interfaceType::iterator mit = _inInterfaces.begin(),
67 mitend = _inInterfaces.end();
68 mit != mitend; mit++) {
69 _os << "\n:>> " << mit->first;
70 (mit->second)->printTemplateArguments(_os);
71 }
72
73 _os << "\n\n:> Number of output Interfaces: " << _outInterfaces.size();
74 for (interfaceType::iterator mit = _outInterfaces.begin(),
75 mitend = _outInterfaces.end();
76 mit != mitend; mit++) {
77 _os << "\n:>> " << mit->first;
78 (mit->second)->printTemplateArguments(_os);
79 }
80
81 _os << "\n\n:> Number of inout Interfaces: " << _inoutInterfaces.size();
82 for (interfaceType::iterator mit = _inoutInterfaces.begin(),
83 mitend = _inoutInterfaces.end();
84 mit != mitend; mit++) {
85 _os << "\n:>> " << mit->first;
86 (mit->second)->printTemplateArguments(_os);
87 }
88 _os << "\n================= END Find Interfaces ================\n\n";
89}
90
92 // _os << "[[ Destructor FindTLMInterfaces ]]\n";
93 for (interfaceType::iterator mit = _inInterfaces.begin(),
94 mitend = _inInterfaces.end();
95 mit != mitend; mit++) {
96 delete mit->second;
97 }
98 _inInterfaces.clear();
99
100 for (interfaceType::iterator mit = _outInterfaces.begin(),
101 mitend = _outInterfaces.end();
102 mit != mitend; mit++) {
103 delete mit->second;
104 }
105 _outInterfaces.clear();
106
107 for (interfaceType::iterator mit = _inoutInterfaces.begin(),
108 mitend = _inoutInterfaces.end();
109 mit != mitend; mit++) {
110 delete mit->second;
111 }
112 _inoutInterfaces.clear();
113}
std::pair< string, FindTemplateTypes * > kvType
virtual bool VisitFieldDecl(FieldDecl *)
FindTLMInterfaces(CXXRecordDecl *, llvm::raw_ostream &)
std::map< string, FindTemplateTypes * > interfaceType
std::vector< TemplateTypePtr > type_vector_t
void Enumerate(const clang::Type *type)