1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2011, 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 Atree; use Atree;
27 with Output; use Output;
29 with Sinfo; use Sinfo;
39 -- Dump ALFA file table
41 Write_Line ("ALFA File Table");
42 Write_Line ("---------------");
44 for Index in 1 .. ALFA_File_Table.Last loop
46 AFR : ALFA_File_Record renames ALFA_File_Table.Table (Index);
50 Write_Int (Int (Index));
51 Write_Str (". File_Num = ");
52 Write_Int (Int (AFR.File_Num));
53 Write_Str (" File_Name = """);
55 if AFR.File_Name /= null then
56 Write_Str (AFR.File_Name.all);
60 Write_Str (" From = ");
61 Write_Int (Int (AFR.From_Scope));
63 Write_Int (Int (AFR.To_Scope));
68 -- Dump ALFA scope table
71 Write_Line ("ALFA Scope Table");
72 Write_Line ("----------------");
74 for Index in 1 .. ALFA_Scope_Table.Last loop
76 ASR : ALFA_Scope_Record renames ALFA_Scope_Table.Table (Index);
80 Write_Int (Int (Index));
81 Write_Str (". File_Num = ");
82 Write_Int (Int (ASR.File_Num));
83 Write_Str (" Scope_Num = ");
84 Write_Int (Int (ASR.Scope_Num));
85 Write_Str (" Scope_Name = """);
87 if ASR.Scope_Name /= null then
88 Write_Str (ASR.Scope_Name.all);
92 Write_Str (" Line = ");
93 Write_Int (Int (ASR.Line));
94 Write_Str (" Col = ");
95 Write_Int (Int (ASR.Col));
96 Write_Str (" Type = ");
97 Write_Char (ASR.Stype);
98 Write_Str (" From = ");
99 Write_Int (Int (ASR.From_Xref));
100 Write_Str (" To = ");
101 Write_Int (Int (ASR.To_Xref));
102 Write_Str (" Scope_Entity = ");
103 Write_Int (Int (ASR.Scope_Entity));
108 -- Dump ALFA cross-reference table
111 Write_Line ("ALFA Xref Table");
112 Write_Line ("---------------");
114 for Index in 1 .. ALFA_Xref_Table.Last loop
116 AXR : ALFA_Xref_Record renames ALFA_Xref_Table.Table (Index);
120 Write_Int (Int (Index));
121 Write_Str (". Entity_Name = """);
123 if AXR.Entity_Name /= null then
124 Write_Str (AXR.Entity_Name.all);
128 Write_Str (" Entity_Line = ");
129 Write_Int (Int (AXR.Entity_Line));
130 Write_Str (" Entity_Col = ");
131 Write_Int (Int (AXR.Entity_Col));
132 Write_Str (" File_Num = ");
133 Write_Int (Int (AXR.File_Num));
134 Write_Str (" Scope_Num = ");
135 Write_Int (Int (AXR.Scope_Num));
136 Write_Str (" Line = ");
137 Write_Int (Int (AXR.Line));
138 Write_Str (" Col = ");
139 Write_Int (Int (AXR.Col));
140 Write_Str (" Type = ");
141 Write_Char (AXR.Rtype);
147 -------------------------
148 -- Get_Entity_For_Decl --
149 -------------------------
151 function Get_Entity_For_Decl (N : Node_Id) return Entity_Id is
152 E : Entity_Id := Empty;
156 when N_Subprogram_Declaration |
158 N_Package_Declaration =>
159 E := Defining_Unit_Name (Specification (N));
161 when N_Package_Body =>
162 E := Defining_Unit_Name (N);
164 when N_Object_Declaration =>
165 E := Defining_Identifier (N);
171 if Nkind (E) = N_Defining_Program_Unit_Name then
172 E := Defining_Identifier (E);
176 end Get_Entity_For_Decl;
178 --------------------------------
179 -- Get_Unique_Entity_For_Decl --
180 --------------------------------
182 function Get_Unique_Entity_For_Decl (N : Node_Id) return Entity_Id is
183 E : Entity_Id := Empty;
187 when N_Subprogram_Declaration |
188 N_Package_Declaration =>
189 E := Defining_Unit_Name (Specification (N));
191 when N_Package_Body =>
192 E := Corresponding_Spec (N);
194 when N_Subprogram_Body =>
195 if Acts_As_Spec (N) then
196 E := Defining_Unit_Name (Specification (N));
198 E := Corresponding_Spec (N);
201 when N_Object_Declaration =>
202 E := Defining_Identifier (N);
208 if Nkind (E) = N_Defining_Program_Unit_Name then
209 E := Defining_Identifier (E);
213 end Get_Unique_Entity_For_Decl;
219 procedure Initialize_ALFA_Tables is
221 ALFA_File_Table.Init;
222 ALFA_Scope_Table.Init;
223 ALFA_Xref_Table.Init;
224 end Initialize_ALFA_Tables;
232 procedure Write_Info_Char (C : Character) renames Write_Char;
233 -- Write one character;
235 function Write_Info_Col return Positive;
236 -- Return next column for writing
238 procedure Write_Info_Initiate (Key : Character) renames Write_Char;
239 -- Start new one and write one character;
241 procedure Write_Info_Nat (N : Nat);
244 procedure Write_Info_Terminate renames Write_Eol;
245 -- Terminate current line
251 function Write_Info_Col return Positive is
253 return Positive (Column);
260 procedure Write_Info_Nat (N : Nat) is
265 procedure Debug_Put_ALFA is new Put_ALFA;
267 -- Start of processing for palfa