1 ------------------------------------------------------------------------------
3 -- GNAT SYSTEM UTILITIES --
9 -- Copyright (C) 1997-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 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
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
;
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
55 procedure P_Float_Range
(Nb_Digits
: Pos
) is
57 -- This routine assumes only IEEE floats.
58 -- ??? Should the following be adapted for OpenVMS ?
62 P
(" range " & IEEES_First
'Universal_Literal_String & " .. " &
63 IEEES_Last
'Universal_Literal_String & ";");
65 P
(" range " & IEEEL_First
'Universal_Literal_String & " .. " &
66 IEEEL_Last
'Universal_Literal_String & ";");
68 P
(" range " & IEEEX_First
'Universal_Literal_String & " .. " &
69 IEEEX_Last
'Universal_Literal_String & ";");
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
81 Short_Float'First'Img & " .. " & Short_Float'Last'Img
);
83 elsif Nb_Digits
= Float'Digits then
85 Float'First'Img & " .. " & Float'Last'Img
);
87 elsif Nb_Digits
= Long_Float'Digits then
89 Long_Float'First'Img & " .. " & Long_Float'Last'Img
);
91 elsif Nb_Digits
= Long_Long_Float'Digits then
93 Long_Long_Float'First'Img & " .. " & Long_Long_Float'Last'Img
);
103 procedure P_Int_Range
(Size
: Pos
; Put_First
: Boolean := True) is
106 Put
(" is range -(2 **" & Pos
'Image (Size
- 1) & ")");
108 P
(" .. +(2 **" & Pos
'Image (Size
- 1) & " - 1);");
111 -- Start of processing for GnatPsta
114 P
("package Standard is");
115 P
("pragma Pure(Standard);");
118 P
(" type Boolean is (False, True);");
123 Put
(" type Integer");
124 P_Int_Range
(Standard_Integer_Size
);
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);
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
);
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;");
169 P
(" -- function ""*"" (Left : root_real; Right : root_integer)");
170 P
(" -- return root_real;");
173 P
(" -- function ""/"" (Left : root_real; Right : root_integer)");
174 P
(" -- return root_real;");
177 P
(" -- function ""*"" (Left : universal_fixed; " &
178 "Right : universal_fixed)");
179 P
(" -- return universal_fixed;");
182 P
(" -- function ""/"" (Left : universal_fixed; " &
183 "Right : universal_fixed)");
184 P
(" -- return universal_fixed;");
187 P
(" -- The declaration of type Character is based on the standard");
188 P
(" -- ISO 8859-1 character set.");
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.");
196 P
(" -- Note: this type cannot be represented accurately in Ada");
199 P
(" -- type Character is");
202 P
(" -- (nul, soh, stx, etx, eot, enq, ack, bel,");
203 P
(" -- bs, ht, lf, vt, ff, cr, so, si,");
206 P
(" -- dle, dc1, dc2, dc3, dc4, nak, syn, etb,");
207 P
(" -- can, em, sub, esc, fs, gs, rs, us,");
210 P
(" -- ' ', '!', '""', '#', '$', '%', '&', ''',");
211 P
(" -- '(', ')', '*', '+', ',', '-', '.', '/',");
214 P
(" -- '0', '1', '2', '3', '4', '5', '6', '7',");
215 P
(" -- '8', '9', ':', ';', '<', '=', '>', '?',");
218 P
(" -- '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',");
219 P
(" -- 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',");
222 P
(" -- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',");
223 P
(" -- 'X', 'Y', 'Z', '[', '\', ']', '^', '_',");
226 P
(" -- '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',");
227 P
(" -- 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',");
230 P
(" -- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',");
231 P
(" -- 'x', 'y', 'z', '{', '|', '}', '~', del,");
234 P
(" -- reserved_128, reserved_129, bph, nbh,");
235 P
(" -- reserved_132, nel, ssa, esa,");
238 P
(" -- hts, htj, vts, pld, plu, ri, ss2, ss3,");
241 P
(" -- dcs, pu1, pu2, sts, cch, mw, spa, epa,");
244 P
(" -- sos, reserved_153, sci, csi,");
245 P
(" -- st, osc, pm, apc,");
251 P
(" -- The declaration of type Wide_Character is based " &
253 P
(" -- ISO 10646 BMP character set.");
256 P
(" -- Note: this type cannot be represented accurately in Ada");
259 P
(" -- The first 256 positions have the same contents as " &
263 P
(" -- type Wide_Character is (nul, soh ... FFFE, FFFF);");
266 P
(" package ASCII is");
269 P
(" -- Control characters:");
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#);");
307 P
(" -- Other characters:");
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 := '~';");
332 P
(" -- Lower case letters:");
335 for C
in Character range 'a' .. 'z' loop
336 P
(" LC_" & Character'Val (Character'Pos (C
) - 32) &
337 " : constant Character := '" & C
& "';");
344 P
(" type String is array (Positive range <>) of Character;");
345 P
(" pragma Pack (String);");
348 P
(" type Wide_String is array (Positive range <>) of Wide_Character;");
349 P
(" pragma Pack (Wide_String);");
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) & ";");
364 P
(" Constraint_Error : exception;");
365 P
(" Program_Error : exception;");
366 P
(" Storage_Error : exception;");
367 P
(" Tasking_Error : exception;");