OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [ada/] [a-wtinau.adb] - Blame information for rev 513

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT RUN-TIME COMPONENTS                         --
4
--                                                                          --
5
--         A D A . W I D E _ T E X T _ I O . I N T E G E R  _ A U X         --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
10
--                                                                          --
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.                                     --
17
--                                                                          --
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.               --
21
--                                                                          --
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/>.                                          --
26
--                                                                          --
27
-- GNAT was originally developed  by the GNAT team at  New York University. --
28
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29
--                                                                          --
30
------------------------------------------------------------------------------
31
 
32
with Ada.Wide_Text_IO.Generic_Aux; use Ada.Wide_Text_IO.Generic_Aux;
33
 
34
with System.Img_BIU; use System.Img_BIU;
35
with System.Img_Int; use System.Img_Int;
36
with System.Img_LLB; use System.Img_LLB;
37
with System.Img_LLI; use System.Img_LLI;
38
with System.Img_LLW; use System.Img_LLW;
39
with System.Img_WIU; use System.Img_WIU;
40
with System.Val_Int; use System.Val_Int;
41
with System.Val_LLI; use System.Val_LLI;
42
 
43
package body Ada.Wide_Text_IO.Integer_Aux is
44
 
45
   -----------------------
46
   -- Local Subprograms --
47
   -----------------------
48
 
49
   procedure Load_Integer
50
     (File : File_Type;
51
      Buf  : out String;
52
      Ptr  : in out Natural);
53
   --  This is an auxiliary routine that is used to load an possibly signed
54
   --  integer literal value from the input file into Buf, starting at Ptr + 1.
55
   --  On return, Ptr is set to the last character stored.
56
 
57
   -------------
58
   -- Get_Int --
59
   -------------
60
 
61
   procedure Get_Int
62
     (File  : File_Type;
63
      Item  : out Integer;
64
      Width : Field)
65
   is
66
      Buf  : String (1 .. Field'Last);
67
      Ptr  : aliased Integer := 1;
68
      Stop : Integer := 0;
69
 
70
   begin
71
      if Width /= 0 then
72
         Load_Width (File, Width, Buf, Stop);
73
         String_Skip (Buf, Ptr);
74
      else
75
         Load_Integer (File, Buf, Stop);
76
      end if;
77
 
78
      Item := Scan_Integer (Buf, Ptr'Access, Stop);
79
      Check_End_Of_Field (Buf, Stop, Ptr, Width);
80
   end Get_Int;
81
 
82
   -------------
83
   -- Get_LLI --
84
   -------------
85
 
86
   procedure Get_LLI
87
     (File  : File_Type;
88
      Item  : out Long_Long_Integer;
89
      Width : Field)
90
   is
91
      Buf  : String (1 .. Field'Last);
92
      Ptr  : aliased Integer := 1;
93
      Stop : Integer := 0;
94
 
95
   begin
96
      if Width /= 0 then
97
         Load_Width (File, Width, Buf, Stop);
98
         String_Skip (Buf, Ptr);
99
      else
100
         Load_Integer (File, Buf, Stop);
101
      end if;
102
 
103
      Item := Scan_Long_Long_Integer (Buf, Ptr'Access, Stop);
104
      Check_End_Of_Field (Buf, Stop, Ptr, Width);
105
   end Get_LLI;
106
 
107
   --------------
108
   -- Gets_Int --
109
   --------------
110
 
111
   procedure Gets_Int
112
     (From : String;
113
      Item : out Integer;
114
      Last : out Positive)
115
   is
116
      Pos : aliased Integer;
117
 
118
   begin
119
      String_Skip (From, Pos);
120
      Item := Scan_Integer (From, Pos'Access, From'Last);
121
      Last := Pos - 1;
122
 
123
   exception
124
      when Constraint_Error =>
125
         raise Data_Error;
126
   end Gets_Int;
127
 
128
   --------------
129
   -- Gets_LLI --
130
   --------------
131
 
132
   procedure Gets_LLI
133
     (From : String;
134
      Item : out Long_Long_Integer;
135
      Last : out Positive)
136
   is
137
      Pos : aliased Integer;
138
 
139
   begin
140
      String_Skip (From, Pos);
141
      Item := Scan_Long_Long_Integer (From, Pos'Access, From'Last);
142
      Last := Pos - 1;
143
 
144
   exception
145
      when Constraint_Error =>
146
         raise Data_Error;
147
   end Gets_LLI;
148
 
149
   ------------------
150
   -- Load_Integer --
151
   ------------------
152
 
153
   procedure Load_Integer
154
     (File : File_Type;
155
      Buf  : out String;
156
      Ptr  : in out Natural)
157
   is
158
      Hash_Loc : Natural;
159
      Loaded   : Boolean;
160
 
161
   begin
162
      Load_Skip (File);
163
      Load (File, Buf, Ptr, '+', '-');
164
 
165
      Load_Digits (File, Buf, Ptr, Loaded);
166
 
167
      if Loaded then
168
         Load (File, Buf, Ptr, '#', ':', Loaded);
169
 
170
         if Loaded then
171
            Hash_Loc := Ptr;
172
            Load_Extended_Digits (File, Buf, Ptr);
173
            Load (File, Buf, Ptr, Buf (Hash_Loc));
174
         end if;
175
 
176
         Load (File, Buf, Ptr, 'E', 'e', Loaded);
177
 
178
         if Loaded then
179
 
180
            --  Note: it is strange to allow a minus sign, since the syntax
181
            --  does not, but that is what ACVC test CE3704F, case (6) wants.
182
 
183
            Load (File, Buf, Ptr, '+', '-');
184
            Load_Digits (File, Buf, Ptr);
185
         end if;
186
      end if;
187
   end Load_Integer;
188
 
189
   -------------
190
   -- Put_Int --
191
   -------------
192
 
193
   procedure Put_Int
194
     (File  : File_Type;
195
      Item  : Integer;
196
      Width : Field;
197
      Base  : Number_Base)
198
   is
199
      Buf : String (1 .. Field'Last);
200
      Ptr : Natural := 0;
201
 
202
   begin
203
      if Base = 10 and then Width = 0 then
204
         Set_Image_Integer (Item, Buf, Ptr);
205
      elsif Base = 10 then
206
         Set_Image_Width_Integer (Item, Width, Buf, Ptr);
207
      else
208
         Set_Image_Based_Integer (Item, Base, Width, Buf, Ptr);
209
      end if;
210
 
211
      Put_Item (File, Buf (1 .. Ptr));
212
   end Put_Int;
213
 
214
   -------------
215
   -- Put_LLI --
216
   -------------
217
 
218
   procedure Put_LLI
219
     (File  : File_Type;
220
      Item  : Long_Long_Integer;
221
      Width : Field;
222
      Base  : Number_Base)
223
   is
224
      Buf : String (1 .. Field'Last);
225
      Ptr : Natural := 0;
226
 
227
   begin
228
      if Base = 10 and then Width = 0 then
229
         Set_Image_Long_Long_Integer (Item, Buf, Ptr);
230
      elsif Base = 10 then
231
         Set_Image_Width_Long_Long_Integer (Item, Width, Buf, Ptr);
232
      else
233
         Set_Image_Based_Long_Long_Integer (Item, Base, Width, Buf, Ptr);
234
      end if;
235
 
236
      Put_Item (File, Buf (1 .. Ptr));
237
   end Put_LLI;
238
 
239
   --------------
240
   -- Puts_Int --
241
   --------------
242
 
243
   procedure Puts_Int
244
     (To   : out String;
245
      Item : Integer;
246
      Base : Number_Base)
247
   is
248
      Buf : String (1 .. Field'Last);
249
      Ptr : Natural := 0;
250
 
251
   begin
252
      if Base = 10 then
253
         Set_Image_Width_Integer (Item, To'Length, Buf, Ptr);
254
      else
255
         Set_Image_Based_Integer (Item, Base, To'Length, Buf, Ptr);
256
      end if;
257
 
258
      if Ptr > To'Length then
259
         raise Layout_Error;
260
      else
261
         To (To'First .. To'First + Ptr - 1) := Buf (1 .. Ptr);
262
      end if;
263
   end Puts_Int;
264
 
265
   --------------
266
   -- Puts_LLI --
267
   --------------
268
 
269
   procedure Puts_LLI
270
     (To   : out String;
271
      Item : Long_Long_Integer;
272
      Base : Number_Base)
273
   is
274
      Buf : String (1 .. Field'Last);
275
      Ptr : Natural := 0;
276
 
277
   begin
278
      if Base = 10 then
279
         Set_Image_Width_Long_Long_Integer (Item, To'Length, Buf, Ptr);
280
      else
281
         Set_Image_Based_Long_Long_Integer (Item, Base, To'Length, Buf, Ptr);
282
      end if;
283
 
284
      if Ptr > To'Length then
285
         raise Layout_Error;
286
      else
287
         To (To'First .. To'First + Ptr - 1) := Buf (1 .. Ptr);
288
      end if;
289
   end Puts_LLI;
290
 
291
end Ada.Wide_Text_IO.Integer_Aux;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.