1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2005, 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 Immediate_Errors
: Boolean := True;
41 -- This is an obsolete flag that is no longer present in opt.ads. We
42 -- retain it here because this flag was written to the tree and there
43 -- is no point in making trees incomaptible just for the sake of saving
44 -- one byte of data. The value written is ignored.
46 ----------------------------------
47 -- Register_Opt_Config_Switches --
48 ----------------------------------
50 procedure Register_Opt_Config_Switches
is
52 Ada_Version_Config
:= Ada_Version
;
53 Ada_Version_Explicit_Config
:= Ada_Version_Explicit
;
54 Assertions_Enabled_Config
:= Assertions_Enabled
;
55 Dynamic_Elaboration_Checks_Config
:= Dynamic_Elaboration_Checks
;
56 Exception_Locations_Suppressed_Config
:= Exception_Locations_Suppressed
;
57 Extensions_Allowed_Config
:= Extensions_Allowed
;
58 External_Name_Exp_Casing_Config
:= External_Name_Exp_Casing
;
59 External_Name_Imp_Casing_Config
:= External_Name_Imp_Casing
;
60 Persistent_BSS_Mode_Config
:= Persistent_BSS_Mode
;
61 Polling_Required_Config
:= Polling_Required
;
62 Use_VADS_Size_Config
:= Use_VADS_Size
;
63 end Register_Opt_Config_Switches
;
65 ---------------------------------
66 -- Restore_Opt_Config_Switches --
67 ---------------------------------
69 procedure Restore_Opt_Config_Switches
(Save
: Config_Switches_Type
) is
71 Ada_Version
:= Save
.Ada_Version
;
72 Ada_Version_Explicit
:= Save
.Ada_Version_Explicit
;
73 Assertions_Enabled
:= Save
.Assertions_Enabled
;
74 Dynamic_Elaboration_Checks
:= Save
.Dynamic_Elaboration_Checks
;
75 Exception_Locations_Suppressed
:= Save
.Exception_Locations_Suppressed
;
76 Extensions_Allowed
:= Save
.Extensions_Allowed
;
77 External_Name_Exp_Casing
:= Save
.External_Name_Exp_Casing
;
78 External_Name_Imp_Casing
:= Save
.External_Name_Imp_Casing
;
79 Persistent_BSS_Mode
:= Save
.Persistent_BSS_Mode
;
80 Polling_Required
:= Save
.Polling_Required
;
81 Use_VADS_Size
:= Save
.Use_VADS_Size
;
82 end Restore_Opt_Config_Switches
;
84 ------------------------------
85 -- Save_Opt_Config_Switches --
86 ------------------------------
88 procedure Save_Opt_Config_Switches
(Save
: out Config_Switches_Type
) is
90 Save
.Ada_Version
:= Ada_Version
;
91 Save
.Ada_Version_Explicit
:= Ada_Version_Explicit
;
92 Save
.Assertions_Enabled
:= Assertions_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
(Internal_Unit
: Boolean) is
109 if Internal_Unit
then
110 Ada_Version
:= Ada_Version_Runtime
;
111 Assertions_Enabled
:= False;
112 Dynamic_Elaboration_Checks
:= False;
113 Extensions_Allowed
:= True;
114 External_Name_Exp_Casing
:= As_Is
;
115 External_Name_Imp_Casing
:= Lowercase
;
116 Persistent_BSS_Mode
:= False;
117 Use_VADS_Size
:= False;
120 Ada_Version
:= Ada_Version_Config
;
121 Assertions_Enabled
:= Assertions_Enabled_Config
;
122 Dynamic_Elaboration_Checks
:= Dynamic_Elaboration_Checks_Config
;
123 Extensions_Allowed
:= Extensions_Allowed_Config
;
124 External_Name_Exp_Casing
:= External_Name_Exp_Casing_Config
;
125 External_Name_Imp_Casing
:= External_Name_Imp_Casing_Config
;
126 Persistent_BSS_Mode
:= Persistent_BSS_Mode_Config
;
127 Use_VADS_Size
:= Use_VADS_Size_Config
;
130 Exception_Locations_Suppressed
:= Exception_Locations_Suppressed_Config
;
131 Polling_Required
:= Polling_Required_Config
;
132 Ada_Version_Explicit
:= Ada_Version_Explicit_Config
;
133 end Set_Opt_Config_Switches
;
139 procedure Tree_Read
is
140 Tree_Version_String_Len
: Nat
;
141 Ada_Version_Config_Val
: Nat
;
142 Ada_Version_Explicit_Config_Val
: Nat
;
143 Assertions_Enabled_Config_Val
: Nat
;
146 Tree_Read_Int
(Tree_ASIS_Version_Number
);
147 Tree_Read_Bool
(Brief_Output
);
148 Tree_Read_Bool
(GNAT_Mode
);
149 Tree_Read_Char
(Identifier_Character_Set
);
150 Tree_Read_Int
(Maximum_File_Name_Length
);
151 Tree_Read_Data
(Suppress_Options
'Address,
152 Suppress_Array
'Object_Size / Storage_Unit
);
153 Tree_Read_Bool
(Verbose_Mode
);
154 Tree_Read_Data
(Warning_Mode
'Address,
155 Warning_Mode_Type
'Object_Size / Storage_Unit
);
156 Tree_Read_Int
(Ada_Version_Config_Val
);
157 Tree_Read_Int
(Ada_Version_Explicit_Config_Val
);
158 Tree_Read_Int
(Assertions_Enabled_Config_Val
);
159 Tree_Read_Bool
(All_Errors_Mode
);
160 Tree_Read_Bool
(Assertions_Enabled
);
161 Tree_Read_Bool
(Enable_Overflow_Checks
);
162 Tree_Read_Bool
(Full_List
);
164 Ada_Version_Config
:=
165 Ada_Version_Type
'Val (Ada_Version_Config_Val
);
166 Ada_Version_Explicit_Config
:=
167 Ada_Version_Type
'Val (Ada_Version_Explicit_Config_Val
);
168 Assertions_Enabled_Config
:=
169 Boolean'Val (Assertions_Enabled_Config_Val
);
171 -- Read version string: we have to check the length first
173 Tree_Read_Int
(Tree_Version_String_Len
);
175 if Tree_Version_String_Len
= Tree_Version_String
'Length then
177 (Tree_Version_String
'Address, Tree_Version_String_Len
);
179 Tree_Version_String
:= (others => '?');
182 Tmp
: String (1 .. Integer (Tree_Version_String_Len
));
185 (Tmp
'Address, Tree_Version_String_Len
);
190 Tree_Read_Data
(Distribution_Stub_Mode
'Address,
191 Distribution_Stub_Mode_Type
'Object_Size / Storage_Unit
);
192 Tree_Read_Bool
(Immediate_Errors
);
193 Tree_Read_Bool
(Inline_Active
);
194 Tree_Read_Bool
(Inline_Processing_Required
);
195 Tree_Read_Bool
(List_Units
);
196 Tree_Read_Bool
(Configurable_Run_Time_Mode
);
197 Tree_Read_Data
(Operating_Mode
'Address,
198 Operating_Mode_Type
'Object_Size / Storage_Unit
);
199 Tree_Read_Bool
(Suppress_Checks
);
200 Tree_Read_Bool
(Try_Semantics
);
201 Tree_Read_Data
(Wide_Character_Encoding_Method
'Address,
202 WC_Encoding_Method
'Object_Size / Storage_Unit
);
203 Tree_Read_Bool
(Upper_Half_Encoding
);
204 Tree_Read_Bool
(Force_ALI_Tree_File
);
211 procedure Tree_Write
is
212 Version_String
: String := Gnat_Version_String
;
214 Tree_Write_Int
(ASIS_Version_Number
);
215 Tree_Write_Bool
(Brief_Output
);
216 Tree_Write_Bool
(GNAT_Mode
);
217 Tree_Write_Char
(Identifier_Character_Set
);
218 Tree_Write_Int
(Maximum_File_Name_Length
);
219 Tree_Write_Data
(Suppress_Options
'Address,
220 Suppress_Array
'Object_Size / Storage_Unit
);
221 Tree_Write_Bool
(Verbose_Mode
);
222 Tree_Write_Data
(Warning_Mode
'Address,
223 Warning_Mode_Type
'Object_Size / Storage_Unit
);
224 Tree_Write_Int
(Ada_Version_Type
'Pos (Ada_Version_Config
));
225 Tree_Write_Int
(Ada_Version_Type
'Pos (Ada_Version_Explicit_Config
));
226 Tree_Write_Int
(Boolean'Pos (Assertions_Enabled_Config
));
227 Tree_Write_Bool
(All_Errors_Mode
);
228 Tree_Write_Bool
(Assertions_Enabled
);
229 Tree_Write_Bool
(Enable_Overflow_Checks
);
230 Tree_Write_Bool
(Full_List
);
231 Tree_Write_Int
(Int
(Version_String
'Length));
232 Tree_Write_Data
(Version_String
'Address,
233 Version_String
'Length);
234 Tree_Write_Data
(Distribution_Stub_Mode
'Address,
235 Distribution_Stub_Mode_Type
'Object_Size / Storage_Unit
);
236 Tree_Write_Bool
(Immediate_Errors
);
237 Tree_Write_Bool
(Inline_Active
);
238 Tree_Write_Bool
(Inline_Processing_Required
);
239 Tree_Write_Bool
(List_Units
);
240 Tree_Write_Bool
(Configurable_Run_Time_Mode
);
241 Tree_Write_Data
(Operating_Mode
'Address,
242 Operating_Mode_Type
'Object_Size / Storage_Unit
);
243 Tree_Write_Bool
(Suppress_Checks
);
244 Tree_Write_Bool
(Try_Semantics
);
245 Tree_Write_Data
(Wide_Character_Encoding_Method
'Address,
246 WC_Encoding_Method
'Object_Size / Storage_Unit
);
247 Tree_Write_Bool
(Upper_Half_Encoding
);
248 Tree_Write_Bool
(Force_ALI_Tree_File
);