Commit 235a327e authored by rmrf's avatar rmrf
Browse files

Continue cleaning up code.

parent e4f37d48
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
using namespace scpar; using namespace scpar;
FindConstructor::FindConstructor(CXXRecordDecl *declaration, llvm::raw_ostream &os) : FindConstructor::FindConstructor( CXXRecordDecl *declaration, llvm::raw_ostream &os ) :
os_{os}, os_{os},
declaration_{declaration}, declaration_{declaration},
constructor_stmt_{nullptr}, constructor_stmt_{nullptr},
...@@ -19,11 +19,11 @@ FindConstructor::~FindConstructor() { ...@@ -19,11 +19,11 @@ FindConstructor::~FindConstructor() {
} }
bool FindConstructor::VisitCXXMethodDecl( CXXMethodDecl *method_declaration ) { bool FindConstructor::VisitCXXMethodDecl( CXXMethodDecl *method_declaration ) {
switch (pass_) { switch ( pass_ ) {
case 1: { case 1: {
if (CXXConstructorDecl *cd = dyn_cast< CXXConstructorDecl >(method_declaration)) { if (CXXConstructorDecl *cd = dyn_cast< CXXConstructorDecl >(method_declaration)) {
const FunctionDecl *fd{nullptr}; const FunctionDecl *fd{nullptr};
cd->getBody(fd); cd->getBody( fd );
if ( cd->hasBody() ) { if ( cd->hasBody() ) {
constructor_stmt_ = cd->getBody(); constructor_stmt_ = cd->getBody();
} }
......
...@@ -144,7 +144,7 @@ bool FindEntryFunctions::VisitCXXMethodDecl( CXXMethodDecl * md ) { ...@@ -144,7 +144,7 @@ bool FindEntryFunctions::VisitCXXMethodDecl( CXXMethodDecl * md ) {
} }
// //
CXXRecordDecl *FindEntryFunctions::getEntryCXXRecordDecl() { CXXRecordDecl *FindEntryFunctions::getEntryCXXRecordDecl() {
assert (entry_cxx_record_decl_ != nullptr ); assert( entry_cxx_record_decl_ != nullptr );
return entry_cxx_record_decl_; return entry_cxx_record_decl_;
} }
......
#include "FindEvents.h" #include "FindEvents.h"
#include "FindTemplateTypes.h" #include "FindTemplateTypes.h"
using namespace scpar; using namespace scpar;
using namespace std; using namespace std;
FindEvents::FindEvents (CXXRecordDecl * d, llvm::raw_ostream & os): FindEvents::FindEvents( CXXRecordDecl *d, llvm::raw_ostream &os ):
_os (os) os_ (os) {
{
TraverseDecl (d); TraverseDecl (d);
// printInClassEvents();
} }
FindEvents::FindEvents (const FindEvents & from FindEvents::FindEvents ( const FindEvents &from ):
): os_(from.os_) {
_os (from._os
)
{
_inClassEvents = from._inClassEvents; _inClassEvents = from._inClassEvents;
} }
FindEvents::~FindEvents () FindEvents::~FindEvents() {
{
// These pointer are NOT to be deleted // These pointer are NOT to be deleted
// : FieldDecl in _inClassEvents. // : FieldDecl in _inClassEvents.
// This is because they are pointers to the clang AST, which clang should free. // This is because they are pointers to the clang AST, which clang should free.
} }
bool FindEvents::VisitFieldDecl (FieldDecl * fd) bool FindEvents::VisitFieldDecl( FieldDecl *fd ) {
{ //FindTemplateTypes te(os_);
//FindTemplateTypes te(_os); QualType q = fd->getType();
QualType if ( q.getAsString () == "class sc_core::sc_event" ) {
q = fd->getType (); if ( IdentifierInfo * info = fd->getIdentifier() ) {
//os_ << "\n+ Name: " << info->getNameStart();
if (q.getAsString () == "class sc_core::sc_event") //os_ << "\n+ Type: " << q.getAsString();
{ _inClassEvents.insert( kvType(info->getNameStart(), fd) );
if (IdentifierInfo * info = fd->getIdentifier ()) }
{ }
//_os << "\n+ Name: " << info->getNameStart();
//_os << "\n+ Type: " << q.getAsString();
_inClassEvents.insert (kvType (info->getNameStart (), fd));
}
}
return true; return true;
} }
FindEvents::classEventMapType FindEvents::getInClassEvents () FindEvents::classEventMapType FindEvents::getInClassEvents() {
{ // FIXME: change to return data structure // FIXME: change to return data structure
return _inClassEvents; return _inClassEvents;
} }
vector < string > FindEvents::getEventNames () vector <string> FindEvents::getEventNames() {
{ vector <string> keys;
vector < string > keys; for ( classEventMapType::iterator vit = begin(_inClassEvents );
for (classEventMapType::iterator vit = _inClassEvents.begin (); vit != end(_inClassEvents); ++vit ) {
vit != _inClassEvents.end (); vit++) keys.push_back(vit->first);
{ }
keys.push_back (vit->first);
}
return keys; return keys;
} }
void void FindEvents::dump() {
FindEvents::dump ( os_ << "\n ============== FindEvents ===============";
) os_ << "\n:> Print in-class sc_event data members";
{
_os << "\n ============== FindEvents ===============";
_os << "\n:> Print in-class sc_event data members";
for (classEventMapType::iterator vit = _inClassEvents.begin (); for (classEventMapType::iterator vit = _inClassEvents.begin ();
vit != _inClassEvents.end (); vit++) vit != _inClassEvents.end (); vit++) {
{ os_ << "\n:> name: " << vit->first << ", FieldDecl*: " << vit->second;
_os << "\n:> name: " << vit->first << ", FieldDecl*: " << vit->second; }
} os_ << "\n ============== END FindEvents ===============";
_os << "\n ============== END FindEvents ===============";
} }
...@@ -33,7 +33,7 @@ namespace scpar { ...@@ -33,7 +33,7 @@ namespace scpar {
void dump(); void dump();
private: private:
llvm::raw_ostream & _os; llvm::raw_ostream & os_;
classEventMapType _inClassEvents; classEventMapType _inClassEvents;
// reflectionDataStructure * _reflectionMap; // reflectionDataStructure * _reflectionMap;
}; };
......
...@@ -25,8 +25,8 @@ bool FindModule::VisitCXXRecordDecl( CXXRecordDecl *declaration ) { ...@@ -25,8 +25,8 @@ bool FindModule::VisitCXXRecordDecl( CXXRecordDecl *declaration ) {
} }
// CXXRecordDecl::base_class_iterator // CXXRecordDecl::base_class_iterator
for ( auto bi = declaration_->bases_begin(), for ( auto bi = begin(declaration_->bases()), be = end(declaration_->bases());
be = declaration_->bases_end(); bi != be; ++bi ) { bi != be; ++bi ) {
string base_name = bi->getType().getAsString(); string base_name = bi->getType().getAsString();
if (base_name == "::sc_core::sc_module" if (base_name == "::sc_core::sc_module"
......
...@@ -10,7 +10,7 @@ namespace scpar { ...@@ -10,7 +10,7 @@ namespace scpar {
using namespace clang; using namespace clang;
using namespace std; using namespace std;
class FindModule: public RecursiveASTVisitor < FindModule > { class FindModule: public RecursiveASTVisitor <FindModule> {
public: public:
FindModule( CXXRecordDecl *, llvm::raw_ostream & ); FindModule( CXXRecordDecl *, llvm::raw_ostream & );
virtual bool VisitCXXRecordDecl( CXXRecordDecl *decl ); virtual bool VisitCXXRecordDecl( CXXRecordDecl *decl );
......
...@@ -204,7 +204,7 @@ void SystemCConsumer::HandleTranslationUnit(ASTContext & context) { ...@@ -204,7 +204,7 @@ void SystemCConsumer::HandleTranslationUnit(ASTContext & context) {
postFire(); postFire();
} }
SystemCConsumer::SystemCConsumer(CompilerInstance & ci): SystemCConsumer::SystemCConsumer(CompilerInstance & ci) :
_os(llvm::errs()), _os(llvm::errs()),
_sm(ci.getSourceManager()), _sm(ci.getSourceManager()),
_ci(ci), _ci(ci),
...@@ -213,9 +213,8 @@ SystemCConsumer::SystemCConsumer(CompilerInstance & ci): ...@@ -213,9 +213,8 @@ SystemCConsumer::SystemCConsumer(CompilerInstance & ci):
} }
SystemCConsumer::~SystemCConsumer() SystemCConsumer::~SystemCConsumer() {
{ if ( _systemcModel != nullptr ) {
if (_systemcModel != nullptr) {
delete _systemcModel; delete _systemcModel;
_systemcModel = nullptr; _systemcModel = nullptr;
} }
......
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