ttype¶
The types of ASR.
Declaration¶
Syntax¶
ttype
= Integer(int kind)
| UnsignedInteger(int kind)
| Real(int kind)
| Complex(int kind)
| String(int kind, expr? len, string_length_kind len_kind, string_physical_type physical_type)
| Logical(int kind)
| Set(ttype type)
| List(ttype type)
| Tuple(ttype* type)
| StructType(ttype* data_member_types, ttype* member_function_types, bool is_cstruct, bool is_unlimited_polymorphic)
| EnumType(symbol enum_type)
| UnionType(ttype* data_member_types)
| Dict(ttype key_type, ttype value_type)
| Pointer(ttype type)
| Allocatable(ttype type)
| CPtr()
| SymbolicExpression()
| TypeParameter(identifier param)
| Array(ttype type, dimension* dims, array_physical_type physical_type)
| FunctionType(ttype* arg_types, ttype? return_var_type, abi abi, deftype deftype, string? bindc_name, bool elemental, bool pure, bool module, bool inline, bool static, symbol* restrictions, bool is_restriction)
Arguments¶
None.
Return values¶
None. A type is not evaluated.
Description¶
A ttype describes what a value is: the type of every expression, of every
variable and of every procedure argument is one of these.
The types divide into a few groups:
the intrinsic scalar types, Integer, UnsignedInteger, Real, Complex, Logical and String, each fixed by a kind;
the derived types, StructType, EnumType and UnionType, whose definitions are symbols;
the composite types Array, Pointer and Allocatable, which wrap another type;
CPtr and FunctionType, which describe a C address and a procedure signature;
TypeParameter, a placeholder inside a generic Template;
the LPython container types List, Set, Dict and Tuple, and SymbolicExpression.
A type separates what a value is from how it is represented. An
Array carries an array_physical_type and a
String a string_physical_type, and two values with the same
logical type may differ in it; the physical casts,
ArrayPhysicalCast and
StringPhysicalCast, convert
between representations without changing the value, while
Cast changes the value itself.