StructMethodDeclaration¶
A type-bound procedure of a derived type.
Declaration¶
Syntax¶
StructMethodDeclaration(symbol_table parent_symtab, identifier name,
identifier? self_argument, identifier proc_name, symbol proc,
abi abi, bool is_deferred, bool is_nopass)
Arguments¶
Argument |
Description |
|---|---|
|
the symbol table of the derived type that declares the binding. |
|
the binding name, the name written after the |
|
the name of the passed-object dummy argument, or |
|
the name of the procedure the binding resolves to. |
|
the procedure symbol itself. |
|
the ABI of the procedure. |
|
|
|
|
Return values¶
None.
Description¶
A StructMethodDeclaration is stored in the symbol table of the
Struct that declares it, and it names the procedure that
implements the binding. Binding name and procedure name are separate, because
procedure :: area => circle_area gives them different spellings.
A call through a binding is an ordinary
SubroutineCall or
FunctionCall whose dt member carries
the object the binding was reached through. For a deferred binding of an
abstract type the actual procedure is chosen at run time from the dynamic type
of dt.
Examples¶
(StructMethodDeclaration
:parent_symtab 2
:name "area"
:self_argument nil
:proc_name "circle_area"
:proc (SymbolRef 1 "circle_area")
:abi :Source
:is_deferred false
:is_nopass false
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"m" (Module
:symtab (SymbolTable
:id 1
:symbols {
"circle" (Struct
:symtab (SymbolTable
:id 2
:symbols {
"area" (StructMethodDeclaration
:parent_symtab 2
:name "area"
:self_argument nil
:proc_name "circle_area"
:proc (SymbolRef 1 "circle_area")
:abi :Source
:is_deferred false
:is_nopass false
)
"r" (Variable
:parent_symtab 2
:name "r"
:dependencies []
:intent :Local
:symbolic_value nil
:value nil
:storage :Default
:type (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 "circle"
:struct_signature (StructType
:data_member_types [
(Real
:kind 4
)
]
:member_function_types []
:is_cstruct false
:is_unlimited_polymorphic false
)
:dependencies []
:members [
"r"
]
:member_functions [
"area"
]
:abi :Source
:access :Public
:is_packed false
:is_abstract false
:is_sequence false
:initializers []
:alignment nil
:parent nil
:kind_params []
)
"circle_area" (Function
:symtab (SymbolTable
:id 3
:symbols {
"a" (Variable
:parent_symtab 3
:name "a"
:dependencies []
:intent :ReturnVar
:symbolic_value nil
:value nil
:storage :Default
:type (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 []
)
"self" (Variable
:parent_symtab 3
:name "self"
:dependencies []
:intent :In
:symbolic_value nil
:value nil
:storage :Default
:type (StructType
:data_member_types [
(Real
:kind 4
)
]
:member_function_types []
:is_cstruct false
:is_unlimited_polymorphic false
)
:type_declaration (SymbolRef 1 "circle")
: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 "circle_area"
:function_signature (FunctionType
:arg_types [
(StructType
:data_member_types [
(Real
:kind 4
)
]
:member_function_types []
:is_cstruct false
:is_unlimited_polymorphic false
)
]
:return_var_type (Real
:kind 4
)
: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 3 "self")
)
]
:body [
(Assignment
:target (Var
:v (SymbolRef 3 "a")
)
:value (StructInstanceMember
:v (Var
:v (SymbolRef 3 "self")
)
:m (SymbolRef 2 "r")
:type (Real
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
]
:return_var (Var
:v (SymbolRef 3 "a")
)
:access :Public
:deterministic false
:side_effect_free false
:module_file nil
)
}
)
:name "m"
:parent_module nil
:dependencies []
:loaded_from_mod false
:intrinsic false
:has_submodules false
)
"main" (Program
:symtab (SymbolTable
:id 4
:symbols {}
)
:name "main"
:dependencies []
:body []
)
}
)
:items []
)