FindSCModules.cpp 1.02 KB
Newer Older
rmrf's avatar
rmrf committed
1
#include "FindSCModules.h"
Anirudh Kaushik's avatar
Anirudh Kaushik committed
2
#include "FindModule.h"
3
#include "clang/AST/ASTContext.h"
Anirudh Kaushik's avatar
Anirudh Kaushik committed
4 5
using namespace scpar;

rmrf's avatar
rmrf committed
6
FindSCModules::FindSCModules(TranslationUnitDecl *tuDecl, llvm::raw_ostream &os)
rmrf's avatar
rmrf committed
7
    : _os(os) {
8
  assert(!(tuDecl == nullptr));
Anirudh Kaushik's avatar
Anirudh Kaushik committed
9 10 11
  TraverseDecl(tuDecl);
}

rmrf's avatar
rmrf committed
12
FindSCModules::~FindSCModules() {}
13

rmrf's avatar
rmrf committed
14
bool FindSCModules::VisitCXXRecordDecl(CXXRecordDecl *cxxDecl) {
Anirudh Kaushik's avatar
Anirudh Kaushik committed
15 16 17 18 19 20 21 22 23 24
  FindModule mod(cxxDecl, _os);

  if (!mod.isSystemCModule()) {
    return true;
  }
  string modName = mod.getModuleName();
  _moduleMap.insert(modulePairType(modName, cxxDecl));
  return true;
}

rmrf's avatar
rmrf committed
25
FindSCModules::moduleMapType FindSCModules::getSystemCModulesMap() {
Anirudh Kaushik's avatar
Anirudh Kaushik committed
26 27 28
  return _moduleMap;
}

rmrf's avatar
rmrf committed
29
void FindSCModules::dump() {
Anirudh Kaushik's avatar
Anirudh Kaushik committed
30 31 32 33 34 35 36 37 38
  _os << "\n================= SCModules ================";
  _os << "\n Print SystemC Module Map";
  for (moduleMapType::iterator mit = _moduleMap.begin();
       mit != _moduleMap.end(); mit++) {
    _os << "\n:> name: " << mit->first << ", CXXRecordDecl*: " << mit->second;
  }
  _os << "\n================= END SCModules ================";
  _os << "\n\n";
}