@@ -59,7 +59,7 @@ def flip(self):
59
59
return Out
60
60
assert False # :nocov:
61
61
62
- def __call__ (self , description , * , reset = None ):
62
+ def __call__ (self , description , * , reset = None , src_loc_at = 0 ):
63
63
"""Create a :class:`Member` with this data flow and the provided description and
64
64
reset value.
65
65
@@ -68,7 +68,7 @@ def __call__(self, description, *, reset=None):
68
68
:class:`Member`
69
69
:pc:`Member(self, description, reset=reset)`
70
70
"""
71
- return Member (self , description , reset = reset )
71
+ return Member (self , description , reset = reset , src_loc_at = src_loc_at + 1 )
72
72
73
73
def __repr__ (self ):
74
74
return self .name
@@ -105,11 +105,12 @@ class Member:
105
105
Although instances can be created directly, most often they will be created through
106
106
:data:`In` and :data:`Out`, e.g. :pc:`In(unsigned(1))` or :pc:`Out(stream.Signature(RGBPixel))`.
107
107
"""
108
- def __init__ (self , flow , description , * , reset = None , _dimensions = ()):
108
+ def __init__ (self , flow , description , * , reset = None , _dimensions = (), src_loc_at = 0 ):
109
109
self ._flow = flow
110
110
self ._description = description
111
111
self ._reset = reset
112
112
self ._dimensions = _dimensions
113
+ self .src_loc = tracer .get_src_loc (src_loc_at = src_loc_at )
113
114
114
115
# Check that the description is valid, and populate derived properties.
115
116
if self .is_port :
@@ -493,8 +494,13 @@ def create(self, *, path=None, src_loc_at=0):
493
494
for name , member in self .items ():
494
495
def create_value (path , * , src_loc_at ):
495
496
if member .is_port :
496
- return Signal (member .shape , reset = member .reset , src_loc_at = 1 + src_loc_at ,
497
- name = "__" .join (str (item ) for item in path ))
497
+ # Ideally we would keep both source locations here, but the .src_loc attribute
498
+ # data structure doesn't currently support that, so keep the more important one:
499
+ # the one with the name of the signal (the `In()`/`Out()` call site.)
500
+ signal = Signal (member .shape , reset = member .reset , src_loc_at = 1 + src_loc_at ,
501
+ name = "__" .join (str (item ) for item in path ))
502
+ signal .src_loc = member .src_loc
503
+ return signal
498
504
if member .is_signature :
499
505
return member .signature .create (path = path , src_loc_at = 1 + src_loc_at )
500
506
assert False # :nocov:
@@ -1610,7 +1616,7 @@ def __init__(self, data_width):
1610
1616
If a name conflict is detected between two variable annotations, or between a member
1611
1617
and an existing attribute.
1612
1618
"""
1613
- def __init__ (self , signature = None ):
1619
+ def __init__ (self , signature = None , * , src_loc_at = 0 ):
1614
1620
cls = type (self )
1615
1621
members = {}
1616
1622
for base in reversed (cls .mro ()[:cls .mro ().index (Component )]):
@@ -1644,7 +1650,7 @@ def __init__(self, signature=None):
1644
1650
if hasattr (self , name ):
1645
1651
raise NameError (f"Cannot initialize attribute for signature member { name !r} "
1646
1652
f"because an attribute with the same name already exists" )
1647
- self .__dict__ .update (signature .members .create (path = ()))
1653
+ self .__dict__ .update (signature .members .create (path = (), src_loc_at = src_loc_at + 1 ))
1648
1654
1649
1655
@property
1650
1656
def signature (self ):
0 commit comments