psyclone.psyir.nodes.array_of_structures_reference

This module contains the implementation of the ArrayOfStructuresReference node.

Classes

class psyclone.psyir.nodes.array_of_structures_reference.ArrayOfStructuresReference(symbol, **kwargs)

Node representing an access to a member of one or more elements of an array of structures. Since this access is to a member of the structure, its first child will be a subclass of Member. All subsequent children give the array-index expressions.

Inheritance

Inheritance diagram of ArrayOfStructuresReference
static create(symbol, indices, members, parent=None, overwrite_datatype=None)

Create a reference to a member of one or more elements of an array of structures.

The symbol to be referred to must be of UnresolvedType, UnsupportedType or ArrayType. If the latter then the ‘intrinsic’ type of the array must be specified with a DataTypeSymbol. The member of the structure that is accessed is specified using the ‘members’ argument. e.g. for a reference to “field(idx)%bundle(2)%flag” this argument would be [(“bundle”, [Literal(“2”, INTEGER4_TYPE)]), “flag”]. The ‘indices’ argument specifies the DataNodes describing the indexing into the array of structures. For the example given previously, this would be [Reference(idx_symbol)] where idx_symbol is the Symbol representing the idx variable in the Fortran code snippet.

Parameters:
  • symbol (psyclone.psyir.symbols.DataSymbol) – the symbol that this reference is to.

  • indices (list of psyclone.psyir.nodes.Node) – a list of Nodes describing the array indices.

  • members (list of str or 2-tuples containing (str, list of nodes describing array access)) – one or more component(s) of the structure(s) that make up the full access. Any components that are array references must provide the name of the array and a list of DataNodes describing which part of it is accessed.

  • parent (sub-class of psyclone.psyir.nodes.Node) – the parent of this node in the PSyIR.

  • overwrite_datatype (Optional[psyclone.psyir.symbols.DataType]) – the datatype for the reference, which will overwrite the value determined by analysing the corresponding user defined type. This is useful when e.g. the module that declares the structure cannot be accessed.

Returns:

an ArrayOfStructuresReference instance.

Return type:

psyclone.psyir.nodes.ArrayOfStructuresReference

Raises:

TypeError – if the arguments to the create method are not of the expected type.