[gcc(refs/users/guojiufu/heads/guojiufu-branch)] [Ada] Ada2020: update Big_Numbers.* specs

Jiu Fu Guo guojiufu@gcc.gnu.org
Sat Jun 13 02:58:45 GMT 2020


https://gcc.gnu.org/g:5fdf7945d9286999d413f1a7232479575ac51bb6

commit 5fdf7945d9286999d413f1a7232479575ac51bb6
Author: Bob Duff <duff@adacore.com>
Date:   Wed Mar 18 17:17:58 2020 -0400

    [Ada] Ada2020: update Big_Numbers.* specs
    
    2020-06-12  Bob Duff  <duff@adacore.com>
    
    gcc/ada/
    
            * libgnat/a-nbnbin.adb, libgnat/a-nbnbin.ads,
            libgnat/a-nbnbin__gmp.adb, libgnat/a-nbnbre.adb,
            libgnat/a-nbnbre.ads: Update Put_Image, and uncomment the aspect
            specification.  Add pragmas Ada_2020.
            * libgnat/a-stouut.ads, libgnat/a-stteou.ads: Add Preelaborate,
            because the Big_Numbers packages have Preelaborate, and now
            depend on these Text_Output packages.

Diff:
---
 gcc/ada/libgnat/a-nbnbin.adb      | 13 ++++++++-----
 gcc/ada/libgnat/a-nbnbin.ads      | 14 +++++++-------
 gcc/ada/libgnat/a-nbnbin__gmp.adb | 13 ++++++++-----
 gcc/ada/libgnat/a-nbnbre.adb      | 13 ++++++++-----
 gcc/ada/libgnat/a-nbnbre.ads      | 15 ++++++++-------
 gcc/ada/libgnat/a-stouut.ads      |  2 +-
 gcc/ada/libgnat/a-stteou.ads      |  2 +-
 7 files changed, 41 insertions(+), 31 deletions(-)

diff --git a/gcc/ada/libgnat/a-nbnbin.adb b/gcc/ada/libgnat/a-nbnbin.adb
index 637e5fba196..fa4ddf08c96 100644
--- a/gcc/ada/libgnat/a-nbnbin.adb
+++ b/gcc/ada/libgnat/a-nbnbin.adb
@@ -29,8 +29,10 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
+pragma Ada_2020;
+
 with Ada.Unchecked_Deallocation;
-with Ada.Characters.Conversions; use Ada.Characters.Conversions;
+with Ada.Strings.Text_Output.Utils;
 
 with Interfaces; use Interfaces;
 
@@ -290,11 +292,12 @@ package body Ada.Numerics.Big_Numbers.Big_Integers is
    -- Put_Image --
    ---------------
 
-   procedure Put_Image
-     (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
-      Arg    : Big_Integer) is
+   procedure Put_Image (S : in out Sink'Class; V : Big_Integer) is
+      --  This is implemented in terms of To_String. It might be more elegant
+      --  and more efficient to do it the other way around, but this is the
+      --  most expedient implementation for now.
    begin
-      Wide_Wide_String'Write (Stream, To_Wide_Wide_String (To_String (Arg)));
+      Strings.Text_Output.Utils.Put_UTF_8 (S, To_String (V));
    end Put_Image;
 
    ---------
diff --git a/gcc/ada/libgnat/a-nbnbin.ads b/gcc/ada/libgnat/a-nbnbin.ads
index 7d1d048fdf9..45a7b6e64eb 100644
--- a/gcc/ada/libgnat/a-nbnbin.ads
+++ b/gcc/ada/libgnat/a-nbnbin.ads
@@ -13,7 +13,9 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with Ada.Streams;
+pragma Ada_2020;
+
+with Ada.Strings.Text_Output; use Ada.Strings.Text_Output;
 
 private with Ada.Finalization;
 private with System;
@@ -24,9 +26,9 @@ private with System;
 package Ada.Numerics.Big_Numbers.Big_Integers
   with Preelaborate
 is
-   type Big_Integer is private;
-   --  with Integer_Literal => From_String,
-   --       Put_Image => Put_Image;
+   type Big_Integer is private with
+   --  Integer_Literal => From_String,
+     Put_Image => Put_Image;
 
    function Is_Valid (Arg : Big_Integer) return Boolean
      with Convention => Intrinsic;
@@ -95,9 +97,7 @@ is
 
    function From_String (Arg : String) return Big_Integer;
 
-   procedure Put_Image
-     (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
-      Arg    : Big_Integer);
+   procedure Put_Image (S : in out Sink'Class; V : Big_Integer);
 
    function "+" (L : Big_Integer) return Big_Integer;
 
diff --git a/gcc/ada/libgnat/a-nbnbin__gmp.adb b/gcc/ada/libgnat/a-nbnbin__gmp.adb
index 5695bc1ff0a..c950389a846 100644
--- a/gcc/ada/libgnat/a-nbnbin__gmp.adb
+++ b/gcc/ada/libgnat/a-nbnbin__gmp.adb
@@ -31,11 +31,13 @@
 
 --  This is the GMP version of this package
 
+pragma Ada_2020;
+
 with Ada.Unchecked_Conversion;
 with Ada.Unchecked_Deallocation;
 with Interfaces.C;               use Interfaces.C;
 with Interfaces.C.Strings;       use Interfaces.C.Strings;
-with Ada.Characters.Conversions; use Ada.Characters.Conversions;
+with Ada.Strings.Text_Output.Utils;
 with Ada.Characters.Handling;    use Ada.Characters.Handling;
 
 package body Ada.Numerics.Big_Numbers.Big_Integers is
@@ -403,11 +405,12 @@ package body Ada.Numerics.Big_Numbers.Big_Integers is
    -- Put_Image --
    ---------------
 
-   procedure Put_Image
-     (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
-      Arg    : Big_Integer) is
+   procedure Put_Image (S : in out Sink'Class; V : Big_Real) is
+      --  This is implemented in terms of To_String. It might be more elegant
+      --  and more efficient to do it the other way around, but this is the
+      --  most expedient implementation for now.
    begin
-      Wide_Wide_String'Write (Stream, To_Wide_Wide_String (To_String (Arg)));
+      Strings.Text_Output.Utils.Put_UTF_8 (S, To_String (V));
    end Put_Image;
 
    ---------
diff --git a/gcc/ada/libgnat/a-nbnbre.adb b/gcc/ada/libgnat/a-nbnbre.adb
index 07a94424df1..11459cafcd9 100644
--- a/gcc/ada/libgnat/a-nbnbre.adb
+++ b/gcc/ada/libgnat/a-nbnbre.adb
@@ -31,7 +31,9 @@
 
 --  This is the default version of this package, based on Big_Integers only.
 
-with Ada.Characters.Conversions; use Ada.Characters.Conversions;
+pragma Ada_2020;
+
+with Ada.Strings.Text_Output.Utils;
 
 package body Ada.Numerics.Big_Numbers.Big_Reals is
 
@@ -399,11 +401,12 @@ package body Ada.Numerics.Big_Numbers.Big_Reals is
    -- Put_Image --
    ---------------
 
-   procedure Put_Image
-     (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
-      Arg    : Big_Real) is
+   procedure Put_Image (S : in out Sink'Class; V : Big_Real) is
+      --  This is implemented in terms of To_String. It might be more elegant
+      --  and more efficient to do it the other way around, but this is the
+      --  most expedient implementation for now.
    begin
-      Wide_Wide_String'Write (Stream, To_Wide_Wide_String (To_String (Arg)));
+      Strings.Text_Output.Utils.Put_UTF_8 (S, To_String (V));
    end Put_Image;
 
    ---------
diff --git a/gcc/ada/libgnat/a-nbnbre.ads b/gcc/ada/libgnat/a-nbnbre.ads
index 2ffc356a1dc..ddfbd7746f7 100644
--- a/gcc/ada/libgnat/a-nbnbre.ads
+++ b/gcc/ada/libgnat/a-nbnbre.ads
@@ -13,8 +13,11 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
+pragma Ada_2020;
+
 with Ada.Numerics.Big_Numbers.Big_Integers;
-with Ada.Streams;
+
+with Ada.Strings.Text_Output; use Ada.Strings.Text_Output;
 
 --  Note that some Ada 2020 aspects are commented out since they are not
 --  supported yet.
@@ -22,9 +25,9 @@ with Ada.Streams;
 package Ada.Numerics.Big_Numbers.Big_Reals
   with Preelaborate
 is
-   type Big_Real is private;
---   with Real_Literal => From_String,
---        Put_Image    => Put_Image;
+   type Big_Real is private with
+--    Real_Literal => From_String,
+     Put_Image    => Put_Image;
 
    function Is_Valid (Arg : Big_Real) return Boolean
      with Convention => Intrinsic;
@@ -105,9 +108,7 @@ is
 
    function From_Quotient_String (Arg : String) return Big_Real;
 
-   procedure Put_Image
-     (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
-      Arg    : Big_Real);
+   procedure Put_Image (S : in out Sink'Class; V : Big_Real);
 
    function "+" (L : Big_Real) return Big_Real;
 
diff --git a/gcc/ada/libgnat/a-stouut.ads b/gcc/ada/libgnat/a-stouut.ads
index c02885e7cb9..d781a0617aa 100644
--- a/gcc/ada/libgnat/a-stouut.ads
+++ b/gcc/ada/libgnat/a-stouut.ads
@@ -31,7 +31,7 @@
 
 pragma Ada_2020;
 
-package Ada.Strings.Text_Output.Utils is
+package Ada.Strings.Text_Output.Utils with Preelaborate is
 
    --  This package provides utility functions on Sink'Class. These are
    --  intended for use by Put_Image attributes, both the default versions
diff --git a/gcc/ada/libgnat/a-stteou.ads b/gcc/ada/libgnat/a-stteou.ads
index 8aaee461378..f4b8966c1fb 100644
--- a/gcc/ada/libgnat/a-stteou.ads
+++ b/gcc/ada/libgnat/a-stteou.ads
@@ -33,7 +33,7 @@ pragma Ada_2020;
 
 with Ada.Strings.UTF_Encoding;
 with Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
-package Ada.Strings.Text_Output is
+package Ada.Strings.Text_Output with Preelaborate is
 
    --  This package provides a "Sink" abstraction, to which characters of type
    --  Character, Wide_Character, and Wide_Wide_Character can be sent. This


More information about the Gcc-cvs mailing list