1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 2000 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 -- Extensive contributions were provided by Ada Core Technologies Inc. --
26 ------------------------------------------------------------------------------
28 -- Expand routines for Image, Value and Width attributes. These are the
29 -- attributes that make use of enumeration type image tables.
31 with Types; use Types;
35 procedure Build_Enumeration_Image_Tables (E : Entity_Id; N : Node_Id);
36 -- Build the enumeration image tables for E, which is an enumeration
37 -- base type. The node N is the point in the tree where the resulting
38 -- declarations are to be inserted.
40 -- The form of the tables generated is as follows:
42 -- xxxS : string := "chars";
43 -- xxxI : array (0 .. N) of Natural_8/16/32 := (1, n, .., n);
45 -- Here xxxS is a string obtained by concatenating all the names
46 -- of the enumeration literals in sequence, representing any wide
47 -- characters according to the current wide character encoding
48 -- method, and with all letters forced to upper case.
50 -- The array xxxI is an array of ones origin indexes to the start
51 -- of each name, with one extra entry at the end, which is the index
52 -- to the character just past the end of the last literal, i.e. it is
53 -- the length of xxxS + 1. The element type is the shortest of the
54 -- possible types that will hold all the values.
56 -- For example, for the type
58 -- type x is (hello,'!',goodbye);
60 -- the generated tables would consist of
62 -- xxxS : String := "hello'!'goodbye";
63 -- xxxI : array (0 .. 3) of Natural_8 := (1, 6, 9, 16);
65 -- Here Natural_8 is used since 16 < 2**(8-1)
67 -- If the entity E needs the tables constructing, the necessary
68 -- declarations are constructed, and the fields Lit_Strings and
69 -- Lit_Indexes of E are set to point to the corresponding entities.
70 -- If no tables are needed (E is not a user defined enumeration
71 -- root type, or pragma Discard_Names is in effect, then the
72 -- declarations are not constructed, and the fields remain Empty.
74 procedure Expand_Image_Attribute (N : Node_Id);
75 -- This procedure is called from Exp_Attr to expand an occurrence
76 -- of the attribute Image.
78 procedure Expand_Value_Attribute (N : Node_Id);
79 -- This procedure is called from Exp_Attr to expand an occurrence
80 -- of the attribute Value.
82 procedure Expand_Width_Attribute (N : Node_Id; Wide : Boolean);
83 -- This procedure is called from Exp_Attr to expand an occurrence of
84 -- the attributes Width (Wide = False) or Wide_Width (Wide = True).