aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/bindo-builders.adb
diff options
context:
space:
mode:
authorHristian Kirtchev <kirtchev@adacore.com>2019-07-05 07:02:08 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-07-05 07:02:08 +0000
commit9795b20366362d63be058f1e4f3009d6bad79310 (patch)
treeaba3763d81a519c490994b1fce8918c7e31e31c2 /gcc/ada/bindo-builders.adb
parentdb6261488e4e53e4ac09ec9db50ea2e4a1859377 (diff)
downloadgcc-9795b20366362d63be058f1e4f3009d6bad79310.zip
gcc-9795b20366362d63be058f1e4f3009d6bad79310.tar.gz
gcc-9795b20366362d63be058f1e4f3009d6bad79310.tar.bz2
[Ada] Diagnostics in Elaboration order v4.0
This patch introduces several changes to the new elaboration order mechanism: * The library graph can now discover, store, and organize the various cycles it contains. * The elaboration order mechanism can now diagnose one or all cycles within the library graph. Diagnostics consist of describing the reason for the cycle, listing all units comprising the circuit, and offering suggestions on how to break the cycle. The patch also modifies unit ALI to hide all invocation-related data structures and several implementation-specific types by relocating them in the body of the unit. The patch cleans up most children of Bindo by using better names of routines and formal parameters. ------------ -- Source -- ------------ -- a.ads with B; pragma Elaborate_All (B); with C; pragma Elaborate_All (C); package A is end A; -- b.ads package B is procedure Force_Body; end B; -- b.adb with D; package body B is procedure Force_Body is null; Elab : constant Integer := D.Func; end B; -- c.ads package C is procedure Force_Body; end C; -- c.adb with E; package body C is procedure Force_Body is null; end C; -- d.ads package D is function Func return Integer; end D; -- d.adb with A; package body D is Local : Integer := 123; function Func return Integer is begin return Local; end Func; end D; -- e.ads with A; package E is end E; -- main.adb with B; -- Elaborate_All Elaborate_All with -- C spec <--------------- A spec ---------------------> B spec <------ Main -- ^ ^ ^ ^ -- | | | | -- sbb | | | | sbb -- | | | | -- C body -----------> E spec | D spec <--------- B body -- with | ^ with | -- | | | -- | sbb | | -- | | | -- +------ D body <------------+ -- with Invocation -- -- The cycles are -- -- A spec --> C spec --> E spec --> A spec -- C body -- -- A spec --> B spec --> D body --> A spec -- B body procedure Main is begin null; end Main; ---------------------------- -- Compilation and output -- ---------------------------- $ gnatmake -q main.adb -bargs -d_C -d_N error: Elaboration circularity detected info: info: Reason: info: info: unit "a (spec)" depends on its own elaboration info: info: Circularity: info: info: unit "a (spec)" has with clause and pragma Elaborate_All for unit "b (spec)" info: unit "b (body)" is in the closure of pragma Elaborate_All info: unit "b (body)" has with clause for unit "d (spec)" info: unit "d (body)" is in the closure of pragma Elaborate_All info: unit "d (body)" has with clause for unit "a (spec)" info: info: Suggestions: info: info: change pragma Elaborate_All for unit "b (spec)" to Elaborate in unit "a (spec)" info: remove pragma Elaborate_All for unit "b (spec)" in unit "a (spec)" info: error: Elaboration circularity detected info: info: Reason: info: info: unit "a (spec)" depends on its own elaboration info: info: Circularity: info: info: unit "a (spec)" has with clause and pragma Elaborate_All for unit "c (spec)" info: unit "c (body)" is in the closure of pragma Elaborate_All info: unit "c (body)" has with clause for unit "e (spec)" info: unit "e (spec)" has with clause for unit "a (spec)" info: info: Suggestions: info: info: change pragma Elaborate_All for unit "c (spec)" to Elaborate in unit "a (spec)" info: remove pragma Elaborate_All for unit "c (spec)" in unit "a (spec)" info: gnatmake: *** bind failed. 2019-07-05 Hristian Kirtchev <kirtchev@adacore.com> gcc/ada/ * ali.adb: Relocate types Invocation_Construct_Record, Invocation_Relation_Record, and Invocation_Signature_Record to the body of ALI. Relocate tables Invocation_Constructs, Invocation_Relations, and Invocation_Signatures to the body of ALI. Remove type Body_Placement_Codes. Add new types Declaration_Placement_Codes, and Invocation_Graph_Encoding_Codes. Update the literals of type Invocation_Graph_Line_Codes. (Add_Invocation_Construct): Update the parameter profile. Add an invocation construct built from all attributes provided. (Add_Invocation_Relation): Update the parameter profile. Add an invocation relation built from all attributes provided. (Body_Placement): New routine. (Body_Placement_Kind_To_Code, Code_To_Body_Placement_Kind): Removed. (Code_To_Declaration_Placement_Kind, Code_To_Invocation_Graph_Encoding_Kind, Column, Declaration_Placement_Kind_To_Code, Extra, For_Each_Invocation_Construct, For_Each_Invocation_Relation, Invocation_Graph_Encoding, Invocation_Graph_Encoding_Kind_To_Code, Invoker, Kind, Line, Locations, Name): New routine. (Scan_Invocation_Construct_Line): Reimplement the scanning mechanism. (Scan_Invocation_Graph_Attributes_Line): New routine. (Scan_Invocation_Graph_Line): Use a case statement to dispatch. (Scan_Invocation_Relation_Line): Reimplement the scanning mechanism. (Scope): New routine. (Set_Invocation_Graph_Encoding, Signature, Spec_Placement, Target): New routine. * ali.ads: Add new type Invocation_Graph_Encoding_Kind. Add component Invocation_Graph_Encoding to type Unit_Record. Relocate various types and data structures to the body of ALI. (Add_Invocation_Construct, Add_Invocation_Relation): Update the parameter profile. (Body_Placement): New routine. (Body_Placement_Kind_To_Code, Code_To_Body_Placement_Kind): Removed. (Code_To_Declaration_Placement_Kind, Code_To_Invocation_Graph_Encoding_Kind, Column, Declaration_Placement_Kind_To_Code, Extra, For_Each_Invocation_Construct, For_Each_Invocation_Relation, Invocation_Graph_Encoding, Invocation_Graph_Encoding_Kind_To_Code, Invoker, Kind, Line, Locations, Name, Scope, Set_Invocation_Graph_Encoding, Signature, Spec_Placement, Target): New routine. * bindo.adb: Add with clause for Binde. Add with and use clauses for Debug. Update the documentation. Add new switches. (Find_Elaboration_Order): Dispatch to the proper elaboration mechanism. * bindo-augmentors.adb: Remove with and use clauses for GNAT and GNAT.Sets. Remove membership set VS. Update the parameter profiles of most routines to use better parameter names. Update the implementation of most routine to use the new parameter names. Remove various redundant assertions. * bindo-builders.adb: Use better names for instantiated data structures. Update all references to these names. Update the parameter profiles of most routines to use better parameter names. Update the implementation of most routine to use the new parameter names. (Build_Library_Graph): Update the parameter profile. Update the call to Create. (Create_Vertex): Reimplemented. (Declaration_Placement_Vertex): New routine. * bindo-builders.ads (Build_Library_Graph): Update the parameter profile and comment on usage. * bindo-diagnostics.adb: Almost a new unit. * bindo-diagnostics.ads: Add a use clause for Bindo.Graphs.Invocation_Graphs. Remove package Cycle_Diagnostics. (Diagnose_Circularities): New routine. * bindo-elaborators.adb: Remove the with and use clauses for Binderr and GNAT.Sets. Remove the use clause for Bindo.Diagnostics.Cycle_Diagnostics. Remove membership set VS. Update the parameter profiles of most routines to use better parameter names. Update the implementation of most routine to use the new parameter names. (Elaborate_Units_Common): Update the parameter profile. Pass an infication to the library graph builder whether the dynamic model is in effect. (Elaborate_Units_Dynamic, Elaborate_Units_Static): Use Diagnose_Circularities to provide diagnostics. (Update_Successor): Use routine In_Same_Component to determine whether the predecessor and successor reside in different components. * bindo-graphs.adb: Add with and use clauses for Butil, Debug, Output, and Bindo.Writers. Remove with and use clauses for GNAT.Lists. Update the parameter profiles of most routines to use better parameter names. Update the implementation of most routine to use the new parameter names. Remove various redundant assertions. Remove doubly linked list EL. Add new type Precedence_Kind. (Add_Cycle): New routine. (Add_Vertex): Update the parameter profile. Update the creation of vertex attributes. (Add_Vertex_And_Complement, Body_Vertex, Column, Complementary_Vertex, Copy_Cycle_Path, Cycle_Kind_Of): New routines. (Destroy_Invocation_Graph_Edge, Destroy_Library_Graph_Cycle, Destroy_Library_Graph_Edge, Extra, File_Name, Find_All_Cycles_Through_Vertex, Find_All_Cycles_With_Edge, Find_Cycles, Find_First_Lower_Precedence_Cycle, Get_LGC_Attributes, Has_Next, Hash_Library_Graph_Cycle, Hash_Library_Graph_Cycle_Attributes, Highest_Precedence_Cycle, Highest_Precedence_Edge, In_Same_Component, Insert_And_Sort, Invocation_Edge_Count, Invocation_Graph_Encoding, Is_Cycle_Initiating_Edge, Is_Cyclic_Edge, Is_Cyclic_Elaborate_All_Edge, Is_Cyclic_Elaborate_Body_Edge, Is_Cyclic_Elaborate_Edge, Is_Cyclic_Forced_Edge, Is_Cyclic_Invocation_Edge, Is_Cyclic_With_Edge, Is_Dynamically_Elaborated, Is_Elaborate_All_Edge, Is_Elaborate_Body_Edge, Is_Elaborate_Edge: New routines. (Is_Existing_Predecessor_Successor_Relation): Removed. (Is_Forced_Edge, Is_Invocation_Edge, Is_Recorded_Cycle, Is_Recorded_Edge, Is_With_Edge, Iterate_Edges_Of_Cycle, Kind, Length): New routine. (Lib_Vertex): Removed. (Line, Links_Vertices_In_Same_Component, Maximum_Invocation_Edge_Count, Next, Normalize_And_Add_Cycle, Normalize_Cycle_Path, Number_Of_Cycles, Path, Precedence, Remove_Vertex_And_Complement, Sequence_Next_Cycle): New routines. (Sequence_Next_IGE_Id): Renamed to Sequence_Next_Edge. (Sequence_Next_IGV_Id): Renamed to Sequence_Next_Vertex. (Sequence_Next_LGE_Id): Renamed to Sequence_Next_Edge. (Sequence_Next_LGV_Id): Renamed to Sequence_Next_Vertex. (Set_Is_Existing_Predecessor_Successor_Relation): Removed. (Set_Is_Recorded_Cycle, Set_Is_Recorded_Edge, Set_LGC_Attributes, Spec_Vertex, Trace_Cycle, Trace_Edge, Trace_Eol, Trace_Vertex): New routines. * bindo-graphs.ads: Add with and use clauses for Types and GNAT.Lists. Update the parameter profiles of most routines to use better parameter names. Update the implementation of most routine to use the new parameter names. Add the new instantiated data structures IGE_Lists, IGV_Sets, LGC_Lists, LGE_Lists, LGE_Sets, LGV_Sets, and RC_Sets. Add new type Library_Graph_Cycle_Id along with an empty and initial value. Remove component Lib_Vertex and add new components Body_Vertex and Spec_Vertex to type Invocation_Graph_Vertex_Attributes. Add new type Library_Graph_Cycle_Kind. Add new iterators All_Cycle_Iterator and Edges_Of_Cycle_Iterator. Add new type Library_Graph_Cycle_Attributes. Add new components Cycle_Attributes, Cycles, and Dynamically_Elaborated to type Library_Graph_Attributes. (Body_Vertex, Column, Destroy_Invocation_Graph_Edge, Destroy_Library_Graph_Cycle_Attributes, Destroy_Library_Graph_Edge, Extra, File_Name, Find_Cycles, Has_Elaborate_All_Cycle, Has_Next, Hash_Library_Graph_Cycle, Hash_Library_Graph_Cycle_Attributes, Highest_Precedence_Cycle, In_Same_Component, Invocation_Edge_Count, Invocation_Graph_Encoding, Is_Dynamically_Elaborated, Is_Elaborate_All_Edge, Is_Elaborate_Body_Edge, Is_Elaborate_Edge, Is_Forced_Edge, Is_Invocation_Edge, Is_With_Edge, Iterate_All_Cycles, Iterate_Edges_Of_Cycle, Kind): New routines. (Length, Lib_Vertex, (Line, Next, Number_Of_Cycles, Present, Same_Library_Graph_Cycle_Attributes, Spec_Vertex): New routines. * bindo-units.adb (File_Name, Invocation_Graph_Encoding): New routines. * bindo-units.ads: Add new instantiated data structure Unit_Sets. (File_Name, Invocation_Graph_Encoding): New routine. * bindo-validators.adb: Remove with and use clauses for GNAT and GNAT.Sets. Remove membership set US. Update the parameter profiles of most routines to use better parameter names. Update the implementation of most routine to use the new parameter names. (Validate_Cycle, Validate_Cycle_Path, Validate_Cycles, Validate_Invocation_Graph_Vertex): Remove the validation of component Lib_Vertex. Add the validation of components Body_Vertex and Spec_Vertex. (Write_Error): New routine. * bindo-validators.ads (Validate_Cycles): New routine. * bindo-writers.adb: Update the parameter profiles of most routines to use better parameter names. Update the implementation of most routine to use the new parameter names. (Write_Cycle, Write_Cyclic_Edge, Write_Cycles): New routines. (Write_Invocation_Graph_Vertex): Remove the output of component Lib_Vertex. Add the output of components Body_Vertex and Spec_Vertex. * bindo-writers.ads (Write_Cycles): New routine. * debug.adb: Use binder switches -d_C and -d_P, add documentation on their usage. * gnatbind.adb: Remove with and use clauses for Binde. Delegate the choice of elaboration mechanism to Bindo. * lib-writ.adb (Column, Extra, Invoker, Kind, Line, Locations, Name, Placement, Scope, Signature, Target): Removed. (Write_Invocation_Graph): Moved at the top level. (Write_Invocation_Graph_Attributes): New routine. (Write_Invocation_Relation, Write_Invocation_Signature): Moved at the top level. * lib-writ.ads: Add a documentation section on invocation graph attributes. * sem_elab.adb (Body_Placement_Of): New routine. (Declare_Invocation_Construct): Update the call to Add_Invocation_Construct. (Declaration_Placement_Of_Node): New routine. (Get_Invocation_Attributes): Correct the retrieval of the enclosing subprogram where the postcondition procedure lives. (Placement_Of, Placement_Of_Node): Removed. (Record_Invocation_Graph): Record the encoding format used. (Record_Invocation_Graph_Encoding): New routine. (Record_Invocation_Relation): Update the call to Add_Invocation_Relation. (Spec_Placement_Of): Removed. * libgnat/g-lists.ads, libgnat/g-lists.adb (Equal): New routine. From-SVN: r273107
Diffstat (limited to 'gcc/ada/bindo-builders.adb')
-rw-r--r--gcc/ada/bindo-builders.adb229
1 files changed, 111 insertions, 118 deletions
diff --git a/gcc/ada/bindo-builders.adb b/gcc/ada/bindo-builders.adb
index c0340c0..f4b8e42 100644
--- a/gcc/ada/bindo-builders.adb
+++ b/gcc/ada/bindo-builders.adb
@@ -64,10 +64,10 @@ package body Bindo.Builders is
procedure Create_Vertex
(IC_Id : Invocation_Construct_Id;
- LGV_Id : Library_Graph_Vertex_Id);
+ Vertex : Library_Graph_Vertex_Id);
pragma Inline (Create_Vertex);
-- Create a new vertex for invocation construct IC_Id in invocation
- -- graph Inv_Graph. The vertex is linked to vertex LGV_Id of library
+ -- graph Inv_Graph. The vertex is linked to vertex Vertex of library
-- graph Lib_Graph.
procedure Create_Vertices (U_Id : Unit_Id);
@@ -75,6 +75,14 @@ package body Bindo.Builders is
-- Create new vertices for all invocation constructs of unit U_Id in
-- invocation graph Inv_Graph.
+ function Declaration_Placement_Vertex
+ (Vertex : Library_Graph_Vertex_Id;
+ Placement : Declaration_Placement_Kind)
+ return Library_Graph_Vertex_Id;
+ pragma Inline (Declaration_Placement_Vertex);
+ -- Obtain the spec or body of vertex Vertex depending on the requested
+ -- placement in Placement.
+
----------------------------
-- Build_Invocation_Graph --
----------------------------
@@ -88,8 +96,9 @@ package body Bindo.Builders is
-- Prepare the global data
Inv_Graph :=
- Create (Initial_Vertices => Number_Of_Elaborable_Units,
- Initial_Edges => Number_Of_Elaborable_Units);
+ Create
+ (Initial_Vertices => Number_Of_Elaborable_Units,
+ Initial_Edges => Number_Of_Elaborable_Units);
Lib_Graph := Lib_G;
For_Each_Elaborable_Unit (Create_Vertices'Access);
@@ -107,33 +116,24 @@ package body Bindo.Builders is
pragma Assert (Present (Lib_Graph));
pragma Assert (Present (IR_Id));
- IR_Rec : Invocation_Relation_Record renames
- Invocation_Relations.Table (IR_Id);
-
- pragma Assert (Present (IR_Rec.Invoker));
- pragma Assert (Present (IR_Rec.Target));
+ Invoker_Sig : constant Invocation_Signature_Id := Invoker (IR_Id);
+ Target_Sig : constant Invocation_Signature_Id := Target (IR_Id);
- Invoker : Invocation_Graph_Vertex_Id;
- Target : Invocation_Graph_Vertex_Id;
+ pragma Assert (Present (Invoker_Sig));
+ pragma Assert (Present (Target_Sig));
begin
-- Nothing to do when the target denotes an invocation construct that
-- resides in a unit which will never be elaborated.
- if not Needs_Elaboration (IR_Rec.Target) then
+ if not Needs_Elaboration (Target_Sig) then
return;
end if;
- Invoker := Corresponding_Vertex (Inv_Graph, IR_Rec.Invoker);
- Target := Corresponding_Vertex (Inv_Graph, IR_Rec.Target);
-
- pragma Assert (Present (Invoker));
- pragma Assert (Present (Target));
-
Add_Edge
(G => Inv_Graph,
- Source => Invoker,
- Target => Target,
+ Source => Corresponding_Vertex (Inv_Graph, Invoker_Sig),
+ Target => Corresponding_Vertex (Inv_Graph, Target_Sig),
IR_Id => IR_Id);
end Create_Edge;
@@ -162,35 +162,25 @@ package body Bindo.Builders is
procedure Create_Vertex
(IC_Id : Invocation_Construct_Id;
- LGV_Id : Library_Graph_Vertex_Id)
+ Vertex : Library_Graph_Vertex_Id)
is
+ begin
pragma Assert (Present (Inv_Graph));
pragma Assert (Present (Lib_Graph));
pragma Assert (Present (IC_Id));
- pragma Assert (Present (LGV_Id));
-
- IC_Rec : Invocation_Construct_Record renames
- Invocation_Constructs.Table (IC_Id);
-
- Body_LGV_Id : Library_Graph_Vertex_Id;
-
- begin
- -- Determine the proper library graph vertex which holds the body of
- -- the invocation construct.
-
- if IC_Rec.Placement = In_Body then
- Body_LGV_Id := Proper_Body (Lib_Graph, LGV_Id);
- else
- pragma Assert (IC_Rec.Placement = In_Spec);
- Body_LGV_Id := Proper_Spec (Lib_Graph, LGV_Id);
- end if;
-
- pragma Assert (Present (Body_LGV_Id));
+ pragma Assert (Present (Vertex));
Add_Vertex
- (G => Inv_Graph,
- IC_Id => IC_Id,
- LGV_Id => Body_LGV_Id);
+ (G => Inv_Graph,
+ IC_Id => IC_Id,
+ Body_Vertex =>
+ Declaration_Placement_Vertex
+ (Vertex => Vertex,
+ Placement => Body_Placement (IC_Id)),
+ Spec_Vertex =>
+ Declaration_Placement_Vertex
+ (Vertex => Vertex,
+ Placement => Spec_Placement (IC_Id)));
end Create_Vertex;
---------------------
@@ -203,18 +193,37 @@ package body Bindo.Builders is
pragma Assert (Present (U_Id));
U_Rec : Unit_Record renames ALI.Units.Table (U_Id);
- LGV_Id : constant Library_Graph_Vertex_Id :=
+ Vertex : constant Library_Graph_Vertex_Id :=
Corresponding_Vertex (Lib_Graph, U_Id);
- pragma Assert (Present (LGV_Id));
-
begin
for IC_Id in U_Rec.First_Invocation_Construct ..
U_Rec.Last_Invocation_Construct
loop
- Create_Vertex (IC_Id, LGV_Id);
+ Create_Vertex (IC_Id, Vertex);
end loop;
end Create_Vertices;
+
+ ----------------------------------
+ -- Declaration_Placement_Vertex --
+ ----------------------------------
+
+ function Declaration_Placement_Vertex
+ (Vertex : Library_Graph_Vertex_Id;
+ Placement : Declaration_Placement_Kind)
+ return Library_Graph_Vertex_Id
+ is
+ begin
+ pragma Assert (Present (Lib_Graph));
+ pragma Assert (Present (Vertex));
+
+ if Placement = In_Body then
+ return Proper_Body (Lib_Graph, Vertex);
+ else
+ pragma Assert (Placement = In_Spec);
+ return Proper_Spec (Lib_Graph, Vertex);
+ end if;
+ end Declaration_Placement_Vertex;
end Invocation_Graph_Builders;
----------------------------
@@ -235,7 +244,7 @@ package body Bindo.Builders is
pragma Inline (Hash_Unit);
-- Obtain the hash value of key U_Id
- package UL is new Dynamic_Hash_Tables
+ package Unit_Line_Tables is new Dynamic_Hash_Tables
(Key_Type => Unit_Id,
Value_Type => Logical_Line_Number,
No_Value => No_Line_Number,
@@ -253,9 +262,10 @@ package body Bindo.Builders is
Lib_Graph : Library_Graph := Library_Graphs.Nil;
- Unit_To_Line : UL.Dynamic_Hash_Table := UL.Nil;
+ Unit_To_Line : Unit_Line_Tables.Dynamic_Hash_Table :=
+ Unit_Line_Tables.Nil;
-- The map of unit name -> line number, used to detect duplicate unit
- -- names and report errors.
+ -- names in the forced-elaboration-order file and report errors.
-----------------------
-- Local subprograms --
@@ -348,20 +358,24 @@ package body Bindo.Builders is
begin
pragma Assert (Present (U_Id));
- UL.Put (Unit_To_Line, U_Id, Line);
+ Unit_Line_Tables.Put (Unit_To_Line, U_Id, Line);
end Add_Unit;
-------------------------
-- Build_Library_Graph --
-------------------------
- function Build_Library_Graph return Library_Graph is
+ function Build_Library_Graph
+ (Dynamically_Elaborated : Boolean) return Library_Graph
+ is
begin
-- Prepare the global data
Lib_Graph :=
- Create (Initial_Vertices => Number_Of_Elaborable_Units,
- Initial_Edges => Number_Of_Elaborable_Units);
+ Create
+ (Initial_Vertices => Number_Of_Elaborable_Units,
+ Initial_Edges => Number_Of_Elaborable_Units,
+ Dynamically_Elaborated => Dynamically_Elaborated);
For_Each_Elaborable_Unit (Create_Vertex'Access);
For_Each_Elaborable_Unit (Create_Spec_And_Body_Edge'Access);
@@ -383,14 +397,11 @@ package body Bindo.Builders is
pragma Assert (Present (Pred));
pragma Assert (Present (Succ));
- Pred_LGV_Id : constant Library_Graph_Vertex_Id :=
+ Pred_Vertex : constant Library_Graph_Vertex_Id :=
Corresponding_Vertex (Lib_Graph, Pred);
- Succ_LGV_Id : constant Library_Graph_Vertex_Id :=
+ Succ_Vertex : constant Library_Graph_Vertex_Id :=
Corresponding_Vertex (Lib_Graph, Succ);
- pragma Assert (Present (Pred_LGV_Id));
- pragma Assert (Present (Succ_LGV_Id));
-
begin
Write_Unit_Name (Name (Pred));
Write_Str (" <-- ");
@@ -399,8 +410,8 @@ package body Bindo.Builders is
Add_Edge
(G => Lib_Graph,
- Pred => Pred_LGV_Id,
- Succ => Succ_LGV_Id,
+ Pred => Pred_Vertex,
+ Succ => Succ_Vertex,
Kind => Forced_Edge);
end Create_Forced_Edge;
@@ -409,15 +420,15 @@ package body Bindo.Builders is
-------------------------
procedure Create_Forced_Edges is
- Curr_Unit : Unit_Id;
- Iter : Forced_Units_Iterator;
- Prev_Unit : Unit_Id;
- Unit_Line : Logical_Line_Number;
- Unit_Name : Unit_Name_Type;
+ Current_Unit : Unit_Id;
+ Iter : Forced_Units_Iterator;
+ Previous_Unit : Unit_Id;
+ Unit_Line : Logical_Line_Number;
+ Unit_Name : Unit_Name_Type;
begin
- Prev_Unit := No_Unit_Id;
- Unit_To_Line := UL.Create (20);
+ Previous_Unit := No_Unit_Id;
+ Unit_To_Line := Unit_Line_Tables.Create (20);
-- Inspect the contents of the forced-elaboration-order file supplied
-- to the binder using switch -f, and diagnose each unit accordingly.
@@ -425,36 +436,35 @@ package body Bindo.Builders is
Iter := Iterate_Forced_Units;
while Has_Next (Iter) loop
Next (Iter, Unit_Name, Unit_Line);
- pragma Assert (Present (Unit_Name));
- Curr_Unit := Corresponding_Unit (Unit_Name);
+ Current_Unit := Corresponding_Unit (Unit_Name);
- if not Present (Curr_Unit) then
+ if not Present (Current_Unit) then
Missing_Unit_Info (Unit_Name);
- elsif Is_Internal_Unit (Curr_Unit) then
+ elsif Is_Internal_Unit (Current_Unit) then
Internal_Unit_Info (Unit_Name);
- elsif Is_Duplicate_Unit (Curr_Unit) then
- Duplicate_Unit_Error (Curr_Unit, Unit_Name, Unit_Line);
+ elsif Is_Duplicate_Unit (Current_Unit) then
+ Duplicate_Unit_Error (Current_Unit, Unit_Name, Unit_Line);
-- Otherwise the unit is a valid candidate for a vertex. Create a
-- forced edge between each pair of units.
else
- Add_Unit (Curr_Unit, Unit_Line);
+ Add_Unit (Current_Unit, Unit_Line);
- if Present (Prev_Unit) then
+ if Present (Previous_Unit) then
Create_Forced_Edge
- (Pred => Prev_Unit,
- Succ => Curr_Unit);
+ (Pred => Previous_Unit,
+ Succ => Current_Unit);
end if;
- Prev_Unit := Curr_Unit;
+ Previous_Unit := Current_Unit;
end if;
end loop;
- UL.Destroy (Unit_To_Line);
+ Unit_Line_Tables.Destroy (Unit_To_Line);
end Create_Forced_Edges;
-------------------------------
@@ -462,42 +472,37 @@ package body Bindo.Builders is
-------------------------------
procedure Create_Spec_And_Body_Edge (U_Id : Unit_Id) is
- Aux_LGV_Id : Library_Graph_Vertex_Id;
- LGV_Id : Library_Graph_Vertex_Id;
+ Extra_Vertex : Library_Graph_Vertex_Id;
+ Vertex : Library_Graph_Vertex_Id;
begin
pragma Assert (Present (Lib_Graph));
pragma Assert (Present (U_Id));
- LGV_Id := Corresponding_Vertex (Lib_Graph, U_Id);
- pragma Assert (Present (LGV_Id));
+ Vertex := Corresponding_Vertex (Lib_Graph, U_Id);
-- The unit denotes a body that completes a previous spec. Link the
-- spec and body. Add an edge between the predecessor spec and the
-- successor body.
- if Is_Body_With_Spec (Lib_Graph, LGV_Id) then
- Aux_LGV_Id :=
+ if Is_Body_With_Spec (Lib_Graph, Vertex) then
+ Extra_Vertex :=
Corresponding_Vertex (Lib_Graph, Corresponding_Spec (U_Id));
- pragma Assert (Present (Aux_LGV_Id));
-
- Set_Corresponding_Item (Lib_Graph, LGV_Id, Aux_LGV_Id);
+ Set_Corresponding_Item (Lib_Graph, Vertex, Extra_Vertex);
Add_Edge
(G => Lib_Graph,
- Pred => Aux_LGV_Id,
- Succ => LGV_Id,
+ Pred => Extra_Vertex,
+ Succ => Vertex,
Kind => Spec_Before_Body_Edge);
-- The unit denotes a spec with a completing body. Link the spec and
-- body.
- elsif Is_Spec_With_Body (Lib_Graph, LGV_Id) then
- Aux_LGV_Id :=
+ elsif Is_Spec_With_Body (Lib_Graph, Vertex) then
+ Extra_Vertex :=
Corresponding_Vertex (Lib_Graph, Corresponding_Body (U_Id));
- pragma Assert (Present (Aux_LGV_Id));
-
- Set_Corresponding_Item (Lib_Graph, LGV_Id, Aux_LGV_Id);
+ Set_Corresponding_Item (Lib_Graph, Vertex, Extra_Vertex);
end if;
end Create_Spec_And_Body_Edge;
@@ -531,11 +536,8 @@ package body Bindo.Builders is
Withed_U_Id : constant Unit_Id :=
Corresponding_Unit (Withed_Rec.Uname);
- pragma Assert (Present (Withed_U_Id));
-
- Aux_LGV_Id : Library_Graph_Vertex_Id;
Kind : Library_Graph_Edge_Kind;
- Withed_LGV_Id : Library_Graph_Vertex_Id;
+ Withed_Vertex : Library_Graph_Vertex_Id;
begin
-- Nothing to do when the withed unit does not need to be elaborated.
@@ -545,8 +547,7 @@ package body Bindo.Builders is
return;
end if;
- Withed_LGV_Id := Corresponding_Vertex (Lib_Graph, Withed_U_Id);
- pragma Assert (Present (Withed_LGV_Id));
+ Withed_Vertex := Corresponding_Vertex (Lib_Graph, Withed_U_Id);
-- The with comes with pragma Elaborate
@@ -557,15 +558,12 @@ package body Bindo.Builders is
-- between the body of the withed predecessor and the withing
-- successor.
- if Is_Spec_With_Body (Lib_Graph, Withed_LGV_Id) then
- Aux_LGV_Id :=
- Corresponding_Vertex
- (Lib_Graph, Corresponding_Body (Withed_U_Id));
- pragma Assert (Present (Aux_LGV_Id));
-
+ if Is_Spec_With_Body (Lib_Graph, Withed_Vertex) then
Add_Edge
(G => Lib_Graph,
- Pred => Aux_LGV_Id,
+ Pred =>
+ Corresponding_Vertex
+ (Lib_Graph, Corresponding_Body (Withed_U_Id)),
Succ => Succ,
Kind => Kind);
end if;
@@ -586,7 +584,7 @@ package body Bindo.Builders is
Add_Edge
(G => Lib_Graph,
- Pred => Withed_LGV_Id,
+ Pred => Withed_Vertex,
Succ => Succ,
Kind => Kind);
end Create_With_Edge;
@@ -596,18 +594,13 @@ package body Bindo.Builders is
-----------------------
procedure Create_With_Edges (U_Id : Unit_Id) is
- LGV_Id : Library_Graph_Vertex_Id;
-
begin
pragma Assert (Present (Lib_Graph));
pragma Assert (Present (U_Id));
- LGV_Id := Corresponding_Vertex (Lib_Graph, U_Id);
- pragma Assert (Present (LGV_Id));
-
Create_With_Edges
(U_Id => U_Id,
- Succ => LGV_Id);
+ Succ => Corresponding_Vertex (Lib_Graph, U_Id));
end Create_With_Edges;
-----------------------
@@ -655,7 +648,7 @@ package body Bindo.Builders is
pragma Assert (Present (Nam));
Prev_Line : constant Logical_Line_Number :=
- UL.Get (Unit_To_Line, U_Id);
+ Unit_Line_Tables.Get (Unit_To_Line, U_Id);
begin
Error_Msg_Nat_1 := Nat (Line);
@@ -698,7 +691,7 @@ package body Bindo.Builders is
begin
pragma Assert (Present (U_Id));
- return UL.Contains (Unit_To_Line, U_Id);
+ return Unit_Line_Tables.Contains (Unit_To_Line, U_Id);
end Is_Duplicate_Unit;
-------------------------