Commit 235a327e authored by rmrf's avatar rmrf

Continue cleaning up code.

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