psyclone.core.signature
This module provides management of variable access information.
Classes
Signature
: Given a variable access of the forma(i,j)%b(k,l)%c
, the signature
- class psyclone.core.signature.Signature(variable, sub_sig=None)
Given a variable access of the form
a(i,j)%b(k,l)%c
, the signature of this access is the tuple(a,b,c)
. For a simple scalar variablea
the signature would just be(a,)
. The signature is the key used in VariablesAccessInfo. In order to make sure two different signature objects containing the same variable can be used as a key, this class implements __hash__ and other special functions. The constructor also supports appending an existing signature to this new signature using the sub_sig argument. This is used in StructureReference to assemble the overall signature of a structure access.- Parameters:
variable (str or tuple of str or list of str) – the variable that is accessed.
sub_sig (
psyclone.core.Signature
) – a signature that is to be added to this new signature.
Inheritance
- property is_structure
- Returns:
True if this signature represents a structure.
- Return type:
bool
- to_language(component_indices=None, language_writer=None)
Converts this signature with the provided indices to a string in the selected language.
TODO 1320 This subroutine can be removed when we stop supporting strings - then we can use a PSyIR writer for the ReferenceNode to provide the right string.
- Parameters:
component_indices (None (default is scalar access), or
psyclone.core.component_indices.ComponentIndices
) – the indices for each component of the signature.language_writer (None (default is Fortran), or an instance of
psyclone.psyir.backend.language_writer.LanguageWriter
) – a backend visitor to convert PSyIR expressions to a representation in the selected language. This is used when creating error and warning messages.
- Raises:
InternalError – if the number of components in this signature is different from the number of indices in component_indices.
- property var_name
- Returns:
the actual variable name, i.e. the first component of the signature.
- Return type:
str