systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
FindEvents.cpp
Go to the documentation of this file.
1#include "FindEvents.h"
2#include "FindTemplateTypes.h"
3
4#include "clang/AST/DeclCXX.h"
5
6using namespace systemc_clang;
7//using namespace std;
8
9FindEvents::FindEvents(clang::CXXRecordDecl *d, llvm::raw_ostream &os) : os_(os) {
10 TraverseDecl(d);
11}
12
13FindEvents::FindEvents(const FindEvents &from) : os_(from.os_) {
15}
16
18 // These pointer are NOT to be deleted
19 // : FieldDecl in _inClassEvents.
20 // This is because they are pointers to the clang AST, which clang should
21 // free.
22}
23
24bool FindEvents::VisitFieldDecl(clang::FieldDecl *fd) {
25 // FindTemplateTypes te(os_);
26 clang::QualType q = fd->getType();
27 if (q.getAsString() == "class sc_core::sc_event") {
28 if (clang::IdentifierInfo *info = fd->getIdentifier()) {
29 // os_ << "\n+ Name: " << info->getNameStart();
30 // os_ << "\n+ Type: " << q.getAsString();
31 _inClassEvents.insert(kvType(info->getNameStart(), fd));
32 }
33 }
34 return true;
35}
36
38 // FIXME: change to return data structure
39 return _inClassEvents;
40}
41
42std::vector<std::string> FindEvents::getEventNames() {
43 std::vector<std::string> keys;
44 for (classEventMapType::iterator vit = begin(_inClassEvents);
45 vit != end(_inClassEvents); ++vit) {
46 keys.push_back(vit->first);
47 }
48 return keys;
49}
50
52 os_ << "\n ============== FindEvents ===============";
53 os_ << "\n:> Print in-class sc_event data members";
54 for (classEventMapType::iterator vit = _inClassEvents.begin();
55 vit != _inClassEvents.end(); vit++) {
56 os_ << "\n:> name: " << vit->first << ", FieldDecl*: " << vit->second;
57 }
58 os_ << "\n ============== END FindEvents ===============";
59}
std::map< std::string, clang::FieldDecl * > classEventMapType
typedefs
Definition FindEvents.h:20
void dump()
Print methods.
std::pair< std::string, clang::FieldDecl * > kvType
Definition FindEvents.h:21
llvm::raw_ostream & os_
Definition FindEvents.h:37
classEventMapType _inClassEvents
Definition FindEvents.h:38
FindEvents(clang::CXXRecordDecl *, llvm::raw_ostream &)
Definition FindEvents.cpp:9
virtual bool VisitFieldDecl(clang::FieldDecl *)
RecursiveASTVisitor methods.
std::vector< std::string > getEventNames()
classEventMapType getInClassEvents()
Access methods.