public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Arnaud Charlet <charlet@adacore.com>
Subject: [Ada] AI12-0407: Fixups on Big_Integers and Big_Reals
Date: Thu, 29 Apr 2021 04:03:47 -0400	[thread overview]
Message-ID: <20210429080347.GA133818@adacore.com> (raw)

[-- 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)) & " / "



                 reply	other threads:[~2021-04-29  8:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210429080347.GA133818@adacore.com \
    --to=derodat@adacore.com \
    --cc=charlet@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).