BindReference¶
Makes a member of a host frame refer to a variable.
声明¶
语法¶
BindReference(expr reference, expr variable)
参数¶
Argument |
描述 |
|---|---|
|
a StructInstanceMember of a member of Reference type of a frame object. |
|
the variable it refers to: a Var of a variable, or a StructInstanceMember of a member of Reference type, which designates the variable that member refers to. |
返回值¶
无。
描述¶
BindReference stores the address of variable in the member: nothing is
copied. A host binds every member of its frame at the start of its body, so
that the internal procedures it calls with the frame reach the variables of
this instance of the host. The second form of variable passes a reference
on from the frame of a host to the frame of an internal procedure that is
itself a host.
The type of variable is the referenced type, including whether it is
allocatable or a pointer and the rank and physical type of an array
(asr.verify.bind_reference.type); a variable that is not a variable is
reported as asr.verify.bind_reference.variable.
示例¶
(BindReference
:reference (StructInstanceMember
:v (Var
:v (SymbolRef 2 "f")
)
:m (SymbolRef 2 "1_frame_n")
:type (Integer
:kind 4
)
:value nil
)
:variable (Var
:v (SymbolRef 2 "n")
)
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"host_frame" (Program
:symtab (SymbolTable
:id 1
:symbols {
"k" (Variable
:parent_symtab 1
:name "k"
: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_asynchronous false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
:common_block nil
)
"outer" (Function
:symtab (SymbolTable
:id 2
:symbols {
"1_frame_n" (ExternalSymbol
:parent_symtab 2
:name "1_frame_n"
:external (SymbolRef 3 "n")
:module_name "frame"
:scope_names []
:original_name "n"
:access :Public
)
"f" (Variable
:parent_symtab 2
:name "f"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (StructType
:data_member_types [
(Reference
:type (Integer
:kind 4
)
)
]
:member_function_types []
:is_cstruct true
:is_unlimited_polymorphic false
)
:type_declaration (SymbolRef 2 "frame")
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_asynchronous false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
:common_block nil
)
"frame" (Struct
:symtab (SymbolTable
:id 3
:symbols {
"n" (Variable
:parent_symtab 3
:name "n"
:dependencies []
:intent :Unspecified
:symbolic_value nil
:value nil
:storage :Default
:type (Reference
: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_asynchronous false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
:common_block nil
)
}
)
:name "frame"
:struct_signature (StructType
:data_member_types [
(Reference
:type (Integer
:kind 4
)
)
]
:member_function_types []
:is_cstruct true
:is_unlimited_polymorphic false
)
:dependencies []
:members [
"n"
]
:member_functions []
:abi :Source
:access :Public
:is_packed false
:is_abstract false
:is_sequence false
:initializers []
:alignment nil
:parent nil
:kind_params []
)
"inner" (Function
:symtab (SymbolTable
:id 4
:symbols {
"f" (Variable
:parent_symtab 4
:name "f"
:dependencies []
:intent :In
:symbolic_value nil
:value nil
:storage :Default
:type (StructType
:data_member_types [
(Reference
:type (Integer
:kind 4
)
)
]
:member_function_types []
:is_cstruct true
:is_unlimited_polymorphic false
)
:type_declaration (SymbolRef 2 "frame")
:abi :Source
:access :Public
:presence :Required
:value_attr false
:target_attr false
:contiguous_attr false
:bindc_name nil
:is_volatile false
:is_asynchronous false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
:common_block nil
)
"n" (Variable
:parent_symtab 4
:name "n"
:dependencies [
"f"
]
:intent :Local
:symbolic_value (StructInstanceMember
:v (Var
:v (SymbolRef 4 "f")
)
:m (SymbolRef 2 "1_frame_n")
:type (Integer
:kind 4
)
:value nil
)
:value nil
:storage :HostAssociated
: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_asynchronous false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
:common_block nil
)
}
)
:name "inner"
:function_signature (FunctionType
:arg_types [
(StructType
:data_member_types [
(Reference
:type (Integer
:kind 4
)
)
]
:member_function_types []
:is_cstruct true
:is_unlimited_polymorphic false
)
]
: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
:exec_space :Host
)
:dependencies []
:args [
(Var
:v (SymbolRef 4 "f")
)
]
:body [
(Assignment
:target (Var
:v (SymbolRef 4 "n")
)
:value (IntegerBinOp
:left (Var
:v (SymbolRef 4 "n")
)
:op :Add
:right (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:type (Integer
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
:new_target false
:new_allocation false
)
]
:return_var nil
:access :Public
:deterministic true
:side_effect_free true
:module_file nil
)
"n" (Variable
:parent_symtab 2
:name "n"
:dependencies []
:intent :InOut
: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_asynchronous false
:is_protected false
:pass_attr :NotMethod
:self_argument nil
:codims []
:common_block nil
)
}
)
:name "outer"
:function_signature (FunctionType
:arg_types [
(Integer
:kind 4
)
]
: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
:exec_space :Host
)
:dependencies []
:args [
(Var
:v (SymbolRef 2 "n")
)
]
:body [
(BindReference
:reference (StructInstanceMember
:v (Var
:v (SymbolRef 2 "f")
)
:m (SymbolRef 2 "1_frame_n")
:type (Integer
:kind 4
)
:value nil
)
:variable (Var
:v (SymbolRef 2 "n")
)
)
(SubroutineCall
:name (SymbolRef 2 "inner")
:original_name nil
:args [
(call_arg
:value (Var
:v (SymbolRef 2 "f")
)
)
]
:dt nil
:strict_bounds_checking false
)
]
:return_var nil
:access :Public
:deterministic true
:side_effect_free true
:module_file nil
)
}
)
:name "host_frame"
:dependencies []
:body [
(Assignment
:target (Var
:v (SymbolRef 1 "k")
)
:value (IntegerConstant
:n 1
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
:overloaded nil
:realloc_lhs false
:move_allocation false
:new_target false
:new_allocation false
)
(SubroutineCall
:name (SymbolRef 1 "outer")
:original_name nil
:args [
(call_arg
:value (Var
:v (SymbolRef 1 "k")
)
)
]
:dt nil
:strict_bounds_checking false
)
(Print
:text (StringFormat
:fmt nil
:args [
(Var
:v (SymbolRef 1 "k")
)
]
:kind :FormatFortran
:dtio_bindings []
:dtio_unit nil
:type (Allocatable
:type (String
:kind 1
:len nil
:len_kind :DeferredLength
:physical_type :DescriptorString
)
)
:value nil
)
)
]
:global_init nil
)
}
)
:items []
:global_init nil
)