Commit 7e25e8e5 authored by rmrf's avatar rmrf

ProcessDecl: JSON print

parent 3de49875
......@@ -221,7 +221,7 @@ void ModuleDecl::dumpProcesses(raw_ostream &os, int tabn) {
} else {
for (auto pit : _processes) {
ProcessDecl *pd = pit.second;
pd->dump(os, tabn);
pd->dump( os );
os << "\n";
}
}
......
#include "ProcessDecl.h"
using namespace scpar;
//using namespace nlohmann::json;
ProcessDecl::ProcessDecl(string t, string n, CXXMethodDecl *entryMethodDecl,
EntryFunctionContainer *e)
: _type(t), _entryName(n), _entryMethodDecl(entryMethodDecl), _ef(e) {}
EntryFunctionContainer *e) :
process_type_(t), entry_name_(n), entry_method_decl_(entryMethodDecl), entry_function_ptr_(e) {}
ProcessDecl::~ProcessDecl() {
// The following points do NOT need to be deleted:_entryMethodDecl,
// The following points do NOT need to be deleted:entry_method_decl_,
// _constructorStmt. This is because they are pointers to the clang AST, which
// are going to be freed by clang itself.
entry_method_decl_ = nullptr;
entry_function_ptr_ = nullptr;
}
ProcessDecl::ProcessDecl(const ProcessDecl &from) {
_type = from._type;
_entryName = from._entryName;
_entryMethodDecl = from._entryMethodDecl;
_ef = from._ef;
process_type_ = from.process_type_;
entry_name_ = from.entry_name_;
entry_method_decl_ = from.entry_method_decl_;
entry_function_ptr_ = from.entry_function_ptr_;
}
string ProcessDecl::getType() { return _type; }
string ProcessDecl::getType() const { return process_type_; }
string ProcessDecl::getName() const { return entry_name_; }
CXXMethodDecl *ProcessDecl::getEntryMethodDecl() const { return entry_method_decl_; }
void ProcessDecl::dump(raw_ostream &os) {
os << "ProcessDecl " << this << " '" << entry_name_ << "' " << entry_method_decl_
<< " " << process_type_;
// TODO: Remove this tabn
os << "\nEntry function:\n";
entry_function_ptr_->dump(os, 1);
dump_json();
}
string ProcessDecl::getName() { return _entryName; }
json ProcessDecl::dump_json() const {
CXXMethodDecl *ProcessDecl::getEntryMethodDecl() { return _entryMethodDecl; }
// These are the three fields that we need to extract from entry_function_ptr.
json process_j;
process_j["entry_name"] = getName();
process_j["procesS_type"] = getType();
process_j["entry_method_declaration"] = to_string( getEntryMethodDecl() );
void ProcessDecl::dump(raw_ostream &os, int tabn) {
for (int i = 0; i < tabn; i++) {
os << " ";
}
os << "ProcessDecl " << this << " '" << _entryName << "' " << _entryMethodDecl
<< " " << _type;
_ef->dump(os, ++tabn);
std::cout << process_j.dump(4);
return process_j;
}
#ifndef _PROCESSDECL_H_
#define _PROCESSDECL_H_
#include "systemc-clang.h"
#include "json.hpp"
#include "EntryFunctionContainer.h"
#include "FindEntryFunctions.h"
#include "clang/AST/DeclCXX.h"
......@@ -11,6 +13,7 @@ namespace scpar {
using namespace std;
using namespace clang;
using json = nlohmann::json;
class ProcessDecl {
public:
......@@ -22,21 +25,22 @@ public:
~ProcessDecl();
/// Accessor methods.
string getType();
string getName();
CXXMethodDecl *getEntryMethodDecl();
string getType() const;
string getName() const;
CXXMethodDecl *getEntryMethodDecl() const;
// Dump.
void dump(raw_ostream &, int);
void dump(raw_ostream &);
json dump_json() const;
protected:
// Process information
string _type;
string _entryName;
string process_type_;
string entry_name_;
// Each process can have 1 entry function.
CXXMethodDecl *_entryMethodDecl;
CXXMethodDecl *entry_method_decl_;
EntryFunctionContainer *_ef;
EntryFunctionContainer *entry_function_ptr_;
}; // End class ProcessDecl
} // End namespace scpar
......
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