public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] AI12-0407: Fixups on Big_Integers and Big_Reals
@ 2021-04-29  8:03 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-04-29  8:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: Arnaud Charlet

[-- Attachment #1: Type: text/plain, Size: 408 bytes --]

This AI updates among other things some declarations in big number
packages.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* libgnat/a-nbnbin.ads (From_Universal_Image): New.
	(Big_Integer): Update definition.
	* libgnat/a-nbnbre.ads, libgnat/a-nbnbre.adb
	(From_Universal_Image): New.
	(From_String): Remove alternate body, replaced by
	From_Universal_Image.
	(Big_Real): Update definition.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2469 bytes --]

diff --git a/gcc/ada/libgnat/a-nbnbin.ads b/gcc/ada/libgnat/a-nbnbin.ads
--- a/gcc/ada/libgnat/a-nbnbin.ads
+++ b/gcc/ada/libgnat/a-nbnbin.ads
@@ -22,7 +22,7 @@ package Ada.Numerics.Big_Numbers.Big_Integers
   with Preelaborate
 is
    type Big_Integer is private
-     with Integer_Literal => From_String,
+     with Integer_Literal => From_Universal_Image,
           Put_Image       => Put_Image;
 
    function Is_Valid (Arg : Big_Integer) return Boolean
@@ -116,6 +116,9 @@ is
    function From_String (Arg : String) return Valid_Big_Integer
      with Global => null;
 
+   function From_Universal_Image (Arg : String) return Valid_Big_Integer
+     renames From_String;
+
    procedure Put_Image (S : in out Sink'Class; V : Big_Integer);
 
    function "+" (L : Valid_Big_Integer) return Valid_Big_Integer


diff --git a/gcc/ada/libgnat/a-nbnbre.adb b/gcc/ada/libgnat/a-nbnbre.adb
--- a/gcc/ada/libgnat/a-nbnbre.adb
+++ b/gcc/ada/libgnat/a-nbnbre.adb
@@ -593,13 +593,6 @@ package body Ada.Numerics.Big_Numbers.Big_Reals is
       end;
    end From_String;
 
-   function From_String
-     (Numerator, Denominator : String) return Valid_Big_Real is
-   begin
-      return Big_Integers.From_String (Numerator) /
-        Big_Integers.From_String (Denominator);
-   end From_String;
-
    --------------------------
    -- From_Quotient_String --
    --------------------------


diff --git a/gcc/ada/libgnat/a-nbnbre.ads b/gcc/ada/libgnat/a-nbnbre.ads
--- a/gcc/ada/libgnat/a-nbnbre.ads
+++ b/gcc/ada/libgnat/a-nbnbre.ads
@@ -21,7 +21,7 @@ package Ada.Numerics.Big_Numbers.Big_Reals
   with Preelaborate
 is
    type Big_Real is private with
-     Real_Literal => From_String,
+     Real_Literal => From_Universal_Image,
      Put_Image    => Put_Image;
 
    function Is_Valid (Arg : Big_Real) return Boolean
@@ -122,8 +122,13 @@ is
 
    function From_String (Arg : String) return Valid_Big_Real
      with Global => null;
-   function From_String (Numerator, Denominator : String) return Valid_Big_Real
-     with Global => null;
+
+   function From_Universal_Image (Arg : String) return Valid_Big_Real
+     renames From_String;
+   function From_Universal_Image (Num, Den : String) return Valid_Big_Real is
+     (Big_Integers.From_Universal_Image (Num) /
+      Big_Integers.From_Universal_Image (Den))
+      with Global => null;
 
    function To_Quotient_String (Arg : Big_Real) return String is
      (Big_Integers.To_String (Numerator (Arg)) & " / "



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-29  8:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29  8:03 [Ada] AI12-0407: Fixups on Big_Integers and Big_Reals Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).