1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- P U T _ S P A R K _ X R E F S --
9 -- Copyright (C) 2011-2013, 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
);
39 Start
:= F
.From_Scope
;
42 Write_Info_Initiate
('F');
43 Write_Info_Char
('D');
44 Write_Info_Char
(' ');
45 Write_Info_Nat
(F
.File_Num
);
46 Write_Info_Char
(' ');
48 for N
in F
.File_Name
'Range loop
49 Write_Info_Char
(F
.File_Name
(N
));
52 -- If file is a subunit, print the file name for the unit
54 if F
.Unit_File_Name
/= null then
55 Write_Info_Char
(' ');
56 Write_Info_Char
('-');
57 Write_Info_Char
('>');
58 Write_Info_Char
(' ');
60 for N
in F
.Unit_File_Name
'Range loop
61 Write_Info_Char
(F
.Unit_File_Name
(N
));
67 -- Loop through scope entries for this file
70 exit when Start
= Stop
+ 1;
71 pragma Assert
(Start
<= Stop
);
74 S
: SPARK_Scope_Record
renames SPARK_Scope_Table
.Table
(Start
);
77 Write_Info_Initiate
('F');
78 Write_Info_Char
('S');
79 Write_Info_Char
(' ');
80 Write_Info_Char
('.');
81 Write_Info_Nat
(S
.Scope_Num
);
82 Write_Info_Char
(' ');
83 Write_Info_Nat
(S
.Line
);
84 Write_Info_Char
(S
.Stype
);
85 Write_Info_Nat
(S
.Col
);
86 Write_Info_Char
(' ');
88 pragma Assert
(S
.Scope_Name
.all /= "");
90 for N
in S
.Scope_Name
'Range loop
91 Write_Info_Char
(S
.Scope_Name
(N
));
94 if S
.Spec_File_Num
/= 0 then
95 Write_Info_Char
(' ');
96 Write_Info_Char
('-');
97 Write_Info_Char
('>');
98 Write_Info_Char
(' ');
99 Write_Info_Nat
(S
.Spec_File_Num
);
100 Write_Info_Char
('.');
101 Write_Info_Nat
(S
.Spec_Scope_Num
);
104 Write_Info_Terminate
;
112 -- Loop through entries in SPARK_File_Table
114 for J
in 1 .. SPARK_File_Table
.Last
loop
116 F
: SPARK_File_Record
renames SPARK_File_Table
.Table
(J
);
125 Start
:= F
.From_Scope
;
128 -- Loop through scope entries for this file
131 exit when Start
= Stop
+ 1;
132 pragma Assert
(Start
<= Stop
);
134 Output_One_Scope
: declare
135 S
: SPARK_Scope_Record
renames SPARK_Scope_Table
.Table
(Start
);
141 XStart
:= S
.From_Xref
;
144 if XStart
> XStop
then
148 Write_Info_Initiate
('F');
149 Write_Info_Char
('X');
150 Write_Info_Char
(' ');
151 Write_Info_Nat
(F
.File_Num
);
152 Write_Info_Char
(' ');
154 for N
in F
.File_Name
'Range loop
155 Write_Info_Char
(F
.File_Name
(N
));
158 Write_Info_Char
(' ');
159 Write_Info_Char
('.');
160 Write_Info_Nat
(S
.Scope_Num
);
161 Write_Info_Char
(' ');
163 for N
in S
.Scope_Name
'Range loop
164 Write_Info_Char
(S
.Scope_Name
(N
));
167 -- Default value of (0,0) is used for the special __HEAP
168 -- variable so use another default value.
173 -- Loop through cross reference entries for this scope
176 exit when XStart
= XStop
+ 1;
177 pragma Assert
(XStart
<= XStop
);
179 Output_One_Xref
: declare
180 R
: SPARK_Xref_Record
renames
181 SPARK_Xref_Table
.Table
(XStart
);
184 if R
.Entity_Line
/= Entity_Line
185 or else R
.Entity_Col
/= Entity_Col
187 Write_Info_Terminate
;
189 Write_Info_Initiate
('F');
190 Write_Info_Char
(' ');
191 Write_Info_Nat
(R
.Entity_Line
);
192 Write_Info_Char
(R
.Etype
);
193 Write_Info_Nat
(R
.Entity_Col
);
194 Write_Info_Char
(' ');
196 for N
in R
.Entity_Name
'Range loop
197 Write_Info_Char
(R
.Entity_Name
(N
));
200 Entity_Line
:= R
.Entity_Line
;
201 Entity_Col
:= R
.Entity_Col
;
203 Scope
:= S
.Scope_Num
;
206 if Write_Info_Col
> 72 then
207 Write_Info_Terminate
;
208 Write_Info_Initiate
('.');
211 Write_Info_Char
(' ');
213 if R
.File_Num
/= File
then
214 Write_Info_Nat
(R
.File_Num
);
215 Write_Info_Char
('|');
220 if R
.Scope_Num
/= Scope
then
221 Write_Info_Char
('.');
222 Write_Info_Nat
(R
.Scope_Num
);
223 Write_Info_Char
(':');
224 Scope
:= R
.Scope_Num
;
227 Write_Info_Nat
(R
.Line
);
228 Write_Info_Char
(R
.Rtype
);
229 Write_Info_Nat
(R
.Col
);
232 XStart
:= XStart
+ 1;
235 Write_Info_Terminate
;
236 end Output_One_Scope
;