Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
S
systemc-clang
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
caesr-pub
systemc-clang
Commits
7e25e8e5
Commit
7e25e8e5
authored
Feb 11, 2019
by
rmrf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ProcessDecl: JSON print
parent
3de49875
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
26 deletions
+49
-26
src/ModuleDecl.cpp
src/ModuleDecl.cpp
+1
-1
src/ProcessDecl.cpp
src/ProcessDecl.cpp
+36
-17
src/ProcessDecl.h
src/ProcessDecl.h
+12
-8
No files found.
src/ModuleDecl.cpp
View file @
7e25e8e5
...
...
@@ -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
"
;
}
}
...
...
src/ProcessDecl.cpp
View file @
7e25e8e5
#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
<<
"
\n
Entry 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
;
}
src/ProcessDecl.h
View file @
7e25e8e5
#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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment