psyclone.psyir.nodes.literal#

This module contains the Literal node implementation.

Classes#

  • Literal: Node representing a Literal. The value and datatype properties of

class psyclone.psyir.nodes.literal.Literal(value, datatype, parent=None)[source]#

Node representing a Literal. The value and datatype properties of this node are immutable.

If the node represents “real” data and the value is expressed with an exponent (e.g. 3.2e4 or 0.1E-3) then the stored value always uses a lower case “e”.

Parameters:
Raises:
  • TypeError – if the datatype is not an instance of psyclone.psyir.symbols.DataType.

  • ValueError – if the datatype is not one of self.VALID_DATA_TYPES.

  • TypeError – if the supplied value is not a string.

  • ValueError – if the supplied value is an empty string and the Literal is not a CHARACTER.

  • ValueError – if the Literal is a BOOLEAN and the value is not ‘true’ or ‘false’.

  • ValueError – if the Literal is a REAL but does not conform to the supported format defined by the _real_value property.

  • ValueError – if the Literal is an INTEGER but does not conform to the supported format defined by the _int_value property.

Inheritance

Inheritance diagram of Literal
property datatype#
Returns:

the type of this Literal.

Return type:

psyclone.psyir.symbols.DataType

get_all_accessed_symbols()[source]#
Return type:

set[Symbol]

Returns:

a set of all the symbols accessed inside this Literal.

node_str(colour=True)[source]#

Construct a text representation of this node, optionally containing colour control codes.

Parameters:

colour (bool) – whether or not to include colour control codes.

Returns:

description of this PSyIR node.

Return type:

str

reference_accesses()[source]#
Return type:

VariablesAccessMap

Returns:

a map of all the symbol accessed inside this node, the keys are Signatures (unique identifiers to a symbol and its structure acccessors) and the values are AccessSequence (a sequence of AccessTypes).

replace_symbols_using(table_or_symbol)[source]#

Replace any Symbols referred to by this object with those in the supplied SymbolTable (or just the supplied Symbol instance) if they have matching names. If there is no match for a given Symbol then it is left unchanged.

Parameters:

table_or_symbol (psyclone.psyir.symbols.SymbolTable | psyclone.psyir.symbols.Symbol) – the symbol table from which to get replacement symbols or a single, replacement Symbol.

property value#
Returns:

String representing the literal value.

Return type:

str