@@ -59,7 +59,7 @@ def flip(self):
5959 return Out
6060 assert False # :nocov:
6161
62- def __call__ (self , description , * , reset = None ):
62+ def __call__ (self , description , * , reset = None , src_loc_at = 0 ):
6363 """Create a :class:`Member` with this data flow and the provided description and
6464 reset value.
6565
@@ -68,7 +68,7 @@ def __call__(self, description, *, reset=None):
6868 :class:`Member`
6969 :pc:`Member(self, description, reset=reset)`
7070 """
71- return Member (self , description , reset = reset )
71+ return Member (self , description , reset = reset , src_loc_at = src_loc_at + 1 )
7272
7373 def __repr__ (self ):
7474 return self .name
@@ -105,11 +105,12 @@ class Member:
105105 Although instances can be created directly, most often they will be created through
106106 :data:`In` and :data:`Out`, e.g. :pc:`In(unsigned(1))` or :pc:`Out(stream.Signature(RGBPixel))`.
107107 """
108- def __init__ (self , flow , description , * , reset = None , _dimensions = ()):
108+ def __init__ (self , flow , description , * , reset = None , _dimensions = (), src_loc_at = 0 ):
109109 self ._flow = flow
110110 self ._description = description
111111 self ._reset = reset
112112 self ._dimensions = _dimensions
113+ self .src_loc = tracer .get_src_loc (src_loc_at = src_loc_at )
113114
114115 # Check that the description is valid, and populate derived properties.
115116 if self .is_port :
@@ -493,8 +494,13 @@ def create(self, *, path=None, src_loc_at=0):
493494 for name , member in self .items ():
494495 def create_value (path , * , src_loc_at ):
495496 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
498504 if member .is_signature :
499505 return member .signature .create (path = path , src_loc_at = 1 + src_loc_at )
500506 assert False # :nocov:
@@ -1610,7 +1616,7 @@ def __init__(self, data_width):
16101616 If a name conflict is detected between two variable annotations, or between a member
16111617 and an existing attribute.
16121618 """
1613- def __init__ (self , signature = None ):
1619+ def __init__ (self , signature = None , * , src_loc_at = 0 ):
16141620 cls = type (self )
16151621 members = {}
16161622 for base in reversed (cls .mro ()[:cls .mro ().index (Component )]):
@@ -1644,7 +1650,7 @@ def __init__(self, signature=None):
16441650 if hasattr (self , name ):
16451651 raise NameError (f"Cannot initialize attribute for signature member { name !r} "
16461652 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 ))
16481654
16491655 @property
16501656 def signature (self ):
0 commit comments