loki.module

Contains the declaration of Module to represent Fortran modules.

Classes

Module([name, docstring, spec, contains, ...])

Class to handle and manipulate source modules.

class Module(name=None, docstring=None, spec=None, contains=None, default_access_spec=None, public_access_spec=None, private_access_spec=None, ast=None, source=None, parent=None, symbol_attrs=None, rescope_symbols=False, incomplete=False, parser_classes=None)

Bases: ProgramUnit

Class to handle and manipulate source modules.

Parameters:
  • name (str) – Name of the module.

  • docstring (CommentBlock or list of Comment) – The module docstring

  • spec (Section, optional) – The spec section of the module.

  • contains (tuple of Subroutine, optional) – The module-subprogram part following a CONTAINS statement declaring member procedures.

  • default_access_spec (str, optional) – The default access attribute for variables as defined by an access-spec statement without access-id-list, i.e., public or private. Default value is None corresponding to the absence of an access-spec statement for default accessibility (which is equivalent to public).

  • public_access_spec (tuple of str, optional) – List of identifiers that are declared public in an access-spec statement. Default value is None which is stored as an empty tuple.

  • private_access_spec (tuple of str, optional) – List of identifiers that are declared private in an access-spec statement. Default value is None which is stored as an empty tuple.

  • ast (optional) – The node for this module from the parse tree produced by the frontend.

  • source (Source, optional) – Object representing the raw source string information from the read file.

  • parent (Scope, optional) – The enclosing parent scope of the module. Declarations from the parent scope remain valid within the module’s scope (unless shadowed by local declarations).

  • rescope_symbols (bool, optional) – Ensure that the type information for all TypedSymbol in the module’s IR exist in the module’s scope. Defaults to False.

  • symbol_attrs (SymbolTable, optional) – Use the provided SymbolTable object instead of creating a new

  • incomplete (bool, optional) – Mark the object as incomplete, i.e. only partially parsed. This is typically the case when it was instantiated using the Frontend.REGEX frontend and a full parse using one of the other frontends is pending.

  • parser_classes (RegexParserClass, optional) – Provide the list of parser classes used during incomplete regex parsing

classmethod from_omni(ast, raw_source, definitions=None, parent=None, type_map=None)

Create Module from OMNI parse tree

Parameters:
  • ast – The OMNI parse tree

  • raw_source (str) – Fortran source string

  • definitions (list, optional) – List of external Module to provide derived-type and procedure declarations

  • parent (Scope, optional) – The enclosing parent scope of the module

  • type_map (dict, optional) – A mapping from type hash identifiers to type definitions, as provided in OMNI’s typeTable parse tree node

classmethod from_ofp(ast, raw_source, definitions=None, pp_info=None, parent=None)

Create Module from OFP parse tree

Parameters:
  • ast – The OFP parse tree

  • raw_source (str) – Fortran source string

  • definitions (list) – List of external Module to provide derived-type and procedure declarations

  • pp_info – Preprocessing info as obtained by sanitize_input

  • parent (Scope, optional) – The enclosing parent scope of the module.

classmethod from_fparser(ast, raw_source, definitions=None, pp_info=None, parent=None)

Create Module from FP parse tree

Parameters:
  • ast – The FParser parse tree

  • raw_source (str) – Fortran source string

  • definitions (list) – List of external Module to provide derived-type and procedure declarations

  • pp_info – Preprocessing info as obtained by sanitize_input

  • parent (Scope, optional) – The enclosing parent scope of the module.

classmethod from_regex(raw_source, parser_classes=None, parent=None)

Create Module from source regex’ing

Parameters:
  • raw_source (str) – Fortran source string

  • parent (Scope, optional) – The enclosing parent scope of the subroutine, typically a Module.

register_in_parent_scope()

Insert the type information for this object in the parent’s symbol table

If parent is None, this does nothing.

clone(**kwargs)

Create a copy of the module with the option to override individual parameters.

Parameters:

**kwargs – Any parameters from the constructor of Module.

Returns:

The cloned module object.

Return type:

Module

property module_type

Return the ModuleType of this module

property definitions

The list of IR nodes defined by this module

Returns Subroutine and TypeDef nodes declared in this module