ArrayPhysicalCast¶
Changes how an array is represented, not what it holds.
Declaration¶
Syntax¶
ArrayPhysicalCast(expr arg, array_physical_type old,
array_physical_type new, ttype type, expr? value)
Arguments¶
Argument |
Description |
|---|---|
|
the array expression to re-describe. |
|
its current representation; see array_physical_type. |
|
the representation to produce. |
|
the type of the result, whose |
|
the compile time value of the expression, when the frontend could fold it; |
Return values¶
The value of the expression.
Description¶
The logical type does not change here: the element type, the rank and the extents are the same on both sides, and only the physical representation differs. That is what separates this node from Cast, which changes the value.
Passing a fixed size array to a procedure that takes an assumed shape
argument, for instance, needs a descriptor to be built around it, and the cast
is where that happens. The new physical type appears both in new and in the
physical_type of type.
Examples¶
(ArrayPhysicalCast
:arg (Var
:v (SymbolRef 1 "a")
)
:old :FixedSizeArray
:new :DescriptorArray
: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 :DescriptorArray
)
:value 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 []
)
"total" (Function
:symtab (SymbolTable
:id 2
:symbols {
"x" (Variable
:parent_symtab 2
:name "x"
:dependencies []
:intent :In
:symbolic_value nil
:value nil
:storage :Default
:type (Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start nil
:length nil
)
]
:physical_type :DescriptorArray
)
: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 "total"
:function_signature (FunctionType
:arg_types [
(Array
:type (Integer
:kind 4
)
:dims [
(dimension
:start nil
:length nil
)
]
:physical_type :DescriptorArray
)
]
:return_var_type nil
:abi :Source
:deftype :Implementation
:bindc_name nil
:elemental false
:pure false
:module false
:inline false
:static false
:restrictions []
:is_restriction false
)
:dependencies []
:args [
(Var
:v (SymbolRef 2 "x")
)
]
:body []
:return_var nil
:access :Public
:deterministic false
:side_effect_free false
:module_file nil
)
}
)
:name "main"
:dependencies []
:body [
(SubroutineCall
:name (SymbolRef 1 "total")
:original_name nil
:args [
(call_arg
:value (ArrayPhysicalCast
:arg (Var
:v (SymbolRef 1 "a")
)
:old :FixedSizeArray
:new :DescriptorArray
: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 :DescriptorArray
)
:value nil
)
)
]
:dt nil
:strict_bounds_checking false
)
]
)
}
)
:items []
)