mirror of
https://github.com/myhdl/myhdl.git
synced 2025-01-24 21:52:56 +08:00
removed special generator handling
This commit is contained in:
parent
29fa0d50b3
commit
f28e09ee29
@ -164,8 +164,12 @@ class _HierExtr(object):
|
||||
if isinstance(so, (tuple, list)):
|
||||
for i, soi in enumerate(so):
|
||||
names[id(soi)] = "%s[%s]" % (sn, i)
|
||||
print id(soi)
|
||||
print "%s[%s]" % (sn, i)
|
||||
absnames[id(soi)] = "%s_%s_%s" % (tn, sn, i)
|
||||
# print "%s_%s_%s" % (tn, sn, i)
|
||||
m[1] = names[id(obj)]
|
||||
# print names
|
||||
|
||||
|
||||
|
||||
@ -191,33 +195,33 @@ class _HierExtr(object):
|
||||
sigdict[n] = v
|
||||
if _isListOfSigs(v):
|
||||
memdict[n] = _makeMemInfo(v)
|
||||
l = []
|
||||
for n, o in frame.f_locals.items():
|
||||
for e in _inferArgs(arg):
|
||||
if e is o:
|
||||
l.append((n, o))
|
||||
for n, o in l:
|
||||
if type(o) is _AlwaysComb:
|
||||
g = o.gen
|
||||
else:
|
||||
g = o
|
||||
# special handling of locally defined generators
|
||||
# outside the profiling mechanism
|
||||
if id(o) not in self.returned and \
|
||||
type(g) is GeneratorType:
|
||||
gsigdict = {}
|
||||
gmemdict = {}
|
||||
for dict in (g.gi_frame.f_globals,
|
||||
g.gi_frame.f_locals):
|
||||
for n, v in dict.items():
|
||||
if isinstance(v, Signal):
|
||||
gsigdict[n] = v
|
||||
if _isListOfSigs(v):
|
||||
gmemdict[n] = _makeMemInfo(v)
|
||||
inst = [self.level+1, (o, ()), gsigdict, gmemdict]
|
||||
self.hierarchy.append(inst)
|
||||
subs = []
|
||||
for n, obj in frame.f_locals.items():
|
||||
for elt in _inferArgs(arg):
|
||||
if elt is obj:
|
||||
subs.append((n, obj))
|
||||
# special handling of locally defined generators
|
||||
# outside the profiling mechanism
|
||||
## for obj in _getGens(arg):
|
||||
## gen = obj
|
||||
## if isinstance(obj, _AlwaysComb):
|
||||
## gen = obj.gen
|
||||
## if id(obj) not in self.returned:
|
||||
## assert type(gen) is GeneratorType
|
||||
## gsigdict = {}
|
||||
## gmemdict = {}
|
||||
## for dict in (gen.gi_frame.f_globals,
|
||||
## gen.gi_frame.f_locals):
|
||||
## for n, v in dict.items():
|
||||
## if isinstance(v, Signal):
|
||||
## gsigdict[n] = v
|
||||
## if _isListOfSigs(v):
|
||||
## gmemdict[n] = _makeMemInfo(v)
|
||||
## inst = [self.level+1, (obj, ()), gsigdict, gmemdict]
|
||||
## # print inst
|
||||
## self.hierarchy.append(inst)
|
||||
self.returned.add(id(arg))
|
||||
inst = [self.level, (arg, l), sigdict, memdict]
|
||||
inst = [self.level, (arg, subs), sigdict, memdict]
|
||||
self.hierarchy.append(inst)
|
||||
self.level -= 1
|
||||
|
||||
@ -228,18 +232,35 @@ class _HierExtr(object):
|
||||
|
||||
|
||||
def _getGens(arg):
|
||||
if type(arg) is GeneratorType:
|
||||
if isinstance(arg, (GeneratorType, _AlwaysComb)):
|
||||
return [arg]
|
||||
elif type(arg) is _AlwaysComb:
|
||||
return [arg.gen]
|
||||
else:
|
||||
l = []
|
||||
gens = []
|
||||
for elt in arg:
|
||||
if type(elt) is GeneratorType:
|
||||
l.append(elt)
|
||||
elif type(elt) is _AlwaysComb:
|
||||
l.append(elt.gen)
|
||||
return l
|
||||
if isinstance(elt, (GeneratorType, _AlwaysComb)):
|
||||
gens.append(elt)
|
||||
return gens
|
||||
|
||||
|
||||
## def _getGens(*args):
|
||||
## gens = []
|
||||
## for arg in args:
|
||||
## if isinstance(arg, (list, tuple, Set)):
|
||||
## for item in arg:
|
||||
## gens.extend(_getGens(item))
|
||||
## else:
|
||||
## if isinstance(arg, (GeneratorType, _AlwaysComb)):
|
||||
## gens.append(arg)
|
||||
## return gens
|
||||
|
||||
|
||||
## def _getGens(*args):
|
||||
## gens = []
|
||||
## for arg in args:
|
||||
## if isinstance(arg, (GeneratorType, _AlwaysComb)):
|
||||
## gens.append(arg)
|
||||
## return gens
|
||||
|
||||
|
||||
|
||||
def _inferArgs(arg):
|
||||
|
Loading…
x
Reference in New Issue
Block a user