1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258 | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A S I S . D A T A _ D E C O M P O S I T I O N . D E B U G --
-- --
-- B o d y --
-- --
-- Copyright (c) 1995-2006, Free Software Foundation, Inc. --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adaccore.com). --
-- --
------------------------------------------------------------------------------
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Asis.Elements; use Asis.Elements;
with Asis.Declarations; use Asis.Declarations;
with A4G.A_Output; use A4G.A_Output;
with A4G.A_Types;
with Asis.Data_Decomposition.Aux;
with Asis.Data_Decomposition.Set_Get;
package body Asis.Data_Decomposition.Debug is
LT : String renames A4G.A_Types.ASIS_Line_Terminator;
-----------------------
-- Local subprograms --
-----------------------
procedure Rec_Comp_Debug_String (RC : Record_Component);
procedure Arr_Comp_Debug_String (AC : Array_Component);
-- Form the Content of the Debug_Buffer
---------------------------
-- Arr_Comp_Debug_String --
---------------------------
procedure Arr_Comp_Debug_String (AC : Array_Component) is
Parent_Type_Image : String_Ptr;
begin
Debug_Buffer_Len := 0;
if Is_Nil (AC) then
Add ("This is a Nil Record Component");
return;
end if;
Parent_Type_Image :=
new String'(To_String (Debug_Image (AC.Parent_Array_Type)));
Debug_Buffer_Len := 0;
Add (LT);
Add ("Parent_Array_Type");
Add (LT);
Add (Parent_Type_Image.all);
Free (Parent_Type_Image);
Add (LT);
Add (LT);
Add ("Parent_Component_Name: ");
if Is_Nil (AC.Parent_Component_Name) then
Add ("Is Nil");
else
Add (To_String (Defining_Name_Image (AC.Parent_Component_Name)));
end if;
Add (LT);
if AC.Is_Record_Comp then
Add (">>> IS RECORD");
Add (LT);
elsif AC.Is_Array_Comp then
Add (">>> IS ARRAY");
Add (LT);
end if;
Add ("Position :");
Add (ASIS_Natural'Image (AC.Position));
Add (LT);
Add ("First_Bit :");
Add (ASIS_Natural'Image (AC.First_Bit));
Add (LT);
Add ("Last_Bit :");
Add (ASIS_Natural'Image (AC.Last_Bit));
Add (LT);
Add ("Size :");
Add (ASIS_Natural'Image (AC.Size));
Add (LT);
Add ("Dimension :");
Add (ASIS_Natural'Image (AC.Dimension));
Add (LT);
for I in 1 .. AC.Dimension loop
Add (" Length (");
Add (ASIS_Natural'Image (I));
Add ("):");
Add (ASIS_Natural'Image (AC.Length (I)));
Add (LT);
end loop;
end Arr_Comp_Debug_String;
-----------------
-- Debug_Image --
-----------------
function Debug_Image (RC : Record_Component) return Wide_String is
begin
Rec_Comp_Debug_String (RC);
return To_Wide_String (
LT & "Record Component Debug_Image: " & LT &
Debug_Buffer (1 .. Debug_Buffer_Len));
end Debug_Image;
-----------------
-- Debug_Image --
-----------------
function Debug_Image (AC : Array_Component) return Wide_String is
begin
Arr_Comp_Debug_String (AC);
return To_Wide_String (
LT & "Array Component Debug_Image: " & LT &
Debug_Buffer (1 .. Debug_Buffer_Len));
end Debug_Image;
---------------------------
-- Rec_Comp_Debug_String --
---------------------------
procedure Rec_Comp_Debug_String (RC : Record_Component) is
Parent_Type_Image : String_Ptr;
begin
Debug_Buffer_Len := 0;
if Is_Nil (RC) then
Add ("This is a Nil Record Component");
return;
end if;
Parent_Type_Image :=
new String'(To_String (Debug_Image (RC.Parent_Record_Type)));
Debug_Buffer_Len := 0;
Add (LT);
Add ("Parent_Record_Type");
Add (LT);
Add (Parent_Type_Image.all);
Free (Parent_Type_Image);
Add (LT);
Add (LT);
Add ("Component_Name: ");
Add (To_String (Defining_Name_Image (RC.Component_Name)));
Add (LT);
if RC.Is_Record_Comp then
Add (">>> IS RECORD");
Add (LT);
elsif RC.Is_Array_Comp then
Add (">>> IS ARRAY");
Add (LT);
end if;
Add ("Position :");
Add (ASIS_Natural'Image (RC.Position));
Add (LT);
Add ("First_Bit :");
Add (ASIS_Natural'Image (RC.First_Bit));
Add (LT);
Add ("Last_Bit :");
Add (ASIS_Natural'Image (RC.Last_Bit));
Add (LT);
Add ("Size :");
Add (ASIS_Natural'Image (RC.Size));
Add (LT);
end Rec_Comp_Debug_String;
---------------------------
-- Is_Derived_From_Array --
----------------------------
function Is_Derived_From_Array (TD : Element) return Boolean renames
Asis.Data_Decomposition.Aux.Is_Derived_From_Array;
----------------------------
-- Is_Derived_From_Record --
-----------------------------
function Is_Derived_From_Record (TD : Element) return Boolean renames
Asis.Data_Decomposition.Aux.Is_Derived_From_Record;
function Dimension (Comp : Array_Component) return ASIS_Natural renames
Asis.Data_Decomposition.Set_Get.Dimension;
-- function Linear_Index
-- (Inds : Dimension_Indexes;
-- D : ASIS_Natural;
-- Ind_Lengths : Dimention_Length;
-- Conv : Convention_Id := Convention_Ada)
-- return Asis.ASIS_Natural
-- renames Asis.Data_Decomposition.Aux.Linear_Index;
-- function De_Linear_Index
-- (Index : Asis.ASIS_Natural;
-- D : ASIS_Natural;
-- Ind_Lengths : Dimention_Length;
-- Conv : Convention_Id := Convention_Ada)
-- return Dimension_Indexes
-- renames Asis.Data_Decomposition.Aux.De_Linear_Index;
end Asis.Data_Decomposition.Debug;
|