Extensions and Experimental Features#
The module pystencils.backend.extensions
contains extensions to the pystencils code generator
beyond its core functionality.
The tools and classes of this module are considered experimental; their support by the remaining code generator is limited. They can be used to model and generate code outside of the usual scope of pystencils, such as non-standard syntax and types. At the moment, the primary use case is the modelling of C++ syntax.
Foreign Syntax Support#
- class pystencils.backend.extensions.foreign_ast.PsForeignExpression(children, dtype=None)#
Base class for foreign expressions.
Foreign expressions are expressions whose properties are not modelled by the pystencils AST, and which pystencils therefore does not understand.
There are many situations where non-supported expressions are needed; the most common use case is C++ syntax. Support for foreign expressions by the code generator is therefore very limited; as a rule of thumb, only printing is supported. Type checking and most transformations will fail when encountering a
PsForeignExpression
.- Parameters:
children (Iterable[PsExpression])
dtype (PsType | None)
- abstract get_code(children_code)#
Print this expression, with the given code for each of its children.
- get_children()#
Retrieve child nodes of this AST node
This operation must be implemented by subclasses.
C++ Language Support#
- class pystencils.backend.extensions.cpp.CppMethodCall(obj, method, return_type, args=())#
C++ method call on an expression.
- Parameters:
obj (PsExpression)
method (str)
return_type (PsType)
args (Iterable)
- structurally_equal(other)#
Check two ASTs for structural equality.
By default this method checks the node’s type and children. If an AST node has additional internal state, it MUST override this method.
- _clone_expr()#
Implementation of expression cloning.
- Return type: