1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- S Y S T E M . W I D _ E N U M --
9 -- Copyright (C) 1992-2009, 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 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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- This package contains the routine used for Enumeration_Type'Width
34 package System
.Wid_Enum
is
37 function Width_Enumeration_8
39 Indexes
: System
.Address
;
42 -- Used to compute Enum'Width where Enum is some enumeration subtype
43 -- other than those defined in package Standard. Names is a string with
44 -- a lower bound of 1 containing the characters of all the enumeration
45 -- literals concatenated together in sequence. Indexes is the address
46 -- of an array of type array (0 .. N) of Natural_8, where N is the
47 -- number of enumeration literals in the type. The Indexes values are
48 -- the starting subscript of each enumeration literal, indexed by Pos
49 -- values, with an extra entry at the end containing Names'Length + 1.
50 -- The reason that Indexes is passed by address is that the actual type
51 -- is created on the fly by the expander.
53 -- Lo and Hi are the Pos values of the lower and upper bounds of the
54 -- subtype. The result is the value of Width, i.e. the maximum value
55 -- of the length of any enumeration literal in the given range.
57 function Width_Enumeration_16
59 Indexes
: System
.Address
;
62 -- Identical to Width_Enumeration_8 except that it handles types
63 -- using array (0 .. Num) of Natural_16 for the Indexes table.
65 function Width_Enumeration_32
67 Indexes
: System
.Address
;
70 -- Identical to Width_Enumeration_8 except that it handles types
71 -- using array (0 .. Num) of Natural_32 for the Indexes table.