1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- P U T _ S P A R K _ X R E F S --
9 -- Copyright (C) 2011-2016, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with SPARK_Xrefs
; use SPARK_Xrefs
;
28 procedure Put_SPARK_Xrefs
is
30 -- Loop through entries in SPARK_File_Table
32 for J
in 1 .. SPARK_File_Table
.Last
loop
34 F
: SPARK_File_Record
renames SPARK_File_Table
.Table
(J
);
37 Write_Info_Initiate
('F');
38 Write_Info_Char
('D');
39 Write_Info_Char
(' ');
40 Write_Info_Nat
(F
.File_Num
);
41 Write_Info_Char
(' ');
43 Write_Info_Str
(F
.File_Name
.all);
45 -- If file is a subunit, print the file name for the unit
47 if F
.Unit_File_Name
/= null then
48 Write_Info_Str
(" -> " & F
.Unit_File_Name
.all);
53 -- Loop through scope entries for this file
55 for J
in F
.From_Scope
.. F
.To_Scope
loop
57 S
: SPARK_Scope_Record
renames SPARK_Scope_Table
.Table
(J
);
60 Write_Info_Initiate
('F');
61 Write_Info_Char
('S');
62 Write_Info_Char
(' ');
63 Write_Info_Char
('.');
64 Write_Info_Nat
(S
.Scope_Num
);
65 Write_Info_Char
(' ');
66 Write_Info_Nat
(S
.Line
);
67 Write_Info_Char
(S
.Stype
);
68 Write_Info_Nat
(S
.Col
);
69 Write_Info_Char
(' ');
71 pragma Assert
(S
.Scope_Name
.all /= "");
73 Write_Info_Str
(S
.Scope_Name
.all);
75 if S
.Spec_File_Num
/= 0 then
76 Write_Info_Str
(" -> ");
77 Write_Info_Nat
(S
.Spec_File_Num
);
78 Write_Info_Char
('.');
79 Write_Info_Nat
(S
.Spec_Scope_Num
);
88 -- Loop through entries in SPARK_File_Table
90 for J
in 1 .. SPARK_File_Table
.Last
loop
92 F
: SPARK_File_Record
renames SPARK_File_Table
.Table
(J
);
99 -- Loop through scope entries for this file
101 for K
in F
.From_Scope
.. F
.To_Scope
loop
102 Output_One_Scope
: declare
103 S
: SPARK_Scope_Record
renames SPARK_Scope_Table
.Table
(K
);
106 -- Write only non-empty tables
108 if S
.From_Xref
<= S
.To_Xref
then
110 Write_Info_Initiate
('F');
111 Write_Info_Char
('X');
112 Write_Info_Char
(' ');
113 Write_Info_Nat
(F
.File_Num
);
114 Write_Info_Char
(' ');
116 Write_Info_Str
(F
.File_Name
.all);
118 Write_Info_Char
(' ');
119 Write_Info_Char
('.');
120 Write_Info_Nat
(S
.Scope_Num
);
121 Write_Info_Char
(' ');
123 Write_Info_Str
(S
.Scope_Name
.all);
125 -- Default value of (0,0) is used for the special __HEAP
126 -- variable so use another default value.
131 -- Loop through cross reference entries for this scope
133 for X
in S
.From_Xref
.. S
.To_Xref
loop
135 Output_One_Xref
: declare
136 R
: SPARK_Xref_Record
renames
137 SPARK_Xref_Table
.Table
(X
);
140 if R
.Entity_Line
/= Entity_Line
141 or else R
.Entity_Col
/= Entity_Col
143 Write_Info_Terminate
;
145 Write_Info_Initiate
('F');
146 Write_Info_Char
(' ');
147 Write_Info_Nat
(R
.Entity_Line
);
148 Write_Info_Char
(R
.Etype
);
149 Write_Info_Nat
(R
.Entity_Col
);
150 Write_Info_Char
(' ');
152 Write_Info_Str
(R
.Entity_Name
.all);
154 Entity_Line
:= R
.Entity_Line
;
155 Entity_Col
:= R
.Entity_Col
;
157 Scope
:= S
.Scope_Num
;
160 if Write_Info_Col
> 72 then
161 Write_Info_Terminate
;
162 Write_Info_Initiate
('.');
165 Write_Info_Char
(' ');
167 if R
.File_Num
/= File
then
168 Write_Info_Nat
(R
.File_Num
);
169 Write_Info_Char
('|');
174 if R
.Scope_Num
/= Scope
then
175 Write_Info_Char
('.');
176 Write_Info_Nat
(R
.Scope_Num
);
177 Write_Info_Char
(':');
178 Scope
:= R
.Scope_Num
;
181 Write_Info_Nat
(R
.Line
);
182 Write_Info_Char
(R
.Rtype
);
183 Write_Info_Nat
(R
.Col
);
188 Write_Info_Terminate
;
190 end Output_One_Scope
;