OSDN Git Service

* configure.in (all_headers, all_lib2funcs): Remove.
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-imgenu.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUNTIME COMPONENTS                          --
4 --                                                                          --
5 --                      S Y S T E M . I M G _ E N U M                       --
6 --                                                                          --
7 --                                 B o d y                                  --
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 -- 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.                                      --
30 --                                                                          --
31 -- GNAT was originally developed  by the GNAT team at  New York University. --
32 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
33 --                                                                          --
34 ------------------------------------------------------------------------------
35
36 with Unchecked_Conversion;
37
38 package body System.Img_Enum is
39
40    -------------------------
41    -- Image_Enumeration_8 --
42    -------------------------
43
44    function Image_Enumeration_8
45      (Pos     : Natural;
46       Names   : String;
47       Indexes : System.Address)
48       return    String
49    is
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;
53
54       function To_Index_Table_Ptr is
55         new Unchecked_Conversion (System.Address, Index_Table_Ptr);
56
57       IndexesT : constant Index_Table_Ptr := To_Index_Table_Ptr (Indexes);
58
59       Start : Natural := Natural (IndexesT (Pos));
60       Next  : Natural := Natural (IndexesT (Pos + 1));
61
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.
65
66    begin
67       return Result_Type (Names (Start .. Next - 1));
68    end Image_Enumeration_8;
69
70    --------------------------
71    -- Image_Enumeration_16 --
72    --------------------------
73
74    function Image_Enumeration_16
75      (Pos     : Natural;
76       Names   : String;
77       Indexes : System.Address)
78       return    String
79    is
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;
83
84       function To_Index_Table_Ptr is
85         new Unchecked_Conversion (System.Address, Index_Table_Ptr);
86
87       IndexesT : constant Index_Table_Ptr := To_Index_Table_Ptr (Indexes);
88
89       Start : Natural := Natural (IndexesT (Pos));
90       Next  : Natural := Natural (IndexesT (Pos + 1));
91
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.
95
96    begin
97       return Result_Type (Names (Start .. Next - 1));
98    end Image_Enumeration_16;
99
100    --------------------------
101    -- Image_Enumeration_32 --
102    --------------------------
103
104    function Image_Enumeration_32
105      (Pos     : Natural;
106       Names   : String;
107       Indexes : System.Address)
108       return    String
109    is
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;
113
114       function To_Index_Table_Ptr is
115         new Unchecked_Conversion (System.Address, Index_Table_Ptr);
116
117       IndexesT : constant Index_Table_Ptr := To_Index_Table_Ptr (Indexes);
118
119       Start : Natural := Natural (IndexesT (Pos));
120       Next  : Natural := Natural (IndexesT (Pos + 1));
121
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.
125
126    begin
127       return Result_Type (Names (Start .. Next - 1));
128    end Image_Enumeration_32;
129
130 end System.Img_Enum;