Skip to content

Commit 140173e

Browse files
committed
add puSrcName helper function
1 parent 4b98e35 commit 140173e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Language/Fortran/Analysis.hs

+8-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
-- |
44
-- Common data structures and functions supporting analysis of the AST.
55
module Language.Fortran.Analysis
6-
( initAnalysis, stripAnalysis, Analysis(..), varName, srcName, genVar, puName, blockRhsExprs, rhsExprs
6+
( initAnalysis, stripAnalysis, Analysis(..), varName, srcName, genVar, puName, puSrcName, blockRhsExprs, rhsExprs
77
, ModEnv, NameType(..), IDType(..), ConstructType(..), BaseType(..)
88
, lhsExprs, isLExpr, allVars, allLhsVars, blockVarUses, blockVarDefs
99
, BB, BBGr
@@ -92,12 +92,18 @@ srcName _ = error "Use of srcName on non-variable."
9292
genVar :: Analysis a -> SrcSpan -> String -> Expression (Analysis a)
9393
genVar a s n = ExpValue (a { uniqueName = Just n }) s (ValVariable n)
9494

95-
-- | Obtain either uniqueName or source program unit name.
95+
-- | Obtain either ProgramUnit uniqueName or whatever is in the AST.
9696
puName :: ProgramUnit (Analysis a) -> ProgramUnitName
9797
puName pu
9898
| Just n <- uniqueName (getAnnotation pu) = Named n
9999
| otherwise = getName pu
100100

101+
-- | Obtain either ProgramUnit sourceName or whatever is in the AST.
102+
puSrcName :: ProgramUnit (Analysis a) -> ProgramUnitName
103+
puSrcName pu
104+
| Just n <- sourceName (getAnnotation pu) = Named n
105+
| otherwise = getName pu
106+
101107
-- | Create analysis annotations for the program, saving the original
102108
-- annotations.
103109
initAnalysis :: Functor b => b a -> b (Analysis a)

0 commit comments

Comments
 (0)