hppa: Revise REG+D address support to allow long displacements before reload
[official-gcc.git] / gcc / ada / libgnat / a-ztcoio.adb
blobf971fe93f3d8f27a528aa6ea46b9413a1d52842a
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . W I D E _ W I D E _ T E X T _ IO . C O M P L E X _ I O --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2023, 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 ------------------------------------------------------------------------------
32 with Ada.Wide_Wide_Text_IO.Complex_Aux;
33 with Ada.Wide_Wide_Text_IO.Float_Aux;
34 with System.Img_Flt; use System.Img_Flt;
35 with System.Img_LFlt; use System.Img_LFlt;
36 with System.Img_LLF; use System.Img_LLF;
37 with System.Val_Flt; use System.Val_Flt;
38 with System.Val_LFlt; use System.Val_LFlt;
39 with System.Val_LLF; use System.Val_LLF;
40 with System.WCh_Con; use System.WCh_Con;
41 with System.WCh_WtS; use System.WCh_WtS;
43 package body Ada.Wide_Wide_Text_IO.Complex_IO is
45 use Complex_Types;
47 package Scalar_Float is new
48 Ada.Wide_Wide_Text_IO.Float_Aux (Float, Scan_Float, Set_Image_Float);
50 package Scalar_Long_Float is new
51 Ada.Wide_Wide_Text_IO.Float_Aux
52 (Long_Float, Scan_Long_Float, Set_Image_Long_Float);
54 package Scalar_Long_Long_Float is new
55 Ada.Wide_Wide_Text_IO.Float_Aux
56 (Long_Long_Float, Scan_Long_Long_Float, Set_Image_Long_Long_Float);
58 package Aux_Float is new
59 Ada.Wide_Wide_Text_IO.Complex_Aux (Float, Scalar_Float);
61 package Aux_Long_Float is new
62 Ada.Wide_Wide_Text_IO.Complex_Aux (Long_Float, Scalar_Long_Float);
64 package Aux_Long_Long_Float is new
65 Ada.Wide_Wide_Text_IO.Complex_Aux
66 (Long_Long_Float, Scalar_Long_Long_Float);
68 -- Throughout this generic body, we distinguish between the case where type
69 -- Float is OK, where type Long_Float is OK and where type Long_Long_Float
70 -- is needed. These boolean constants are used to test for this, such that
71 -- only code for the relevant case is included in the instance.
73 OK_Float : constant Boolean := Real'Base'Digits <= Float'Digits;
75 OK_Long_Float : constant Boolean := Real'Base'Digits <= Long_Float'Digits;
77 ---------
78 -- Get --
79 ---------
81 procedure Get
82 (File : File_Type;
83 Item : out Complex;
84 Width : Field := 0)
86 Real_Item : Real'Base;
87 Imag_Item : Real'Base;
89 begin
90 if OK_Float then
91 Aux_Float.Get (File, Float (Real_Item), Float (Imag_Item), Width);
92 elsif OK_Long_Float then
93 Aux_Long_Float.Get
94 (File, Long_Float (Real_Item), Long_Float (Imag_Item), Width);
95 else
96 Aux_Long_Long_Float.Get
97 (File, Long_Long_Float (Real_Item), Long_Long_Float (Imag_Item),
98 Width);
99 end if;
101 Item := (Real_Item, Imag_Item);
103 exception
104 when Constraint_Error => raise Data_Error;
105 end Get;
107 ---------
108 -- Get --
109 ---------
111 procedure Get
112 (Item : out Complex;
113 Width : Field := 0)
115 begin
116 Get (Current_In, Item, Width);
117 end Get;
119 ---------
120 -- Get --
121 ---------
123 procedure Get
124 (From : Wide_Wide_String;
125 Item : out Complex;
126 Last : out Positive)
128 Real_Item : Real'Base;
129 Imag_Item : Real'Base;
131 S : constant String := Wide_Wide_String_To_String (From, WCEM_Upper);
132 -- String on which we do the actual conversion. Note that the method
133 -- used for wide character encoding is irrelevant, since if there is
134 -- a character outside the Standard.Character range then the call to
135 -- Aux.Gets will raise Data_Error in any case.
137 begin
138 if OK_Float then
139 Aux_Float.Gets (S, Float (Real_Item), Float (Imag_Item), Last);
140 elsif OK_Long_Float then
141 Aux_Long_Float.Gets
142 (S, Long_Float (Real_Item), Long_Float (Imag_Item), Last);
143 else
144 Aux_Long_Long_Float.Gets
145 (S, Long_Long_Float (Real_Item), Long_Long_Float (Imag_Item),
146 Last);
147 end if;
149 Item := (Real_Item, Imag_Item);
151 exception
152 when Data_Error => raise Constraint_Error;
153 end Get;
155 ---------
156 -- Put --
157 ---------
159 procedure Put
160 (File : File_Type;
161 Item : Complex;
162 Fore : Field := Default_Fore;
163 Aft : Field := Default_Aft;
164 Exp : Field := Default_Exp)
166 begin
167 if OK_Float then
168 Aux_Float.Put
169 (File, Float (Re (Item)), Float (Im (Item)), Fore, Aft, Exp);
170 elsif OK_Long_Float then
171 Aux_Long_Float.Put
172 (File, Long_Float (Re (Item)), Long_Float (Im (Item)), Fore, Aft,
173 Exp);
174 else
175 Aux_Long_Long_Float.Put
176 (File, Long_Long_Float (Re (Item)), Long_Long_Float (Im (Item)),
177 Fore, Aft, Exp);
178 end if;
179 end Put;
181 ---------
182 -- Put --
183 ---------
185 procedure Put
186 (Item : Complex;
187 Fore : Field := Default_Fore;
188 Aft : Field := Default_Aft;
189 Exp : Field := Default_Exp)
191 begin
192 Put (Current_Out, Item, Fore, Aft, Exp);
193 end Put;
195 ---------
196 -- Put --
197 ---------
199 procedure Put
200 (To : out Wide_Wide_String;
201 Item : Complex;
202 Aft : Field := Default_Aft;
203 Exp : Field := Default_Exp)
205 S : String (To'First .. To'Last);
207 begin
208 if OK_Float then
209 Aux_Float.Puts (S, Float (Re (Item)), Float (Im (Item)), Aft, Exp);
210 elsif OK_Long_Float then
211 Aux_Long_Float.Puts
212 (S, Long_Float (Re (Item)), Long_Float (Im (Item)), Aft, Exp);
213 else
214 Aux_Long_Long_Float.Puts
215 (S, Long_Long_Float (Re (Item)), Long_Long_Float (Im (Item)),
216 Aft, Exp);
217 end if;
219 for J in S'Range loop
220 To (J) := Wide_Wide_Character'Val (Character'Pos (S (J)));
221 end loop;
222 end Put;
224 end Ada.Wide_Wide_Text_IO.Complex_IO;