psyclone.core.component_indices#
This module provides a class to manage indices in variable accesses.
Classes#
ComponentIndices: This class stores index information for variable accesses. It stores
- class psyclone.core.component_indices.ComponentIndices(indices=None)[source]#
This class stores index information for variable accesses. It stores one index list for each component of a variable, e.g. for a(i)%b(j) it would store [ [i], [j] ]. Even for scalar accesses an empty list is stored, so a would have the component indices [ [] ], and a%b would have [ [], [] ]. Each member of this list of lists is the PSyIR node describing the array expression used.
As a shortcut, the indices parameter can be None or an empty list (which then creates the component indices as [[]], i.e. indicating a scalar access), a list l (which will then create the component indices as [l], i.e. a single component variable, which uses all the indices in the list l as array indices).
TODO #845 - the constructor should check that the things it is passed are PSyIR nodes. Currently it is sometimes given strings.
- Parameters:
indices (None, [], a list or a list of lists of
psyclone.psyir.nodes.Node) – the indices from which to create this object.- Raises:
InternalError – if the indices parameter is not None, a list or a list of lists.
InternalError – if the indices parameter is a list, and some but not all members are a list.
Inheritance

- get_subscripts_of(set_of_vars)[source]#
This function returns a flat list of which variable from the given set of variables is used in each subscript. For example, the access a(i+i2)%b(j*j+k,k)%c(l,5) would have the component_indices [[i+i2], [j*j+k,k], [l,5]]. If the set of variables is (i,j,k), then get_subscripts_of would return [{i},{j,k},{k},{l},{}].
- Parameters:
set_of_vars (Set[str]) – set with name of all variables.
- Returns:
a list of sets with all variables used in the corresponding array subscripts as strings.
- Return type:
List[Set[str]]
- has_indices()[source]#
- Return type:
bool- Returns:
whether any of the access components uses an index
- property indices_lists#
- Returns:
the component indices list of lists.
- Return type:
list of list of
psyclone.psyir.nodes.Node
- iterate()[source]#
Allows iterating over all component indices. It returns a tuple with two elements, the first one indicating the component, the second the dimension for which the index is. The return tuple can be used in a dictionary access (see __getitem__) of this object.
- Returns:
a tuple of the component index and index.
- Return type:
tuple(int, int)