1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2001, 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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 Ada
.Exceptions
; use Ada
.Exceptions
;
35 with Gnatvsn
; use Gnatvsn
;
36 with System
; use System
;
37 with Tree_IO
; use Tree_IO
;
41 Tree_Version_String
: String (Gnat_Version_String
'Range);
42 -- Used to store the compiler version string read from a tree file to
43 -- check if it is the same as stored in the version ctring in Gnatvsn.
44 -- Therefore its length is taken directly from the version string in
45 -- Gnatvsn. If the length of the version string stored in the three is
46 -- different, then versions are for sure different.
48 Immediate_Errors
: Boolean := True;
49 -- This is an obsolete flag that is no longer present in opt.ads. We
50 -- retain it here because this flag was written to the tree and there
51 -- is no point in making trees incomaptible just for the sake of saving
52 -- one byte of data. The value written is ignored.
54 ----------------------------------
55 -- Register_Opt_Config_Switches --
56 ----------------------------------
58 procedure Register_Opt_Config_Switches
is
60 Ada_83_Config
:= Ada_83
;
61 Dynamic_Elaboration_Checks_Config
:= Dynamic_Elaboration_Checks
;
62 Extensions_Allowed_Config
:= Extensions_Allowed
;
63 External_Name_Exp_Casing_Config
:= External_Name_Exp_Casing
;
64 External_Name_Imp_Casing_Config
:= External_Name_Imp_Casing
;
65 Polling_Required_Config
:= Polling_Required
;
66 Use_VADS_Size_Config
:= Use_VADS_Size
;
67 end Register_Opt_Config_Switches
;
69 ---------------------------------
70 -- Restore_Opt_Config_Switches --
71 ---------------------------------
73 procedure Restore_Opt_Config_Switches
(Save
: Config_Switches_Type
) is
75 Ada_83
:= Save
.Ada_83
;
77 Dynamic_Elaboration_Checks
:= Save
.Dynamic_Elaboration_Checks
;
78 Extensions_Allowed
:= Save
.Extensions_Allowed
;
79 External_Name_Exp_Casing
:= Save
.External_Name_Exp_Casing
;
80 External_Name_Imp_Casing
:= Save
.External_Name_Imp_Casing
;
81 Polling_Required
:= Save
.Polling_Required
;
82 Use_VADS_Size
:= Save
.Use_VADS_Size
;
83 end Restore_Opt_Config_Switches
;
85 ------------------------------
86 -- Save_Opt_Config_Switches --
87 ------------------------------
89 procedure Save_Opt_Config_Switches
(Save
: out Config_Switches_Type
) is
91 Save
.Ada_83
:= Ada_83
;
92 Save
.Dynamic_Elaboration_Checks
:= Dynamic_Elaboration_Checks
;
93 Save
.Extensions_Allowed
:= Extensions_Allowed
;
94 Save
.External_Name_Exp_Casing
:= External_Name_Exp_Casing
;
95 Save
.External_Name_Imp_Casing
:= External_Name_Imp_Casing
;
96 Save
.Polling_Required
:= Polling_Required
;
97 Save
.Use_VADS_Size
:= Use_VADS_Size
;
98 end Save_Opt_Config_Switches
;
100 -----------------------------
101 -- Set_Opt_Config_Switches --
102 -----------------------------
104 procedure Set_Opt_Config_Switches
(Internal_Unit
: Boolean) is
106 if Internal_Unit
then
109 Dynamic_Elaboration_Checks
:= False;
110 Extensions_Allowed
:= True;
111 External_Name_Exp_Casing
:= As_Is
;
112 External_Name_Imp_Casing
:= Lowercase
;
113 Use_VADS_Size
:= False;
116 Ada_83
:= Ada_83_Config
;
117 Ada_95
:= not Ada_83_Config
;
118 Dynamic_Elaboration_Checks
:= Dynamic_Elaboration_Checks_Config
;
119 Extensions_Allowed
:= Extensions_Allowed_Config
;
120 External_Name_Exp_Casing
:= External_Name_Exp_Casing_Config
;
121 External_Name_Imp_Casing
:= External_Name_Imp_Casing_Config
;
122 Use_VADS_Size
:= Use_VADS_Size_Config
;
125 Polling_Required
:= Polling_Required_Config
;
126 end Set_Opt_Config_Switches
;
132 procedure Tree_Read
is
133 Tree_Version_String_Len
: Nat
;
136 Tree_Read_Bool
(Brief_Output
);
137 Tree_Read_Bool
(GNAT_Mode
);
138 Tree_Read_Char
(Identifier_Character_Set
);
139 Tree_Read_Int
(Maximum_File_Name_Length
);
140 Tree_Read_Data
(Suppress_Options
'Address,
141 Suppress_Record
'Object_Size / Storage_Unit
);
142 Tree_Read_Bool
(Verbose_Mode
);
143 Tree_Read_Data
(Warning_Mode
'Address,
144 Warning_Mode_Type
'Object_Size / Storage_Unit
);
145 Tree_Read_Bool
(Ada_83_Config
);
146 Tree_Read_Bool
(All_Errors_Mode
);
147 Tree_Read_Bool
(Assertions_Enabled
);
148 Tree_Read_Bool
(Enable_Overflow_Checks
);
149 Tree_Read_Bool
(Full_List
);
151 -- Read and check version string
153 Tree_Read_Int
(Tree_Version_String_Len
);
155 if Tree_Version_String_Len
= Tree_Version_String
'Length then
157 (Tree_Version_String
'Address, Tree_Version_String
'Length);
160 if Tree_Version_String_Len
/= Tree_Version_String
'Length
161 or else Tree_Version_String
/= Gnat_Version_String
164 (Program_Error
'Identity, "Inconsistent versions of GNAT and ASIS");
167 Tree_Read_Data
(Distribution_Stub_Mode
'Address,
168 Distribution_Stub_Mode_Type
'Object_Size / Storage_Unit
);
169 Tree_Read_Bool
(Immediate_Errors
);
170 Tree_Read_Bool
(Inline_Active
);
171 Tree_Read_Bool
(Inline_Processing_Required
);
172 Tree_Read_Bool
(List_Units
);
173 Tree_Read_Bool
(No_Run_Time
);
174 Tree_Read_Data
(Operating_Mode
'Address,
175 Operating_Mode_Type
'Object_Size / Storage_Unit
);
176 Tree_Read_Bool
(Suppress_Checks
);
177 Tree_Read_Bool
(Try_Semantics
);
178 Tree_Read_Data
(Wide_Character_Encoding_Method
'Address,
179 WC_Encoding_Method
'Object_Size / Storage_Unit
);
180 Tree_Read_Bool
(Upper_Half_Encoding
);
181 Tree_Read_Bool
(Force_ALI_Tree_File
);
188 procedure Tree_Write
is
190 Tree_Write_Bool
(Brief_Output
);
191 Tree_Write_Bool
(GNAT_Mode
);
192 Tree_Write_Char
(Identifier_Character_Set
);
193 Tree_Write_Int
(Maximum_File_Name_Length
);
194 Tree_Write_Data
(Suppress_Options
'Address,
195 Suppress_Record
'Object_Size / Storage_Unit
);
196 Tree_Write_Bool
(Verbose_Mode
);
197 Tree_Write_Data
(Warning_Mode
'Address,
198 Warning_Mode_Type
'Object_Size / Storage_Unit
);
199 Tree_Write_Bool
(Ada_83_Config
);
200 Tree_Write_Bool
(All_Errors_Mode
);
201 Tree_Write_Bool
(Assertions_Enabled
);
202 Tree_Write_Bool
(Enable_Overflow_Checks
);
203 Tree_Write_Bool
(Full_List
);
204 Tree_Write_Int
(Int
(Gnat_Version_String
'Length));
205 Tree_Write_Data
(Gnat_Version_String
'Address,
206 Gnat_Version_String
'Length);
207 Tree_Write_Data
(Distribution_Stub_Mode
'Address,
208 Distribution_Stub_Mode_Type
'Object_Size / Storage_Unit
);
209 Tree_Write_Bool
(Immediate_Errors
);
210 Tree_Write_Bool
(Inline_Active
);
211 Tree_Write_Bool
(Inline_Processing_Required
);
212 Tree_Write_Bool
(List_Units
);
213 Tree_Write_Bool
(No_Run_Time
);
214 Tree_Write_Data
(Operating_Mode
'Address,
215 Operating_Mode_Type
'Object_Size / Storage_Unit
);
216 Tree_Write_Bool
(Suppress_Checks
);
217 Tree_Write_Bool
(Try_Semantics
);
218 Tree_Write_Data
(Wide_Character_Encoding_Method
'Address,
219 WC_Encoding_Method
'Object_Size / Storage_Unit
);
220 Tree_Write_Bool
(Upper_Half_Encoding
);
221 Tree_Write_Bool
(Force_ALI_Tree_File
);