FunctionCall¶
Calls a function and uses its result.
Declaration¶
Syntax¶
FunctionCall(symbol name, symbol? original_name, call_arg* args,
ttype type, expr? value, expr? dt)
Arguments¶
Argument |
Description |
|---|---|
|
the function actually called, after generic resolution. |
|
the symbol as written, when it differs; |
|
the actual arguments, each a call_arg. |
|
the type of the result. |
|
the compile time value of the expression, when the frontend could fold it; |
|
for a call through a type-bound procedure, the object it was reached through; |
Return values¶
The value of the expression.
Description¶
A FunctionCall is an expression, so it appears where a value is wanted;
SubroutineCall is the statement form.
Both store the resolved procedure in name and what was written in
original_name.
An actual argument for an intent(out) or intent(inout) dummy must be
writable. value is set when the frontend could evaluate the call at compile
time, which it can do for some intrinsics.
Examples¶
(FunctionCall
:name (SymbolRef 3 "square")
:original_name nil
:args [
(call_arg
:value (IntegerConstant
:n 5
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:type (Integer
:kind 4
)
:value nil
:dt nil
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"m" (Module
:symtab (SymbolTable
:id 1
:symbols {
"square" (Function
:symtab (SymbolTable
:id 2
:symbols {
"a" (Variable
:parent_symtab 2
:name "a"
:dependencies []
:intent :In
: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 []
)
"b" (Variable
:parent_symtab 2
:name "b"
:dependencies []
:intent :ReturnVar
: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 "square"
:function_signature (FunctionType
:arg_types [
(Integer
:kind 4
)
]
:return_var_type (Integer
: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 2 "a")
)
]
:body [
(Assignment
:target (Var
:v (SymbolRef 2 "b")
)
:value (IntegerBinOp
:left (Var
:v (SymbolRef 2 "a")
)
:op :Mul
:right (Var
:v (SymbolRef 2 "a")
)
:type (Integer
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
]
:return_var (Var
:v (SymbolRef 2 "b")
)
: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 3
:symbols {
"n" (Variable
:parent_symtab 3
:name "n"
: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 []
)
"square" (ExternalSymbol
:parent_symtab 3
:name "square"
:external (SymbolRef 1 "square")
:module_name "m"
:scope_names []
:original_name "square"
:access :Public
)
}
)
:name "main"
:dependencies [
"m"
]
:body [
(Assignment
:target (Var
:v (SymbolRef 3 "n")
)
:value (FunctionCall
:name (SymbolRef 3 "square")
:original_name nil
:args [
(call_arg
:value (IntegerConstant
:n 5
:type (Integer
:kind 4
)
:intboz_type :Decimal
)
)
]
:type (Integer
:kind 4
)
:value nil
:dt nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
]
)
}
)
:items []
)