ttype¶
Type nodes.
Declaration¶
Sintaxe¶
ttype
= Integer(int kind, dimension* dims)
| Real(int kind, dimension* dims)
| Complex(int kind, dimension* dims)
| Character(int kind, int len, expr? len_expr, dimension* dims)
| Logical(int kind, dimension* dims)
| Set(ttype type)
| List(ttype type)
| Tuple(ttype* type)
| Struct(symbol derived_type, dimension* dims)
| Enum(symbol enum_type, dimension *dims)
| UnionType(symbol union_type, dimension *dims)
| Class(symbol class_type, dimension* dims)
| Dict(ttype key_type, ttype value_type)
| Pointer(ttype type)
| CPtr()
| TypeParameter(identifier param, dimension* dims)
Argumentos¶
kind
member selects the kind of a given type.
dims
denotes dimension descriptor.
expr
denotes expression.
len
denotes length of variable allowed.
derived_type
denotes derived type of class. derived_type
must point to a
symbol with a symbol table.
enum_type
denotes enumeration type.
union_type
denotes union type.
class_type
denotes class type.
key_type
denotes key type in dictonary type.
value_type
denotes value type in dictionary type.
param
denotes identifier or variable’s.
Valores de retorno¶
Nenhum.
Descrição¶
ttype
denotes type of variables supported by LFortran. It consists of:
Integer
denotes integer type.Real
denotes real type.Complex
denotes complex type.Character
denotes character type.Logical
denotes logical type.Set
denotes set type.List
denotes list type.Tuple
denotes tuple type.Struct
denotes structure type.Enum
denotes enumeration type.UnionType
denotes union type.Class
denotes class type.Dict
denotes dictionary type.Pointer
denotes Pointer type.CPtr
denotes C pointer type.TypeParameter
denotes type of parameter.
Tipos¶
ttype defines types of variables or identifiers supported by LFortran.
Exemplos¶
Example for integer
:
integer(8) :: x
x = 6
x
ASR:
(TranslationUnit
(SymbolTable
1
{
x:
(Variable
1
x
Local
()
()
Default
(Integer 8 [])
Source
Public
Required
.false.
)
})
[(=
(Var 1 x)
(Cast
(IntegerConstant 6 (Integer 4 []))
IntegerToInteger
(Integer 8 [])
(IntegerConstant 6 (Integer 8 []))
)
()
)
(Var 1 x)]
)
Example for derived_type
:
program t01_derived_type
implicit none
type type_A
integer :: i
real :: r
end type
type(type_A) :: A
A%i = 5
A%r = 5.5
end program
ASR:
(TranslationUnit
(SymbolTable
1
{
t01_derived_type:
(Program
(SymbolTable
2
{
a:
(Variable
2
a
Local
()
()
Default
(Struct
2 type_a
[]
)
Source
Public
Required
.false.
),
type_a:
(StructType
(SymbolTable
3
{
i:
(Variable
3
i
Local
()
()
Default
(Integer 4 [])
Source
Public
Required
.false.
),
r:
(Variable
3
r
Local
()
()
Default
(Real 4 [])
Source
Public
Required
.false.
)
})
type_a
[i
r]
Source
Public
()
)
})
t01_derived_type
[]
[(=
(StructInstanceMember
(Var 2 a)
3 i
(Integer 4 [])
()
)
(IntegerConstant 5 (Integer 4 []))
()
)
(=
(StructInstanceMember
(Var 2 a)
3 r
(Real 4 [])
()
)
(RealConstant
5.500000
(Real 4 [])
)
()
)]
)
})
[]
)
Example for complex
:
program complex1
complex :: x
x = (3.0, 4.0)
end program
ASR:
(TranslationUnit
(SymbolTable
1
{
complex1:
(Program
(SymbolTable
2
{
x:
(Variable
2
x
Local
()
()
Default
(Complex 4 [])
Source
Public
Required
.false.
)
})
complex1
[]
[(=
(Var 2 x)
(ComplexConstructor
(RealConstant
3.000000
(Real 4 [])
)
(RealConstant
4.000000
(Real 4 [])
)
(Complex 4 [])
(ComplexConstant
3.000000
4.000000
(Complex 4 [])
)
)
()
)]
)
})
[]
)
Example for dimension
:
integer :: x
dimension x(3)
ASR:
(TranslationUnit
(SymbolTable
1
{
x:
(Variable
1
x
Local
()
()
Default
(Integer 4 [((IntegerConstant 1 (Integer 4 []))
(IntegerConstant 3 (Integer 4 [])))])
Source
Public
Required
.false.
)
})
[]
)