psyclone.psyir.transformations.move_trans#
This module provides the MoveTrans transformation.
Classes#
MoveTrans: Provides a transformation to move a node in the tree. For
- class psyclone.psyir.transformations.move_trans.MoveTrans[source]#
Provides a transformation to move a node in the tree. For example:
>>> from psyclone.parse.algorithm import parse >>> from psyclone.psyGen import PSyFactory >>> ast,invokeInfo=parse("lfric.F90") >>> psy=PSyFactory("lfric").create(invokeInfo) >>> schedule=psy.invokes.get('invoke_v3_kernel_type').schedule >>> # Uncomment the following line to see a text view of the schedule >>> # print(schedule.view()) >>> >>> from psyclone.transformations import MoveTrans >>> trans=MoveTrans() >>> trans.apply(schedule.children[0], schedule.children[2], ... options = {"position":"after") >>> # Uncomment the following line to see a text view of the schedule >>> # print(schedule.view())
Nodes may only be moved to a new location with the same parent and must not break any dependencies otherwise an exception is raised.
Inheritance

- apply(node, location, position='before', options=None, **kwargs)[source]#
Move the node represented by
nodebefore locationlocation(which is also a node) by default and after if the optional position argument is set to ‘after’.- Parameters:
node (
Node) – the node to be moved.location (
Node) – node before or after which the given node should be moved.position (
str) – whether to place the moved node before or after the location. This must be ‘before’ or ‘after’.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
options["position"] (str) – either ‘before’ or ‘after’.
- Raises:
TransformationError – if the given node is not an instance of
psyclone.psyir.nodes.NodeTransformationError – if the location is not valid.
- validate(node, location, options=None, **kwargs)[source]#
validity checks for input arguments.
- Parameters:
node (
Node) – the node to be moved.options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.
options["position"] (str) – either ‘before’ or ‘after’.
location (
Node) – node before or after which the given node should be moved.position (str) – whether to place the moved node before or after the location. This must be ‘before’ or ‘after’.
- Raises:
TransformationError – if the given node is not an instance of
psyclone.psyir.nodes.NodeTransformationError – if the location is not valid.