TupleItem¶
One element of a tuple.
Declaration¶
Syntax¶
TupleItem(expr a, expr pos, ttype type, expr? value)
Arguments¶
Argument |
Description |
|---|---|
|
the tuple. |
|
the index. |
|
the type of that element. |
|
the compile time value of the expression, when the frontend could fold it; |
Return values¶
The value of the expression.
Description¶
t[i], counting from zero. The index must be a constant, because the type of
the result depends on it.
Examples¶
(TupleItem
:a (Var
:v (SymbolRef 1 "t")
)
:pos (IntegerConstant
:n 0
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Integer
:kind 4
)
:value nil
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"main" (Program
:symtab (SymbolTable
:id 1
:symbols {
"i" (Variable
:parent_symtab 1
:name "i"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Integer
:kind 4
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
"p" (Variable
:parent_symtab 1
:name "p"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Logical
:kind 4
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
"t" (Variable
:parent_symtab 1
:name "t"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Tuple
:type [
(Integer
:kind 4
)
(Real
:kind 4
)
]
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
"u" (Variable
:parent_symtab 1
:name "u"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Tuple
:type [
(Integer
:kind 4
)
(Real
:kind 4
)
(Integer
:kind 4
)
(Real
:kind 4
)
]
)
:type_declaration nil
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
)
}
)
:name "main"
:dependencies []
:body [
(Assignment
:target (Var
:v (SymbolRef 1 "t")
)
:value (TupleConstant
:elements [
(IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
(RealConstant
:r 2.0
:type (Real
:kind 4
)
)
]
:type (Tuple
:type [
(Integer
:kind 4
)
(Real
:kind 4
)
]
)
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 1 "i")
)
:value (TupleLen
:arg (Var
:v (SymbolRef 1 "t")
)
:type (Integer
:kind 4
)
:value (IntegerConstant
:n 2
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 1 "u")
)
:value (TupleConcat
:left (Var
:v (SymbolRef 1 "t")
)
:right (Var
:v (SymbolRef 1 "t")
)
:type (Tuple
:type [
(Integer
:kind 4
)
(Real
:kind 4
)
(Integer
:kind 4
)
(Real
:kind 4
)
]
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 1 "p")
)
:value (TupleCompare
:left (Var
:v (SymbolRef 1 "t")
)
:op :Eq
:right (Var
:v (SymbolRef 1 "t")
)
:type (Logical
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 1 "p")
)
:value (TupleContains
:left (Var
:v (SymbolRef 1 "t")
)
:right (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Logical
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
(Assignment
:target (Var
:v (SymbolRef 1 "i")
)
:value (TupleItem
:a (Var
:v (SymbolRef 1 "t")
)
:pos (IntegerConstant
:n 0
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Integer
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
]
)
}
)
:items []
)