mirror of
https://github.com/myhdl/myhdl.git
synced 2024-12-14 07:44:38 +08:00
improve trace_sigs
This commit is contained in:
parent
4497f0f32c
commit
c32f1f5f2c
@ -49,6 +49,11 @@ def fun():
|
||||
inst = gen(clk)
|
||||
return inst
|
||||
|
||||
def fun2():
|
||||
clk = Signal(bool(0))
|
||||
inst = gen(clk)
|
||||
return inst
|
||||
|
||||
def dummy():
|
||||
clk = Signal(bool(0))
|
||||
inst = gen(clk)
|
||||
|
@ -63,12 +63,12 @@ re_assname = re.compile(r"^\s*(?P<assname>\w[\w\d]*)\s*=")
|
||||
|
||||
def trace_sigs(dut, *args, **kwargs):
|
||||
global _tracing
|
||||
if _tracing:
|
||||
return dut(*args, **kwargs) # skip
|
||||
if not callable(dut):
|
||||
raise ArgTypeError("got %s" % type(dut))
|
||||
if _isgeneratorfunction(dut):
|
||||
raise ArgTypeError("got generator function")
|
||||
if _tracing:
|
||||
return dut(*args, **kwargs) # skip
|
||||
_tracing = 1
|
||||
try:
|
||||
o = getouterframes(currentframe())[1]
|
||||
|
@ -98,15 +98,15 @@ def _isGenSeq(obj):
|
||||
return 1
|
||||
|
||||
def _isgeneratorfunction(obj):
|
||||
if type(obj) is FunctionType:
|
||||
s = inspect.getsource(obj)
|
||||
s = s.lstrip()
|
||||
s = 'from __future__ import generators\n' + s # for 2.2 ...
|
||||
tree = compiler.parse(s)
|
||||
v = _YieldVisitor()
|
||||
compiler.walk(tree, v)
|
||||
return v.isgenfunc
|
||||
return 0
|
||||
if type(obj) is FunctionType:
|
||||
s = inspect.getsource(obj)
|
||||
s = s.lstrip()
|
||||
s = 'from __future__ import generators\n' + s # for 2.2 ...
|
||||
tree = compiler.parse(s)
|
||||
v = _YieldVisitor()
|
||||
compiler.walk(tree, v)
|
||||
return v.isgenfunc
|
||||
return 0
|
||||
|
||||
class _YieldVisitor(object):
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user