CustomOperator¶
A user-defined or overloaded operator.
Declaration¶
Syntax¶
CustomOperator(symbol_table parent_symtab, identifier name,
symbol* procs, access access)
Arguments¶
Argument |
Description |
|---|---|
|
the symbol table this symbol is stored in. |
|
the operator name, such as |
|
the procedures that implement the operator. |
|
|
Return values¶
None.
Description¶
CustomOperator holds the procedures declared in an
interface operator(.op.), interface operator(+) or interface assignment(=) block. Like GenericProcedure it is only
a symbol: the frontend resolves an operator use to one specific procedure and
emits an ordinary call, wrapped in an
OverloadedBinOp,
OverloadedCompare or the
overloaded member of
Assignment, so that the original spelling
is not lost.
Examples¶
(CustomOperator
:parent_symtab 1
:name "~add"
:procs [
(SymbolRef 1 "plus")
]
:access :Public
)
It comes from this complete ASR text document:
(TranslationUnit
:symtab (SymbolTable
:id 0
:symbols {
"m" (Module
:symtab (SymbolTable
:id 1
:symbols {
"plus" (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 :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 []
)
"c" (Variable
:parent_symtab 2
:name "c"
: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 "plus"
:function_signature (FunctionType
:arg_types [
(Integer
:kind 4
)
(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
)
:dependencies []
:args [
(Var
:v (SymbolRef 2 "a")
)
(Var
:v (SymbolRef 2 "b")
)
]
:body [
(Assignment
:target (Var
:v (SymbolRef 2 "c")
)
:value (IntegerBinOp
:left (Var
:v (SymbolRef 2 "a")
)
:op :Add
:right (Var
:v (SymbolRef 2 "b")
)
:type (Integer
:kind 4
)
:value nil
)
:overloaded nil
:realloc_lhs false
:move_allocation false
)
]
:return_var (Var
:v (SymbolRef 2 "c")
)
:access :Public
:deterministic false
:side_effect_free false
:module_file nil
)
"~add" (CustomOperator
:parent_symtab 1
:name "~add"
:procs [
(SymbolRef 1 "plus")
]
:access :Public
)
}
)
:name "m"
:parent_module nil
:dependencies []
:loaded_from_mod false
:intrinsic false
:has_submodules false
)
"main" (Program
:symtab (SymbolTable
:id 3
:symbols {}
)
:name "main"
:dependencies []
:body []
)
}
)
:items []
)
See Also¶
GenericProcedure, OverloadedBinOp, OverloadedCompare, Assignment