Safe Haskell | None |
---|---|
Language | Haskell2010 |
Common data structures and functions supporting analysis of the AST.
Synopsis
- initAnalysis :: Functor b => b a -> b (Analysis a)
- stripAnalysis :: Functor b => b (Analysis a) -> b a
- data Analysis a = Analysis {}
- data Constant
- varName :: Expression (Analysis a) -> String
- srcName :: Expression (Analysis a) -> String
- lvVarName :: LValue (Analysis a) -> String
- lvSrcName :: LValue (Analysis a) -> String
- isNamedExpression :: Expression a -> Bool
- genVar :: Analysis a -> SrcSpan -> String -> 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 IDType = IDType {}
- data ConstructType
- = CTFunction
- | CTSubroutine
- | CTExternal
- | CTVariable
- | CTArray [(Maybe Int, Maybe Int)]
- | CTParameter
- | CTIntrinsic
- data BaseType
- lhsExprs :: forall a b. (Data a, Data (b a)) => b a -> [Expression a]
- isLExpr :: Expression a -> Bool
- allVars :: forall a b. (Data a, Data (b (Analysis a))) => b (Analysis a) -> [Name]
- analyseAllLhsVars :: forall a. 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 :: forall a. 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 {
- bbgrGr :: Gr (BB a) ()
- bbgrEntries :: [Node]
- bbgrExits :: [Node]
- 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 g a = (f (Analysis a) -> f (Analysis a)) -> g (Analysis a) -> g (Analysis a)
- type TransFuncM m f g 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.
Analysis | |
|
Instances
Information about potential / actual constant expressions.
ConstInt Integer | interpreted integer |
ConstUninterpInt String | uninterpreted integer |
ConstUninterpReal String | uninterpreted real |
ConstBinary BinaryOp Constant Constant | binary operation on potential constants |
ConstUnary UnaryOp Constant | unary operation on potential constants |
Instances
varName :: Expression (Analysis a) -> String Source #
Obtain either uniqueName or source name from an ExpValue variable.
srcName :: Expression (Analysis a) -> String Source #
Obtain the source name from an ExpValue variable.
lvVarName :: LValue (Analysis a) -> String Source #
Obtain either uniqueName or source name from an LvSimpleVar variable.
lvSrcName :: LValue (Analysis a) -> String 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 -> String -> 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.
Instances
Eq NameType Source # | |
Data NameType Source # | |
Defined in Language.Fortran.Analysis 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 # | |
Ord NameType Source # | |
Defined in Language.Fortran.Analysis | |
Show NameType Source # | |
Generic NameType Source # | |
Binary NameType Source # | |
Out NameType Source # | |
type Rep NameType Source # | |
Defined in Language.Fortran.Analysis type Rep NameType = D1 ('MetaData "NameType" "Language.Fortran.Analysis" "fortran-src-0.4.3-inplace" 'False) (C1 ('MetaCons "NTSubprogram" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NTVariable" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NTIntrinsic" 'PrefixI 'False) (U1 :: Type -> Type))) |
Instances
Eq IDType Source # | |
Data IDType Source # | |
Defined in Language.Fortran.Analysis 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 # | |
Ord IDType Source # | |
Show IDType Source # | |
Generic IDType Source # | |
Binary IDType Source # | |
Out IDType Source # | |
type Rep IDType Source # | |
Defined in Language.Fortran.Analysis type Rep IDType = D1 ('MetaData "IDType" "Language.Fortran.Analysis" "fortran-src-0.4.3-inplace" 'False) (C1 ('MetaCons "IDType" 'PrefixI 'True) (S1 ('MetaSel ('Just "idVType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe BaseType)) :*: S1 ('MetaSel ('Just "idCType") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ConstructType)))) |
data ConstructType Source #
CTFunction | |
CTSubroutine | |
CTExternal | |
CTVariable | |
CTArray [(Maybe Int, Maybe Int)] | |
CTParameter | |
CTIntrinsic |
Instances
Type name referenced in syntax.
In many Fortran specs and compilers, certain types are actually "synonyms" for other types with specified kinds. The primary example is DOUBLE PRECISION being equivalent to REAL(8). Type kinds were introduced in Fortran 90, and it should be safe to replace all instances of DOUBLE PRECISION with REAL(8) in Fortran 90 code. However, type kinds weren't present in (standard) Fortran 77, so this equivalence was detached from the user.
In any case, it's unclear how strong the equivalence is and whether it can
be retroactively applied to previous standards. We choose to parse types
directly, and handle those transformations during type analysis, where we
assign most scalars a kind (see SemType
).
TypeInteger | |
TypeReal | |
TypeDoublePrecision | |
TypeComplex | |
TypeDoubleComplex | |
TypeLogical | |
TypeCharacter (Maybe CharacterLen) (Maybe String) | len and kind, if specified |
TypeCustom String | |
ClassStar | |
ClassCustom String | |
TypeByte |
Instances
lhsExprs :: forall a b. (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 :: forall a b. (Data a, Data (b (Analysis a))) => b (Analysis a) -> [Name] Source #
Set of names found in an AST node.
analyseAllLhsVars :: forall a. 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 :: forall a. 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.
BBGr | |
|
Instances
Eq a => Eq (BBGr a) Source # | |
Data a => Data (BBGr a) Source # | |
Defined in Language.Fortran.Analysis 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) # | |
Show a => Show (BBGr a) Source # | |
Generic (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.4.3-inplace" '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 g a = (f (Analysis a) -> f (Analysis a)) -> g (Analysis a) -> g (Analysis a) Source #
The type of "transformBi"-family functions
type TransFuncM m f g 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 # | |
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) # |