loki.transformations.sanitise.associates
A small selection of utility transformations that resolve certain code constructs to unify code structure and make reasoning about Fortran code easier.
Functions
  | 
Moves associate mappings in   | 
  | 
Resolve   | 
Classes
  | 
  | 
  | 
  | 
  | 
Exppression mapper that will resolve symbol associations due   | 
  | 
  | 
- class AssociatesTransformation(resolve_associates=True, merge_associates=False, start_depth=0, max_parents=None)
 Bases:
TransformationTransformationobject to apply code sanitisation steps specific toAssociatenodes.It allows merging in nested
Associatescopes to move independent assocation pairs to the outermost scope, optionally restricted by a number ofmax_parentssymbols.It also provides partial or full resolution of
Associatenodes by replacingidentifiersymbols with the correspondingselectorin the node’s body.- Parameters:
 resolve_associates (bool, default: True) – Enable full or partial resolution of only
Associatescopes.merge_associates (bool, default: False) – Enable merging
Associateto the outermost possible scope in nested associate blocks.start_depth (int, optional) – Starting depth for partial resolution of
Associateafter merging.max_parents (int, optional) – Maximum number of parent symbols for valid selector to have when merging
Associatenodes.
- transform_subroutine(routine, **kwargs)
 Defines the transformation to apply to
Subroutineitems.For transformations that modify
Subroutineobjects, this method should be implemented. It gets called via the dispatch methodapply().- Parameters:
 routine (
Subroutine) – The subroutine to be transformed.**kwargs (optional) – Keyword arguments for the transformation.
- do_resolve_associates(routine, start_depth=0)
 Resolve
Associatemappings in the body of a given routine.Optionally, partial resolution of only inner
Associatemappings is supported when astart_depthis specified.- Parameters:
 routine (
Subroutine) – The subroutine for which to resolve all associate blocks.start_depth (int, optional) – Starting depth for partial resolution of
Associate
- class ResolveAssociatesTransformer(start_depth=0, **kwargs)
 Bases:
TransformerTransformerclass to resolveAssociatenodes in IR trees.This will replace each
Associatenode with its own body, where allidentifiersymbols have been replaced with the correspondingselectorexpression defined inassociations.Importantly, this
Transformercan also be applied over partial bodies ofAssociatebodies.Optionally, partial resolution of only inner
Associatemappings is supported when astart_depthis specified.- visit_Expression(o, **kwargs)
 
- visit_CallStatement(o, **kwargs)
 
- do_merge_associates(routine, max_parents=None)
 Moves associate mappings in
Associatewithin aSubroutineto the outermost parent scope.Please see
MergeAssociatesTransformerfor mode details.Note
This method can be combined with
resolve_associatesto create a more unified look-and-feel for nested ASSOCIATE blocks.- Parameters:
 routine (
Subroutine) – The subroutine for which to resolve all associate blocks.max_parents (int, optional) – Maximum number of parent symbols for valid selector to have.