Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
caesr-pub
systemc-clang
Commits
e58cbf53
Commit
e58cbf53
authored
Mar 19, 2019
by
rmrf
Browse files
Globals should have json dump too
parent
47623cf0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
14 deletions
+33
-14
src/FindGlobalEvents.cpp
src/FindGlobalEvents.cpp
+21
-9
src/FindGlobalEvents.h
src/FindGlobalEvents.h
+6
-1
src/SystemCClang.cpp
src/SystemCClang.cpp
+6
-4
No files found.
src/FindGlobalEvents.cpp
View file @
e58cbf53
#include "FindGlobalEvents.h"
using
namespace
scpar
;
FindGlobalEvents
::
FindGlobalEvents
(
TranslationUnitDecl
*
d
,
llvm
::
raw_ostream
&
os
)
:
_os
(
os
)
{
TraverseDecl
(
d
);
FindGlobalEvents
::
FindGlobalEvents
(
TranslationUnitDecl
*
declaration
,
llvm
::
raw_ostream
&
os
)
:
_os
(
os
)
{
TraverseDecl
(
d
eclaration
);
}
FindGlobalEvents
::~
FindGlobalEvents
()
{}
bool
FindGlobalEvents
::
VisitVarDecl
(
VarDecl
*
vd
)
{
QualType
q
=
vd
->
getType
();
bool
FindGlobalEvents
::
VisitVarDecl
(
VarDecl
*
variable_declaration
)
{
QualType
variable_type
{
variable_declaration
->
getType
()
}
;
if
(
q
.
getAsString
()
==
"class sc_core::sc_event"
)
{
if
(
IdentifierInfo
*
info
=
v
d
->
getIdentifier
())
{
if
(
variable_type
.
getAsString
()
==
"class sc_core::sc_event"
)
{
if
(
IdentifierInfo
*
info
=
v
ariable_declaration
->
getIdentifier
())
{
_globalEvents
.
insert
(
kvType
(
info
->
getNameStart
(),
v
d
)
);
_globalEvents
.
insert
(
kvType
(
info
->
getNameStart
(),
v
ariable_declaration
)
);
}
}
return
true
;
...
...
@@ -34,3 +34,15 @@ void FindGlobalEvents::dump() {
}
_os
<<
"
\n
============== END FindGlobalEvents ==============="
;
}
json
FindGlobalEvents
::
dump_json
()
{
json
globals_j
{};
for
(
auto
const
&
event
:
_globalEvents
)
{
globals_j
[
"global_declarations"
].
emplace_back
(
event
.
first
)
;
}
std
::
cout
<<
globals_j
.
dump
(
4
)
<<
endl
;
return
globals_j
;
}
src/FindGlobalEvents.h
View file @
e58cbf53
#ifndef _FIND_GLOBAL_EVENTS_H_
#define _FIND_GLOBAL_EVENTS_H_
#include "systemc-clang.h"
#include "json.hpp"
#include "clang/AST/Decl.h"
#include "clang/AST/RecursiveASTVisitor.h"
...
...
@@ -11,7 +13,8 @@
namespace
scpar
{
using
namespace
clang
;
using
namespace
std
;
using
json
=
nlohmann
::
json
;
class
FindGlobalEvents
:
public
RecursiveASTVisitor
<
FindGlobalEvents
>
{
public:
typedef
map
<
string
,
VarDecl
*>
globalEventMapType
;
...
...
@@ -26,6 +29,8 @@ public:
vector
<
string
>
getEventNames
();
void
dump
();
json
dump_json
();
private:
llvm
::
raw_ostream
&
_os
;
...
...
src/SystemCClang.cpp
View file @
e58cbf53
...
...
@@ -15,13 +15,15 @@ bool SystemCConsumer::fire() {
// Reflection database.
_systemcModel
=
new
Model
{}
;
// ANI : Do we need FindGlobalEvents?
FindGlobalEvents
globals
{
tu
,
_os
};
FindGlobalEvents
::
globalEventMapType
eventMap
{
globals
.
getEventMap
()};
globals
.
dump_json
();
_systemcModel
->
addGlobalEvents
(
eventMap
);
// Find the sc_modules
FindSCModules
scmod
{
tu
,
_os
};
// ANI : Do we need FindGlobalEvents?
FindGlobalEvents
fglobals
{
tu
,
_os
};
FindGlobalEvents
::
globalEventMapType
eventMap
{
fglobals
.
getEventMap
()};
_systemcModel
->
addGlobalEvents
(
eventMap
);
FindSCModules
::
moduleMapType
scmodules
{
scmod
.
getSystemCModulesMap
()};
...
...
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