1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- S Y S T E M . I M G _ E N U M --
9 -- Copyright (C) 2000-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 ------------------------------------------------------------------------------
34 with Ada
.Unchecked_Conversion
;
36 package body System
.Img_Enum
is
38 -------------------------
39 -- Image_Enumeration_8 --
40 -------------------------
42 function Image_Enumeration_8
45 Indexes
: System
.Address
)
48 type Natural_8
is range 0 .. 2 ** 7 - 1;
49 type Index_Table
is array (Natural) of Natural_8
;
50 type Index_Table_Ptr
is access Index_Table
;
52 function To_Index_Table_Ptr
is
53 new Ada
.Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
55 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
57 Start
: constant Natural := Natural (IndexesT
(Pos
));
58 Next
: constant Natural := Natural (IndexesT
(Pos
+ 1));
60 subtype Result_Type
is String (1 .. Next
- Start
);
61 -- We need this result type to force the result to have the
62 -- required lower bound of 1, rather than the slice bounds.
65 return Result_Type
(Names
(Start
.. Next
- 1));
66 end Image_Enumeration_8
;
68 --------------------------
69 -- Image_Enumeration_16 --
70 --------------------------
72 function Image_Enumeration_16
75 Indexes
: System
.Address
)
78 type Natural_16
is range 0 .. 2 ** 15 - 1;
79 type Index_Table
is array (Natural) of Natural_16
;
80 type Index_Table_Ptr
is access Index_Table
;
82 function To_Index_Table_Ptr
is
83 new Ada
.Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
85 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
87 Start
: constant Natural := Natural (IndexesT
(Pos
));
88 Next
: constant Natural := Natural (IndexesT
(Pos
+ 1));
90 subtype Result_Type
is String (1 .. Next
- Start
);
91 -- We need this result type to force the result to have the
92 -- required lower bound of 1, rather than the slice bounds.
95 return Result_Type
(Names
(Start
.. Next
- 1));
96 end Image_Enumeration_16
;
98 --------------------------
99 -- Image_Enumeration_32 --
100 --------------------------
102 function Image_Enumeration_32
105 Indexes
: System
.Address
)
108 type Natural_32
is range 0 .. 2 ** 31 - 1;
109 type Index_Table
is array (Natural) of Natural_32
;
110 type Index_Table_Ptr
is access Index_Table
;
112 function To_Index_Table_Ptr
is
113 new Ada
.Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
115 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
117 Start
: constant Natural := Natural (IndexesT
(Pos
));
118 Next
: constant Natural := Natural (IndexesT
(Pos
+ 1));
120 subtype Result_Type
is String (1 .. Next
- Start
);
121 -- We need this result type to force the result to have the
122 -- required lower bound of 1, rather than the slice bounds.
125 return Result_Type
(Names
(Start
.. Next
- 1));
126 end Image_Enumeration_32
;