OSDN Git Service

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