1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2007, 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 with Gnatvsn
; use Gnatvsn
;
35 with System
; use System
;
36 with Tree_IO
; use Tree_IO
;
40 SU
: constant := Storage_Unit
;
41 -- Shorthand for System.Storage_Unit
43 ----------------------------------
44 -- Register_Opt_Config_Switches --
45 ----------------------------------
47 procedure Register_Opt_Config_Switches
is
49 Ada_Version_Config
:= Ada_Version
;
50 Ada_Version_Explicit_Config
:= Ada_Version_Explicit
;
51 Assertions_Enabled_Config
:= Assertions_Enabled
;
52 Debug_Pragmas_Enabled_Config
:= Debug_Pragmas_Enabled
;
53 Dynamic_Elaboration_Checks_Config
:= Dynamic_Elaboration_Checks
;
54 Exception_Locations_Suppressed_Config
:= Exception_Locations_Suppressed
;
55 Extensions_Allowed_Config
:= Extensions_Allowed
;
56 External_Name_Exp_Casing_Config
:= External_Name_Exp_Casing
;
57 External_Name_Imp_Casing_Config
:= External_Name_Imp_Casing
;
58 Persistent_BSS_Mode_Config
:= Persistent_BSS_Mode
;
59 Polling_Required_Config
:= Polling_Required
;
60 Use_VADS_Size_Config
:= Use_VADS_Size
;
61 end Register_Opt_Config_Switches
;
63 ---------------------------------
64 -- Restore_Opt_Config_Switches --
65 ---------------------------------
67 procedure Restore_Opt_Config_Switches
(Save
: Config_Switches_Type
) is
69 Ada_Version
:= Save
.Ada_Version
;
70 Ada_Version_Explicit
:= Save
.Ada_Version_Explicit
;
71 Assertions_Enabled
:= Save
.Assertions_Enabled
;
72 Debug_Pragmas_Enabled
:= Save
.Debug_Pragmas_Enabled
;
73 Dynamic_Elaboration_Checks
:= Save
.Dynamic_Elaboration_Checks
;
74 Exception_Locations_Suppressed
:= Save
.Exception_Locations_Suppressed
;
75 Extensions_Allowed
:= Save
.Extensions_Allowed
;
76 External_Name_Exp_Casing
:= Save
.External_Name_Exp_Casing
;
77 External_Name_Imp_Casing
:= Save
.External_Name_Imp_Casing
;
78 Persistent_BSS_Mode
:= Save
.Persistent_BSS_Mode
;
79 Polling_Required
:= Save
.Polling_Required
;
80 Use_VADS_Size
:= Save
.Use_VADS_Size
;
81 end Restore_Opt_Config_Switches
;
83 ------------------------------
84 -- Save_Opt_Config_Switches --
85 ------------------------------
87 procedure Save_Opt_Config_Switches
(Save
: out Config_Switches_Type
) is
89 Save
.Ada_Version
:= Ada_Version
;
90 Save
.Ada_Version_Explicit
:= Ada_Version_Explicit
;
91 Save
.Assertions_Enabled
:= Assertions_Enabled
;
92 Save
.Debug_Pragmas_Enabled
:= Debug_Pragmas_Enabled
;
93 Save
.Dynamic_Elaboration_Checks
:= Dynamic_Elaboration_Checks
;
94 Save
.Exception_Locations_Suppressed
:= Exception_Locations_Suppressed
;
95 Save
.Extensions_Allowed
:= Extensions_Allowed
;
96 Save
.External_Name_Exp_Casing
:= External_Name_Exp_Casing
;
97 Save
.External_Name_Imp_Casing
:= External_Name_Imp_Casing
;
98 Save
.Persistent_BSS_Mode
:= Persistent_BSS_Mode
;
99 Save
.Polling_Required
:= Polling_Required
;
100 Save
.Use_VADS_Size
:= Use_VADS_Size
;
101 end Save_Opt_Config_Switches
;
103 -----------------------------
104 -- Set_Opt_Config_Switches --
105 -----------------------------
107 procedure Set_Opt_Config_Switches
108 (Internal_Unit
: Boolean;
112 -- Case of internal unit
114 if Internal_Unit
then
116 -- Set standard switches. Note we do NOT set Ada_Version_Explicit
117 -- since the whole point of this is that it still properly indicates
118 -- the configuration setting even in a run time unit.
120 Ada_Version
:= Ada_Version_Runtime
;
121 Dynamic_Elaboration_Checks
:= False;
122 Extensions_Allowed
:= True;
123 External_Name_Exp_Casing
:= As_Is
;
124 External_Name_Imp_Casing
:= Lowercase
;
125 Persistent_BSS_Mode
:= False;
126 Use_VADS_Size
:= False;
128 -- For an internal unit, assertions/debug pragmas are off unless this
129 -- is the main unit and they were explicitly enabled.
132 Assertions_Enabled
:= Assertions_Enabled_Config
;
133 Debug_Pragmas_Enabled
:= Debug_Pragmas_Enabled_Config
;
135 Assertions_Enabled
:= False;
136 Debug_Pragmas_Enabled
:= False;
139 -- Case of non-internal unit
142 Ada_Version
:= Ada_Version_Config
;
143 Ada_Version_Explicit
:= Ada_Version_Explicit_Config
;
144 Assertions_Enabled
:= Assertions_Enabled_Config
;
145 Debug_Pragmas_Enabled
:= Debug_Pragmas_Enabled_Config
;
146 Dynamic_Elaboration_Checks
:= Dynamic_Elaboration_Checks_Config
;
147 Extensions_Allowed
:= Extensions_Allowed_Config
;
148 External_Name_Exp_Casing
:= External_Name_Exp_Casing_Config
;
149 External_Name_Imp_Casing
:= External_Name_Imp_Casing_Config
;
150 Persistent_BSS_Mode
:= Persistent_BSS_Mode_Config
;
151 Use_VADS_Size
:= Use_VADS_Size_Config
;
154 Exception_Locations_Suppressed
:= Exception_Locations_Suppressed_Config
;
155 Polling_Required
:= Polling_Required_Config
;
156 end Set_Opt_Config_Switches
;
162 procedure Tree_Read
is
163 Tree_Version_String_Len
: Nat
;
164 Ada_Version_Config_Val
: Nat
;
165 Ada_Version_Explicit_Config_Val
: Nat
;
166 Assertions_Enabled_Config_Val
: Nat
;
169 Tree_Read_Int
(Tree_ASIS_Version_Number
);
170 Tree_Read_Bool
(Brief_Output
);
171 Tree_Read_Bool
(GNAT_Mode
);
172 Tree_Read_Char
(Identifier_Character_Set
);
173 Tree_Read_Int
(Maximum_File_Name_Length
);
174 Tree_Read_Data
(Suppress_Options
'Address,
175 (Suppress_Options
'Size + SU
- 1) / SU
);
176 Tree_Read_Bool
(Verbose_Mode
);
177 Tree_Read_Data
(Warning_Mode
'Address,
178 (Warning_Mode
'Size + SU
- 1) / SU
);
179 Tree_Read_Int
(Ada_Version_Config_Val
);
180 Tree_Read_Int
(Ada_Version_Explicit_Config_Val
);
181 Tree_Read_Int
(Assertions_Enabled_Config_Val
);
182 Tree_Read_Bool
(All_Errors_Mode
);
183 Tree_Read_Bool
(Assertions_Enabled
);
184 Tree_Read_Bool
(Debug_Pragmas_Enabled
);
185 Tree_Read_Bool
(Enable_Overflow_Checks
);
186 Tree_Read_Bool
(Full_List
);
188 Ada_Version_Config
:=
189 Ada_Version_Type
'Val (Ada_Version_Config_Val
);
190 Ada_Version_Explicit_Config
:=
191 Ada_Version_Type
'Val (Ada_Version_Explicit_Config_Val
);
192 Assertions_Enabled_Config
:=
193 Boolean'Val (Assertions_Enabled_Config_Val
);
195 -- Read version string: we have to get the length first
197 Tree_Read_Int
(Tree_Version_String_Len
);
200 Tmp
: String (1 .. Integer (Tree_Version_String_Len
));
203 (Tmp
'Address, Tree_Version_String_Len
);
204 System
.Strings
.Free
(Tree_Version_String
);
205 Free
(Tree_Version_String
);
206 Tree_Version_String
:= new String'(Tmp);
209 Tree_Read_Data (Distribution_Stub_Mode'Address,
210 (Distribution_Stub_Mode'Size + SU - 1) / Storage_Unit);
211 Tree_Read_Bool (Inline_Active);
212 Tree_Read_Bool (Inline_Processing_Required);
213 Tree_Read_Bool (List_Units);
214 Tree_Read_Bool (Configurable_Run_Time_Mode);
215 Tree_Read_Data (Operating_Mode'Address,
216 (Operating_Mode'Size + SU - 1) / Storage_Unit);
217 Tree_Read_Bool (Suppress_Checks);
218 Tree_Read_Bool (Try_Semantics);
219 Tree_Read_Data (Wide_Character_Encoding_Method'Address,
220 (Wide_Character_Encoding_Method'Size + SU - 1) / SU);
221 Tree_Read_Bool (Upper_Half_Encoding);
222 Tree_Read_Bool (Force_ALI_Tree_File);
229 procedure Tree_Write is
230 Version_String : String := Gnat_Version_String;
233 Tree_Write_Int (ASIS_Version_Number);
234 Tree_Write_Bool (Brief_Output);
235 Tree_Write_Bool (GNAT_Mode);
236 Tree_Write_Char (Identifier_Character_Set);
237 Tree_Write_Int (Maximum_File_Name_Length);
238 Tree_Write_Data (Suppress_Options'Address,
239 (Suppress_Options'Size + SU - 1) / SU);
240 Tree_Write_Bool (Verbose_Mode);
241 Tree_Write_Data (Warning_Mode'Address,
242 (Warning_Mode'Size + SU - 1) / Storage_Unit);
243 Tree_Write_Int (Ada_Version_Type'Pos (Ada_Version_Config));
244 Tree_Write_Int (Ada_Version_Type'Pos (Ada_Version_Explicit_Config));
245 Tree_Write_Int (Boolean'Pos (Assertions_Enabled_Config));
246 Tree_Write_Bool (All_Errors_Mode);
247 Tree_Write_Bool (Assertions_Enabled);
248 Tree_Write_Bool (Debug_Pragmas_Enabled);
249 Tree_Write_Bool (Enable_Overflow_Checks);
250 Tree_Write_Bool (Full_List);
251 Tree_Write_Int (Int (Version_String'Length));
252 Tree_Write_Data (Version_String'Address, Version_String'Length);
253 Tree_Write_Data (Distribution_Stub_Mode'Address,
254 (Distribution_Stub_Mode'Size + SU - 1) / SU);
255 Tree_Write_Bool (Inline_Active);
256 Tree_Write_Bool (Inline_Processing_Required);
257 Tree_Write_Bool (List_Units);
258 Tree_Write_Bool (Configurable_Run_Time_Mode);
259 Tree_Write_Data (Operating_Mode'Address,
260 (Operating_Mode'Size + SU - 1) / SU);
261 Tree_Write_Bool (Suppress_Checks);
262 Tree_Write_Bool (Try_Semantics);
263 Tree_Write_Data (Wide_Character_Encoding_Method'Address,
264 (Wide_Character_Encoding_Method'Size + SU - 1) / SU);
265 Tree_Write_Bool (Upper_Half_Encoding);
266 Tree_Write_Bool (Force_ALI_Tree_File);