psyclone.psyir.backend.language_writer#

PSyIR visitor layer that provides convenient functions that can be reused for different language-specific visitors.

Classes#

  • LanguageWriter: A convenience PSyIR visitor intermediate class. It provides

class psyclone.psyir.backend.language_writer.LanguageWriter(array_parenthesis, structure_character, **kwargs)[source]#

A convenience PSyIR visitor intermediate class. It provides configuration options and functions that can be shared between different language-specific visitors.

Parameters:
  • array_parenthesis (2-tuple of str) – a tuple of two strings that contain the opening and closing parenthesis used for array accesses - e.g.: (“(”, “)”).

  • structure_symbol (str) – the symbol to be used to address a member of a structure, e.g. “%”.

  • kwargs (unwrapped dict.) – additional keyword arguments provided to the super class.

Raises:

TypeError – if any of the supplied parameters are of the wrong type.

Inheritance

Inheritance diagram of LanguageWriter
property array_parenthesis#
Returns:

the array parenthesis to be used in this language.

Return type:

two element list of str

arrayofstructuresreference_node(node)[source]#

Creates the code for a reference to one or more elements of an array of derived types.

Parameters:

node (psyclone.psyir.nodes.ArrayOfStructuresReference) – an ArrayOfStructuresReference PSyIR node.

Returns:

the code as string.

Return type:

str

Raises:

VisitorError – if the supplied node does not have the correct number and type of children.

arrayreference_node(node)[source]#

This method is called when an ArrayReference instance is found in the PSyIR tree.

Parameters:

node (psyclone.psyir.nodes.ArrayNode) – an ArrayNode PSyIR node.

Returns:

the code as a string.

Return type:

str

Raises:

VisitorError – if the node does not have any children.

clause_node(node)[source]#

This method is called when a Clause instance is found in the PSyIR tree. It returns the clause and its children as a string.

Parameters:

node (psyclone.psyir.nodes.Clause) – a Clause PSyIR node.

Returns:

the code for this node.

Return type:

str

abstractmethod gen_indices(indices, var_name=None)[source]#

Given a list of PSyIR nodes representing the dimensions of an array, return a list of strings representing those array dimensions.

Parameters:
  • indices (list of psyclone.psyir.symbols.Node) – list of PSyIR nodes.

  • var_name (str) – name of the variable for which the dimensions are created. Only used in the C implementation.

Returns:

the code representation of the dimensions.

Return type:

list of str

member_node(node)[source]#

Creates the code for an access to a member of a derived type.

Parameters:

node (psyclone.psyir.nodes.Member) – a Member PSyIR node.

Returns:

the code as string

Return type:

str

property structure_character#
Returns:

the character use to access a member of a structure in this language.

Return type:

str

structurereference_node(node)[source]#

Creates the code for an access to a member of a structure type.

Parameters:

node (psyclone.psyir.nodes.StructureReference) – a StructureReference PSyIR node.

Returns:

the code as string.

Return type:

str

Raises:

VisitorError – if this node does not have an instance of Member as its only child.