# loki.transformations.inline.transformation

Classes

`InlineTransformation`([inline_constants, ...]) | `Transformation` class to apply several types of source inlining when batch-processing large source trees via the `Scheduler`.

class InlineTransformation(inline_constants=False, inline_elementals=True, inline_stmt_funcs=False, inline_internals=False, inline_marked=True, remove_dead_code=True, allowed_aliases=None, adjust_imports=True, external_only=True, resolve_sequence_association=False)

  Bases: `Transformation`

  `Transformation` class to apply several types of source inlining when batch-processing large source trees via the `Scheduler`.

  Parameters:

    - inline_constants (bool) – Replace instances of variables with known constant values by `Literal` (see `inline_constant_parameters`); default: False.

    - inline_elementals (bool) – Replaces `InlineCall` expression to elemental functions with the called function’s body (see `inline_elemental_functions`); default: True.

    - inline_stmt_funcs (bool) – Replaces `InlineCall` expression to statement functions with the corresponding rhs of the statement function if the statement function declaration is available; default: False.

    - inline_internals (bool) – Inline internal procedure (see `inline_internal_procedures`); default: False.

    - inline_marked (bool) – Inline `Subroutine` objects marked by pragma annotations (see `inline_marked_subroutines`); default: True.

    - remove_dead_code (bool) – Perform dead code elimination, where unreachable branches are trimmed from the code (see `dead_code_elimination`); default: True

    - allowed_aliases (tuple or list of str or `Expression`, optional) – List of variables that will not be renamed in the parent scope during internal and pragma-driven inlining.

    - adjust_imports (bool) – Adjust imports by removing the symbol of the inlined routine or adding imports needed by the imported routine (optional, default: True)

    - external_only (bool, optional) – Do not replace variables declared in the local scope when inlining constants (default: True)

    - resolve_sequence_association (bool) – Resolve sequence association for routines that contain calls to inline (default: False)

  reverse_traversal = True
  creates_items = False
  transform_subroutine(routine, **kwargs)

    Defines the transformation to apply to `Subroutine` items.

    For transformations that modify `Subroutine` objects, this method should be implemented. It gets called via the dispatch method `apply()`.

    Parameters:

      - routine (`Subroutine`) – The subroutine to be transformed.

      - **kwargs (optional) – Keyword arguments for the transformation.

  plan_subroutine(routine, **kwargs)

    Define the planning steps to apply for `Subroutine` items.

    For transformations that modify the dependencies of `routine` (e.g., adding new procedure calls, inlining calls, renaming the interface) this should be implemented. It gets called via the dispatch method `apply()` if the optional `plan_mode` argument is set to True.

    Parameters:

      - routine (`Subroutine`) – The subroutine to be transformed.

      - **kwargs (optional) – Keyword arguments for the transformation.