38 ''' This module contains the implementation of the StructureMember node.'''
40 from __future__
import absolute_import
48 Node representing a membership expression of the parent's Reference that
49 resolves into another structure.
55 _children_valid_format =
"[Member]"
56 _text_name =
"StructureMember"
59 def create(member_name, inner_member):
61 Given the name of a structure member of a structure and a Member
62 node describing the access to a component of it, construct a
65 e.g. if we had the following Fortran access: grid%subdomain%xstart
66 then 'subdomain' must itself be of structure type and we are accessing
67 the 'xstart' component of it. We would therefore create the
68 `StructureMember` for this by calling:
70 >>> smem = StructureMember.create("subdomain", Member("xstart"))
72 :param str member_name: name of the structure member.
73 :param inner_member: a Member describing the access to a component \
74 of the named structure member.
75 :type inner_member: sub-class of \
76 :py:class:`psyclone.psyir.nodes.Member`
80 smem.addchild(inner_member)
84 result = super(StructureMember, self).__str__()
86 result +=
"\n" + str(self.
_children_children[0])
90 def _validate_child(position, child):
92 :param int position: the position to be validated.
93 :param child: a child to be validated.
94 :type child: :py:class:`psyclone.psyir.nodes.Node`
96 :return: whether the given child and position are valid for this node.
102 return isinstance(child, Member)
109 :returns: the member of the structure that is being accessed.
110 :rtype: (sub-class of) :py:class:`psyclone.psyir.nodes.Member`
112 :raises InternalError: if the first child of this node is not an \
117 f
"{type(self).__name__} malformed or incomplete. The first "
118 f
"child must be an instance of Member, but found "
119 f
"'{type(self.children[0]).__name__}'")
123 ''':returns: the Signature of this structure member, and \
124 a list of the indices used for each component (empty list \
125 for this component, since the access is not an array - but \
126 other components might have indices).
127 :rtype: tuple(:py:class:`psyclone.core.Signature`, list of \
135 __all__ = [
'StructureMember']
def children(self, my_children)
def create(member_name, inner_member)
def get_signature_and_indices(self)