pyccel.ast.c_concepts module#
Module representing concepts that are only applicable to C code (e.g. ObjectAddress).
- class pyccel.ast.c_concepts.CMacro(arg)[source]#
Bases:
PyccelAstNode
Represents a c macro
- property macro#
The string containing macro name
- class pyccel.ast.c_concepts.CNativeInt(self)[source]#
Bases:
FixedSizeNumericType
Class representing C’s native integer type.
Class representing C’s native integer type.
- class pyccel.ast.c_concepts.CStackArray(self, element_type)[source]#
Bases:
HomogeneousContainerType
A data type representing an array allocated on the stack.
A data type representing an array allocated on the stack. E.g. float a[4];
- Parameters:
element_type (FixedSizeType) – The type of the elements inside the array.
- class pyccel.ast.c_concepts.CStrStr(arg)[source]#
Bases:
PyccelFunction
A class which extracts a const char* from a literal string.
A class which extracts a const char* from a literal string. This is useful for calling C functions which were not designed for STC.
- Parameters:
arg (TypedAstNode | CMacro) – The object which should be passed as a const char*.
- class pyccel.ast.c_concepts.CStringExpression(*args)[source]#
Bases:
PyccelAstNode
Internal class used to hold a C string that has LiteralStrings and C macros.
- Parameters:
*args (str / LiteralString / CMacro / CStringExpression) – any number of arguments to be added to the expression note: they will get added in the order provided
Example
>>> expr = CStringExpression( ... CMacro("m"), ... CStringExpression( ... LiteralString("the macro is: "), ... CMacro("mc") ... ), ... LiteralString("."), ... )
- append(o)[source]#
append the argument o to the end of the list _expression
Parameter#
- ostr / LiteralString / CMacro / CStringExpression
the expression to append
- property expression#
The list containing the literal strings and c macros
- get_flat_expression_list()[source]#
returns a list of LiteralStrings and CMacros after merging every consecutive LiteralString
- join(lst)[source]#
insert self between each element of the list lst
Parameter#
- lstlist
the list to insert self between its elements
Example
>>> a = [ ... CMacro("m"), ... CStringExpression(LiteralString("the macro is: ")), ... LiteralString("."), ... ] >>> b = CStringExpression("?").join(a) ... ... # is the same as: ... >>> b = CStringExpression( ... CMacro("m"), ... CStringExpression("?"), ... CStringExpression(LiteralString("the macro is: ")), CStringExpression("?"), ... LiteralString("."), ... )
- class pyccel.ast.c_concepts.ObjectAddress(obj)[source]#
Bases:
TypedAstNode
Class representing the address of an object.
Class representing the address of an object. In most situations it will not be necessary to use this object explicitly. E.g. if you assign a pointer to a target then the pointer will be printed using AliasAssign. However for the _print_AliasAssign function to print neatly, this class will be used.
- Parameters:
obj (TypedAstNode) – The object whose address should be printed.
Examples
>>> CCodePrinter._print(ObjectAddress(Variable(PythonNativeInt(),'a'))) '&a' >>> CCodePrinter._print(ObjectAddress(Variable(PythonNativeInt(),'a', memory_handling='alias'))) 'a'
- property is_alias#
Indicate that an ObjectAddress uses alias memory handling.
Indicate that an ObjectAddress uses alias memory handling.
- property obj#
The object whose address is of interest
- class pyccel.ast.c_concepts.PointerCast(obj, cast_type)[source]#
Bases:
TypedAstNode
A class which represents the casting of one pointer to another.
A class which represents the casting of one pointer to another in C code. This is useful for storing addresses in a void pointer. Using this class is not strictly necessary to produce correct C code, but avoids compiler warnings about the implicit conversion of pointers.
- Parameters:
obj (Variable) – The pointer being cast.
cast_type (TypedAstNode) – A TypedAstNode describing the object resulting from the cast.
- property cast_type#
Get the TypedAstNode which describes the object resulting from the cast.
Get the TypedAstNode which describes the object resulting from the cast.
- property is_argument#
Indicates whether the variable is an argument.
Indicates whether the variable is an argument.
- property obj#
The object whose address is of interest.
The object whose address is of interest.