systemc-clang
2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
plugins
hdl
parselib
transforms
name_stub.py
Go to the documentation of this file.
1
from
lark
import
Tree
2
import
random
3
from
types
import
LambdaType
4
5
class
FuncNameStub
(Tree):
6
"""Name stub for function"""
7
def
__init__
(self, func_name, meta=None):
8
super().
__init__
(
'func_name_stub'
, [func_name], meta)
9
10
11
class
FuncParamNameStub
(Tree):
12
"""Name stub for function parameter"""
13
def __init__(self, param_name, tpe, meta=None):
14
super().__init__('func_param_name_stub', [param_name, tpe], meta)
15
16
def insert_name(self, name_list):
17
id = 0
18
pn = self.children[0]
19
rn = pn + f'__ref_{id}'
20
while rn in name_list:
21
id += 1
22
rn = pn + f'__ref_{id}'
23
self.children[0] = rn
24
25
26
class ProcessVarNameStub(Tree):
27
"""
Name stub for variables in a process"""
28
def __init__(self, var_name, tpe, meta=None):
29
super().__init__('process_var_name_stub', [var_name, tpe], meta)
30
self.orig_name = var_name
31
32
def insert_name(self, name_check):
33
id = 0
34
pn = self.children[0]
35
rn = pn + f'__ref_{id}'
36
if isinstance(name_check, LambdaType):
37
while name_check(rn):
38
id += 1
39
rn = pn + f'__ref_{id}'
40
else:
41
raise ValueError('Unsupported name generation check for ProcessVarNameStub')
42
self.children[0] = rn
parselib.transforms.name_stub.FuncNameStub
Definition
name_stub.py:5
parselib.transforms.name_stub.FuncNameStub.__init__
__init__(self, func_name, meta=None)
Definition
name_stub.py:7
parselib.transforms.name_stub.FuncParamNameStub
Definition
name_stub.py:11
Generated by
1.12.0