Pointer¶
A pointer to another type.
Declaration¶
Syntax¶
Pointer(ttype type)
Arguments¶
Argument |
Описание |
|---|---|
|
the type of what the pointer refers to. |
Return values¶
None. A type is not evaluated.
Описание¶
A pointer refers to storage owned by something else, or by nothing at all when it is disassociated. It is associated by Associate, tested with PointerAssociated and cleared by Nullify.
A pointer array is a Pointer of an Array whose extents are
nil. Pointer association sets the bounds and the strides at run time, so
that array always has physical type DescriptorArray (AssumedRankArray when
its rank is assumed); the verifier reports any other as
asr.verify.pointer.array_descriptor.
Examples¶
(Pointer
:type (Integer
:kind 4
)
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"main" (Program
:symtab (SymbolTable
:id 1
:symbols {
"b" (Variable
:parent_symtab 1
:name "b"
: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 []
:common_block nil
)
"c" (Variable
:parent_symtab 1
:name "c"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (CPtr
:kind :CPtrUnspecified
)
: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 []
:common_block nil
)
"n" (Variable
:parent_symtab 1
:name "n"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Integer
:kind 8
)
: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 []
:common_block nil
)
"p" (Variable
:parent_symtab 1
:name "p"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (Pointer
: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 []
:common_block nil
)
"target" (Variable
:parent_symtab 1
:name "target"
: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 true
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
:common_block nil
)
}
)
:name "main"
:dependencies []
:body [
(Assignment
:target (Var
:v (SymbolRef 1 "c")
)
:value (CLoc
:arg (Var
:v (SymbolRef 1 "target")
)
:type (CPtr
:kind :CPtrUnspecified
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
:new_target false
)
(Assignment
:target (Var
:v (SymbolRef 1 "c")
)
:value (PointerToCPtr
:arg (Var
:v (SymbolRef 1 "p")
)
:type (CPtr
:kind :CPtrUnspecified
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
:new_target false
)
(Associate
:target (Var
:v (SymbolRef 1 "p")
)
:value (GetPointer
:arg (Var
:v (SymbolRef 1 "target")
)
:type (Pointer
:type (Integer
:kind 4
)
)
:value nil
)
:form :NoPointerBounds
)
(Assignment
:target (Var
:v (SymbolRef 1 "b")
)
:value (CPtrCompare
:left (Var
:v (SymbolRef 1 "c")
)
:op :Eq
:right (Var
:v (SymbolRef 1 "c")
)
:type (Logical
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
:new_target false
)
(Assignment
:target (Var
:v (SymbolRef 1 "b")
)
:value (PointerAssociated
:ptr (Var
:v (SymbolRef 1 "p")
)
:tgt (Var
:v (SymbolRef 1 "target")
)
:type (Logical
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
:new_target false
)
(Assignment
:target (Var
:v (SymbolRef 1 "n")
)
:value (SizeOfType
:arg (Integer
:kind 4
)
:type (Integer
:kind 8
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
:new_target false
)
]
:global_init nil
)
}
)
:items []
:global_init nil
)