Commit 177bb1ac authored by rmrf's avatar rmrf
Browse files

Clean up code format.

parent 23d5e154
......@@ -2,50 +2,40 @@
using namespace scpar;
FindArgument::FindArgument (Expr * e):_e (e) {
TraverseStmt (e);
FindArgument::FindArgument(Expr * e) :
expression_(e) {
TraverseStmt(expression_);
}
FindArgument::~FindArgument() {
_e = nullptr;
expression_ = nullptr;
}
bool FindArgument::VisitMemberExpr (MemberExpr * me)
{
_argumentName = me->getMemberNameInfo ().getAsString ();
bool FindArgument::VisitMemberExpr ( MemberExpr *member_expr ) {
argument_name_ = member_expr->getMemberNameInfo().getAsString();
return true;
}
bool FindArgument::VisitDeclRefExpr (DeclRefExpr * de)
{
_argumentName = de->getFoundDecl ()->getNameAsString ();
bool FindArgument::VisitDeclRefExpr( DeclRefExpr *declaration_ref ) {
argument_name_ = declaration_ref->getFoundDecl()->getNameAsString();
return true;
}
bool FindArgument::VisitIntegerLiteral (IntegerLiteral * il)
{
_argumentName = il->getValue ().toString (10, false);
bool FindArgument::VisitIntegerLiteral( IntegerLiteral *integer_literal ) {
argument_name_ = integer_literal->getValue().toString(10, false);
return true;
}
bool FindArgument::VisitCXXBoolLiteralExpr (CXXBoolLiteralExpr * bl)
{
if (bl->getValue () == false)
{
_argumentName = "false";
bool FindArgument::VisitCXXBoolLiteralExpr( CXXBoolLiteralExpr *boolean_expr ) {
if ( boolean_expr->getValue() == false ) {
argument_name_ = "false";
}
else
{
_argumentName = "true";
else {
argument_name_ = "true";
}
return true;
}
string FindArgument::getArgumentName ()
{
return _argumentName;
string FindArgument::getArgumentName() {
return argument_name_;
}
......@@ -12,19 +12,17 @@ namespace scpar {
class FindArgument:public RecursiveASTVisitor < FindArgument > {
public:
FindArgument(Expr * ce);
FindArgument( Expr * );
virtual ~FindArgument();
virtual bool VisitMemberExpr (MemberExpr * me);
virtual bool VisitDeclRefExpr (DeclRefExpr * de);
virtual bool VisitIntegerLiteral (IntegerLiteral * il);
virtual bool VisitCXXBoolLiteralExpr (CXXBoolLiteralExpr * bl);
string getArgumentName (
);
string getArgumentName();
private:
Expr * _e;
string _argumentName;
Expr * expression_;
string argument_name_;
};
}
#endif
......@@ -2,12 +2,14 @@
#define _FIND_CONSTRUCTOR_H_
#include <vector>
#include <map>
#include <string>
#include "clang/AST/DeclCXX.h"
#include "llvm/Support/raw_ostream.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "EntryFunctionContainer.h"
#include <map>
namespace scpar {
using namespace clang;
......
......@@ -2,145 +2,110 @@
#include "FindTemplateTypes.h"
using namespace scpar;
FindPorts::FindPorts (CXXRecordDecl * d, llvm::raw_ostream & os):
_os (os)
//, _reflectionContainer(container)
{
TraverseDecl (d);
FindPorts::FindPorts ( CXXRecordDecl *d, llvm::raw_ostream &os ) :
os_{os} {
TraverseDecl(d);
}
FindPorts::portType FindPorts::getInputPorts ()
{
FindPorts::PortType FindPorts::getInputPorts() const {
return _inPorts;
}
FindPorts::portType FindPorts::getOutputPorts ()
{
FindPorts::PortType FindPorts::getOutputPorts() const {
return _outPorts;
}
FindPorts::portType FindPorts::getInputOutputPorts ()
{
FindPorts::PortType FindPorts::getInputOutputPorts() const {
return _inoutPorts;
}
bool FindPorts::VisitFieldDecl (FieldDecl * fd)
{
// _os << "####################### VisitFieldDecl\n ";
QualType
q = fd->getType ();
string
fname;
if (IdentifierInfo * info = fd->getIdentifier ())
{
fname = info->getNameStart ();
// _os << "\n+ Name: " << info->getNameStart();
// _os << "\n+ Type: " << q.getAsString();
}
//
bool FindPorts::VisitFieldDecl( FieldDecl *fd ) {
// os_ << "####################### VisitFieldDecl\n ";
QualType q = fd->getType();
string fname;
if (IdentifierInfo *info = fd->getIdentifier()) {
fname = info->getNameStart();
// os_ << "\n+ Name: " << info->getNameStart();
// os_ << "\n+ Type: " << q.getAsString();
}
//
/// FIXME: We have to delete these somewhere. Who is responsible of doing this?
/// We are going to store these. So use pointers.
const Type *
tp = q.getTypePtr ();
FindTemplateTypes *
te = new FindTemplateTypes ();
const Type *tp = q.getTypePtr();
FindTemplateTypes *te = new FindTemplateTypes();
te->Enumerate (tp);
te->Enumerate(tp);
//te->printTemplateArguments();
/// Check if we have sc_in/sc_out/sc_inout ports.
/// The vector is organized such that the first element is the port type.
FindTemplateTypes::argVectorType args = te->getTemplateArgumentsType ();
FindTemplateTypes::argVectorType::iterator ait = args.begin ();
if (args.size () == 0)
{
return true;
}
if (ait->first == "sc_in")
{
// _os << "\n+ sc_in";
_inPorts.insert (kvType (fname, te));
}
else if (ait->first == "sc_out")
{
// _os << "\n+ sc_out";
_outPorts.insert (kvType (fname, te));
}
else if (ait->first == "sc_inout")
{
// _os << "\n+ sc_inout";
_inoutPorts.insert (kvType (fname, te));
}
else
{
/// This is sometype we don't know about.
}
FindTemplateTypes::argVectorType args{ te->getTemplateArgumentsType() };
FindTemplateTypes::argVectorType::iterator ait{ args.begin() };
if ( args.size() == 0 ) {
return true;
}
if ( ait->first == "sc_in" ) {
// os_ << "\n+ sc_in";
_inPorts.insert ( kvType(fname, te) );
} else if (ait->first == "sc_out") {
// os_ << "\n+ sc_out";
_outPorts.insert( kvType( fname, te ) );
}
else if ( ait->first == "sc_inout" ) {
// os_ << "\n+ sc_inout";
_inoutPorts.insert ( kvType( fname, te ) );
}
else {
/// This is sometype we don't know about.
}
return true;
}
void
FindPorts::dump (
)
{
_os << "\n================= Find Ports ================\n";
_os << "\n:> Number of input Ports: " << _inPorts.size ();
for (portType::iterator mit = _inPorts.begin (), mitend = _inPorts.end ();
mit != mitend; mit++)
{
_os << "\n:>> " << mit->first;
(mit->second)->printTemplateArguments (_os);
}
_os << "\n\n:> Number of output Ports: " << _outPorts.size ();
for (portType::iterator mit = _outPorts.begin (), mitend = _outPorts.end ();
mit != mitend; mit++)
{
_os << "\n:>> " << mit->first;
(mit->second)->printTemplateArguments (_os);
}
_os << "\n\n:> Number of inout Ports: " << _inoutPorts.size ();
for (portType::iterator mit = _inoutPorts.begin (), mitend =
_inoutPorts.end (); mit != mitend; mit++)
{
_os << "\n:>> " << mit->first;
(mit->second)->printTemplateArguments (_os);
}
_os << "\n================= END Find Ports ================\n\n";
void FindPorts::dump() {
os_ << "\n================= Find Ports ================\n";
os_ << "\n:> Number of input Ports: " << _inPorts.size ();
for (PortType::iterator mit = _inPorts.begin (), mitend = _inPorts.end (); mit != mitend; mit++) {
os_ << "\n:>> " << mit->first;
(mit->second)->printTemplateArguments(os_);
}
os_ << "\n\n:> Number of output Ports: " << _outPorts.size ();
for (PortType::iterator mit = _outPorts.begin (), mitend = _outPorts.end (); mit != mitend; mit++) {
os_ << "\n:>> " << mit->first;
(mit->second)->printTemplateArguments(os_);
}
os_ << "\n\n:> Number of inout Ports: " << _inoutPorts.size ();
for (PortType::iterator mit = _inoutPorts.begin (), mitend = _inoutPorts.end (); mit != mitend; mit++) {
os_ << "\n:>> " << mit->first;
(mit->second)->printTemplateArguments(os_);
}
os_ << "\n================= END Find Ports ================\n\n";
}
FindPorts::~FindPorts ()
{
// _os << "[[ Destructor FindPorts ]]\n";
for (portType::iterator mit = _inPorts.begin (), mitend = _inPorts.end ();
mit != mitend; mit++)
{
delete mit->second;
}
FindPorts::~FindPorts() {
// os_ << "[[ Destructor FindPorts ]]\n";
for (PortType::iterator mit = _inPorts.begin (), mitend = _inPorts.end (); mit != mitend; mit++) {
// for ( auto mit : _inPorts ) {
delete mit->second;
}
_inPorts.clear ();
for (portType::iterator mit = _outPorts.begin (), mitend = _outPorts.end ();
mit != mitend; mit++)
{
// _os << "\n:>> " << mit->first;
delete mit->second;
}
_outPorts.clear ();
// _os << "\n\n:> Number of inout Ports: " << _inoutPorts.size();
for (portType::iterator mit = _inoutPorts.begin (), mitend =
_inoutPorts.end (); mit != mitend; mit++)
{
// _os << "\n:>> " << mit->first;
delete mit->second;
}
_inoutPorts.clear ();
for (PortType::iterator mit = _outPorts.begin (), mitend = _outPorts.end (); mit != mitend; mit++) {
// for ( auto mit : _outPorts ) {
// os_ << "\n:>> " << mit->first;
delete mit->second;
}
_outPorts.clear();
// os_ << "\n\n:> Number of inout Ports: " << _inoutPorts.size();
for (PortType::iterator mit = _inoutPorts.begin (), mitend = _inoutPorts.end (); mit != mitend; mit++) {
// for ( auto mit : _inoutPorts ) {
// os_ << "\n:>> " << mit->first;
delete mit->second;
}
_inoutPorts.clear();
}
......@@ -11,27 +11,27 @@ namespace scpar {
using namespace clang;
using namespace std;
class FindPorts:public RecursiveASTVisitor < FindPorts > {
class FindPorts : public RecursiveASTVisitor < FindPorts > {
public:
/// typedefs
typedef map < string, FindTemplateTypes * >portType;
typedef map < string, FindTemplateTypes * > PortType;
typedef pair < string, FindTemplateTypes * >kvType;
FindPorts(CXXRecordDecl *, llvm::raw_ostream & );
FindPorts( CXXRecordDecl *, llvm::raw_ostream &);
virtual ~FindPorts();
virtual bool VisitFieldDecl (FieldDecl *);
virtual bool VisitFieldDecl( FieldDecl * );
portType getInputPorts();
portType getOutputPorts();
portType getInputOutputPorts();
void dump ();
PortType getInputPorts() const;
PortType getOutputPorts() const;
PortType getInputOutputPorts() const;
void dump();
private:
llvm::raw_ostream & _os;
portType _inPorts;
portType _outPorts;
portType _inoutPorts;
llvm::raw_ostream & os_;
PortType _inPorts;
PortType _outPorts;
PortType _inoutPorts;
};
......
......@@ -66,7 +66,7 @@ void ModuleDecl::addSignals( FindSignals::signalMapType *signal_map ) {
}
}
void ModuleDecl::addInputPorts( FindPorts::portType p ) {
void ModuleDecl::addInputPorts( FindPorts::PortType p ) {
for ( auto mit: p ) {
string name = mit.first;
FindTemplateTypes *template_type = new FindTemplateTypes(mit.second);
......@@ -76,7 +76,7 @@ void ModuleDecl::addInputPorts( FindPorts::portType p ) {
}
}
void ModuleDecl::addOutputPorts(FindPorts::portType p) {
void ModuleDecl::addOutputPorts(FindPorts::PortType p) {
for ( auto mit: p ) {
string n = mit.first;
FindTemplateTypes *tt = new FindTemplateTypes( mit.second );
......@@ -86,7 +86,7 @@ void ModuleDecl::addOutputPorts(FindPorts::portType p) {
}
}
void ModuleDecl::addInputOutputPorts( FindPorts::portType p ) {
void ModuleDecl::addInputOutputPorts( FindPorts::PortType p ) {
for ( auto mit: p ) {
_ioports.insert(portPairType( mit.first, new PortDecl(mit.first, mit.second ) ) );
}
......
......@@ -47,13 +47,13 @@ namespace scpar {
~ModuleDecl();
void addSignals(FindSignals::signalMapType *);
void addInputPorts(FindPorts::portType);
void addOutputPorts(FindPorts::portType);
void addInputOutputPorts(FindPorts::portType);
void addInputInterfaces(FindTLMInterfaces::interfaceType);
void addOutputInterfaces(FindTLMInterfaces::interfaceType);
void addInputOutputInterfaces(FindTLMInterfaces::interfaceType);
void addSignals( FindSignals::signalMapType * );
void addInputPorts( FindPorts::PortType );
void addOutputPorts( FindPorts::PortType );
void addInputOutputPorts( FindPorts::PortType );
void addInputInterfaces( FindTLMInterfaces::interfaceType );
void addOutputInterfaces( FindTLMInterfaces::interfaceType );
void addInputOutputInterfaces( FindTLMInterfaces::interfaceType );
void addProcess(FindEntryFunctions::entryFunctionVectorType *);
void addInstances(vector<string>);
void addSignalBinding(map<string, string>);
......
Supports Markdown
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