~ubuntu-branches/ubuntu/karmic/asis/karmic

« back to all changes in this revision

Viewing changes to tools/gnatelim/gnatelim-entities.ads

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Quinot
  • Date: 2002-03-03 19:55:58 UTC
  • Revision ID: james.westby@ubuntu.com-20020303195558-g7dp4vaq1zdkf814
Tags: upstream-3.14p
ImportĀ upstreamĀ versionĀ 3.14p

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
------------------------------------------------------------------------------
 
2
--                                                                          --
 
3
--                            GNATELIM COMPONENTS                           --
 
4
--                                                                          --
 
5
--                       G N A T E L I M . E N T I T I E S                  --
 
6
--                                                                          --
 
7
--                                 S p e c                                  --
 
8
--                                                                          --
 
9
--            Copyright (c) 1997-1999, Free Software Foundation, Inc.       --
 
10
--                                                                          --
 
11
-- Gnatelim is free software; you can redistribute it and/or modify it      --
 
12
-- under terms of the  GNU General Public License  as published by the Free --
 
13
-- Software Foundation;  either version 2,  or  (at your option)  any later --
 
14
-- version. Gnatelim is distributed  in the hope  that it will be useful,   --
 
15
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MER-      --
 
16
-- CHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General  --
 
17
-- Public License for more details. You should have received a copy of the  --
 
18
-- GNU General Public License distributed with GNAT; see file COPYING. If   --
 
19
-- not, write to the Free Software Foundation, 59 Temple Place Suite 330,   --
 
20
-- Boston, MA 02111-1307, USA.                                              --
 
21
--                                                                          --
 
22
-- Gnatelim is distributed as a part of the ASIS implementation for GNAT    --
 
23
-- (ASIS-for-GNAT).                                                         --
 
24
--                                                                          --
 
25
-- Gnatelim was originally developed by Alain Le Guennec                    --
 
26
--                                                                          --
 
27
-- Gnatelim  is  now  maintained  by  Ada  Core  Technologies  Inc          --
 
28
-- (http://www.gnat.com).                                                   --
 
29
------------------------------------------------------------------------------
 
30
 
 
31
with Asis;
 
32
 
 
33
package GNATELIM.Entities is
 
34
 
 
35
   type Entity_Id is private;
 
36
   type Entity_Id_List is array (Natural range <>) of Entity_Id;
 
37
 
 
38
 
 
39
   No_Entity : constant Entity_Id;
 
40
 
 
41
 
 
42
   function No (Entity : Entity_Id) return Boolean;
 
43
   pragma Inline (No);
 
44
   --  Returns True if Entity = No_Entity.
 
45
 
 
46
 
 
47
   function Present (Entity : Entity_Id) return Boolean;
 
48
   pragma Inline (Present);
 
49
   --  Returns True if Entity /= No_Entity.
 
50
 
 
51
 
 
52
   Already_Registered : exception;
 
53
   --  Raised when trying to register an entity that was already registered.
 
54
 
 
55
 
 
56
   function  New_Entity (Element  : Asis.Element;
 
57
                         Instance : Entity_Id;
 
58
                         Name     : Wide_String;
 
59
                         Scope    : Entity_Id)
 
60
                         return Entity_Id;
 
61
   --  Creates (and inserts in a Table) a new Entity.
 
62
   --  This is the only function that creates a _new_ Entity_Id.
 
63
 
 
64
 
 
65
   function  Get_Element (Entity  : Entity_Id)
 
66
                          return Asis.Element;
 
67
   --  Returns the (ASIS.)Element corresponding to the Entity.
 
68
   --  Get_Element (No_Entity) = Asis.Nil_Element.
 
69
 
 
70
 
 
71
   function  Get_Name (Entity : Entity_Id) return Wide_String;
 
72
   --  Returns the defining name of the Entity.
 
73
   --  Get_Name (No_Entity) = "".
 
74
 
 
75
 
 
76
   function  Get_Instance (Entity  : Entity_Id)
 
77
                           return Entity_Id;
 
78
   --  Returns the Instance in which Entity is declared.
 
79
   --  Returns No_Entity for Entities that are not part of any instance.
 
80
   --  Get_Instance (No_Entity) = No_Entity.
 
81
 
 
82
 
 
83
   function  Get_Scope (Entity  : Entity_Id)
 
84
                        return Entity_Id;
 
85
   --  Returns the Scope in which Entity is declared.
 
86
   --  Get_Scope (No_Entity) = No_Entity.
 
87
 
 
88
 
 
89
   function  Corresponding_Declaration (Entity  : Entity_Id)
 
90
                                        return Asis.Declaration;
 
91
   --  Returns the declaration Element corresponding to Entity.
 
92
   --  If the Entity is not based on a defining name, return Nil_element.
 
93
 
 
94
 
 
95
   function  First_Homonym (Entity : Entity_Id) return Entity_Id;
 
96
   --  Returns the first homonym of Entity (same scope & name.)
 
97
 
 
98
 
 
99
   function  Next_Homonym  (Entity : Entity_Id) return Entity_Id;
 
100
   --  Returns the next homonym of Entity.
 
101
 
 
102
 
 
103
   function  Corresponding_Entity  (Element  : Asis.Element;
 
104
                                    Instance : Entity_Id)
 
105
                                    return Entity_Id;
 
106
   --  Returns the Entity (a element of the Table) corresponding
 
107
   --  to the (ASIS.)Element, and declared in the given Instance.
 
108
   --  If the Entity is not part of any instance, use No_Entity
 
109
   --  as the actual value for Instance.
 
110
   --  NOTE: If the expected result had not been registered before,
 
111
   --  a No_Entity is returned.
 
112
 
 
113
 
 
114
   function  Renamed_Entity (Renaming : Entity_Id) return Entity_Id;
 
115
   --  Returns the entity renamed by the Renaming.
 
116
 
 
117
 
 
118
   function  Unwind_Renamings (Entity : Entity_Id) return Entity_Id;
 
119
   --  Unwinds all renamings and returns the last renamed Entity.
 
120
 
 
121
 
 
122
   procedure Note_Use (Entity : Entity_Id; Used_By : Entity_Id);
 
123
   --  Marks a given entity as used by transitivity by another one.
 
124
   --  If Used_By is the No_Entity,
 
125
   --  the Entity can not be eliminated
 
126
   --  (ie. Is_Used (Entity) will be True.)
 
127
 
 
128
 
 
129
   function  Is_A_Master (Entity : Entity_Id) return Boolean;
 
130
   --  Returns True if the Entity is a master.
 
131
 
 
132
 
 
133
   function  Is_An_Instance (Entity : Entity_Id) return Boolean;
 
134
   --  Returns True if the Entity is a generic instantiation.
 
135
 
 
136
 
 
137
   function  Is_Used  (Entity : Entity_Id) return Boolean;
 
138
   --  Returns True if the Entity can't be eliminated.
 
139
 
 
140
 
 
141
   procedure Perform_Transitive_Closure;
 
142
   --  Performs the transitive closure on the whole call-graph.
 
143
   --  After this is done, it is possible to check if a given
 
144
   --  Entity can be eliminated by using the Is_Used function.
 
145
 
 
146
 
 
147
   generic
 
148
      with procedure Action (Entity   : in     Entity_Id;
 
149
                             Continue : in out Boolean);
 
150
   procedure Iterate;
 
151
   --  Apply the Action procedure to all registered entities.
 
152
   --  If Action sets Continue to False, then the iteration is aborted
 
153
   --  (Action is called with Continue set to True.)
 
154
 
 
155
private
 
156
 
 
157
   type Entity_Id is new Natural;
 
158
   --  Used to index the Entity_Information table.
 
159
 
 
160
   No_Entity : constant Entity_Id := 0;
 
161
 
 
162
 
 
163
   --  Boolean flags to characterize entities.
 
164
   Nb_Available_Flags : constant := 4;
 
165
   type Flag_Range is new Natural range 1 .. Nb_Available_Flags;
 
166
   Nb_Allocated_Flags : Flag_Range'Base := 0;
 
167
 
 
168
   generic
 
169
   package Boolean_Flag is
 
170
      procedure Set_Flag (Id : Entity_Id; Flag : Boolean);
 
171
      function  Get_Flag (Id : Entity_Id) return Boolean;
 
172
   end Boolean_Flag;
 
173
 
 
174
 
 
175
   --  Static links to connect entities with other entities.
 
176
   Nb_Available_Links : constant := 5;
 
177
   type Link_Range is new Natural range 1 .. Nb_Available_Links;
 
178
   Nb_Allocated_Links : Link_Range'Base := 0;
 
179
 
 
180
   generic
 
181
   package Static_Link is
 
182
      procedure Set_Link (Id : Entity_Id; Next : Entity_Id);
 
183
      function  Get_Link (Id : Entity_Id) return Entity_Id;
 
184
   end Static_Link;
 
185
 
 
186
end GNATELIM.Entities;
 
 
b'\\ No newline at end of file'