mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
fhdl/tracer: remove leading underscores from names
This commit is contained in:
parent
c4d9734e53
commit
3c75121783
1 changed files with 8 additions and 0 deletions
|
@ -28,6 +28,11 @@ def get_var_name(frame):
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def remove_underscore(s):
|
||||||
|
if len(s) > 2 and s[0] == "_" and s[1] != "_":
|
||||||
|
s = s[1:]
|
||||||
|
return s
|
||||||
|
|
||||||
name_to_idx = defaultdict(int)
|
name_to_idx = defaultdict(int)
|
||||||
classname_to_objs = dict()
|
classname_to_objs = dict()
|
||||||
|
|
||||||
|
@ -44,6 +49,7 @@ def trace_back(varname=None):
|
||||||
if varname is None:
|
if varname is None:
|
||||||
varname = get_var_name(frame)
|
varname = get_var_name(frame)
|
||||||
if varname is not None:
|
if varname is not None:
|
||||||
|
varname = remove_underscore(varname)
|
||||||
l.insert(0, (varname, name_to_idx[varname]))
|
l.insert(0, (varname, name_to_idx[varname]))
|
||||||
name_to_idx[varname] += 1
|
name_to_idx[varname] += 1
|
||||||
|
|
||||||
|
@ -61,6 +67,7 @@ def trace_back(varname=None):
|
||||||
modules = frame.f_globals["__name__"]
|
modules = frame.f_globals["__name__"]
|
||||||
modules = modules.split(".")
|
modules = modules.split(".")
|
||||||
coname = modules[len(modules)-1]
|
coname = modules[len(modules)-1]
|
||||||
|
coname = remove_underscore(coname)
|
||||||
l.insert(0, (coname, name_to_idx[coname]))
|
l.insert(0, (coname, name_to_idx[coname]))
|
||||||
name_to_idx[coname] += 1
|
name_to_idx[coname] += 1
|
||||||
else:
|
else:
|
||||||
|
@ -76,6 +83,7 @@ def trace_back(varname=None):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
idx = len(objs)
|
idx = len(objs)
|
||||||
objs.append(obj)
|
objs.append(obj)
|
||||||
|
classname = remove_underscore(classname)
|
||||||
l.insert(0, (classname, idx))
|
l.insert(0, (classname, idx))
|
||||||
|
|
||||||
varname = None
|
varname = None
|
||||||
|
|
Loading…
Reference in a new issue