ArrayConstructor¶
An array value built from a list of expressions.
Declaration¶
Syntax¶
ArrayConstructor(expr* args, ttype type, expr? value,
arraystorage storage_format, expr? struct_var)
Arguments¶
Argument |
Description |
|---|---|
|
the elements, in order. An element may be an ImpliedDoLoop, which contributes several values. |
|
the array type of the result. |
|
the folded ArrayConstant, when every element is constant; |
|
the order the elements are given in; see arraystorage. |
|
for a constructor of an array of derived type, the object the components belong to; |
Return values¶
The value of the expression.
Description¶
[1, i, 3]. When the frontend can fold every element it also stores the
resulting ArrayConstant in value, so a backend can use
the folded form and ignore the expressions.
Examples¶
(ArrayConstructor
:args [
(IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
(Var
:v (SymbolRef 1 "i")
)
(IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
]
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:physical_type :FixedSizeArray
)
:value nil
:storage_format :ColMajor
:struct_var nil
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"main" (Program
:symtab (SymbolTable
:id 1
:symbols {
"a" (Variable
:parent_symtab 1
:name "a"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:physical_type :FixedSizeArray
)
: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 []
)
"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 []
)
}
)
:name "main"
:dependencies []
:body [
(Assignment
:target (Var
:v (SymbolRef 1 "a")
)
:value (ArrayConstructor
:args [
(IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
(Var
:v (SymbolRef 1 "i")
)
(IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
]
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:length (IntegerConstant
:n 3
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:physical_type :FixedSizeArray
)
:value nil
:storage_format :ColMajor
:struct_var nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
]
)
}
)
:items []
)