loki.module
Contains the declaration of Module
to represent Fortran modules.
Classes
|
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 ofComment
) – The module docstringspec (
Section
, optional) – The spec section of the module.contains (tuple of
Subroutine
, optional) – The module-subprogram part following aCONTAINS
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
orprivate
. Default value is None corresponding to the absence of an access-spec statement for default accessibility (which is equivalent topublic
).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 providedSymbolTable
object instead of creating a newincomplete (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
fromOMNI
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 declarationsparent (
Scope
, optional) – The enclosing parent scope of the moduletype_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
fromOFP
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 declarationspp_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
fromFP
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 declarationspp_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
- 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.
- property module_type
Return the
ModuleType
of this module
- property definitions
The list of IR nodes defined by this module
Returns
Subroutine
andTypeDef
nodes declared in this module