Reference Guide
2.5.0
|
Public Member Functions | |
def | __init__ (self, name, filename) |
def | name (self) |
def | filename (self) |
def | get_source_code (self) |
def | get_parse_tree (self) |
def | contains_routine (self, routine_name) |
def | get_used_modules (self) |
def | get_used_symbols_from_modules (self) |
def | get_psyir (self) |
def | resolve_routine (self, routine_name) |
This class stores mostly cached information about modules: it stores the original filename, if requested it will read the file and then caches the plain text file, and if required it will parse the file, and then cache the fparser AST. :param str name: the module name. :param str filename: the name of the source file that stores this module \ (including path).
Definition at line 73 of file module_info.py.
def psyclone.parse.module_info.ModuleInfo.contains_routine | ( | self, | |
routine_name | |||
) |
:returns: whether the specified routine name is part of this module or not. It will also return False if the file could not be parsed. :rtype: bool
Definition at line 218 of file module_info.py.
References psyclone.parse.module_info.ModuleInfo._routine_names, psyclone.parse.module_info.ModuleInfo._used_modules, psyclone.parse.module_info.ModuleInfo._used_symbols_from_module, and psyclone.parse.module_info.ModuleInfo.get_parse_tree().
def psyclone.parse.module_info.ModuleInfo.filename | ( | self | ) |
:returns: the filename that contains the source code for this \ module. :rtype: str
Definition at line 133 of file module_info.py.
References psyclone.parse.module_info.ModuleInfo._filename.
def psyclone.parse.module_info.ModuleInfo.get_parse_tree | ( | self | ) |
Returns the fparser AST for this module. The first time, the file will be parsed by fparser using the Fortran 2008 standard. The AST is then cached for any future uses. :returns: the fparser AST for this module. :rtype: :py:class:`fparser.two.Fortran2003.Program`
Definition at line 164 of file module_info.py.
References psyclone.parse.module_info.ModuleInfo._generic_interfaces, psyclone.parse.module_info.ModuleInfo._parse_tree, psyclone.parse.module_info.ModuleInfo._routine_names, and psyclone.parse.module_info.ModuleInfo.get_source_code().
def psyclone.parse.module_info.ModuleInfo.get_psyir | ( | self | ) |
Returns the PSyIR representation of this module. This is based on the fparser tree (see get_parse_tree), and the information is cached. If the PSyIR must be modified, it needs to be copied, otherwise the modified tree will be returned from the cache in the future. If the conversion to PSyIR fails, a dummy FileContainer with an empty Container (module) is returned, which avoids additional error handling in many other subroutines. #TODO 2120: This should be revisited when improving on the error handling. :param routine_name: optional the name of a routine. :type routine_name: Optional[str] :returns: PSyIR representing this module. :rtype: list[:py:class:`psyclone.psyir.nodes.Node`]
Definition at line 312 of file module_info.py.
References psyclone.parse.module_info.ModuleInfo._filename, psyclone.parse.module_info.ModuleInfo._processor, psyclone.psyir.frontend.fortran.FortranReader._processor, psyclone.parse.module_info.ModuleInfo._psyir, and psyclone.parse.module_info.ModuleInfo.get_parse_tree().
def psyclone.parse.module_info.ModuleInfo.get_source_code | ( | self | ) |
Returns the source code for the module. The first time, it will be read from the file, but the data is then cached. :returns: the source code. :rtype: str :raises ModuleInfoError: when the file cannot be read.
Definition at line 142 of file module_info.py.
References psyclone.parse.module_info.ModuleInfo._filename, and psyclone.parse.module_info.ModuleInfo._source_code.
def psyclone.parse.module_info.ModuleInfo.get_used_modules | ( | self | ) |
This function returns a set of all modules `used` in this module. Fortran `intrinsic` modules will be ignored. The information is based on the fparser parse tree of the module (since fparser can handle more files than PSyir, like LFRic's `constants_mod` which has pre-processor directives). :returns: a set with all imported module names. :rtype: set[str]
Definition at line 278 of file module_info.py.
References psyclone.parse.module_info.ModuleInfo._extract_import_information(), and psyclone.parse.module_info.ModuleInfo._used_modules.
def psyclone.parse.module_info.ModuleInfo.get_used_symbols_from_modules | ( | self | ) |
This function returns information about which modules are used by this module, and also which symbols are imported. The return value is a dictionary with the used module name as key, and a set of all imported symbol names as value. :returns: a dictionary that gives for each module name the set \ of symbols imported from it. :rtype: dict[str, set[str]]
Definition at line 295 of file module_info.py.
References psyclone.parse.module_info.ModuleInfo._extract_import_information(), and psyclone.parse.module_info.ModuleInfo._used_symbols_from_module.
def psyclone.parse.module_info.ModuleInfo.name | ( | self | ) |
:returns: the name of this module. :rtype: str
Definition at line 124 of file module_info.py.
References psyclone.domain.common.algorithm.psyir.AlgorithmInvokeCall._name, psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata._name, psyclone.domain.gocean.kernel.psyir.GOceanKernelMetadata.GridArg._name, psyclone.domain.lfric.kernel.lfric_kernel_metadata.LFRicKernelMetadata._name, psyclone.dynamo0p3.DynFuncDescriptor03._name, psyclone.expression.NamedArg._name, psyclone.gocean1p0.GOKernelGridArgument._name, psyclone.gocean1p0.GOStencil._name, psyclone.nemo.NemoInvoke._name, psyclone.nemo.NemoPSy._name, psyclone.parse.algorithm.FileInfo._name, psyclone.parse.algorithm.InvokeCall._name, psyclone.parse.kernel.KernelProcedure._name, psyclone.parse.kernel.KernelType._name, psyclone.parse.module_info.ModuleInfo._name, psyclone.psyGen.PSy._name, psyclone.psyGen.Invoke._name, psyclone.psyGen.Kern._name, psyclone.psyGen.Argument._name, psyclone.psyir.nodes.container.Container._name, psyclone.psyir.nodes.routine.Routine._name, and psyclone.psyir.symbols.symbol.Symbol._name.
def psyclone.parse.module_info.ModuleInfo.resolve_routine | ( | self, | |
routine_name | |||
) |
This function returns a list of function names that might be actually called when the routine `name` is called. In most cases this is exactly name, but in case of a generic subroutine the name might change. For now (since we cannot resolve generic interfaces yet), we return the list of all possible functions that might be called. :param str routine_name: the name of the routine to resolve :returns: list of routine name(s) that could be called. :rtype: list[str]
Definition at line 354 of file module_info.py.
References psyclone.parse.module_info.ModuleInfo._generic_interfaces, psyclone.parse.module_info.ModuleInfo._psyir, and psyclone.parse.module_info.ModuleInfo.get_psyir().