1
------------------------------------------------------------------------------
3
-- GNATELIM COMPONENTS --
5
-- G N A T E L I M . E N T I T I E S --
9
-- Copyright (c) 1997-1999, Free Software Foundation, Inc. --
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. --
22
-- Gnatelim is distributed as a part of the ASIS implementation for GNAT --
23
-- (ASIS-for-GNAT). --
25
-- Gnatelim was originally developed by Alain Le Guennec --
27
-- Gnatelim is now maintained by Ada Core Technologies Inc --
28
-- (http://www.gnat.com). --
29
------------------------------------------------------------------------------
33
package GNATELIM.Entities is
35
type Entity_Id is private;
36
type Entity_Id_List is array (Natural range <>) of Entity_Id;
39
No_Entity : constant Entity_Id;
42
function No (Entity : Entity_Id) return Boolean;
44
-- Returns True if Entity = No_Entity.
47
function Present (Entity : Entity_Id) return Boolean;
48
pragma Inline (Present);
49
-- Returns True if Entity /= No_Entity.
52
Already_Registered : exception;
53
-- Raised when trying to register an entity that was already registered.
56
function New_Entity (Element : Asis.Element;
61
-- Creates (and inserts in a Table) a new Entity.
62
-- This is the only function that creates a _new_ Entity_Id.
65
function Get_Element (Entity : Entity_Id)
67
-- Returns the (ASIS.)Element corresponding to the Entity.
68
-- Get_Element (No_Entity) = Asis.Nil_Element.
71
function Get_Name (Entity : Entity_Id) return Wide_String;
72
-- Returns the defining name of the Entity.
73
-- Get_Name (No_Entity) = "".
76
function Get_Instance (Entity : 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.
83
function Get_Scope (Entity : Entity_Id)
85
-- Returns the Scope in which Entity is declared.
86
-- Get_Scope (No_Entity) = No_Entity.
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.
95
function First_Homonym (Entity : Entity_Id) return Entity_Id;
96
-- Returns the first homonym of Entity (same scope & name.)
99
function Next_Homonym (Entity : Entity_Id) return Entity_Id;
100
-- Returns the next homonym of Entity.
103
function Corresponding_Entity (Element : Asis.Element;
104
Instance : 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.
114
function Renamed_Entity (Renaming : Entity_Id) return Entity_Id;
115
-- Returns the entity renamed by the Renaming.
118
function Unwind_Renamings (Entity : Entity_Id) return Entity_Id;
119
-- Unwinds all renamings and returns the last renamed Entity.
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.)
129
function Is_A_Master (Entity : Entity_Id) return Boolean;
130
-- Returns True if the Entity is a master.
133
function Is_An_Instance (Entity : Entity_Id) return Boolean;
134
-- Returns True if the Entity is a generic instantiation.
137
function Is_Used (Entity : Entity_Id) return Boolean;
138
-- Returns True if the Entity can't be eliminated.
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.
148
with procedure Action (Entity : in Entity_Id;
149
Continue : in out Boolean);
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.)
157
type Entity_Id is new Natural;
158
-- Used to index the Entity_Information table.
160
No_Entity : constant Entity_Id := 0;
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;
169
package Boolean_Flag is
170
procedure Set_Flag (Id : Entity_Id; Flag : Boolean);
171
function Get_Flag (Id : Entity_Id) return Boolean;
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;
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;
186
end GNATELIM.Entities;
b'\\ No newline at end of file'