comparison gcc/ada/sem_disp.ads @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S E M _ D I S P --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 1992-2016, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
25
26 -- This package contains routines involved in tagged types and dynamic
27 -- dispatching.
28
29 with Types; use Types;
30 package Sem_Disp is
31
32 procedure Check_Controlling_Formals (Typ : Entity_Id; Subp : Entity_Id);
33 -- Check that all controlling parameters of Subp are of type Typ, that
34 -- defaults for controlling parameters are tag-indeterminate, and that the
35 -- nominal subtype of the parameters and result statically match the first
36 -- subtype of the controlling type. Issues appropriate error messages if
37 -- any of these requirements is not met.
38
39 procedure Check_Dispatching_Call (N : Node_Id);
40 -- Check if the call N is a dispatching call. The subprogram is known to be
41 -- a dispatching operation. The call is dispatching if all the controlling
42 -- actuals are dynamically tagged. This procedure is called after overload
43 -- resolution, so the call is known to be unambiguous.
44
45 procedure Check_Dispatching_Operation (Subp, Old_Subp : Entity_Id);
46 -- Add Subp to the list of primitive operations of the corresponding type
47 -- if it has a parameter of this type and is defined at a proper place for
48 -- primitive operations (new primitives are only defined in package spec,
49 -- overridden operation can be defined in any scope). If Old_Subp is not
50 -- Empty we are in the overriding case. If the tagged type associated with
51 -- Subp is a concurrent type (case that occurs when the type is declared
52 -- in a generic because the analysis of generics disables generation of the
53 -- corresponding record) then this routine does not add Subp to the list of
54 -- primitive operations but leaves Subp decorated as dispatching operation
55 -- to enable checks associated with the Object.Operation notation.
56
57 procedure Check_Operation_From_Incomplete_Type
58 (Subp : Entity_Id;
59 Typ : Entity_Id);
60 -- If a primitive operation was defined for the incomplete view of the
61 -- type, and the full type declaration is a derived type definition,
62 -- the operation may override an inherited one.
63 -- Need more description here, what are the parameters, and what does
64 -- this call actually do???
65
66 procedure Check_Operation_From_Private_View (Subp, Old_Subp : Entity_Id);
67 -- Add Old_Subp to the list of primitive operations of the corresponding
68 -- tagged type if it is the full view of a private tagged type. The Alias
69 -- of Old_Subp is adjusted to point to the inherited procedure of the
70 -- full view because it is always this one which has to be called.
71 -- What is Subp used for???
72
73 function Covered_Interface_Op (Prim : Entity_Id) return Entity_Id;
74 -- Returns the interface primitive that Prim covers, when its controlling
75 -- type has progenitors.
76
77 function Find_Controlling_Arg (N : Node_Id) return Node_Id;
78 -- Returns the actual controlling argument if N is dynamically tagged, and
79 -- Empty if it is not dynamically tagged.
80
81 function Find_Dispatching_Type (Subp : Entity_Id) return Entity_Id;
82 -- Check whether the subprogram Subp is dispatching, and find the tagged
83 -- type of the controlling argument or arguments. Returns Empty if Subp
84 -- is not a dispatching operation.
85
86 function Find_Primitive_Covering_Interface
87 (Tagged_Type : Entity_Id;
88 Iface_Prim : Entity_Id) return Entity_Id;
89 -- Search the homonym chain for the primitive of Tagged_Type that covers
90 -- Iface_Prim. The homonym chain traversal is required to catch primitives
91 -- associated with the partial view of private types when processing the
92 -- corresponding full view. If the entity is not found, then search for it
93 -- in the list of primitives of Tagged_Type. This latter search is needed
94 -- when the interface primitive is covered by a private subprogram. If the
95 -- primitive has not been covered yet then return the entity that will be
96 -- overridden when the primitive is covered (that is, return the entity
97 -- whose alias attribute references the interface primitive). If none of
98 -- these entities is found then return Empty.
99
100 type Subprogram_List is array (Nat range <>) of Entity_Id;
101 -- Type returned by Inherited_Subprograms function
102
103 function Inherited_Subprograms
104 (S : Entity_Id;
105 No_Interfaces : Boolean := False;
106 Interfaces_Only : Boolean := False;
107 One_Only : Boolean := False) return Subprogram_List;
108 -- Given the spec of a subprogram, this function gathers any inherited
109 -- subprograms from direct inheritance or via interfaces. The result is an
110 -- array of Entity_Ids of the specs of inherited subprograms. Returns a
111 -- null array if passed an Empty spec id. Note that the returned array
112 -- only includes subprograms and generic subprograms (and excludes any
113 -- other inherited entities, in particular enumeration literals). If
114 -- No_Interfaces is True, only return inherited subprograms not coming
115 -- from an interface. If Interfaces_Only is True, only return inherited
116 -- subprograms from interfaces. Otherwise, subprograms inherited directly
117 -- come first, starting with the closest ancestors, and are followed by
118 -- subprograms inherited from interfaces. At most one of No_Interfaces
119 -- and Interfaces_Only should be True.
120 --
121 -- If One_Only is set, the search is discontinued as soon as one entry
122 -- is found. In this case the resulting array is either null or contains
123 -- exactly one element.
124
125 function Is_Dynamically_Tagged (N : Node_Id) return Boolean;
126 -- Used to determine whether a call is dispatching, i.e. if it is
127 -- an expression of a class_Wide type, or a call to a function with
128 -- controlling result where at least one operand is dynamically tagged.
129 -- Also used to determine whether an entity has a class-wide type, or a
130 -- function call that dispatches on the result. Used to verify that all the
131 -- dependent expressions in a conditional expression are equally tagged.
132
133 function Is_Null_Interface_Primitive (E : Entity_Id) return Boolean;
134 -- Returns True if E is a null procedure that is an interface primitive
135
136 function Is_Overriding_Subprogram (E : Entity_Id) return Boolean;
137 -- Returns True if E is an overriding subprogram
138
139 function Is_Tag_Indeterminate (N : Node_Id) return Boolean;
140 -- Returns true if the expression N is tag-indeterminate. An expression
141 -- is tag-indeterminate if it is a call that dispatches on result, and all
142 -- controlling operands are also indeterminate. Such a function call may
143 -- inherit a tag from an enclosing call.
144
145 procedure Override_Dispatching_Operation
146 (Tagged_Type : Entity_Id;
147 Prev_Op : Entity_Id;
148 New_Op : Entity_Id;
149 Is_Wrapper : Boolean := False);
150 -- Replace an implicit dispatching operation of the type Tagged_Type
151 -- with an explicit one. Prev_Op is an inherited primitive operation which
152 -- is overridden by the explicit declaration of New_Op. Is_Wrapper is
153 -- True when New_Op is an internally generated wrapper of a controlling
154 -- function. The caller checks that Tagged_Type is indeed a tagged type.
155
156 procedure Propagate_Tag (Control : Node_Id; Actual : Node_Id);
157 -- If a function call is tag-indeterminate, its controlling argument is
158 -- found in the context: either an enclosing call, or the left-hand side
159 -- of the enclosing assignment statement. The tag must be propagated
160 -- recursively to the tag-indeterminate actuals of the call.
161 -- Need clear description of the parameters Control and Actual, especially
162 -- since the comments above refer to actuals in the plural ???
163
164 end Sem_Disp;