Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Language.Fortran.Analysis.SemanticTypes
Synopsis
- type Kind = Int
- data SemType
- type Dimensions = [(Int, Int)]
- data CharacterLen
- charLenSelector :: Maybe (Selector a) -> (Maybe CharacterLen, Maybe String)
- charLenSelector' :: Expression a -> CharacterLen
- charLenToValue :: CharacterLen -> Maybe (Value a)
- getTypeKind :: SemType -> Kind
- setTypeKind :: SemType -> Kind -> SemType
- charLenConcat :: CharacterLen -> CharacterLen -> CharacterLen
- recoverSemTypeTypeSpec :: forall a. a -> SrcSpan -> FortranVersion -> SemType -> TypeSpec a
- kindOfBaseType :: BaseType -> Int
- getTypeSize :: SemType -> Maybe Int
- setTypeSize :: SemType -> Maybe Int -> SemType
Documentation
Semantic type assigned to variables.
BaseType
stores the "type tag" given in syntax. SemType
s add metadata
(kind and length), and resolve some "simple" types to a core type with a
preset kind (e.g. `DOUBLE PRECISION` -> `REAL(8)`).
Fortran 90 (and beyond) features may not be well supported.
Constructors
TInteger Kind | |
TReal Kind | |
TComplex Kind | |
TLogical Kind | |
TByte Kind | |
TCharacter CharacterLen Kind | |
TArray SemType (Maybe Dimensions) | Nothing denotes dynamic dimensions |
TCustom String |
Instances
type Dimensions = [(Int, Int)] Source #
The declared dimensions of a staticically typed array variable type is of the form [(dim1_lower, dim1_upper), (dim2_lower, dim2_upper)]
data CharacterLen Source #
Constructors
CharLenStar | specified with a * |
CharLenColon | specified with a : (Fortran2003) FIXME, possibly, with a more robust const-exp: |
CharLenExp | specified with a non-trivial expression |
CharLenInt Int | specified with a constant integer |
Instances
charLenSelector :: Maybe (Selector a) -> (Maybe CharacterLen, Maybe String) Source #
charLenSelector' :: Expression a -> CharacterLen Source #
charLenToValue :: CharacterLen -> Maybe (Value a) Source #
Attempt to recover the Value
that generated the given CharacterLen
.
getTypeKind :: SemType -> Kind Source #
charLenConcat :: CharacterLen -> CharacterLen -> CharacterLen Source #
recoverSemTypeTypeSpec :: forall a. a -> SrcSpan -> FortranVersion -> SemType -> TypeSpec a Source #
Recover the most appropriate TypeSpec
for the given SemType
, depending
on the given FortranVersion
.
Kinds weren't formalized as a syntactic feature until Fortran 90, so we ask
for a context. If possible (>=F90), we prefer the more explicit
representation e.g. REAL(8)
. For older versions, for specific type-kind
combinations, DOUBLE PRECISION
and DOUBLE COMPLEX
are used instead.
However, we otherwise don't shy away from adding kind info regardless of
theoretical version support.
Array types don't work properly, due to array type info being in a parent node that holds individual elements.
kindOfBaseType :: BaseType -> Int Source #
Given a BaseType
infer the "default" kind (or size of the
variable in memory).
Useful when you need a default kind, but gives you an unwrapped type. Consider using Analysis.deriveSemTypeFromBaseType also.
Further documentation: https://docs.oracle.com/cd/E19957-01/805-4939/c400041360f5/index.html