PyForTool
Python-fortran-tool
Loading...
Searching...
No Matches
Classes | Functions
pyfortool.variables Namespace Reference

Classes

class  Variables
 
class  VarList
 

Functions

 _getDeclStmtTag (scopePath)
 
 updateVarList (func)
 

Detailed Description

Variable management and declaration manipulation.

Provides the VarList and Variables classes for managing FORTRAN variable
declarations and characteristics.

Key Features
------------
- Variable declaration parsing and analysis
- Array specification management (attach/detach dimensions)
- Automatic array transformation (stack to heap allocation)
- Unused variable detection and removal
- Module and dummy argument handling

Classes
-------
VarList : Manages a list of variables for a scope
Variables : Mixin class providing variable manipulation methods

Examples
--------
>>> pft = PYFT('input.F90')
>>> pft.varList.findVar('X')
{'n': 'X', 't': 'REAL', 'as': [], 'i': None, ...}
>>> pft.attachArraySpecToEntity()
>>> pft.modifyAutomaticArrays(
        declTemplate="{type}, DIMENSION({doubledotshape}), ALLOCATABLE :: {name}",
        startTemplate="ALLOCATE({name}({shape}))",
        endTemplate="DEALLOCATE({name})")

Function Documentation

◆ _getDeclStmtTag()

pyfortool.variables._getDeclStmtTag (   scopePath)
protected
Get the declaration statement tag for a given scope path.

Parameters
----------
scopePath : str
    A scope path (e.g., 'module:MOD/sub:SUB' or 'type:MYTYPE').

Returns
-------
str
    The XML tag for declaration statements:
    - 'component-decl-stmt' for type declarations
    - 'T-decl-stmt' for other scopes (module, subroutine, function)

Definition at line 46 of file variables.py.

Here is the caller graph for this function:

◆ updateVarList()

pyfortool.variables.updateVarList (   func)
Decorator to invalidate the variable list cache.

Signals that the variable list needs to be recomputed after
a modification to the code tree.

Definition at line 69 of file variables.py.