1 ------------------------------------------------------------------------------
3 -- GNAT SYSTEM UTILITIES --
10 -- Copyright (C) 1997-2001 Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 ------------------------------------------------------------------------------
28 -- Program to print out listing of Standard package for the target (not
29 -- the host) with all constants appearing explicitly. This is not really
30 -- valid Ada, since one cannot really define new base types, but it is a
31 -- helpful listing from a documentation point of view.
33 -- Note that special care has been taken to use the host parameters for
34 -- integer and floating point sizes.
36 with Ada
.Text_IO
; use Ada
.Text_IO
;
38 with Ttypef
; use Ttypef
;
39 with Ttypes
; use Ttypes
;
40 with Types
; use Types
;
43 pragma Ident
(Gnatvsn
.Gnat_Version_String
);
45 procedure P
(Item
: String) renames Ada
.Text_IO
.Put_Line
;
47 procedure P_Int_Range
(Size
: Pos
; Put_First
: Boolean := True);
48 -- Prints the range of an integer based on its Size. If Put_First is
49 -- False, then skip the first bound.
51 procedure P_Float_Range
(Nb_Digits
: Pos
);
52 -- Prints the maximum range of a Float whose 'Digits is given by Nb_Digits
58 procedure P_Float_Range
(Nb_Digits
: Pos
) is
60 -- This routine assumes only IEEE floats.
61 -- ??? Should the following be adapted for OpenVMS ?
65 P
(" range " & IEEES_First
'Universal_Literal_String & " .. " &
66 IEEES_Last
'Universal_Literal_String & ";");
68 P
(" range " & IEEEL_First
'Universal_Literal_String & " .. " &
69 IEEEL_Last
'Universal_Literal_String & ";");
71 P
(" range " & IEEEX_First
'Universal_Literal_String & " .. " &
72 IEEEX_Last
'Universal_Literal_String & ";");
78 -- If one of the floating point types of the host computer has the
79 -- same digits as the target float we are processing, then print out
80 -- the float range using the host computer float type.
82 if Nb_Digits
= Short_Float'Digits then
84 Short_Float'First'Img & " .. " & Short_Float'Last'Img
);
86 elsif Nb_Digits
= Float'Digits then
88 Float'First'Img & " .. " & Float'Last'Img
);
90 elsif Nb_Digits
= Long_Float'Digits then
92 Long_Float'First'Img & " .. " & Long_Float'Last'Img
);
94 elsif Nb_Digits
= Long_Long_Float'Digits then
96 Long_Long_Float'First'Img & " .. " & Long_Long_Float'Last'Img
);
106 procedure P_Int_Range
(Size
: Pos
; Put_First
: Boolean := True) is
109 Put
(" is range -(2 **" & Pos
'Image (Size
- 1) & ")");
111 P
(" .. +(2 **" & Pos
'Image (Size
- 1) & " - 1);");
114 -- Start of processing for GnatPsta
117 P
("package Standard is");
118 P
("pragma Pure(Standard);");
121 P
(" type Boolean is (False, True);");
126 Put
(" type Integer");
127 P_Int_Range
(Standard_Integer_Size
);
130 Put
(" subtype Natural is Integer range 0");
131 P_Int_Range
(Standard_Integer_Size
, Put_First
=> False);
133 Put
(" subtype Positive is Integer range 1");
134 P_Int_Range
(Standard_Integer_Size
, Put_First
=> False);
137 Put
(" type Short_Short_Integer");
138 P_Int_Range
(Standard_Short_Short_Integer_Size
);
140 Put
(" type Short_Integer ");
141 P_Int_Range
(Standard_Short_Integer_Size
);
143 Put
(" type Long_Integer ");
144 P_Int_Range
(Standard_Long_Integer_Size
);
146 Put
(" type Long_Long_Integer ");
147 P_Int_Range
(Standard_Long_Long_Integer_Size
);
150 -- Floating point types
152 P
(" type Short_Float is digits"
153 & Standard_Short_Float_Digits
'Img);
154 P_Float_Range
(Standard_Short_Float_Digits
);
156 P
(" type Float is digits"
157 & Standard_Float_Digits
'Img);
158 P_Float_Range
(Standard_Float_Digits
);
160 P
(" type Long_Float is digits"
161 & Standard_Long_Float_Digits
'Img);
162 P_Float_Range
(Standard_Long_Float_Digits
);
164 P
(" type Long_Long_Float is digits"
165 & Standard_Long_Long_Float_Digits
'Img);
166 P_Float_Range
(Standard_Long_Long_Float_Digits
);
168 P
(" -- function ""*"" (Left : root_integer; Right : root_real)");
169 P
(" -- return root_real;");
172 P
(" -- function ""*"" (Left : root_real; Right : root_integer)");
173 P
(" -- return root_real;");
176 P
(" -- function ""/"" (Left : root_real; Right : root_integer)");
177 P
(" -- return root_real;");
180 P
(" -- function ""*"" (Left : universal_fixed; " &
181 "Right : universal_fixed)");
182 P
(" -- return universal_fixed;");
185 P
(" -- function ""/"" (Left : universal_fixed; " &
186 "Right : universal_fixed)");
187 P
(" -- return universal_fixed;");
190 P
(" -- The declaration of type Character is based on the standard");
191 P
(" -- ISO 8859-1 character set.");
194 P
(" -- There are no character literals corresponding to the positions");
195 P
(" -- for control characters. They are indicated by lower case");
196 P
(" -- identifiers in the following list.");
199 P
(" -- Note: this type cannot be represented accurately in Ada");
202 P
(" -- type Character is");
205 P
(" -- (nul, soh, stx, etx, eot, enq, ack, bel,");
206 P
(" -- bs, ht, lf, vt, ff, cr, so, si,");
209 P
(" -- dle, dc1, dc2, dc3, dc4, nak, syn, etb,");
210 P
(" -- can, em, sub, esc, fs, gs, rs, us,");
213 P
(" -- ' ', '!', '""', '#', '$', '%', '&', ''',");
214 P
(" -- '(', ')', '*', '+', ',', '-', '.', '/',");
217 P
(" -- '0', '1', '2', '3', '4', '5', '6', '7',");
218 P
(" -- '8', '9', ':', ';', '<', '=', '>', '?',");
221 P
(" -- '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',");
222 P
(" -- 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',");
225 P
(" -- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',");
226 P
(" -- 'X', 'Y', 'Z', '[', '\', ']', '^', '_',");
229 P
(" -- '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',");
230 P
(" -- 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',");
233 P
(" -- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',");
234 P
(" -- 'x', 'y', 'z', '{', '|', '}', '~', del,");
237 P
(" -- reserved_128, reserved_129, bph, nbh,");
238 P
(" -- reserved_132, nel, ssa, esa,");
241 P
(" -- hts, htj, vts, pld, plu, ri, ss2, ss3,");
244 P
(" -- dcs, pu1, pu2, sts, cch, mw, spa, epa,");
247 P
(" -- sos, reserved_153, sci, csi,");
248 P
(" -- st, osc, pm, apc,");
254 P
(" -- The declaration of type Wide_Character is based " &
256 P
(" -- ISO 10646 BMP character set.");
259 P
(" -- Note: this type cannot be represented accurately in Ada");
262 P
(" -- The first 256 positions have the same contents as " &
266 P
(" -- type Wide_Character is (nul, soh ... FFFE, FFFF);");
269 P
(" package ASCII is");
272 P
(" -- Control characters:");
275 P
(" NUL : constant Character := Character'Val (16#00#);");
276 P
(" SOH : constant Character := Character'Val (16#01#);");
277 P
(" STX : constant Character := Character'Val (16#02#);");
278 P
(" ETX : constant Character := Character'Val (16#03#);");
279 P
(" EOT : constant Character := Character'Val (16#04#);");
280 P
(" ENQ : constant Character := Character'Val (16#05#);");
281 P
(" ACK : constant Character := Character'Val (16#06#);");
282 P
(" BEL : constant Character := Character'Val (16#07#);");
283 P
(" BS : constant Character := Character'Val (16#08#);");
284 P
(" HT : constant Character := Character'Val (16#09#);");
285 P
(" LF : constant Character := Character'Val (16#0A#);");
286 P
(" VT : constant Character := Character'Val (16#0B#);");
287 P
(" FF : constant Character := Character'Val (16#0C#);");
288 P
(" CR : constant Character := Character'Val (16#0D#);");
289 P
(" SO : constant Character := Character'Val (16#0E#);");
290 P
(" SI : constant Character := Character'Val (16#0F#);");
291 P
(" DLE : constant Character := Character'Val (16#10#);");
292 P
(" DC1 : constant Character := Character'Val (16#11#);");
293 P
(" DC2 : constant Character := Character'Val (16#12#);");
294 P
(" DC3 : constant Character := Character'Val (16#13#);");
295 P
(" DC4 : constant Character := Character'Val (16#14#);");
296 P
(" NAK : constant Character := Character'Val (16#15#);");
297 P
(" SYN : constant Character := Character'Val (16#16#);");
298 P
(" ETB : constant Character := Character'Val (16#17#);");
299 P
(" CAN : constant Character := Character'Val (16#18#);");
300 P
(" EM : constant Character := Character'Val (16#19#);");
301 P
(" SUB : constant Character := Character'Val (16#1A#);");
302 P
(" ESC : constant Character := Character'Val (16#1B#);");
303 P
(" FS : constant Character := Character'Val (16#1C#);");
304 P
(" GS : constant Character := Character'Val (16#1D#);");
305 P
(" RS : constant Character := Character'Val (16#1E#);");
306 P
(" US : constant Character := Character'Val (16#1F#);");
307 P
(" DEL : constant Character := Character'Val (16#7F#);");
310 P
(" -- Other characters:");
313 P
(" Exclam : constant Character := '!';");
314 P
(" Quotation : constant Character := '""';");
315 P
(" Sharp : constant Character := '#';");
316 P
(" Dollar : constant Character := '$';");
317 P
(" Percent : constant Character := '%';");
318 P
(" Ampersand : constant Character := '&';");
319 P
(" Colon : constant Character := ':';");
320 P
(" Semicolon : constant Character := ';';");
321 P
(" Query : constant Character := '?';");
322 P
(" At_Sign : constant Character := '@';");
323 P
(" L_Bracket : constant Character := '[';");
324 P
(" Back_Slash : constant Character := '\';");
325 P
(" R_Bracket : constant Character := ']';");
326 P
(" Circumflex : constant Character := '^';");
327 P
(" Underline : constant Character := '_';");
328 P
(" Grave : constant Character := '`';");
329 P
(" L_Brace : constant Character := '{';");
330 P
(" Bar : constant Character := '|';");
331 P
(" R_Brace : constant Character := '}';");
332 P
(" Tilde : constant Character := '~';");
335 P
(" -- Lower case letters:");
338 for C
in Character range 'a' .. 'z' loop
339 P
(" LC_" & Character'Val (Character'Pos (C
) - 32) &
340 " : constant Character := '" & C
& "';");
347 P
(" type String is array (Positive range <>) of Character;");
348 P
(" pragma Pack (String);");
351 P
(" type Wide_String is array (Positive range <>) of Wide_Character;");
352 P
(" pragma Pack (Wide_String);");
355 -- Here it's OK to use the Duration type of the host compiler since
356 -- the implementation of Duration in GNAT is target independent.
358 P
(" type Duration is delta" &
359 Duration'Image (Duration'Delta));
360 P
(" range -((2 **" & Natural'Image (Duration'Size - 1) &
361 " - 1) *" & Duration'Image (Duration'Delta) & ") ..");
362 P
(" +((2 **" & Natural'Image (Duration'Size - 1) &
363 " - 1) *" & Duration'Image (Duration'Delta) & ");");
364 P
(" for Duration'Small use" & Duration'Image (Duration'Small) & ";");
367 P
(" Constraint_Error : exception;");
368 P
(" Program_Error : exception;");
369 P
(" Storage_Error : exception;");
370 P
(" Tasking_Error : exception;");