Commit 054dc72e authored by rmrf's avatar rmrf
Browse files

Cleanup code.

parent 9a814f4b
......@@ -2,39 +2,39 @@
using namespace scpar;
FindSCMain::FindSCMain ( TranslationUnitDecl *tuDecl, llvm::raw_ostream &os ):
os_{os},
sc_main_function_declaration_{nullptr} {
assert (!( tuDecl == nullptr ));
TraverseDecl( tuDecl );
}
FindSCMain::FindSCMain ( TranslationUnitDecl *tuDecl, llvm::raw_ostream &os ) :
os_{os},
sc_main_function_declaration_{nullptr} {
assert (!( tuDecl == nullptr ));
TraverseDecl( tuDecl );
}
FindSCMain::~FindSCMain() {
sc_main_function_declaration_ = nullptr;
sc_main_function_declaration_ = nullptr;
}
bool FindSCMain::VisitFunctionDecl( FunctionDecl *function_declaration ) {
/// Find sc_main.
/// There are three conditions to satisfy this:
/// 1. Must have sc_main in its name.
/// 2. Must have a body
/// 3. Must *not* be a first declaration. (This is becuase systemc.h includes a null definition of sc_main.
if ((function_declaration->getNameInfo ().getAsString () != "sc_main")
|| (!function_declaration->hasBody ()) || (function_declaration->isMain ())) {
return true;
}
sc_main_function_declaration_ = function_declaration;
return true;
/// Find sc_main.
/// There are three conditions to satisfy this:
/// 1. Must have sc_main in its name.
/// 2. Must have a body
/// 3. Must *not* be a first declaration. (This is becuase systemc.h includes a null definition of sc_main.
if ((function_declaration->getNameInfo ().getAsString () != "sc_main")
|| (!function_declaration->hasBody ()) || (function_declaration->isMain ())) {
return true;
}
sc_main_function_declaration_ = function_declaration;
return true;
}
FunctionDecl *FindSCMain::getSCMainFunctionDecl() const {
assert ( sc_main_function_declaration_ != nullptr );
assert ( sc_main_function_declaration_ != nullptr );
return sc_main_function_declaration_;
return sc_main_function_declaration_;
}
bool FindSCMain::isSCMainFound() const {
return ( sc_main_function_declaration_ != nullptr );
return ( sc_main_function_declaration_ != nullptr );
}
#include "FindSimTime.h"
using namespace scpar;
FindSimTime::FindSimTime (FunctionDecl * tuDecl, llvm::raw_ostream & os):
_os (os), _sigInst (NULL), _callexpr (NULL)
{
assert (!(tuDecl == NULL));
FindSimTime::FindSimTime ( FunctionDecl * tuDecl, llvm::raw_ostream & os ) :
os_ (os) {
// _sigInst{nullptr},
// call_expr_{nullptr} {
TraverseDecl (tuDecl);
assert (!(tuDecl == nullptr ));
TraverseDecl (tuDecl);
}
FindSimTime::~FindSimTime ()
{
_simTime.clear ();
FindSimTime::~FindSimTime() {
simulation_time_.clear ();
}
bool FindSimTime::VisitCallExpr (CallExpr * c)
{
if (c->getDirectCallee ()->getNameInfo ().getAsString () != "sc_start")
{
bool FindSimTime::VisitCallExpr( CallExpr * c ) {
if (c->getDirectCallee ()->getNameInfo ().getAsString () != "sc_start") {
return true;
}
// _os << "Found sc_start";
if (c->getNumArgs () > 0)
{
// _os <<"\n Simulation time is :" << getArgumentName(c->getArg(0));
if (c->getNumArgs () > 1)
{
// _os << " " << getArgumentName(c->getArg(1));
_simTime.insert (simulationTimePairType
// os_ << "Found sc_start";
if (c->getNumArgs () > 0) {
// os_ <<"\n Simulation time is :" << getArgumentName(c->getArg(0));
if (c->getNumArgs () > 1) {
// os_ << " " << getArgumentName(c->getArg(1));
simulation_time_.insert (simulationTimePairType
(getArgumentName (c->getArg (0)),
getArgumentName (c->getArg (1))));
}
......@@ -38,27 +34,25 @@ bool FindSimTime::VisitCallExpr (CallExpr * c)
}
/*
string FindSimTime::getArgumentName (Expr * arg)
{
string FindSimTime::getArgumentName (Expr * arg)
{
if (arg == NULL)
return string ("NULL");
return string ("NULL");
clang::LangOptions LangOpts;
LangOpts.CPlusPlus = true;
clang::PrintingPolicy Policy (LangOpts);
string
TypeS;
TypeS;
llvm::raw_string_ostream s (TypeS);
arg->printPretty (s, 0, Policy);
// _os << ", argument: " << s.str() << "\n";
// os_ << ", argument: " << s.str() << "\n";
return s.str ();
}
}
*/
FindSimTime::simulationTimeMapType FindSimTime::returnSimTime ()
{
return _simTime;
FindSimTime::simulationTimeMapType FindSimTime::returnSimTime() {
return simulation_time_;
}
......@@ -12,23 +12,25 @@ namespace scpar {
using namespace clang;
using namespace std;
class FindSimTime:public RecursiveASTVisitor < FindSimTime >, public Utility {
class FindSimTime :
public RecursiveASTVisitor < FindSimTime >,
public Utility {
public:
typedef pair < string, string > simulationTimePairType;
typedef map < string, string > simulationTimeMapType;
typedef pair <string, string> simulationTimePairType;
typedef map <string, string> simulationTimeMapType;
FindSimTime (FunctionDecl *, llvm::raw_ostream &);
FindSimTime( FunctionDecl *, llvm::raw_ostream & );
virtual ~FindSimTime();
virtual bool VisitCallExpr(CallExpr * C);
virtual bool VisitCallExpr( CallExpr * c );
simulationTimeMapType returnSimTime ();
simulationTimeMapType returnSimTime();
private:
llvm::raw_ostream & _os;
FunctionDecl *_sigInst;
simulationTimeMapType _simTime;
CallExpr *_callexpr;
llvm::raw_ostream & os_;
// FunctionDecl *_sigInst;
simulationTimeMapType simulation_time_;
// CallExpr *call_expr_;
};
}
#endif
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