1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT COMPILER COMPONENTS                         --
4--                                                                          --
5--                                S T A N D                                 --
6--                                                                          --
7--                                 S p e c                                  --
8--                                                                          --
9--          Copyright (C) 1992-2013, 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 3,  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.                                     --
17--                                                                          --
18-- As a special exception under Section 7 of GPL version 3, you are granted --
19-- additional permissions described in the GCC Runtime Library Exception,   --
20-- version 3.1, as published by the Free Software Foundation.               --
21--                                                                          --
22-- You should have received a copy of the GNU General Public License and    --
23-- a copy of the GCC Runtime Library Exception along with this program;     --
24-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25-- <http://www.gnu.org/licenses/>.                                          --
26--                                                                          --
27-- GNAT was originally developed  by the GNAT team at  New York University. --
28-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29--                                                                          --
30------------------------------------------------------------------------------
31
32--  This package contains the declarations of entities in package Standard,
33--  These values are initialized either by calling CStand.Create_Standard,
34--  or by calling Stand.Tree_Read.
35
36with Types; use Types;
37
38package Stand is
39
40   type Standard_Entity_Type is (
41   --  This enumeration type contains an entry for each name in Standard
42
43      --  Package names
44
45      S_Standard,
46      S_ASCII,
47
48      --  Types and subtypes defined in package Standard (in the order in which
49      --  they appear in the RM, so that the declarations are in the right
50      --  order for the purposes of ASIS traversals
51
52      S_Boolean,
53
54      S_Short_Short_Integer,
55      S_Short_Integer,
56      S_Integer,
57      S_Long_Integer,
58      S_Long_Long_Integer,
59
60      S_Natural,
61      S_Positive,
62
63      S_Short_Float,
64      S_Float,
65      S_Long_Float,
66      S_Long_Long_Float,
67
68      S_Character,
69      S_Wide_Character,
70      S_Wide_Wide_Character,
71
72      S_String,
73      S_Wide_String,
74      S_Wide_Wide_String,
75
76      S_Duration,
77
78      --  Enumeration literals for type Boolean
79
80      S_False,
81      S_True,
82
83      --  Exceptions declared in package Standard
84
85      S_Constraint_Error,
86      S_Numeric_Error,
87      S_Program_Error,
88      S_Storage_Error,
89      S_Tasking_Error,
90
91      --  Binary Operators declared in package Standard
92
93      S_Op_Add,
94      S_Op_And,
95      S_Op_Concat,
96      S_Op_Concatw,
97      S_Op_Concatww,
98      S_Op_Divide,
99      S_Op_Eq,
100      S_Op_Expon,
101      S_Op_Ge,
102      S_Op_Gt,
103      S_Op_Le,
104      S_Op_Lt,
105      S_Op_Mod,
106      S_Op_Multiply,
107      S_Op_Ne,
108      S_Op_Or,
109      S_Op_Rem,
110      S_Op_Subtract,
111      S_Op_Xor,
112
113      --  Unary operators declared in package Standard
114
115      S_Op_Abs,
116      S_Op_Minus,
117      S_Op_Not,
118      S_Op_Plus,
119
120      --  Constants defined in package ASCII (with value in hex).
121      --  First the thirty-two C0 control characters)
122
123      S_NUL,            -- 16#00#
124      S_SOH,            -- 16#01#
125      S_STX,            -- 16#02#
126      S_ETX,            -- 16#03#
127      S_EOT,            -- 16#04#
128      S_ENQ,            -- 16#05#
129      S_ACK,            -- 16#06#
130      S_BEL,            -- 16#07#
131      S_BS,             -- 16#08#
132      S_HT,             -- 16#09#
133      S_LF,             -- 16#0A#
134      S_VT,             -- 16#0B#
135      S_FF,             -- 16#0C#
136      S_CR,             -- 16#0D#
137      S_SO,             -- 16#0E#
138      S_SI,             -- 16#0F#
139      S_DLE,            -- 16#10#
140      S_DC1,            -- 16#11#
141      S_DC2,            -- 16#12#
142      S_DC3,            -- 16#13#
143      S_DC4,            -- 16#14#
144      S_NAK,            -- 16#15#
145      S_SYN,            -- 16#16#
146      S_ETB,            -- 16#17#
147      S_CAN,            -- 16#18#
148      S_EM,             -- 16#19#
149      S_SUB,            -- 16#1A#
150      S_ESC,            -- 16#1B#
151      S_FS,             -- 16#1C#
152      S_GS,             -- 16#1D#
153      S_RS,             -- 16#1E#
154      S_US,             -- 16#1F#
155
156      --  Here are the ones for Colonel Whitaker's O26 keypunch
157
158      S_Exclam,         -- 16#21#
159      S_Quotation,      -- 16#22#
160      S_Sharp,          -- 16#23#
161      S_Dollar,         -- 16#24#
162      S_Percent,        -- 16#25#
163      S_Ampersand,      -- 16#26#
164
165      S_Colon,          -- 16#3A#
166      S_Semicolon,      -- 16#3B#
167
168      S_Query,          -- 16#3F#
169      S_At_Sign,        -- 16#40#
170
171      S_L_Bracket,      -- 16#5B#
172      S_Back_Slash,     -- 16#5C#
173      S_R_Bracket,      -- 16#5D#
174      S_Circumflex,     -- 16#5E#
175      S_Underline,      -- 16#5F#
176      S_Grave,          -- 16#60#
177
178      S_LC_A,           -- 16#61#
179      S_LC_B,           -- 16#62#
180      S_LC_C,           -- 16#63#
181      S_LC_D,           -- 16#64#
182      S_LC_E,           -- 16#65#
183      S_LC_F,           -- 16#66#
184      S_LC_G,           -- 16#67#
185      S_LC_H,           -- 16#68#
186      S_LC_I,           -- 16#69#
187      S_LC_J,           -- 16#6A#
188      S_LC_K,           -- 16#6B#
189      S_LC_L,           -- 16#6C#
190      S_LC_M,           -- 16#6D#
191      S_LC_N,           -- 16#6E#
192      S_LC_O,           -- 16#6F#
193      S_LC_P,           -- 16#70#
194      S_LC_Q,           -- 16#71#
195      S_LC_R,           -- 16#72#
196      S_LC_S,           -- 16#73#
197      S_LC_T,           -- 16#74#
198      S_LC_U,           -- 16#75#
199      S_LC_V,           -- 16#76#
200      S_LC_W,           -- 16#77#
201      S_LC_X,           -- 16#78#
202      S_LC_Y,           -- 16#79#
203      S_LC_Z,           -- 16#7A#
204
205      S_L_BRACE,        -- 16#7B#
206      S_BAR,            -- 16#7C#
207      S_R_BRACE,        -- 16#7D#
208      S_TILDE,          -- 16#7E#
209
210      --  And one more control character, all on its own
211
212      S_DEL);           -- 16#7F#
213
214   subtype S_Types is
215     Standard_Entity_Type range S_Boolean .. S_Duration;
216
217   subtype S_Exceptions is
218     Standard_Entity_Type range S_Constraint_Error .. S_Tasking_Error;
219
220   subtype S_ASCII_Names is
221     Standard_Entity_Type range S_NUL .. S_DEL;
222
223   subtype S_Binary_Ops is
224      Standard_Entity_Type range S_Op_Add .. S_Op_Xor;
225
226   subtype S_Unary_Ops is
227      Standard_Entity_Type range S_Op_Abs .. S_Op_Plus;
228
229   type Standard_Entity_Array_Type is array (Standard_Entity_Type) of Node_Id;
230
231   Standard_Entity : Standard_Entity_Array_Type;
232   --  This array contains pointers to the Defining Identifier nodes for each
233   --  of the visible entities defined in Standard_Entities_Type. The array is
234   --  initialized by the Create_Standard procedure.
235
236   Standard_Package_Node : Node_Id;
237   --  Points to the N_Package_Declaration node for standard. Also
238   --  initialized by the Create_Standard procedure.
239
240   --  The following Entities are the pointers to the Defining Identifier
241   --  nodes for some visible entities defined in Standard_Entities_Type.
242
243   SE : Standard_Entity_Array_Type renames Standard_Entity;
244
245   Standard_Standard            : Entity_Id renames SE (S_Standard);
246
247   Standard_ASCII               : Entity_Id renames SE (S_ASCII);
248   Standard_Character           : Entity_Id renames SE (S_Character);
249   Standard_Wide_Character      : Entity_Id renames SE (S_Wide_Character);
250   Standard_Wide_Wide_Character : Entity_Id renames SE (S_Wide_Wide_Character);
251   Standard_String              : Entity_Id renames SE (S_String);
252   Standard_Wide_String         : Entity_Id renames SE (S_Wide_String);
253   Standard_Wide_Wide_String    : Entity_Id renames SE (S_Wide_Wide_String);
254
255   Standard_Boolean             : Entity_Id renames SE (S_Boolean);
256   Standard_False               : Entity_Id renames SE (S_False);
257   Standard_True                : Entity_Id renames SE (S_True);
258
259   Standard_Duration            : Entity_Id renames SE (S_Duration);
260
261   Standard_Natural             : Entity_Id renames SE (S_Natural);
262   Standard_Positive            : Entity_Id renames SE (S_Positive);
263
264   Standard_Constraint_Error    : Entity_Id renames SE (S_Constraint_Error);
265   Standard_Numeric_Error       : Entity_Id renames SE (S_Numeric_Error);
266   Standard_Program_Error       : Entity_Id renames SE (S_Program_Error);
267   Standard_Storage_Error       : Entity_Id renames SE (S_Storage_Error);
268   Standard_Tasking_Error       : Entity_Id renames SE (S_Tasking_Error);
269
270   Standard_Short_Float         : Entity_Id renames SE (S_Short_Float);
271   Standard_Float               : Entity_Id renames SE (S_Float);
272   Standard_Long_Float          : Entity_Id renames SE (S_Long_Float);
273   Standard_Long_Long_Float     : Entity_Id renames SE (S_Long_Long_Float);
274
275   Standard_Short_Short_Integer : Entity_Id renames SE (S_Short_Short_Integer);
276   Standard_Short_Integer       : Entity_Id renames SE (S_Short_Integer);
277   Standard_Integer             : Entity_Id renames SE (S_Integer);
278   Standard_Long_Integer        : Entity_Id renames SE (S_Long_Integer);
279   Standard_Long_Long_Integer   : Entity_Id renames SE (S_Long_Long_Integer);
280
281   Standard_Op_Add              : Entity_Id renames SE (S_Op_Add);
282   Standard_Op_And              : Entity_Id renames SE (S_Op_And);
283   Standard_Op_Concat           : Entity_Id renames SE (S_Op_Concat);
284   Standard_Op_Concatw          : Entity_Id renames SE (S_Op_Concatw);
285   Standard_Op_Concatww         : Entity_Id renames SE (S_Op_Concatww);
286   Standard_Op_Divide           : Entity_Id renames SE (S_Op_Divide);
287   Standard_Op_Eq               : Entity_Id renames SE (S_Op_Eq);
288   Standard_Op_Expon            : Entity_Id renames SE (S_Op_Expon);
289   Standard_Op_Ge               : Entity_Id renames SE (S_Op_Ge);
290   Standard_Op_Gt               : Entity_Id renames SE (S_Op_Gt);
291   Standard_Op_Le               : Entity_Id renames SE (S_Op_Le);
292   Standard_Op_Lt               : Entity_Id renames SE (S_Op_Lt);
293   Standard_Op_Mod              : Entity_Id renames SE (S_Op_Mod);
294   Standard_Op_Multiply         : Entity_Id renames SE (S_Op_Multiply);
295   Standard_Op_Ne               : Entity_Id renames SE (S_Op_Ne);
296   Standard_Op_Or               : Entity_Id renames SE (S_Op_Or);
297   Standard_Op_Rem              : Entity_Id renames SE (S_Op_Rem);
298   Standard_Op_Subtract         : Entity_Id renames SE (S_Op_Subtract);
299   Standard_Op_Xor              : Entity_Id renames SE (S_Op_Xor);
300
301   Standard_Op_Abs              : Entity_Id renames SE (S_Op_Abs);
302   Standard_Op_Minus            : Entity_Id renames SE (S_Op_Minus);
303   Standard_Op_Not              : Entity_Id renames SE (S_Op_Not);
304   Standard_Op_Plus             : Entity_Id renames SE (S_Op_Plus);
305
306   Last_Standard_Node_Id : Node_Id;
307   --  Highest Node_Id value used by Standard
308
309   Last_Standard_List_Id : List_Id;
310   --  Highest List_Id value used by Standard (including those used by
311   --  normal list headers, element list headers, and list elements)
312
313   Boolean_Literals : array (Boolean) of Entity_Id;
314   --  Entities for the two boolean literals, used by the expander
315
316   -------------------------------------
317   -- Semantic Phase Special Entities --
318   -------------------------------------
319
320   --  The semantic phase needs a number of entities for internal processing
321   --  that are logically at the level of Standard, and hence defined in this
322   --  package. However, they are never visible to a program, and are not
323   --  chained on to the Decls list of Standard. The names of all these
324   --  types are relevant only in certain debugging and error message
325   --  situations. They have names that are suitable for use in such
326   --  error messages (see body for actual names used).
327
328   Standard_Void_Type  : Entity_Id;
329   --  This is a type used to represent the return type of procedures
330
331   Standard_Exception_Type  : Entity_Id;
332   --  This is a type used to represent the Etype of exceptions
333
334   Standard_A_String   : Entity_Id;
335   --  An access to String type used for building elements of tables
336   --  carrying the enumeration literal names.
337
338   Standard_A_Char : Entity_Id;
339   --  Access to character, used as a component of the exception type to denote
340   --  a thin pointer component.
341
342   Standard_Debug_Renaming_Type : Entity_Id;
343   --  A zero-size subtype of Integer, used as the type of variables used to
344   --  provide the debugger with name encodings for renaming declarations.
345
346   Predefined_Float_Types : Elist_Id;
347   --  Entities for predefined floating point types. These are used by
348   --  the semantic phase to select appropriate types for floating point
349   --  declarations. This list is ordered by preference. All types up to
350   --  Long_Long_Float_Type are considered for plain "digits N" declarations,
351   --  while selection of later types requires a range specification and
352   --  possibly other attributes or pragmas.
353
354   --  The entities labeled Any_xxx are used in situations where the full
355   --  characteristics of an entity are not yet known, e.g. Any_Character
356   --  is used to label a character literal before resolution is complete.
357   --  These entities are also used to construct appropriate references in
358   --  error messages ("expecting an integer type").
359
360   Any_Id : Entity_Id;
361   --  Used to represent some unknown identifier. Used to label undefined
362   --  identifier references to prevent cascaded errors.
363
364   Any_Type : Entity_Id;
365   --  Used to represent some unknown type. Any_Type is the type of an
366   --  unresolved operator, and it is the type of a node where a type error
367   --  has been detected. Any_Type plays an important role in avoiding cascaded
368   --  errors, because it is compatible with all other types, and is propagated
369   --  to any expression that has a subexpression of Any_Type. When resolving
370   --  operators, Any_Type is the initial type of the node before any of its
371   --  candidate interpretations has been examined. If after examining all of
372   --  them the type is still Any_Type, the node has no possible interpretation
373   --  and an error can be emitted (and Any_Type will be propagated upwards).
374
375   Any_Access : Entity_Id;
376   --  Used to resolve the overloaded literal NULL
377
378   Any_Array : Entity_Id;
379   --  Used to represent some unknown array type
380
381   Any_Boolean : Entity_Id;
382   --  The context type of conditions in IF and WHILE statements
383
384   Any_Character : Entity_Id;
385   --  Any_Character is used to label character literals, which in general
386   --  will not have an explicit declaration (this is true of the predefined
387   --  character types).
388
389   Any_Composite : Entity_Id;
390   --  The type Any_Composite is used for aggregates before type resolution.
391   --  It is compatible with any array or non-limited record type.
392
393   Any_Discrete : Entity_Id;
394   --  Used to represent some unknown discrete type
395
396   Any_Fixed : Entity_Id;
397   --  Used to represent some unknown fixed-point type
398
399   Any_Integer : Entity_Id;
400   --  Used to represent some unknown integer type
401
402   Any_Modular : Entity_Id;
403   --  Used to represent the result type of a boolean operation on an integer
404   --  literal. The result is not Universal_Integer, because it is only legal
405   --  in a modular context.
406
407   Any_Numeric : Entity_Id;
408   --  Used to represent some unknown numeric type
409
410   Any_Real : Entity_Id;
411   --  Used to represent some unknown real type
412
413   Any_Scalar : Entity_Id;
414   --  Used to represent some unknown scalar type
415
416   Any_String : Entity_Id;
417   --  The type Any_String is used for string literals before type resolution.
418   --  It corresponds to array (Positive range <>) of character where the
419   --  component type is compatible with any character type, not just
420   --  Standard_Character.
421
422   Raise_Type : Entity_Id;
423   --  The type Raise_Type denotes the type of a Raise_Expression. It is
424   --  compatible with all other types, and must eventually resolve to a
425   --  concrete type that is imposed by the context.
426   --
427   --  Historical note: we used to use Any_Type for this purpose, but the
428   --  confusion of meanings (Any_Type normally indicates an error) caused
429   --  difficulties. In particular some needed expansions were skipped since
430   --  the nodes in question looked like they had an error.
431
432   Universal_Integer : Entity_Id;
433   --  Entity for universal integer type. The bounds of this type correspond
434   --  to the largest supported integer type (i.e. Long_Long_Integer). It is
435   --  the type used for runtime calculations in type universal integer.
436
437   Universal_Real : Entity_Id;
438   --  Entity for universal real type. The bounds of this type correspond to
439   --  to the largest supported real type (i.e. Long_Long_Float). It is the
440   --  type used for runtime calculations in type universal real. Note that
441   --  this type is always IEEE format, even if Long_Long_Float is Vax_Float
442   --  (and in that case the bounds don't correspond exactly).
443
444   Universal_Fixed : Entity_Id;
445   --  Entity for universal fixed type. This is a type with  arbitrary
446   --  precision that can only appear in  a context with a specific type.
447   --  Universal_Fixed labels the result of multiplication or division of
448   --  two fixed point numbers, and has no specified bounds (since, unlike
449   --  universal integer and universal real, it is never used for runtime
450   --  calculations).
451
452   Standard_Integer_8  : Entity_Id;
453   Standard_Integer_16 : Entity_Id;
454   Standard_Integer_32 : Entity_Id;
455   Standard_Integer_64 : Entity_Id;
456   --  These are signed integer types with the indicated sizes. Used for the
457   --  underlying implementation types for fixed-point and enumeration types.
458
459   Standard_Short_Short_Unsigned : Entity_Id;
460   Standard_Short_Unsigned       : Entity_Id;
461   Standard_Unsigned             : Entity_Id;
462   Standard_Long_Unsigned        : Entity_Id;
463   Standard_Long_Long_Unsigned   : Entity_Id;
464   --  Unsigned types with same Esize as corresponding signed integer types
465
466   Standard_Unsigned_64 : Entity_Id;
467   --  An unsigned type, mod 2 ** 64, size of 64 bits.
468
469   Abort_Signal : Entity_Id;
470   --  Entity for abort signal exception
471
472   Standard_Op_Rotate_Left            : Entity_Id;
473   Standard_Op_Rotate_Right           : Entity_Id;
474   Standard_Op_Shift_Left             : Entity_Id;
475   Standard_Op_Shift_Right            : Entity_Id;
476   Standard_Op_Shift_Right_Arithmetic : Entity_Id;
477   --  These entities are used for shift operators generated by the expander
478
479   -----------------
480   -- Subprograms --
481   -----------------
482
483   procedure Tree_Read;
484   --  Initializes entity values in this package from the current tree file
485   --  using Tree_IO. Note that Tree_Read includes all the initialization that
486   --  is carried out by Create_Standard.
487
488   procedure Tree_Write;
489   --  Writes out the entity values in this package to the current tree file
490   --  using Tree_IO.
491
492end Stand;
493