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, iterable_type)[source]#
Bases:
PyccelType
The 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)
- Parameters:
iterable_type (ContainerType) – The container that is iterated over.
- property datatype#
The datatype of the object.
The datatype of the object.
- property iterable_type#
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 order#
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 rank#
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]#
Bases:
PyccelAstNode
A 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_name#
The name of the macro being defined.
The name of the macro being defined.
- property object#
The object that will define the macro.
The object that will define the macro.
- class pyccel.ast.low_level_tools.MacroUndef(macro_name)[source]#
Bases:
PyccelAstNode
A 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_name#
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]#
Bases:
PyccelAstNode
A 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_var#
Get the variable responsible for managing the memory.
Get the variable responsible for managing the memory.
- property var#
Get the variable whose memory is being managed.
Get the variable whose memory is being managed.
- class pyccel.ast.low_level_tools.MemoryHandlerType(self, element_type)[source]#
Bases:
PyccelType
The 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.
- Parameters:
element_type (PyccelType) – The type of the element whose memory is being managed.
- property container_rank#
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_type#
The type of the element whose memory is being managed.
The type of the element whose memory is being managed.
- property rank#
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]#
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, key_type, value_type)[source]#
Bases:
PyccelType
The type of an element of a dictionary type.
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_type#
The type of the keys of the object.
The type of the keys of the object.
- property value_type#
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]#
Bases:
PyccelAstNode
Assign 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_object#
Get the object whose memory is being managed.
Get the object whose memory is being managed.
- property memory_handler_var#
Get the variable responsible for managing the memory.
Get the variable responsible for managing the memory.
- property out_ptr#
Get the variable which will point at the managed memory block.
Get the variable which will point at the managed memory block.