112
111
-- Current still points to the last node
113
112
Current.Next := new Node'(Upper_Unit'Length, Upper_Unit, null);
113
List_Length := List_Length + 1;
114
114
if Cursor = null then
115
115
Cursor := Current.Next;
116
116
Previous := Current;
124
procedure Raise_Specification_Error (Mess : String) is
127
Raise_Exception (Specification_Error'Identity, Mess);
128
end Raise_Specification_Error;
129
pragma No_Return (Raise_Specification_Error);
134
procedure Free is new Ada.Unchecked_Deallocation (Node, Link);
140
procedure Post_Procedure (Element : in Asis.Element;
141
Control : in out Asis.Traverse_Control;
144
pragma Unreferenced (Element);
145
pragma Unreferenced (Control);
146
pragma Unreferenced (State);
151
------------------------
152
-- Pre_Procedure_With --
153
------------------------
155
procedure Pre_Procedure_With (Element : in Asis.Element;
156
Control : in out Asis.Traverse_Control;
159
pragma Unreferenced (State);
160
use Asis, Asis.Elements, Asis.Expressions, Asis.Compilation_Units;
166
case Element_Kind (Element) is
167
when A_Clause => ------------ Clause ------------
168
case Clause_Kind (Element) is
169
when A_With_Clause =>
170
-- Let recurse into children
174
Control := Abandon_Children;
176
when An_Expression => ------------ Expression ------------
177
case Expression_Kind (Element) is
178
when An_Identifier =>
179
-- Only identifiers from with clauses come here
180
-- However, we do not add predefined units
181
if Unit_Origin (Enclosing_Compilation_Unit
182
(Corresponding_Name_Definition (Element))) =
185
Add (Full_Name_Image (Corresponding_Name_Definition (Element)));
193
Control := Abandon_Children;
198
Trace ("Exception in Pre-proc of Units_List ", Element); --## rule line off no_trace
200
end Pre_Procedure_With;
206
procedure Traverse_With is new Asis.Iterator.Traverse_Element
207
(Info, Pre_Procedure_With, Post_Procedure);
209
121
----------------------------------------------------------------
210
122
-- Exported subprograms --
256
179
use Asis, Asis.Compilation_Units, Asis.Elements, Ada.Strings.Wide_Fixed, Ada.Strings.Wide_Maps;
258
procedure Free is new Ada.Unchecked_Deallocation (Wide_String, WS_Access);
260
181
Ignored_Units : array (1 .. Count (Unit_Spec, "-") ) of WS_Access;
261
182
Ignored_Inx : Natural := 0;
262
183
Separators : constant Wide_Character_Set := To_Set ("+-");
185
procedure Free is new Ada.Unchecked_Deallocation (Wide_String, WS_Access);
187
procedure Raise_Specification_Error (Mess : String) is
190
Raise_Exception (Specification_Error'Identity, Mess);
191
end Raise_Specification_Error;
192
pragma No_Return (Raise_Specification_Error);
264
194
function Must_Ignore (Name : Wide_String) return Boolean is
265
195
-- Check if unit name is either ignored, or a child (or a subunit) of an ignored unit
279
209
procedure Do_Process_With (My_Unit : Compilation_Unit) is
280
The_Control : Traverse_Control := Continue;
212
procedure Add_Withed_Unit (Withed_Name : Asis.Expression) is
213
use Asis.Expressions;
215
Unit_Name : Asis.Expression;
217
if Expression_Kind (Withed_Name) = A_Selected_Component then
218
-- Must add all units in the prefix
219
Add_Withed_Unit (Prefix (Withed_Name));
222
Unit_Name := Selector (Withed_Name);
224
Unit_Name := Withed_Name;
228
Name_Def : constant Asis.Definition := Corresponding_Name_Definition (Unit_Name);
230
if Unit_Origin (Enclosing_Compilation_Unit (Name_Def)) = An_Application_Unit then
231
Add (Full_Name_Image (Name_Def));
284
236
if Is_Nil (My_Unit) then
289
My_CC_List : constant Context_Clause_List
290
:= Context_Clause_Elements (Compilation_Unit => My_Unit,
291
Include_Pragmas => True) ;
241
My_CC_List : constant Context_Clause_List := Context_Clause_Elements (My_Unit) ;
293
243
for I in My_CC_List'Range loop
294
Traverse_With (My_CC_List (I), The_Control, The_Info);
244
if Clause_Kind (My_CC_List (I)) = A_With_Clause then
246
Withed_Units : constant Asis.Name_List := Clause_Names (My_CC_List (I));
248
for J in Withed_Units'Range loop
249
Add_Withed_Unit (Withed_Units (J));
297
255
end Do_Process_With;
312
270
My_CU_List : constant Compilation_Unit_List := A4G_Bugs.Subunits (My_Unit);
314
272
for I in My_CU_List'Range loop
315
-- We do not add stubs is Add_Stubs is false, but we still need to
316
-- add units that are withed by the stub
273
-- We do not add stubs if Add_Stubs is false, but if recursive, we still need
274
-- to add units that are withed by the stub
317
275
if Add_Stubs then
318
276
Add (Unit_Full_Name (My_CU_List (I)));
320
Do_Process_With (My_CU_List (I));
280
Do_Process_With (My_CU_List (I));
323
284
end Do_Process_Stub;
325
-- Forward declaration:
326
procedure Process_Unit_Spec (Unit_Spec : Wide_String);
328
procedure Process_Indirect_File (Name : String) is
329
use Ada.Wide_Text_IO, Ada.Strings,Ada.Strings.Wide_Fixed;
331
Units_File : Ada.Wide_Text_IO.File_Type;
333
function Read_Line return Wide_String is
334
Buffer : Wide_String (1..250);
337
Get_Line (Units_File, Buffer, Last);
338
if Last = Buffer'Last then
339
return Buffer & Read_Line;
341
return Buffer (1 .. Last);
345
Open (Units_File, In_File, Name);
348
-- This is the simplest way to deal with improperly formed files
351
Line : constant Wide_String := Trim (Read_Line, Both);
286
procedure Process_Unit_Spec (Spec : Wide_String) is
287
use Ada.Characters.Handling;
289
procedure Process_Indirect_File (Name : String) is
290
use Ada.Wide_Text_IO, Ada.Strings;
292
Units_File : Ada.Wide_Text_IO.File_Type;
294
function Read_Line return Wide_String is
295
Buffer : Wide_String (1..250);
353
if Line /= "" and then Line (1) /= '#' then
354
Process_Unit_Spec (Line);
298
Get_Line (Units_File, Buffer, Last);
299
if Last = Buffer'Last then
300
return Buffer & Read_Line;
302
return Buffer (1 .. Last);
362
Raise_Specification_Error ("Missing units file: " & Name);
363
when others => -- Including End_Error
364
if Is_Open (Units_File) then
306
Open (Units_File, In_File, Name);
309
-- This is the simplest way to deal with improperly formed files
312
Line : constant Wide_String := Trim (Read_Line, Both);
314
if Line /= "" and then Line (1) /= '#' then
315
Process_Unit_Spec (Line);
323
Raise_Specification_Error ("Missing units file: " & Name);
324
when others => -- Including End_Error
325
if Is_Open (Units_File) then
365
326
Close (Units_File);
367
end Process_Indirect_File;
369
procedure Process_Unit_Spec (Unit_Spec : Wide_String) is
370
use Ada.Characters.Handling;
328
end Process_Indirect_File;
372
330
Start : Positive;
332
begin -- Process_Unit_Spec
376
334
-- Get rid of case of indirect file:
378
if Unit_Spec (Unit_Spec'First) = '@' then
379
if Unit_Spec'Length = 1 then
336
if Spec (Spec'First) = '@' then
337
if Spec'Length = 1 then
381
339
Raise_Specification_Error ("Missing file name after @");
383
Process_Indirect_File (To_String (Unit_Spec (Unit_Spec'First+1 .. Unit_Spec'Last)));
341
Process_Indirect_File (To_String (Spec (Spec'First+1 .. Spec'Last)));
389
347
-- Extract unit names and ignored units from unit spec.
392
-- If Unit_spec starts with '-', our count is wrong...
350
-- If Spec starts with '-', our count is wrong...
393
351
-- let's forbid this case
394
if Unit_Spec (Unit_Spec'First) = '-' then
395
Raise_Specification_Error ("Wrong unit specification: " & To_String (Unit_Spec));
352
if Spec (Spec'First) = '-' then
353
Raise_Specification_Error ("Wrong unit specification: " & To_String (Spec));
398
if Unit_Spec (Unit_Spec'First) = '+' then
399
Start := Unit_Spec'First + 1;
356
if Spec (Spec'First) = '+' then
357
Start := Spec'First + 1;
401
Start := Unit_Spec'First;
404
Stop := Index (Unit_Spec (Start .. Unit_Spec'Last), Separators);
362
Stop := Index (Spec (Start .. Spec'Last), Separators);
406
Stop := Unit_Spec'Last;
407
365
elsif Stop = Start then -- "--" or "+-" or "-+" or "++" ...
408
366
Raise_Specification_Error ("No unit name after '-' or '+'");
410
368
Stop := Stop - 1;
412
if Start = Unit_Spec'First or else Unit_Spec (Start-1) = '+' then
413
Add (To_Upper(Unit_Spec (Start .. Stop)));
370
if Start = Spec'First or else Spec (Start-1) = '+' then
371
Add (To_Upper(Spec (Start .. Stop)));
415
373
Ignored_Inx := Ignored_Inx + 1;
416
Ignored_Units (Ignored_Inx) := new Wide_String'(To_Upper(Unit_Spec (Start .. Stop)));
374
Ignored_Units (Ignored_Inx) := new Wide_String'(To_Upper(Spec (Start .. Stop)));
418
exit when Stop = Unit_Spec'Last;
376
exit when Stop = Spec'Last;
419
377
Start := Stop + 2;
421
379
end Process_Unit_Spec;