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

Cleanup code.

parent 9a814f4b
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
using namespace scpar; using namespace scpar;
FindSCMain::FindSCMain ( TranslationUnitDecl *tuDecl, llvm::raw_ostream &os ): FindSCMain::FindSCMain ( TranslationUnitDecl *tuDecl, llvm::raw_ostream &os ) :
os_{os}, os_{os},
sc_main_function_declaration_{nullptr} { sc_main_function_declaration_{nullptr} {
assert (!( tuDecl == nullptr )); assert (!( tuDecl == nullptr ));
TraverseDecl( tuDecl ); TraverseDecl( tuDecl );
} }
FindSCMain::~FindSCMain() { FindSCMain::~FindSCMain() {
sc_main_function_declaration_ = nullptr; sc_main_function_declaration_ = nullptr;
......
#include "FindSimTime.h" #include "FindSimTime.h"
using namespace scpar; using namespace scpar;
FindSimTime::FindSimTime (FunctionDecl * tuDecl, llvm::raw_ostream & os): FindSimTime::FindSimTime ( FunctionDecl * tuDecl, llvm::raw_ostream & os ) :
_os (os), _sigInst (NULL), _callexpr (NULL) os_ (os) {
{ // _sigInst{nullptr},
assert (!(tuDecl == NULL)); // call_expr_{nullptr} {
assert (!(tuDecl == nullptr ));
TraverseDecl (tuDecl); TraverseDecl (tuDecl);
} }
FindSimTime::~FindSimTime () FindSimTime::~FindSimTime() {
{ simulation_time_.clear ();
_simTime.clear ();
} }
bool FindSimTime::VisitCallExpr (CallExpr * c) bool FindSimTime::VisitCallExpr( CallExpr * c ) {
{ if (c->getDirectCallee ()->getNameInfo ().getAsString () != "sc_start") {
if (c->getDirectCallee ()->getNameInfo ().getAsString () != "sc_start")
{
return true; return true;
} }
// _os << "Found sc_start"; // os_ << "Found sc_start";
if (c->getNumArgs () > 0) if (c->getNumArgs () > 0) {
{ // os_ <<"\n Simulation time is :" << getArgumentName(c->getArg(0));
// _os <<"\n Simulation time is :" << getArgumentName(c->getArg(0)); if (c->getNumArgs () > 1) {
if (c->getNumArgs () > 1) // os_ << " " << getArgumentName(c->getArg(1));
{ simulation_time_.insert (simulationTimePairType
// _os << " " << getArgumentName(c->getArg(1));
_simTime.insert (simulationTimePairType
(getArgumentName (c->getArg (0)), (getArgumentName (c->getArg (0)),
getArgumentName (c->getArg (1)))); getArgumentName (c->getArg (1))));
} }
...@@ -38,8 +34,8 @@ bool FindSimTime::VisitCallExpr (CallExpr * c) ...@@ -38,8 +34,8 @@ bool FindSimTime::VisitCallExpr (CallExpr * c)
} }
/* /*
string FindSimTime::getArgumentName (Expr * arg) string FindSimTime::getArgumentName (Expr * arg)
{ {
if (arg == NULL) if (arg == NULL)
return string ("NULL"); return string ("NULL");
...@@ -51,14 +47,12 @@ string FindSimTime::getArgumentName (Expr * arg) ...@@ -51,14 +47,12 @@ string FindSimTime::getArgumentName (Expr * arg)
TypeS; TypeS;
llvm::raw_string_ostream s (TypeS); llvm::raw_string_ostream s (TypeS);
arg->printPretty (s, 0, Policy); arg->printPretty (s, 0, Policy);
// _os << ", argument: " << s.str() << "\n"; // os_ << ", argument: " << s.str() << "\n";
return s.str (); return s.str ();
} }
*/ */
FindSimTime::simulationTimeMapType FindSimTime::returnSimTime () FindSimTime::simulationTimeMapType FindSimTime::returnSimTime() {
{ return simulation_time_;
return _simTime;
} }
...@@ -12,23 +12,25 @@ namespace scpar { ...@@ -12,23 +12,25 @@ namespace scpar {
using namespace clang; using namespace clang;
using namespace std; using namespace std;
class FindSimTime:public RecursiveASTVisitor < FindSimTime >, public Utility { class FindSimTime :
public RecursiveASTVisitor < FindSimTime >,
public Utility {
public: public:
typedef pair < string, string > simulationTimePairType; typedef pair <string, string> simulationTimePairType;
typedef map < string, string > simulationTimeMapType; typedef map <string, string> simulationTimeMapType;
FindSimTime (FunctionDecl *, llvm::raw_ostream &); FindSimTime( FunctionDecl *, llvm::raw_ostream & );
virtual ~FindSimTime(); virtual ~FindSimTime();
virtual bool VisitCallExpr(CallExpr * C); virtual bool VisitCallExpr( CallExpr * c );
simulationTimeMapType returnSimTime (); simulationTimeMapType returnSimTime();
private: private:
llvm::raw_ostream & _os; llvm::raw_ostream & os_;
FunctionDecl *_sigInst; // FunctionDecl *_sigInst;
simulationTimeMapType _simTime; simulationTimeMapType simulation_time_;
CallExpr *_callexpr; // CallExpr *call_expr_;
}; };
} }
#endif #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