systemc-clang
2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
plugins
hdl
parselib
transforms
node_movement.py
Go to the documentation of this file.
1
from
lark
import
Tree, Token
2
from
parselib.utils
import
dprint
3
from
parselib.transforms
import
TopDown
4
5
6
class
NodeMovement
(
TopDown
):
7
def
__init__
(self):
8
super().
__init__
()
9
# record function per module
10
self.
functions
= dict()
11
self.
current_module
=
None
12
13
def
hmodule
(self, tree):
14
self.
current_module
= tree.children[0]
15
self.
__push_up
(tree)
16
functions = self.
functions
.get(self.
current_module
)
17
if
functions:
18
for
f
in
functions:
19
tree.children.append(f)
20
self.
current_module
=
None
21
return
tree
22
23
def
__add_functions
(self, functions):
24
res = self.
functions
.setdefault(self.
current_module
, [])
25
res.extend(functions)
26
27
def
hprocess
(self, tree):
28
functions = list(filter(
lambda
x: isinstance(x, Tree)
and
x.data ==
'hfunction'
, tree.children))
29
tree.children = list(filter(
lambda
x:
not
(isinstance(x, Tree)
and
x.data ==
'hfunction'
), tree.children))
30
self.
__add_functions
(functions)
31
return
tree
parselib.transforms.node_movement.NodeMovement
Definition
node_movement.py:6
parselib.transforms.node_movement.NodeMovement.__init__
__init__(self)
Definition
node_movement.py:7
parselib.transforms.node_movement.NodeMovement.functions
functions
Definition
node_movement.py:10
parselib.transforms.node_movement.NodeMovement.__add_functions
__add_functions(self, functions)
Definition
node_movement.py:23
parselib.transforms.node_movement.NodeMovement.hprocess
hprocess(self, tree)
Definition
node_movement.py:27
parselib.transforms.node_movement.NodeMovement.current_module
current_module
Definition
node_movement.py:11
parselib.transforms.node_movement.NodeMovement.hmodule
hmodule(self, tree)
Definition
node_movement.py:13
parselib.transforms.top_down.TopDown
Definition
top_down.py:24
parselib.transforms.top_down.TopDown.__push_up
__push_up(self, current_node)
Definition
top_down.py:29
parselib.transforms
Definition
__init__.py:1
parselib.utils
Definition
utils.py:1
Generated by
1.12.0