pyccel.ast.low_level_tools module#
Module to handle low-level language agnostic objects such as macros.
- class pyccel.ast.low_level_tools.IteratorType(self)[source]View on GitHub#
Bases:
PyccelTypeThe type of an iterator which accesses elements of a container.
The type of an iterator which accesses elements of a container (e.g. list, set, etc)
- property datatypeView on GitHub#
The datatype of the object.
The datatype of the object.
- classmethod get_new(iterable_type)[source]View on GitHub#
Get the parametrised iterator type.
Get the subclass of IteratorType describing the type of an iterator element of iterable_type.
- Parameters:
iterable_type (PyccelType) – The type of the iterable object whose elements are accessed via this type.
- property iterable_typeView on GitHub#
The type of the iterable object whose elements are accessed via this type.
The type of the iterable object whose elements are accessed via this type.
- property orderView on GitHub#
The data layout ordering in memory.
Indicates whether the data is stored in row-major (‘C’) or column-major (‘F’) format. This is only relevant if rank > 1. When it is not relevant this function returns None.
- property rankView on GitHub#
Number of dimensions of the object.
Number of dimensions of the object. If the object is a scalar then this is equal to 0.
- class pyccel.ast.low_level_tools.MacroDefinition(macro_name, obj)[source]View on GitHub#
Bases:
PyccelAstNodeA class for defining a macro in a file.
A class for defining a macro in a file.
- Parameters:
macro_name (str) – The name of the macro.
obj (Any) – The object that will define the macro.
- property macro_nameView on GitHub#
The name of the macro being defined.
The name of the macro being defined.
- property objectView on GitHub#
The object that will define the macro.
The object that will define the macro.
- class pyccel.ast.low_level_tools.MacroUndef(macro_name)[source]View on GitHub#
Bases:
PyccelAstNodeA class for undefining a macro in a file.
A class for undefining a macro in a file.
- Parameters:
macro_name (str) – The name of the macro.
- property macro_nameView on GitHub#
The name of the macro being undefined.
The name of the macro being undefined.
- class pyccel.ast.low_level_tools.ManagedMemory(var, mem_var)[source]View on GitHub#
Bases:
PyccelAstNodeA class which links a variable to the variable which manages its memory.
A class which links a variable to the variable which manages its memory. This class does not need to appear in the AST description of the file. Simply creating an instance will add it to the AST tree which will ensure that it is found when examining the variable.
- Parameters:
- property mem_varView on GitHub#
Get the variable responsible for managing the memory.
Get the variable responsible for managing the memory.
- property varView on GitHub#
Get the variable whose memory is being managed.
Get the variable whose memory is being managed.
- class pyccel.ast.low_level_tools.MemoryHandlerType(self)[source]View on GitHub#
Bases:
PyccelTypeThe type of an object which can hold a pointer and manage its memory.
The type of an object which can hold a pointer and manage its memory by choosing whether or not to deallocate. This class may be used notably for list elements and dictionary values.
- property container_rankView on GitHub#
Number of dimensions of the memory handler object.
Number of dimensions of the memory handler object. This is the number of indices that can be used to directly index the object.
- property element_typeView on GitHub#
The type of the element whose memory is being managed.
The type of the element whose memory is being managed.
- classmethod get_new(element_type)[source]View on GitHub#
Get the parametrised MemoryHandlerType.
Get the subclass of MemoryHandlerType describing the type of an object which can hold a pointer and manage its memory.
- Parameters:
element_type (PyccelType) – The type of the element whose memory is being managed.
- property rankView on GitHub#
Number of dimensions of the object.
Number of dimensions of the object. This is equal to the number of dimensions of the element whose memory is being managed.
- shape_is_compatible(shape)[source]View on GitHub#
Check if the provided shape is compatible with the datatype.
Check if the provided shape is compatible with the format expected for this datatype.
- Parameters:
shape (Any) – The proposed shape.
- Returns:
True if the shape is acceptable, False otherwise.
- Return type:
bool
- class pyccel.ast.low_level_tools.PairType(self)[source]View on GitHub#
Bases:
PyccelTypeThe type of an element of a dictionary type.
The type of an element of a dictionary type.
- classmethod get_new(key_type, value_type)[source]View on GitHub#
Get the type of an element of a dictionary type.
Get the type of an element of a dictionary type.
- Parameters:
key_type (PyccelType) – The type of the keys of the homogeneous dictionary.
value_type (PyccelType) – The type of the values of the homogeneous dictionary.
- property key_typeView on GitHub#
The type of the keys of the object.
The type of the keys of the object.
- property value_typeView on GitHub#
The type of the values of the object.
The type of the values of the object.
- class pyccel.ast.low_level_tools.UnpackManagedMemory(out_ptr, managed_object, mem_var)[source]View on GitHub#
Bases:
PyccelAstNodeAssign a pointer to a managed memory block.
A class representing the operation whereby an object whose memory is managed by a MemoryHandlerType is assigned as the target of a pointer.
- Parameters:
out_ptr (Variable) – The variable which will point at this memory block.
managed_object (TypedAstNode) – The object whose memory is being managed.
mem_var (Variable) – The variable responsible for managing the memory.
- property managed_objectView on GitHub#
Get the object whose memory is being managed.
Get the object whose memory is being managed.
- property memory_handler_varView on GitHub#
Get the variable responsible for managing the memory.
Get the variable responsible for managing the memory.
- property out_ptrView on GitHub#
Get the variable which will point at the managed memory block.
Get the variable which will point at the managed memory block.