1 ------------------------------------------------------------------------------
3 -- GNAT RUNTIME COMPONENTS --
5 -- S Y S T E M . I M G _ E N U M --
11 -- Copyright (C) 2000 Free Software Foundation, Inc. --
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. --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
31 -- GNAT was originally developed by the GNAT team at New York University. --
32 -- Extensive contributions were provided by Ada Core Technologies Inc. --
34 ------------------------------------------------------------------------------
36 with Unchecked_Conversion
;
38 package body System
.Img_Enum
is
40 -------------------------
41 -- Image_Enumeration_8 --
42 -------------------------
44 function Image_Enumeration_8
47 Indexes
: System
.Address
)
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 Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
57 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
59 Start
: Natural := Natural (IndexesT
(Pos
));
60 Next
: Natural := Natural (IndexesT
(Pos
+ 1));
62 subtype Result_Type
is String (1 .. Next
- Start
);
63 -- We need this result type to force the result to have the
64 -- required lower bound of 1, rather than the slice bounds.
67 return Result_Type
(Names
(Start
.. Next
- 1));
68 end Image_Enumeration_8
;
70 --------------------------
71 -- Image_Enumeration_16 --
72 --------------------------
74 function Image_Enumeration_16
77 Indexes
: System
.Address
)
80 type Natural_16
is range 0 .. 2 ** 15 - 1;
81 type Index_Table
is array (Natural) of Natural_16
;
82 type Index_Table_Ptr
is access Index_Table
;
84 function To_Index_Table_Ptr
is
85 new Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
87 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
89 Start
: Natural := Natural (IndexesT
(Pos
));
90 Next
: Natural := Natural (IndexesT
(Pos
+ 1));
92 subtype Result_Type
is String (1 .. Next
- Start
);
93 -- We need this result type to force the result to have the
94 -- required lower bound of 1, rather than the slice bounds.
97 return Result_Type
(Names
(Start
.. Next
- 1));
98 end Image_Enumeration_16
;
100 --------------------------
101 -- Image_Enumeration_32 --
102 --------------------------
104 function Image_Enumeration_32
107 Indexes
: System
.Address
)
110 type Natural_32
is range 0 .. 2 ** 31 - 1;
111 type Index_Table
is array (Natural) of Natural_32
;
112 type Index_Table_Ptr
is access Index_Table
;
114 function To_Index_Table_Ptr
is
115 new Unchecked_Conversion
(System
.Address
, Index_Table_Ptr
);
117 IndexesT
: constant Index_Table_Ptr
:= To_Index_Table_Ptr
(Indexes
);
119 Start
: Natural := Natural (IndexesT
(Pos
));
120 Next
: Natural := Natural (IndexesT
(Pos
+ 1));
122 subtype Result_Type
is String (1 .. Next
- Start
);
123 -- We need this result type to force the result to have the
124 -- required lower bound of 1, rather than the slice bounds.
127 return Result_Type
(Names
(Start
.. Next
- 1));
128 end Image_Enumeration_32
;