OSDN Git Service

New Language: Ada
[pf3gnuchains/gcc-fork.git] / gcc / ada / exp_imgv.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                             E X P _ I M G V                              --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                            $Revision: 1.2 $                              --
10 --                                                                          --
11 --            Copyright (C) 2000 Free Software Foundation, Inc.             --
12 --                                                                          --
13 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
14 -- terms of the  GNU General Public License as published  by the Free Soft- --
15 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
16 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
19 -- for  more details.  You should have  received  a copy of the GNU General --
20 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
21 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
22 -- MA 02111-1307, USA.                                                      --
23 --                                                                          --
24 -- GNAT was originally developed  by the GNAT team at  New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 --                                                                          --
27 ------------------------------------------------------------------------------
28
29 --  Expand routines for Image, Value and Width attributes. These are the
30 --  attributes that make use of enumeration type image tables.
31
32 with Types; use Types;
33
34 package Exp_Imgv is
35
36    procedure Build_Enumeration_Image_Tables (E : Entity_Id; N : Node_Id);
37    --  Build the enumeration image tables for E, which is an enumeration
38    --  base type. The node N is the point in the tree where the resulting
39    --  declarations are to be inserted.
40    --
41    --    The form of the tables generated is as follows:
42    --
43    --      xxxS : string := "chars";
44    --      xxxI : array (0 .. N) of Natural_8/16/32 := (1, n, .., n);
45    --
46    --    Here xxxS is a string obtained by concatenating all the names
47    --    of the enumeration literals in sequence, representing any wide
48    --    characters according to the current wide character encoding
49    --    method, and with all letters forced to upper case.
50    --
51    --    The array xxxI is an array of ones origin indexes to the start
52    --    of each name, with one extra entry at the end, which is the index
53    --    to the character just past the end of the last literal, i.e. it is
54    --    the length of xxxS + 1. The element type is the shortest of the
55    --    possible types that will hold all the values.
56    --
57    --      For example, for the type
58    --
59    --         type x is (hello,'!',goodbye);
60    --
61    --      the generated tables would consist of
62    --
63    --          xxxS : String := "hello'!'goodbye";
64    --          xxxI : array (0 .. 3) of Natural_8 := (1, 6, 9, 16);
65    --
66    --      Here Natural_8 is used since 16 < 2**(8-1)
67    --
68    --    If the entity E needs the tables constructing, the necessary
69    --    declarations are constructed, and the fields Lit_Strings and
70    --    Lit_Indexes of E are set to point to the corresponding entities.
71    --    If no tables are needed (E is not a user defined enumeration
72    --    root type, or pragma Discard_Names is in effect, then the
73    --    declarations are not constructed, and the fields remain Empty.
74
75    procedure Expand_Image_Attribute (N : Node_Id);
76    --  This procedure is called from Exp_Attr to expand an occurrence
77    --  of the attribute Image.
78
79    procedure Expand_Value_Attribute (N : Node_Id);
80    --  This procedure is called from Exp_Attr to expand an occurrence
81    --  of the attribute Value.
82
83    procedure Expand_Width_Attribute (N : Node_Id; Wide : Boolean);
84    --  This procedure is called from Exp_Attr to expand an occurrence of
85    --  the attributes Width (Wide = False) or Wide_Width (Wide = True).
86
87 end Exp_Imgv;