Module¶
A Fortran module or submodule.
Declaration¶
Syntax¶
Module(symbol_table symtab, identifier name, identifier? parent_module,
identifier* dependencies, bool loaded_from_mod, bool intrinsic,
bool has_submodules, location start_name, location end_name)
Arguments¶
Argument |
Description |
|---|---|
|
the symbol table of the module, owning everything the module declares. |
|
the name of the module. |
|
for a submodule, the name of the module it extends; |
|
the names of the modules this module uses. |
|
|
|
|
|
|
|
the source span of the name in |
|
the source span of the name in |
Return values¶
None.
Description¶
A Module owns the symbols it declares. Code in another program unit never looks a module symbol up through this table directly: it declares an ExternalSymbol in its own scope that points at the symbol here.
When a module is compiled, the full ASR (abi=Source, non-empty procedure
bodies) and the interface ASR (abi=LFortranModule, empty bodies) are both
written to the module file. loaded_from_mod records which side of that a
particular Module came from.
Examples¶
(Module
:symtab (SymbolTable
:id 1
:symbols {
"pi" (Variable
:parent_symtab 1
:name "pi"
:dependencies []
:intent :Local
:symbolic_value (RealConstant
:r 3.1415926535897931
:type (Real
:kind 8
)
)
:value (RealConstant
:r 3.1415926535897931
:type (Real
:kind 8
)
)
:storage :Parameter
:type (Real
:kind 8
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
}
)
:name "constants"
:parent_module nil
:dependencies []
:loaded_from_mod false
:intrinsic false
:has_submodules false
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"constants" (Module
:symtab (SymbolTable
:id 1
:symbols {
"pi" (Variable
:parent_symtab 1
:name "pi"
:dependencies []
:intent :Local
:symbolic_value (RealConstant
:r 3.1415926535897931
:type (Real
:kind 8
)
)
:value (RealConstant
:r 3.1415926535897931
:type (Real
:kind 8
)
)
:storage :Parameter
:type (Real
:kind 8
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
}
)
:name "constants"
:parent_module nil
:dependencies []
:loaded_from_mod false
:intrinsic false
:has_submodules false
)
"main" (Program
:symtab (SymbolTable
:id 2
:symbols {}
)
:name "main"
:dependencies []
:body []
)
}
)
:items []
)