]>
Commit | Line | Data |
---|---|---|
1 | .. | |
2 | Copyright 1988-2022 Free Software Foundation, Inc. | |
3 | This is part of the GCC manual. | |
4 | For copying conditions, see the copyright.rst file. | |
5 | ||
6 | .. _type-bound-operators: | |
7 | ||
8 | Type-bound Operators | |
9 | ******************** | |
10 | ||
11 | Type-bound operators are in fact basically just ``GENERIC`` procedure | |
12 | bindings and are represented much in the same way as those (see | |
13 | :ref:`type-bound-procedures`). | |
14 | ||
15 | They come in two flavours: | |
16 | User-defined operators (like ``.MYOPERATOR.``) | |
17 | are stored in the ``f2k_derived`` namespace's ``tb_uop_root`` | |
18 | symtree exactly like ordinary type-bound procedures are stored in | |
19 | ``tb_sym_root`` ; their symtrees' names are the operator-names (e.g. | |
20 | :samp:`myoperator` in the example). | |
21 | Intrinsic operators on the other hand are stored in the namespace's | |
22 | array member ``tb_op`` indexed by the intrinsic operator's enum | |
23 | value. Those need not be packed into ``gfc_symtree`` structures and are | |
24 | only ``gfc_typebound_proc`` instances. | |
25 | ||
26 | When an operator call or assignment is found that cannot be handled in | |
27 | another way (i.e. neither matches an intrinsic nor interface operator | |
28 | definition) but that contains a derived-type expression, all type-bound | |
29 | operators defined on that derived-type are checked for a match with | |
30 | the operator call. If there's indeed a relevant definition, the | |
31 | operator call is replaced with an internally generated ``GENERIC`` | |
32 | type-bound procedure call to the respective definition and that call is | |
33 | further processed. |