OSDN Git Service

Nathanael Nerode <neroden@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / ada / sem_disp.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                             S E M _ D I S P                              --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                                                                          --
10 --          Copyright (C) 1992-1999 Free Software Foundation, Inc.          --
11 --                                                                          --
12 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
13 -- terms of the  GNU General Public License as published  by the Free Soft- --
14 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
15 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
18 -- for  more details.  You should have  received  a copy of the GNU General --
19 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
20 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, USA.                                                      --
22 --                                                                          --
23 -- GNAT was originally developed  by the GNAT team at  New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
25 --                                                                          --
26 ------------------------------------------------------------------------------
27
28 --  This package contains routines involved in tagged types and dynamic
29 --  dispatching.
30
31 with Types; use Types;
32 package Sem_Disp is
33
34    procedure Check_Controlling_Formals (Typ : Entity_Id; Subp : Entity_Id);
35    --  Check that all controlling parameters of Subp are of type Typ,
36    --  that defaults for controlling parameters are tag-indeterminate,
37    --  and that the nominal subtype of the parameters and result
38    --  statically match the first subtype of the controlling type.
39
40    procedure Check_Dispatching_Call (N : Node_Id);
41    --  Check if a call is a dispatching call. The subprogram is known to
42    --  be a dispatching operation. The call is dispatching if all the
43    --  controlling actuals are dynamically tagged. This procedure is called
44    --  after overload resolution, so the call is known to be unambiguous.
45
46    procedure Check_Dispatching_Operation (Subp, Old_Subp : Entity_Id);
47    --  Add "Subp" to the list of primitive operations of the corresponding type
48    --  if it has a parameter of this type and is defined at a proper place for
49    --  primitive operations. (new primitives are only defined in package spec,
50    --  overridden operation can be defined in any scope). If Old_Subp is not
51    --  Empty we are in the overriding case.
52
53    procedure Check_Operation_From_Incomplete_Type
54      (Subp : Entity_Id;
55       Typ  : Entity_Id);
56    --  If a primitive operation was defined for the incomplete view of the
57    --  type, and the full type declaration is a derived type definition,
58    --  the operation may override an inherited one.
59
60    procedure Check_Operation_From_Private_View (Subp, Old_Subp : Entity_Id);
61    --  Add "Old_Subp" to the list of primitive operations of the corresponding
62    --  tagged type if it is the full view of a private tagged type. The Alias
63    --  of "OldSubp" is adjusted to point to the inherited procedure of the
64    --  full view because it is always this one which has to be called.
65
66    function Find_Controlling_Arg (N : Node_Id) return Node_Id;
67    --  Returns the actual controlling argument if N is dynamically tagged,
68    --  and Empty if it is not dynamically tagged.
69
70    function Find_Dispatching_Type (Subp : Entity_Id) return Entity_Id;
71    --  Check whether a subprogram is dispatching, and find the tagged
72    --  type of the controlling argument or arguments.
73
74    function Is_Dynamically_Tagged (N : Node_Id) return Boolean;
75    --  Used to determine whether a call is dispatching, i.e. if is an
76    --  an expression of a class_Wide type, or a call to a function with
77    --  controlling result where at least one operand is dynamically tagged.
78
79    function Is_Tag_Indeterminate (N : Node_Id) return Boolean;
80    --  An expression is tag-indeterminate if it is a call that dispatches
81    --  on result, and all controlling operands are also indeterminate.
82    --  Such a function call may inherit a tag from an enclosing call.
83
84    procedure Propagate_Tag (Control : Node_Id; Actual : Node_Id);
85    --  If a function call is tag-indeterminate,  its controlling argument is
86    --  found in the context;  either an enclosing call, or the left-hand side
87    --  of the enclosing assignment statement. The tag must be propagated
88    --  recursively to the tag-indeterminate actuals of the call.
89
90 end Sem_Disp;