systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
ProcessDecl.cpp
Go to the documentation of this file.
1#include "ProcessDecl.h"
3
4#include "clang/AST/DeclCXX.h"
5
6using namespace systemc_clang;
7
8ProcessDecl::ProcessDecl(std::string process_type, std::string entry_name,
9 clang::CXXMethodDecl *entry_method_decl,
10 EntryFunctionContainer *entry_fn)
11 : process_type_(process_type),
12 entry_name_(entry_name),
13 entry_method_decl_(entry_method_decl),
14 entry_function_ptr_(entry_fn) {}
15
17 // The following points do NOT need to be deleted:entry_method_decl_,
18 // _constructorStmt. This is because they are pointers to the clang AST, which
19 // are going to be freed by clang itself.
20
21 entry_method_decl_ = nullptr;
22 entry_function_ptr_ = nullptr;
23}
24
31
32std::string ProcessDecl::getType() const { return process_type_; }
33
34std::string ProcessDecl::getName() const { return entry_name_; }
35
36const clang::CXXMethodDecl *ProcessDecl::getEntryMethodDecl() const {
37 return entry_method_decl_;
38}
39
43
45 LLVM_DEBUG(llvm::dbgs() << "ProcessDecl " << this << " '" << entry_name_
46 << "' " << entry_method_decl_ << " "
47 << process_type_;);
48
49 LLVM_DEBUG(llvm::dbgs() << "\nEntry function:\n";);
50 LLVM_DEBUG(entry_function_ptr_->dump(llvm::outs()));
51}
52
53std::string ProcessDecl::asString() const {
54 std::string str{};
55
56 str += "entry_name: " + getName() + "\n";
57 str += "process_type: " + getType() + "\n";
58 str += "entry_method_declaration: " + to_string(getEntryMethodDecl());
59
60 if (entry_function_ptr_ != nullptr) {
61 auto sense_map{entry_function_ptr_->getSenseMap()};
62 str +=
63 "number_of_sensitivity_signals: " + std::to_string(sense_map.size()) +
64 "\n";
65
66 for (auto const &sense : sense_map) {
67 str += "sensitivity_list[" + sense.first + "]" +
68 std::to_string(sense.second.size()) + "\n";
69 }
70 }
71 return str;
72}
A container class to hold entry function information.
ProcessDecl(std::string process_type, std::string entry_name, clang::CXXMethodDecl *entry_method_decl, EntryFunctionContainer *entry_fn)
const clang::CXXMethodDecl * entry_method_decl_
Each process can have 1 entry function.
Definition ProcessDecl.h:61
virtual ~ProcessDecl()
Destructor.
std::string process_type_
Process information.
Definition ProcessDecl.h:57
std::string getName() const
std::string getType() const
Get methods.
EntryFunctionContainer * entry_function_ptr_
This is a container that holds information about the entry function.
Definition ProcessDecl.h:63
std::string asString() const
Dump.
std::string entry_name_
Name of the entry function.
Definition ProcessDecl.h:59
const clang::CXXMethodDecl * getEntryMethodDecl() const
EntryFunctionContainer * getEntryFunction()
std::string to_string(T *pointer)
Definition ProcessDecl.h:18