Safe Haskell | None |
---|---|
Language | Haskell2010 |
Language.Fortran.Analysis
Contents
Description
Common data structures and functions supporting analysis of the AST.
Synopsis
- initAnalysis :: Functor b => b a -> b (Analysis a)
- analysis0 :: a -> Analysis a
- stripAnalysis :: Functor b => b (Analysis a) -> b a
- data Analysis a = Analysis {}
- varName :: Expression (Analysis a) -> Name
- srcName :: Expression (Analysis a) -> Name
- lvVarName :: LValue (Analysis a) -> Name
- lvSrcName :: LValue (Analysis a) -> Name
- isNamedExpression :: Expression a -> Bool
- genVar :: Analysis a -> SrcSpan -> Name -> Expression (Analysis a)
- puName :: ProgramUnit (Analysis a) -> ProgramUnitName
- puSrcName :: ProgramUnit (Analysis a) -> ProgramUnitName
- blockRhsExprs :: Data a => Block a -> [Expression a]
- rhsExprs :: (Data a, Data (b a)) => b a -> [Expression a]
- type ModEnv = Map String (String, NameType)
- data NameType
- data Locality
- markAsImported :: NameType -> NameType
- isImported :: NameType -> Bool
- data IDType = IDType {}
- data ConstructType
- = CTFunction
- | CTSubroutine
- | CTExternal
- | CTVariable
- | CTArray [(Maybe Int, Maybe Int)]
- | CTParameter
- | CTIntrinsic
- lhsExprs :: (Data a, Data (b a)) => b a -> [Expression a]
- isLExpr :: Expression a -> Bool
- allVars :: (Data a, Data (b (Analysis a))) => b (Analysis a) -> [Name]
- analyseAllLhsVars :: Data a => ProgramFile (Analysis a) -> ProgramFile (Analysis a)
- analyseAllLhsVars1 :: (Annotated f, Data (f (Analysis a)), Data a) => f (Analysis a) -> f (Analysis a)
- allLhsVars :: Data a => Block (Analysis a) -> [Name]
- blockVarUses :: Data a => Block (Analysis a) -> [Name]
- blockVarDefs :: Data a => Block (Analysis a) -> [Name]
- type BB a = [Block a]
- type BBNode = Int
- data BBGr a = BBGr {}
- bbgrMap :: (Gr (BB a) () -> Gr (BB b) ()) -> BBGr a -> BBGr b
- bbgrMapM :: Monad m => (Gr (BB a1) () -> m (Gr (BB a2) ())) -> BBGr a1 -> m (BBGr a2)
- bbgrEmpty :: BBGr a
- type TransFunc (f :: Type -> Type) (g :: Type -> Type) a = (f (Analysis a) -> f (Analysis a)) -> g (Analysis a) -> g (Analysis a)
- type TransFuncM (m :: Type -> Type) (f :: Type -> Type) (g :: Type -> Type) a = (f (Analysis a) -> m (f (Analysis a))) -> g (Analysis a) -> m (g (Analysis a))
Documentation
initAnalysis :: Functor b => b a -> b (Analysis a) Source #
Create analysis annotations for the program, saving the original annotations.
stripAnalysis :: Functor b => b (Analysis a) -> b a Source #
Remove analysis annotations from the program, restoring the original annotations.
Constructors
Analysis | |
Fields
|
Instances
varName :: Expression (Analysis a) -> Name Source #
Obtain either uniqueName
or sourceName
from an ExpValue
variable, or
an ExpDataRef
.
Precedence is as follows:
- if
uniqueName
is present, it is returned - else if
sourceName
is present, it is returned - else the variable name itself is returned
Crashes on Expression
s which don't define a variable.
srcName :: Expression (Analysis a) -> Name Source #
Obtain the source name from an ExpValue variable.
lvVarName :: LValue (Analysis a) -> Name Source #
Obtain either uniqueName or source name from an LvSimpleVar variable.
lvSrcName :: LValue (Analysis a) -> Name Source #
Obtain the source name from an LvSimpleVar variable.
isNamedExpression :: Expression a -> Bool Source #
True iff the expression can be used with varName or srcName
genVar :: Analysis a -> SrcSpan -> Name -> Expression (Analysis a) Source #
Generate an ExpValue variable with its source name == to its uniqueName.
puName :: ProgramUnit (Analysis a) -> ProgramUnitName Source #
Obtain either ProgramUnit uniqueName or whatever is in the AST.
puSrcName :: ProgramUnit (Analysis a) -> ProgramUnitName Source #
Obtain either ProgramUnit sourceName or whatever is in the AST.
blockRhsExprs :: Data a => Block a -> [Expression a] Source #
Set of expressions used -- not defined -- by an AST-block.
rhsExprs :: (Data a, Data (b a)) => b a -> [Expression a] Source #
Return list of expressions that are not "left-hand-side" of assignment statements.
Constructors
NTSubprogram Locality | |
NTVariable Locality | |
NTIntrinsic |
Instances
Out NameType Source # | |||||
Data NameType Source # | |||||
Defined in Language.Fortran.Analysis Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NameType -> c NameType # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c NameType # toConstr :: NameType -> Constr # dataTypeOf :: NameType -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c NameType) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c NameType) # gmapT :: (forall b. Data b => b -> b) -> NameType -> NameType # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NameType -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NameType -> r # gmapQ :: (forall d. Data d => d -> u) -> NameType -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> NameType -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> NameType -> m NameType # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NameType -> m NameType # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NameType -> m NameType # | |||||
Generic NameType Source # | |||||
Defined in Language.Fortran.Analysis Associated Types
| |||||
Show NameType Source # | |||||
Binary NameType Source # | |||||
Eq NameType Source # | |||||
Ord NameType Source # | |||||
Defined in Language.Fortran.Analysis | |||||
type Rep NameType Source # | |||||
Defined in Language.Fortran.Analysis type Rep NameType = D1 ('MetaData "NameType" "Language.Fortran.Analysis" "fortran-src-0.16.5-DEcV9ONnUql6DtSe5HgRpa" 'False) (C1 ('MetaCons "NTSubprogram" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Locality)) :+: (C1 ('MetaCons "NTVariable" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Locality)) :+: C1 ('MetaCons "NTIntrinsic" 'PrefixI 'False) (U1 :: Type -> Type))) |
Instances
Out Locality Source # | |
Data Locality Source # | |
Defined in Language.Fortran.Analysis Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Locality -> c Locality # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Locality # toConstr :: Locality -> Constr # dataTypeOf :: Locality -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Locality) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Locality) # gmapT :: (forall b. Data b => b -> b) -> Locality -> Locality # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Locality -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Locality -> r # gmapQ :: (forall d. Data d => d -> u) -> Locality -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Locality -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Locality -> m Locality # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Locality -> m Locality # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Locality -> m Locality # | |
Generic Locality Source # | |
Defined in Language.Fortran.Analysis | |
Show Locality Source # | |
Binary Locality Source # | |
Eq Locality Source # | |
Ord Locality Source # | |
Defined in Language.Fortran.Analysis | |
type Rep Locality Source # | |
markAsImported :: NameType -> NameType Source #
isImported :: NameType -> Bool Source #
Instances
Out IDType Source # | |||||
Data IDType Source # | |||||
Defined in Language.Fortran.Analysis Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> IDType -> c IDType # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c IDType # toConstr :: IDType -> Constr # dataTypeOf :: IDType -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c IDType) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IDType) # gmapT :: (forall b. Data b => b -> b) -> IDType -> IDType # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IDType -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IDType -> r # gmapQ :: (forall d. Data d => d -> u) -> IDType -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> IDType -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> IDType -> m IDType # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> IDType -> m IDType # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> IDType -> m IDType # | |||||
Generic IDType Source # | |||||
Defined in Language.Fortran.Analysis Associated Types
| |||||
Show IDType Source # | |||||
Binary IDType Source # | |||||
Eq IDType Source # | |||||
Ord IDType Source # | |||||
type Rep IDType Source # | |||||
Defined in Language.Fortran.Analysis type Rep IDType = D1 ('MetaData "IDType" "Language.Fortran.Analysis" "fortran-src-0.16.5-DEcV9ONnUql6DtSe5HgRpa" 'False) (C1 ('MetaCons "IDType" 'PrefixI 'True) (S1 ('MetaSel ('Just "idVType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe SemType)) :*: S1 ('MetaSel ('Just "idCType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ConstructType)))) |
data ConstructType Source #
Constructors
CTFunction | |
CTSubroutine | |
CTExternal | |
CTVariable | |
CTArray [(Maybe Int, Maybe Int)] | |
CTParameter | |
CTIntrinsic |
Instances
Out ConstructType Source # | |||||
Defined in Language.Fortran.Analysis Methods docPrec :: Int -> ConstructType -> Doc # doc :: ConstructType -> Doc # docList :: [ConstructType] -> Doc # | |||||
Data ConstructType Source # | |||||
Defined in Language.Fortran.Analysis Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ConstructType -> c ConstructType # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ConstructType # toConstr :: ConstructType -> Constr # dataTypeOf :: ConstructType -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ConstructType) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ConstructType) # gmapT :: (forall b. Data b => b -> b) -> ConstructType -> ConstructType # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ConstructType -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ConstructType -> r # gmapQ :: (forall d. Data d => d -> u) -> ConstructType -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ConstructType -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ConstructType -> m ConstructType # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ConstructType -> m ConstructType # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ConstructType -> m ConstructType # | |||||
Generic ConstructType Source # | |||||
Defined in Language.Fortran.Analysis Associated Types
| |||||
Show ConstructType Source # | |||||
Defined in Language.Fortran.Analysis Methods showsPrec :: Int -> ConstructType -> ShowS # show :: ConstructType -> String # showList :: [ConstructType] -> ShowS # | |||||
Binary ConstructType Source # | |||||
Defined in Language.Fortran.Analysis | |||||
Eq ConstructType Source # | |||||
Defined in Language.Fortran.Analysis Methods (==) :: ConstructType -> ConstructType -> Bool # (/=) :: ConstructType -> ConstructType -> Bool # | |||||
Ord ConstructType Source # | |||||
Defined in Language.Fortran.Analysis Methods compare :: ConstructType -> ConstructType -> Ordering # (<) :: ConstructType -> ConstructType -> Bool # (<=) :: ConstructType -> ConstructType -> Bool # (>) :: ConstructType -> ConstructType -> Bool # (>=) :: ConstructType -> ConstructType -> Bool # max :: ConstructType -> ConstructType -> ConstructType # min :: ConstructType -> ConstructType -> ConstructType # | |||||
type Rep ConstructType Source # | |||||
Defined in Language.Fortran.Analysis type Rep ConstructType = D1 ('MetaData "ConstructType" "Language.Fortran.Analysis" "fortran-src-0.16.5-DEcV9ONnUql6DtSe5HgRpa" 'False) ((C1 ('MetaCons "CTFunction" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "CTSubroutine" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CTExternal" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "CTVariable" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CTArray" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(Maybe Int, Maybe Int)]))) :+: (C1 ('MetaCons "CTParameter" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CTIntrinsic" 'PrefixI 'False) (U1 :: Type -> Type)))) |
lhsExprs :: (Data a, Data (b a)) => b a -> [Expression a] Source #
Return list of expressions used as the left-hand-side of assignment statements (including for-loops and function-calls by reference).
isLExpr :: Expression a -> Bool Source #
Is this an expression capable of assignment?
allVars :: (Data a, Data (b (Analysis a))) => b (Analysis a) -> [Name] Source #
Set of names found in an AST node.
analyseAllLhsVars :: Data a => ProgramFile (Analysis a) -> ProgramFile (Analysis a) Source #
Initiate (lazy) computation of all LHS variables for each node of the AST so that it may be accessed later.
analyseAllLhsVars1 :: (Annotated f, Data (f (Analysis a)), Data a) => f (Analysis a) -> f (Analysis a) Source #
allLhsVars :: Data a => Block (Analysis a) -> [Name] Source #
Set of names found in the parts of an AST that are the target of an assignment statement. allLhsVars :: (Annotated b, Data a, Data (b (Analysis a))) => b (Analysis a) -> [Name]
blockVarUses :: Data a => Block (Analysis a) -> [Name] Source #
Set of names used -- not defined -- by an AST-block.
blockVarDefs :: Data a => Block (Analysis a) -> [Name] Source #
Set of names defined by an AST-block.
Basic block graph.
Constructors
BBGr | |
Instances
Data a => Data (BBGr a) Source # | |||||
Defined in Language.Fortran.Analysis Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BBGr a -> c (BBGr a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (BBGr a) # toConstr :: BBGr a -> Constr # dataTypeOf :: BBGr a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (BBGr a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (BBGr a)) # gmapT :: (forall b. Data b => b -> b) -> BBGr a -> BBGr a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BBGr a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BBGr a -> r # gmapQ :: (forall d. Data d => d -> u) -> BBGr a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> BBGr a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> BBGr a -> m (BBGr a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BBGr a -> m (BBGr a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BBGr a -> m (BBGr a) # | |||||
Generic (BBGr a) Source # | |||||
Defined in Language.Fortran.Analysis Associated Types
| |||||
Show a => Show (BBGr a) Source # | |||||
Eq a => Eq (BBGr a) Source # | |||||
type Rep (BBGr a) Source # | |||||
Defined in Language.Fortran.Analysis type Rep (BBGr a) = D1 ('MetaData "BBGr" "Language.Fortran.Analysis" "fortran-src-0.16.5-DEcV9ONnUql6DtSe5HgRpa" 'False) (C1 ('MetaCons "BBGr" 'PrefixI 'True) (S1 ('MetaSel ('Just "bbgrGr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Gr (BB a) ())) :*: (S1 ('MetaSel ('Just "bbgrEntries") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Node]) :*: S1 ('MetaSel ('Just "bbgrExits") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Node])))) |
bbgrMap :: (Gr (BB a) () -> Gr (BB b) ()) -> BBGr a -> BBGr b Source #
Call function on the underlying graph
bbgrMapM :: Monad m => (Gr (BB a1) () -> m (Gr (BB a2) ())) -> BBGr a1 -> m (BBGr a2) Source #
Monadically call function on the underlying graph
type TransFunc (f :: Type -> Type) (g :: Type -> Type) a = (f (Analysis a) -> f (Analysis a)) -> g (Analysis a) -> g (Analysis a) Source #
The type of "transformBi"-family functions
type TransFuncM (m :: Type -> Type) (f :: Type -> Type) (g :: Type -> Type) a = (f (Analysis a) -> m (f (Analysis a))) -> g (Analysis a) -> m (g (Analysis a)) Source #
The type of "transformBiM"-family functions
Orphan instances
(Typeable a, Typeable b) => Data (Gr a b) Source # | |
Methods gfoldl :: (forall d b0. Data d => c (d -> b0) -> d -> c b0) -> (forall g. g -> c g) -> Gr a b -> c (Gr a b) # gunfold :: (forall b0 r. Data b0 => c (b0 -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Gr a b) # toConstr :: Gr a b -> Constr # dataTypeOf :: Gr a b -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Gr a b)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Gr a b)) # gmapT :: (forall b0. Data b0 => b0 -> b0) -> Gr a b -> Gr a b # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Gr a b -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Gr a b -> r # gmapQ :: (forall d. Data d => d -> u) -> Gr a b -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Gr a b -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Gr a b -> m (Gr a b) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Gr a b -> m (Gr a b) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Gr a b -> m (Gr a b) # |