configure.ac: GCC_NO_EXECUTABLES was supposed to be commented in the patch from 3...
[official-gcc.git] / gcc / ada / gnatpsta.adb
blob12a38fcf6a83a15d648b1e7edf73ec7fc5626362
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT SYSTEM UTILITIES --
4 -- --
5 -- G N A T P S T A --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1997-2001 Free Software Foundation, Inc. --
10 -- --
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. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 -- Program to print out listing of Standard package for the target (not
28 -- the host) with all constants appearing explicitly. This is not really
29 -- valid Ada, since one cannot really define new base types, but it is a
30 -- helpful listing from a documentation point of view.
32 -- Note that special care has been taken to use the host parameters for
33 -- integer and floating point sizes.
35 with Ada.Text_IO; use Ada.Text_IO;
36 with Ttypef; use Ttypef;
37 with Ttypes; use Ttypes;
38 with Types; use Types;
40 procedure GnatPsta is
42 procedure P (Item : String) renames Ada.Text_IO.Put_Line;
44 procedure P_Int_Range (Size : Pos; Put_First : Boolean := True);
45 -- Prints the range of an integer based on its Size. If Put_First is
46 -- False, then skip the first bound.
48 procedure P_Float_Range (Nb_Digits : Pos);
49 -- Prints the maximum range of a Float whose 'Digits is given by Nb_Digits
51 -------------------
52 -- P_Float_Range --
53 -------------------
55 procedure P_Float_Range (Nb_Digits : Pos) is
56 begin
57 -- This routine assumes only IEEE floats.
58 -- ??? Should the following be adapted for OpenVMS ?
60 case Nb_Digits is
61 when IEEES_Digits =>
62 P (" range " & IEEES_First'Universal_Literal_String & " .. " &
63 IEEES_Last'Universal_Literal_String & ";");
64 when IEEEL_Digits =>
65 P (" range " & IEEEL_First'Universal_Literal_String & " .. " &
66 IEEEL_Last'Universal_Literal_String & ";");
67 when IEEEX_Digits =>
68 P (" range " & IEEEX_First'Universal_Literal_String & " .. " &
69 IEEEX_Last'Universal_Literal_String & ";");
71 when others =>
72 P (";");
73 end case;
75 -- If one of the floating point types of the host computer has the
76 -- same digits as the target float we are processing, then print out
77 -- the float range using the host computer float type.
79 if Nb_Digits = Short_Float'Digits then
80 P (" -- " &
81 Short_Float'First'Img & " .. " & Short_Float'Last'Img);
83 elsif Nb_Digits = Float'Digits then
84 P (" -- " &
85 Float'First'Img & " .. " & Float'Last'Img);
87 elsif Nb_Digits = Long_Float'Digits then
88 P (" -- " &
89 Long_Float'First'Img & " .. " & Long_Float'Last'Img);
91 elsif Nb_Digits = Long_Long_Float'Digits then
92 P (" -- " &
93 Long_Long_Float'First'Img & " .. " & Long_Long_Float'Last'Img);
94 end if;
96 New_Line;
97 end P_Float_Range;
99 -----------------
100 -- P_Int_Range --
101 -----------------
103 procedure P_Int_Range (Size : Pos; Put_First : Boolean := True) is
104 begin
105 if Put_First then
106 Put (" is range -(2 **" & Pos'Image (Size - 1) & ")");
107 end if;
108 P (" .. +(2 **" & Pos'Image (Size - 1) & " - 1);");
109 end P_Int_Range;
111 -- Start of processing for GnatPsta
113 begin
114 P ("package Standard is");
115 P ("pragma Pure(Standard);");
116 New_Line;
118 P (" type Boolean is (False, True);");
119 New_Line;
121 -- Integer types
123 Put (" type Integer");
124 P_Int_Range (Standard_Integer_Size);
125 New_Line;
127 Put (" subtype Natural is Integer range 0");
128 P_Int_Range (Standard_Integer_Size, Put_First => False);
130 Put (" subtype Positive is Integer range 1");
131 P_Int_Range (Standard_Integer_Size, Put_First => False);
132 New_Line;
134 Put (" type Short_Short_Integer");
135 P_Int_Range (Standard_Short_Short_Integer_Size);
137 Put (" type Short_Integer ");
138 P_Int_Range (Standard_Short_Integer_Size);
140 Put (" type Long_Integer ");
141 P_Int_Range (Standard_Long_Integer_Size);
143 Put (" type Long_Long_Integer ");
144 P_Int_Range (Standard_Long_Long_Integer_Size);
145 New_Line;
147 -- Floating point types
149 P (" type Short_Float is digits"
150 & Standard_Short_Float_Digits'Img);
151 P_Float_Range (Standard_Short_Float_Digits);
153 P (" type Float is digits"
154 & Standard_Float_Digits'Img);
155 P_Float_Range (Standard_Float_Digits);
157 P (" type Long_Float is digits"
158 & Standard_Long_Float_Digits'Img);
159 P_Float_Range (Standard_Long_Float_Digits);
161 P (" type Long_Long_Float is digits"
162 & Standard_Long_Long_Float_Digits'Img);
163 P_Float_Range (Standard_Long_Long_Float_Digits);
165 P (" -- function ""*"" (Left : root_integer; Right : root_real)");
166 P (" -- return root_real;");
167 New_Line;
169 P (" -- function ""*"" (Left : root_real; Right : root_integer)");
170 P (" -- return root_real;");
171 New_Line;
173 P (" -- function ""/"" (Left : root_real; Right : root_integer)");
174 P (" -- return root_real;");
175 New_Line;
177 P (" -- function ""*"" (Left : universal_fixed; " &
178 "Right : universal_fixed)");
179 P (" -- return universal_fixed;");
180 New_Line;
182 P (" -- function ""/"" (Left : universal_fixed; " &
183 "Right : universal_fixed)");
184 P (" -- return universal_fixed;");
185 New_Line;
187 P (" -- The declaration of type Character is based on the standard");
188 P (" -- ISO 8859-1 character set.");
189 New_Line;
191 P (" -- There are no character literals corresponding to the positions");
192 P (" -- for control characters. They are indicated by lower case");
193 P (" -- identifiers in the following list.");
194 New_Line;
196 P (" -- Note: this type cannot be represented accurately in Ada");
197 New_Line;
199 P (" -- type Character is");
200 New_Line;
202 P (" -- (nul, soh, stx, etx, eot, enq, ack, bel,");
203 P (" -- bs, ht, lf, vt, ff, cr, so, si,");
204 New_Line;
206 P (" -- dle, dc1, dc2, dc3, dc4, nak, syn, etb,");
207 P (" -- can, em, sub, esc, fs, gs, rs, us,");
208 New_Line;
210 P (" -- ' ', '!', '""', '#', '$', '%', '&', ''',");
211 P (" -- '(', ')', '*', '+', ',', '-', '.', '/',");
212 New_Line;
214 P (" -- '0', '1', '2', '3', '4', '5', '6', '7',");
215 P (" -- '8', '9', ':', ';', '<', '=', '>', '?',");
216 New_Line;
218 P (" -- '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',");
219 P (" -- 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',");
220 New_Line;
222 P (" -- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',");
223 P (" -- 'X', 'Y', 'Z', '[', '\', ']', '^', '_',");
224 New_Line;
226 P (" -- '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',");
227 P (" -- 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',");
228 New_Line;
230 P (" -- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',");
231 P (" -- 'x', 'y', 'z', '{', '|', '}', '~', del,");
232 New_Line;
234 P (" -- reserved_128, reserved_129, bph, nbh,");
235 P (" -- reserved_132, nel, ssa, esa,");
236 New_Line;
238 P (" -- hts, htj, vts, pld, plu, ri, ss2, ss3,");
239 New_Line;
241 P (" -- dcs, pu1, pu2, sts, cch, mw, spa, epa,");
242 New_Line;
244 P (" -- sos, reserved_153, sci, csi,");
245 P (" -- st, osc, pm, apc,");
246 New_Line;
248 P (" -- ... );");
249 New_Line;
251 P (" -- The declaration of type Wide_Character is based " &
252 "on the standard");
253 P (" -- ISO 10646 BMP character set.");
254 New_Line;
256 P (" -- Note: this type cannot be represented accurately in Ada");
257 New_Line;
259 P (" -- The first 256 positions have the same contents as " &
260 "type Character");
261 New_Line;
263 P (" -- type Wide_Character is (nul, soh ... FFFE, FFFF);");
264 New_Line;
266 P (" package ASCII is");
267 New_Line;
269 P (" -- Control characters:");
270 New_Line;
272 P (" NUL : constant Character := Character'Val (16#00#);");
273 P (" SOH : constant Character := Character'Val (16#01#);");
274 P (" STX : constant Character := Character'Val (16#02#);");
275 P (" ETX : constant Character := Character'Val (16#03#);");
276 P (" EOT : constant Character := Character'Val (16#04#);");
277 P (" ENQ : constant Character := Character'Val (16#05#);");
278 P (" ACK : constant Character := Character'Val (16#06#);");
279 P (" BEL : constant Character := Character'Val (16#07#);");
280 P (" BS : constant Character := Character'Val (16#08#);");
281 P (" HT : constant Character := Character'Val (16#09#);");
282 P (" LF : constant Character := Character'Val (16#0A#);");
283 P (" VT : constant Character := Character'Val (16#0B#);");
284 P (" FF : constant Character := Character'Val (16#0C#);");
285 P (" CR : constant Character := Character'Val (16#0D#);");
286 P (" SO : constant Character := Character'Val (16#0E#);");
287 P (" SI : constant Character := Character'Val (16#0F#);");
288 P (" DLE : constant Character := Character'Val (16#10#);");
289 P (" DC1 : constant Character := Character'Val (16#11#);");
290 P (" DC2 : constant Character := Character'Val (16#12#);");
291 P (" DC3 : constant Character := Character'Val (16#13#);");
292 P (" DC4 : constant Character := Character'Val (16#14#);");
293 P (" NAK : constant Character := Character'Val (16#15#);");
294 P (" SYN : constant Character := Character'Val (16#16#);");
295 P (" ETB : constant Character := Character'Val (16#17#);");
296 P (" CAN : constant Character := Character'Val (16#18#);");
297 P (" EM : constant Character := Character'Val (16#19#);");
298 P (" SUB : constant Character := Character'Val (16#1A#);");
299 P (" ESC : constant Character := Character'Val (16#1B#);");
300 P (" FS : constant Character := Character'Val (16#1C#);");
301 P (" GS : constant Character := Character'Val (16#1D#);");
302 P (" RS : constant Character := Character'Val (16#1E#);");
303 P (" US : constant Character := Character'Val (16#1F#);");
304 P (" DEL : constant Character := Character'Val (16#7F#);");
305 New_Line;
307 P (" -- Other characters:");
308 New_Line;
310 P (" Exclam : constant Character := '!';");
311 P (" Quotation : constant Character := '""';");
312 P (" Sharp : constant Character := '#';");
313 P (" Dollar : constant Character := '$';");
314 P (" Percent : constant Character := '%';");
315 P (" Ampersand : constant Character := '&';");
316 P (" Colon : constant Character := ':';");
317 P (" Semicolon : constant Character := ';';");
318 P (" Query : constant Character := '?';");
319 P (" At_Sign : constant Character := '@';");
320 P (" L_Bracket : constant Character := '[';");
321 P (" Back_Slash : constant Character := '\';");
322 P (" R_Bracket : constant Character := ']';");
323 P (" Circumflex : constant Character := '^';");
324 P (" Underline : constant Character := '_';");
325 P (" Grave : constant Character := '`';");
326 P (" L_Brace : constant Character := '{';");
327 P (" Bar : constant Character := '|';");
328 P (" R_Brace : constant Character := '}';");
329 P (" Tilde : constant Character := '~';");
330 New_Line;
332 P (" -- Lower case letters:");
333 New_Line;
335 for C in Character range 'a' .. 'z' loop
336 P (" LC_" & Character'Val (Character'Pos (C) - 32) &
337 " : constant Character := '" & C & "';");
338 end loop;
339 New_Line;
341 P (" end ASCII;");
342 New_Line;
344 P (" type String is array (Positive range <>) of Character;");
345 P (" pragma Pack (String);");
346 New_Line;
348 P (" type Wide_String is array (Positive range <>) of Wide_Character;");
349 P (" pragma Pack (Wide_String);");
350 New_Line;
352 -- Here it's OK to use the Duration type of the host compiler since
353 -- the implementation of Duration in GNAT is target independent.
355 P (" type Duration is delta" &
356 Duration'Image (Duration'Delta));
357 P (" range -((2 **" & Natural'Image (Duration'Size - 1) &
358 " - 1) *" & Duration'Image (Duration'Delta) & ") ..");
359 P (" +((2 **" & Natural'Image (Duration'Size - 1) &
360 " - 1) *" & Duration'Image (Duration'Delta) & ");");
361 P (" for Duration'Small use" & Duration'Image (Duration'Small) & ";");
362 New_Line;
364 P (" Constraint_Error : exception;");
365 P (" Program_Error : exception;");
366 P (" Storage_Error : exception;");
367 P (" Tasking_Error : exception;");
368 New_Line;
370 P ("end Standard;");
371 end GnatPsta;