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 with Ada
.Unchecked_Conversion
;
34 package body System
.Wid_Enum
is
36 -------------------------
37 -- Width_Enumeration_8 --
38 -------------------------
40 function Width_Enumeration_8
42 Indexes
: System
.Address
;
46 pragma Warnings
(Off
, Names
);
50 type Natural_8
is range 0 .. 2 ** 7 - 1;
51 type Index_Table
is array (Natural) of Natural_8
;
52 type Index_Table_Ptr
is access Index_Table
;
54 function To_Index_Table_Ptr
is
55 new Ada
.Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
57 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
62 for J
in Lo
.. Hi
loop
63 W
:= Natural'Max (W
, Natural (IndexesT
(J
+ 1) - IndexesT
(J
)));
67 end Width_Enumeration_8
;
69 --------------------------
70 -- Width_Enumeration_16 --
71 --------------------------
73 function Width_Enumeration_16
75 Indexes
: System
.Address
;
79 pragma Warnings
(Off
, Names
);
83 type Natural_16
is range 0 .. 2 ** 15 - 1;
84 type Index_Table
is array (Natural) of Natural_16
;
85 type Index_Table_Ptr
is access Index_Table
;
87 function To_Index_Table_Ptr
is
88 new Ada
.Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
90 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
95 for J
in Lo
.. Hi
loop
96 W
:= Natural'Max (W
, Natural (IndexesT
(J
+ 1) - IndexesT
(J
)));
100 end Width_Enumeration_16
;
102 --------------------------
103 -- Width_Enumeration_32 --
104 --------------------------
106 function Width_Enumeration_32
108 Indexes
: System
.Address
;
112 pragma Warnings
(Off
, Names
);
116 type Natural_32
is range 0 .. 2 ** 31 - 1;
117 type Index_Table
is array (Natural) of Natural_32
;
118 type Index_Table_Ptr
is access Index_Table
;
120 function To_Index_Table_Ptr
is
121 new Ada
.Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
123 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
128 for J
in Lo
.. Hi
loop
129 W
:= Natural'Max (W
, Natural (IndexesT
(J
+ 1) - IndexesT
(J
)));
133 end Width_Enumeration_32
;