]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Ada2020: AI12-0304 Put_Image attrs of lang-def types
authorBob Duff <duff@adacore.com>
Thu, 2 Jul 2020 17:32:40 +0000 (13:32 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 19 Oct 2020 09:53:36 +0000 (05:53 -0400)
gcc/ada/

* exp_put_image.adb (Build_Elementary_Put_Image_Call): Use the
base type to recognize various cases of access types.
* libgnat/a-cbdlli.adb, libgnat/a-cbdlli.ads, libgnat/a-cbhama.adb,
libgnat/a-cbhama.ads, libgnat/a-cbhase.adb, libgnat/a-cbhase.ads,
libgnat/a-cbmutr.adb, libgnat/a-cbmutr.ads, libgnat/a-cborma.adb,
libgnat/a-cborma.ads, libgnat/a-cborse.adb, libgnat/a-cborse.ads,
libgnat/a-cdlili.adb, libgnat/a-cdlili.ads, libgnat/a-cidlli.adb,
libgnat/a-cidlli.ads, libgnat/a-cihama.adb, libgnat/a-cihama.ads,
libgnat/a-cihase.adb, libgnat/a-cihase.ads, libgnat/a-cimutr.adb,
libgnat/a-cimutr.ads, libgnat/a-ciorma.adb, libgnat/a-ciorma.ads,
libgnat/a-ciormu.adb, libgnat/a-ciormu.ads, libgnat/a-ciorse.adb,
libgnat/a-ciorse.ads, libgnat/a-coboho.adb, libgnat/a-coboho.ads,
libgnat/a-cobove.adb, libgnat/a-cobove.ads, libgnat/a-cohama.adb,
libgnat/a-cohama.ads, libgnat/a-cohase.adb, libgnat/a-cohase.ads,
libgnat/a-coinho.adb, libgnat/a-coinho.ads,
libgnat/a-coinho__shared.adb, libgnat/a-coinho__shared.ads,
libgnat/a-coinve.adb, libgnat/a-coinve.ads, libgnat/a-comutr.adb,
libgnat/a-comutr.ads, libgnat/a-coorma.adb, libgnat/a-coorma.ads,
libgnat/a-coormu.adb, libgnat/a-coormu.ads, libgnat/a-coorse.adb,
libgnat/a-coorse.ads, libgnat/a-strunb.adb, libgnat/a-strunb.ads,
libgnat/a-strunb__shared.adb, libgnat/a-strunb__shared.ads:
Implement Put_Image attibute.
* libgnat/a-stteou.ads, libgnat/s-putima.ads,
libgnat/a-stouut.ads, libgnat/a-stoubu.adb: Make
Ada.Strings.Text_Output, Ada.Strings.Text_Output.Utils, and
System.Put_Images Pure, so they can be with'ed by Pure units
that should have Put_Image defined.
* libgnat/a-stouut.adb: Add missing column adjustments, and
remove a redundant one.
* libgnat/s-putima.adb (Put_Arrow): New routine to print an
arrow. Avoids adding a with clause to some containers.

61 files changed:
gcc/ada/exp_put_image.adb
gcc/ada/libgnat/a-cbdlli.adb
gcc/ada/libgnat/a-cbdlli.ads
gcc/ada/libgnat/a-cbhama.adb
gcc/ada/libgnat/a-cbhama.ads
gcc/ada/libgnat/a-cbhase.adb
gcc/ada/libgnat/a-cbhase.ads
gcc/ada/libgnat/a-cbmutr.adb
gcc/ada/libgnat/a-cbmutr.ads
gcc/ada/libgnat/a-cborma.adb
gcc/ada/libgnat/a-cborma.ads
gcc/ada/libgnat/a-cborse.adb
gcc/ada/libgnat/a-cborse.ads
gcc/ada/libgnat/a-cdlili.adb
gcc/ada/libgnat/a-cdlili.ads
gcc/ada/libgnat/a-cidlli.adb
gcc/ada/libgnat/a-cidlli.ads
gcc/ada/libgnat/a-cihama.adb
gcc/ada/libgnat/a-cihama.ads
gcc/ada/libgnat/a-cihase.adb
gcc/ada/libgnat/a-cihase.ads
gcc/ada/libgnat/a-cimutr.adb
gcc/ada/libgnat/a-cimutr.ads
gcc/ada/libgnat/a-ciorma.adb
gcc/ada/libgnat/a-ciorma.ads
gcc/ada/libgnat/a-ciormu.adb
gcc/ada/libgnat/a-ciormu.ads
gcc/ada/libgnat/a-ciorse.adb
gcc/ada/libgnat/a-ciorse.ads
gcc/ada/libgnat/a-coboho.adb
gcc/ada/libgnat/a-coboho.ads
gcc/ada/libgnat/a-cobove.adb
gcc/ada/libgnat/a-cobove.ads
gcc/ada/libgnat/a-cohama.adb
gcc/ada/libgnat/a-cohama.ads
gcc/ada/libgnat/a-cohase.adb
gcc/ada/libgnat/a-cohase.ads
gcc/ada/libgnat/a-coinho.adb
gcc/ada/libgnat/a-coinho.ads
gcc/ada/libgnat/a-coinho__shared.adb
gcc/ada/libgnat/a-coinho__shared.ads
gcc/ada/libgnat/a-coinve.adb
gcc/ada/libgnat/a-coinve.ads
gcc/ada/libgnat/a-comutr.adb
gcc/ada/libgnat/a-comutr.ads
gcc/ada/libgnat/a-coorma.adb
gcc/ada/libgnat/a-coorma.ads
gcc/ada/libgnat/a-coormu.adb
gcc/ada/libgnat/a-coormu.ads
gcc/ada/libgnat/a-coorse.adb
gcc/ada/libgnat/a-coorse.ads
gcc/ada/libgnat/a-stoubu.adb
gcc/ada/libgnat/a-stouut.adb
gcc/ada/libgnat/a-stouut.ads
gcc/ada/libgnat/a-strunb.adb
gcc/ada/libgnat/a-strunb.ads
gcc/ada/libgnat/a-strunb__shared.adb
gcc/ada/libgnat/a-strunb__shared.ads
gcc/ada/libgnat/a-stteou.ads
gcc/ada/libgnat/s-putima.adb
gcc/ada/libgnat/s-putima.ads

index 80b49a70cce7bd3360f23ac7c64e665d1d8ead44..1933bd0597b41545e1021bd96e4d81dca1f939f6 100644 (file)
@@ -314,9 +314,9 @@ package body Exp_Put_Image is
          end if;
 
       elsif Is_Access_Type (U_Type) then
-         if Is_Access_Protected_Subprogram_Type (U_Type) then
+         if Is_Access_Protected_Subprogram_Type (Base_Type (U_Type)) then
             Lib_RE := RE_Put_Image_Access_Prot_Subp;
-         elsif Is_Access_Subprogram_Type (U_Type) then
+         elsif Is_Access_Subprogram_Type (Base_Type (U_Type)) then
             Lib_RE := RE_Put_Image_Access_Subp;
          elsif P_Size = System_Address_Size then
             Lib_RE := RE_Put_Image_Thin_Pointer;
index 8f40d6c0b8d1e60562bf16ef148353f6c7cc7a82..fa8174b5c3ff77401c4054b857d022356c75b813 100644 (file)
@@ -28,6 +28,7 @@
 ------------------------------------------------------------------------------
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Bounded_Doubly_Linked_Lists with
   SPARK_Mode => Off
@@ -1491,6 +1492,31 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : List)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 62624f34e074fd37dfab188583498ed7014eee0e..7f16368a59902208168e70b57bc371e0f841cb1e 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 with Ada.Containers.Helpers;
 private with Ada.Streams;
 private with Ada.Finalization;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type is private;
@@ -279,7 +280,10 @@ private
       Last   : Count_Type := 0;
       Length : Count_Type := 0;
       TC     : aliased Tamper_Counts;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : List);
 
    procedure Read
      (Stream : not null access Root_Stream_Type'Class;
index 1881db212bcd0e52c96d51461b30111eef385e06..b2137c1619b4ed751276726900ddb21f7e73612f 100644 (file)
@@ -38,6 +38,7 @@ with Ada.Containers.Helpers; use Ada.Containers.Helpers;
 with Ada.Containers.Prime_Numbers; use Ada.Containers.Prime_Numbers;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Bounded_Hashed_Maps with
   SPARK_Mode => Off
@@ -885,6 +886,36 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Map)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+
+      procedure Put_Key_Value (Position : Cursor);
+      procedure Put_Key_Value (Position : Cursor) is
+      begin
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Key_Type'Put_Image (S, Key (Position));
+         Put_Arrow (S);
+         Element_Type'Put_Image (S, Element (Position));
+      end Put_Key_Value;
+
+   begin
+      Array_Before (S);
+      Iterate (V, Put_Key_Value'Access);
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index d1225e090a3e613242978383778ef5382e215fb1..9a1aee97c4f6f222ad271fb0f0caf9326b6498f9 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 private with Ada.Containers.Hash_Tables;
 private with Ada.Streams;
 private with Ada.Finalization;
+private with Ada.Strings.Text_Output;
 
 generic
    type Key_Type is private;
@@ -342,7 +343,11 @@ private
      new Hash_Tables.Generic_Bounded_Hash_Table_Types (Node_Type);
 
    type Map (Capacity : Count_Type; Modulus : Hash_Type) is
-      new HT_Types.Hash_Table_Type (Capacity, Modulus) with null record;
+      new HT_Types.Hash_Table_Type (Capacity, Modulus)
+      with null record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Map);
 
    use HT_Types, HT_Types.Implementation;
    use Ada.Streams;
index 09505535e5eeee784689e155b4a523f28581ff52..db61f77f1cdabbef24597e25bceed3f9be82183d 100644 (file)
@@ -38,6 +38,7 @@ with Ada.Containers.Helpers; use Ada.Containers.Helpers;
 with Ada.Containers.Prime_Numbers; use Ada.Containers.Prime_Numbers;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Bounded_Hashed_Sets with
   SPARK_Mode => Off
@@ -1108,6 +1109,31 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 2d8a7ee56f68e1eee2068d9d4cf8f2c9466cff79..70a311931d5ebb96cc6c7a8517bcf588e0d8eabc 100644 (file)
@@ -37,6 +37,7 @@ private with Ada.Containers.Hash_Tables;
 with Ada.Containers.Helpers;
 private with Ada.Streams;
 private with Ada.Finalization;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type is private;
@@ -500,7 +501,11 @@ private
      new Hash_Tables.Generic_Bounded_Hash_Table_Types (Node_Type);
 
    type Set (Capacity : Count_Type; Modulus : Hash_Type) is
-     new HT_Types.Hash_Table_Type (Capacity, Modulus) with null record;
+     new HT_Types.Hash_Table_Type (Capacity, Modulus)
+      with null record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set);
 
    use HT_Types, HT_Types.Implementation;
    use Ada.Streams;
index 58db8cf4471d0e9bd044d6494f4a4db953d6041e..3b25d20ebb5a5997e325673d7b4574e57c27cf9e 100644 (file)
@@ -29,6 +29,7 @@
 
 with Ada.Finalization;
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Bounded_Multiway_Trees with
   SPARK_Mode => Off
@@ -2322,6 +2323,49 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Tree)
+   is
+      use System.Put_Images;
+
+      procedure Rec (Position : Cursor);
+      --  Recursive routine operating on cursors
+
+      procedure Rec (Position : Cursor) is
+         First_Time : Boolean := True;
+      begin
+         Array_Before (S);
+
+         for X in Iterate_Children (V, Position) loop
+            if First_Time then
+               First_Time := False;
+            else
+               Array_Between (S);
+            end if;
+
+            Element_Type'Put_Image (S, Element (X));
+            if Child_Count (X) > 0 then
+               Simple_Array_Between (S);
+               Rec (X);
+            end if;
+         end loop;
+
+         Array_After (S);
+      end Rec;
+
+   begin
+      if First_Child (Root (V)) = No_Element then
+         Array_Before (S);
+         Array_After (S);
+      else
+         Rec (First_Child (Root (V)));
+      end if;
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 653407bfcdc60507f98320470155613635271d64..82b3d60c9778ee522a583fed131528b1752b704c 100644 (file)
@@ -35,6 +35,7 @@ with Ada.Iterator_Interfaces;
 
 with Ada.Containers.Helpers;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type is private;
@@ -307,7 +308,10 @@ private
       Free     : Count_Type'Base := No_Node;
       TC       : aliased Tamper_Counts;
       Count    : Count_Type := 0;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Tree);
 
    procedure Write
      (Stream    : not null access Root_Stream_Type'Class;
index 6f59471cb7c2a06b33cfe6bd1a26e4c96b9874df..23e21dac073c25828fe2b96a905826d7b2481360 100644 (file)
@@ -38,6 +38,7 @@ pragma Elaborate_All
   (Ada.Containers.Red_Black_Trees.Generic_Bounded_Keys);
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Bounded_Ordered_Maps with
   SPARK_Mode => Off
@@ -1289,6 +1290,36 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Map)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+
+      procedure Put_Key_Value (Position : Cursor);
+      procedure Put_Key_Value (Position : Cursor) is
+      begin
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Key_Type'Put_Image (S, Key (Position));
+         Put_Arrow (S);
+         Element_Type'Put_Image (S, Element (Position));
+      end Put_Key_Value;
+
+   begin
+      Array_Before (S);
+      Iterate (V, Put_Key_Value'Access);
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 6dac0504e9cbd14df9a18ef14a5ecbafb85b46e4..b10b0d05edb59bd7b9b192e2721851dacfb49900 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 private with Ada.Containers.Red_Black_Trees;
 private with Ada.Streams;
 private with Ada.Finalization;
+private with Ada.Strings.Text_Output;
 
 generic
    type Key_Type is private;
@@ -250,7 +251,11 @@ private
      new Red_Black_Trees.Generic_Bounded_Tree_Types (Node_Type);
 
    type Map (Capacity : Count_Type) is
-     new Tree_Types.Tree_Type (Capacity) with null record;
+     new Tree_Types.Tree_Type (Capacity)
+      with null record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Map);
 
    use Red_Black_Trees;
    use Tree_Types, Tree_Types.Implementation;
index af4f87f157d58538899f0d086097a0f9b0bab193..2daad8e17da51fb297d7c88e7ee826b48f5f6819 100644 (file)
@@ -41,6 +41,7 @@ pragma Elaborate_All
   (Ada.Containers.Red_Black_Trees.Generic_Bounded_Set_Operations);
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Bounded_Ordered_Sets with
   SPARK_Mode => Off
@@ -1628,6 +1629,31 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 1b711c413704d5571acedc4a7d10c1a99c5ca705..90e68e3c4d02c9816780d2f757481365017da81a 100644 (file)
@@ -37,6 +37,7 @@ with Ada.Containers.Helpers;
 private with Ada.Containers.Red_Black_Trees;
 private with Ada.Streams;
 private with Ada.Finalization;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type is private;
@@ -338,7 +339,11 @@ private
      new Red_Black_Trees.Generic_Bounded_Tree_Types (Node_Type);
 
    type Set (Capacity : Count_Type) is
-     new Tree_Types.Tree_Type (Capacity) with null record;
+     new Tree_Types.Tree_Type (Capacity)
+      with null record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set);
 
    use Tree_Types, Tree_Types.Implementation;
    use Ada.Finalization;
index 0e25418368bfd6fb51cbe095f258e2e9840d40bf..f07190ec2f43564d9e6262c82f4bf7c641e77bb7 100644 (file)
@@ -30,6 +30,7 @@
 with Ada.Unchecked_Deallocation;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Doubly_Linked_Lists with
   SPARK_Mode => Off
@@ -1267,6 +1268,31 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : List)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 6d369c06652e3a39e3966e9d9181b706486c3461..dc52564961929e6d97d1e47ea47df7f4f113d3ff 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 with Ada.Containers.Helpers;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type is private;
@@ -281,7 +282,10 @@ private
         Last   : Node_Access := null;
         Length : Count_Type := 0;
         TC     : aliased Tamper_Counts;
-     end record;
+     end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : List);
 
    overriding procedure Adjust (Container : in out List);
 
index 0898db8c401444d6d6408c5fe00b8bb8bf581004..ea962c32cf6f8a95f960d478484088c80b85f3aa 100644 (file)
@@ -30,6 +30,7 @@
 with Ada.Unchecked_Deallocation;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Indefinite_Doubly_Linked_Lists with
   SPARK_Mode => Off
@@ -1297,6 +1298,31 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : List)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index e9220a6e257cd7e3bd2efcbd9c4417d28fd80772..fe9c7e10471ddbe94b15d6cdee8e018433272c3b 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 with Ada.Containers.Helpers;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type (<>) is private;
@@ -269,7 +270,10 @@ private
         Last   : Node_Access := null;
         Length : Count_Type := 0;
         TC     : aliased Tamper_Counts;
-     end record;
+     end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : List);
 
    overriding procedure Adjust (Container : in out List);
 
index 9f5aed7b02be81c70394df051ee9178979928fa8..2b4499c6eb5cd3ab5f7108bd4ad092b0776c20e8 100644 (file)
@@ -38,6 +38,7 @@ with Ada.Containers.Helpers; use Ada.Containers.Helpers;
 with Ada.Unchecked_Deallocation;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Indefinite_Hashed_Maps with
   SPARK_Mode => Off
@@ -952,6 +953,36 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Map)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+
+      procedure Put_Key_Value (Position : Cursor);
+      procedure Put_Key_Value (Position : Cursor) is
+      begin
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Key_Type'Put_Image (S, Key (Position));
+         Put_Arrow (S);
+         Element_Type'Put_Image (S, Element (Position));
+      end Put_Key_Value;
+
+   begin
+      Array_Before (S);
+      Iterate (V, Put_Key_Value'Access);
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index d29cbb402f74bf5580e7c2aed73c87f6b20da82c..f92331415d2de27d68380db6052a7ad0eb87fa27 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 private with Ada.Containers.Hash_Tables;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Key_Type (<>) is private;
@@ -330,7 +331,10 @@ private
 
    type Map is new Ada.Finalization.Controlled with record
       HT : HT_Types.Hash_Table_Type;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Map);
 
    overriding procedure Adjust   (Container : in out Map);
 
index b91532dc9741e866148b020a415d616e88e35c5d..dc0cfed58f81cf60f6ead7039421d210d03a369c 100644 (file)
@@ -40,6 +40,7 @@ with Ada.Containers.Helpers; use Ada.Containers.Helpers;
 with Ada.Containers.Prime_Numbers;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Indefinite_Hashed_Sets with
   SPARK_Mode => Off
@@ -1264,6 +1265,31 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 8af0b7d19e053d395c306ce2f4a9394bbaccdbb4..965071cc39d0369059ea4a52e13e79ff4931b51b 100644 (file)
@@ -37,6 +37,7 @@ private with Ada.Containers.Hash_Tables;
 with Ada.Containers.Helpers;
 private with Ada.Streams;
 private with Ada.Finalization;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type (<>) is private;
@@ -494,7 +495,10 @@ private
 
    type Set is new Ada.Finalization.Controlled with record
       HT : HT_Types.Hash_Table_Type;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set);
 
    overriding procedure Adjust (Container : in out Set);
 
index 293275ae5a99c1d7bcbccb39461eb013098efcc3..b358aad3366308de236338d2a33dba1b98c7cb82 100644 (file)
@@ -30,6 +30,7 @@
 with Ada.Unchecked_Deallocation;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Indefinite_Multiway_Trees with
   SPARK_Mode => Off
@@ -1875,6 +1876,49 @@ is
       Process (Position.Node.Element.all);
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Tree)
+   is
+      use System.Put_Images;
+
+      procedure Rec (Position : Cursor);
+      --  Recursive routine operating on cursors
+
+      procedure Rec (Position : Cursor) is
+         First_Time : Boolean := True;
+      begin
+         Array_Before (S);
+
+         for X in Iterate_Children (V, Position) loop
+            if First_Time then
+               First_Time := False;
+            else
+               Array_Between (S);
+            end if;
+
+            Element_Type'Put_Image (S, Element (X));
+            if Child_Count (X) > 0 then
+               Simple_Array_Between (S);
+               Rec (X);
+            end if;
+         end loop;
+
+         Array_After (S);
+      end Rec;
+
+   begin
+      if First_Child (Root (V)) = No_Element then
+         Array_Before (S);
+         Array_After (S);
+      else
+         Rec (First_Child (Root (V)));
+      end if;
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 474a1b57aa96207adaba23c43773e3314987f9f1..9e03eb9f79b229a5e8badeb3d2ba456ee3ae4fb7 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 with Ada.Containers.Helpers;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type (<>) is private;
@@ -348,7 +349,10 @@ private
       Root  : aliased Tree_Node_Type;
       TC    : aliased Tamper_Counts;
       Count : Count_Type := 0;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Tree);
 
    overriding procedure Adjust (Container : in out Tree);
 
index 86cd01f09c8b00b7ecb2ef57a34fd27d17eb3ea5..7cfe07d0eb911fe7147a2aa4c8c9dc1c5239e3cb 100644 (file)
@@ -38,6 +38,7 @@ with Ada.Containers.Red_Black_Trees.Generic_Keys;
 pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Keys);
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Indefinite_Ordered_Maps with
   SPARK_Mode => Off
@@ -1291,6 +1292,36 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Map)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+
+      procedure Put_Key_Value (Position : Cursor);
+      procedure Put_Key_Value (Position : Cursor) is
+      begin
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Key_Type'Put_Image (S, Key (Position));
+         Put_Arrow (S);
+         Element_Type'Put_Image (S, Element (Position));
+      end Put_Key_Value;
+
+   begin
+      Array_Before (S);
+      Iterate (V, Put_Key_Value'Access);
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 909ab7af9417df0c9cbdfe33e90aef9470a1abb7..dbc59488d2596a9dc9946a8d5d894172d1c795fb 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 private with Ada.Containers.Red_Black_Trees;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Key_Type (<>) is private;
@@ -258,7 +259,10 @@ private
 
    type Map is new Ada.Finalization.Controlled with record
       Tree : Tree_Types.Tree_Type;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Map);
 
    overriding procedure Adjust (Container : in out Map);
 
index 110d734db5914047919a3fee4fcc02253aa6e559..c3672f4b17f406ca4077efec669a4baec9dba0d2 100644 (file)
@@ -39,6 +39,7 @@ with Ada.Containers.Red_Black_Trees.Generic_Set_Operations;
 pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Set_Operations);
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Indefinite_Ordered_Multisets with
   SPARK_Mode => Off
@@ -1657,6 +1658,31 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 474ccc75e0d3595b366aa277c5a3dbb312bad7aa..5667e2c52ebd4faeb0e19651b4763dbdb647e5be 100644 (file)
@@ -35,6 +35,7 @@
 private with Ada.Containers.Red_Black_Trees;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 with Ada.Iterator_Interfaces;
 
 generic
@@ -468,7 +469,10 @@ private
 
    type Set is new Ada.Finalization.Controlled with record
       Tree : Tree_Types.Tree_Type;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set);
 
    overriding procedure Adjust (Container : in out Set);
 
index 772061d886c22123f3441c778ab0351560d40301..df56e481dd04028fda8096ffe1446685ba7a1326 100644 (file)
@@ -41,6 +41,7 @@ pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Set_Operations);
 with Ada.Unchecked_Deallocation;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Indefinite_Ordered_Sets with
   SPARK_Mode => Off
@@ -1722,6 +1723,31 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 84c680ac7136fc128bd2f8c859d800eeaf0f231f..b75a7a34cf3314679d062ce9dc6f7ebb53b5f0e2 100644 (file)
@@ -37,6 +37,7 @@ with Ada.Containers.Helpers;
 private with Ada.Containers.Red_Black_Trees;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type (<>) is private;
@@ -359,7 +360,10 @@ private
 
    type Set is new Ada.Finalization.Controlled with record
       Tree : Tree_Types.Tree_Type;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set);
 
    overriding procedure Adjust (Container : in out Set);
 
index eefb1064b8d157bd2a39b9dc0a302c02739a4562..5d441634aba618ffaf01f7cee7cf19d757139f41 100644 (file)
@@ -26,6 +26,7 @@
 ------------------------------------------------------------------------------
 
 with Unchecked_Conversion;
+with System.Put_Images;
 
 package body Ada.Containers.Bounded_Holders is
 
@@ -64,6 +65,20 @@ package body Ada.Containers.Bounded_Holders is
       return Get (Left) = Get (Right);
    end "=";
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Holder)
+   is
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+      Element_Type'Put_Image (S, Get (V));
+      Array_After (S);
+   end Put_Image;
+
    ---------
    -- Get --
    ---------
index cb24c8904e28a94455a8ffac1fd8292159801737..024e6a66a8184c953b97906176e53568a8154206 100644 (file)
@@ -30,6 +30,7 @@
 ------------------------------------------------------------------------------
 
 private with System;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type (<>) is private;
@@ -93,11 +94,14 @@ private
    type Holder is record
       Data : Storage_Array (1 .. Max_Size_In_Storage_Elements);
    end record
-     with Alignment => Standard'Maximum_Alignment;
+     with Alignment => Standard'Maximum_Alignment, Put_Image => Put_Image;
    --  We would like to say "Alignment => Element_Type'Alignment", but that
    --  is illegal because it's not static, so we use the maximum possible
    --  (default) alignment instead.
 
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Holder);
+
    type Element_Access is access all Element_Type;
    pragma Assert (Element_Access'Size = Standard'Address_Size,
                   "cannot instantiate with an array type");
index 410686b42bb8270e8a9eca179c4816c257a73c79..ba105a2a59f6016b0bd95103bc989ebb81fc91a2 100644 (file)
@@ -30,6 +30,7 @@
 with Ada.Containers.Generic_Array_Sort;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Bounded_Vectors is
 
@@ -2118,6 +2119,31 @@ package body Ada.Containers.Bounded_Vectors is
       Query_Element (Position.Container.all, Position.Index, Process);
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Vector)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 265fd52675a64018f782c45d2fc25b3e42a1e4f1..4c8905cf51e6d2ae4bd95b5ef4da9d4402313585 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 with Ada.Containers.Helpers;
 private with Ada.Streams;
 private with Ada.Finalization;
+private with Ada.Strings.Text_Output;
 
 generic
    type Index_Type is range <>;
@@ -392,7 +393,10 @@ private
       Elements : Elements_Array (1 .. Capacity) := (others => <>);
       Last     : Extended_Index := No_Index;
       TC       : aliased Tamper_Counts;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Vector);
 
    procedure Write
      (Stream    : not null access Root_Stream_Type'Class;
index 7f2d8e16ab5361661eafa5d1f9dca33ca5cbb735..44bf3d5b72982cc576d8afdeb3cb3c078cd54714 100644 (file)
@@ -38,6 +38,7 @@ pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Keys);
 with Ada.Containers.Helpers; use Ada.Containers.Helpers;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Hashed_Maps with
   SPARK_Mode => Off
@@ -870,6 +871,36 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Map)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+
+      procedure Put_Key_Value (Position : Cursor);
+      procedure Put_Key_Value (Position : Cursor) is
+      begin
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Key_Type'Put_Image (S, Key (Position));
+         Put_Arrow (S);
+         Element_Type'Put_Image (S, Element (Position));
+      end Put_Key_Value;
+
+   begin
+      Array_Before (S);
+      Iterate (V, Put_Key_Value'Access);
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 4c87aeae29436412a07f884d7ee77e8fba86cca3..cb5d2c5bf3e2b9195788539ae6d8407c5c74d1cf 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 private with Ada.Containers.Hash_Tables;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 --  The language-defined generic package Containers.Hashed_Maps provides
 --  private types Map and Cursor, and a set of operations for each type. A map
@@ -425,7 +426,10 @@ private
 
    type Map is new Ada.Finalization.Controlled with record
       HT : HT_Types.Hash_Table_Type;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Map);
 
    overriding procedure Adjust (Container : in out Map);
 
index bc4e53f68f3108a836694eb8fee35b080a6c4260..4de3dacf714f882d44962fa51281a1b788e6d56e 100644 (file)
@@ -40,6 +40,7 @@ with Ada.Containers.Helpers; use Ada.Containers.Helpers;
 with Ada.Containers.Prime_Numbers;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Hashed_Sets with
   SPARK_Mode => Off
@@ -1149,6 +1150,31 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 38d079fbbcc6909cb8ac3988bff9baa883cedead..451f592ce47b263c327f591fcc847809dba89294 100644 (file)
@@ -37,6 +37,7 @@ private with Ada.Containers.Hash_Tables;
 with Ada.Containers.Helpers;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type is private;
@@ -504,7 +505,10 @@ private
 
    type Set is new Ada.Finalization.Controlled with record
       HT : HT_Types.Hash_Table_Type;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set);
 
    overriding procedure Adjust (Container : in out Set);
 
index c5da9432dd994911ea044ceaebd33f59ebe883aa..6c99c8d2fb116dd3075f24f5098d44fd3c69ffca 100644 (file)
@@ -26,6 +26,7 @@
 ------------------------------------------------------------------------------
 
 with Ada.Unchecked_Deallocation;
+with System.Put_Images;
 
 package body Ada.Containers.Indefinite_Holders is
 
@@ -229,6 +230,22 @@ package body Ada.Containers.Indefinite_Holders is
       B := B - 1;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Holder)
+   is
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+      if not Is_Empty (V) then
+         Element_Type'Put_Image (S, Element (V));
+      end if;
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index bf6165e954d5b110199940463cd3053753e241b6..372f0693506bf46e03b9990e4023ff6f842e18f9 100644 (file)
@@ -31,6 +31,7 @@
 
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type (<>) is private;
@@ -115,7 +116,11 @@ private
    type Holder is new Ada.Finalization.Controlled with record
       Element : Element_Access;
       Busy    : Natural := 0;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Holder);
+
    for Holder'Read use Read;
    for Holder'Write use Write;
 
index 43f5d52f7db5d59a132de64a74454a410c9416db..16bb7081e33ea4ece78da15393f3736e197c141a 100644 (file)
@@ -33,6 +33,7 @@
 --  internal shared object and element).
 
 with Ada.Unchecked_Deallocation;
+with System.Put_Images;
 
 package body Ada.Containers.Indefinite_Holders is
 
@@ -319,6 +320,22 @@ package body Ada.Containers.Indefinite_Holders is
       B := B - 1;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Holder)
+   is
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+      if not Is_Empty (V) then
+         Element_Type'Put_Image (S, Element (V));
+      end if;
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 0345b5ee0db3d3aeec999a745b91cff3389bf688..e7bea85b4ac0dca198fb6f433fad61269fcf8dd6 100644 (file)
@@ -36,6 +36,7 @@ private with Ada.Finalization;
 private with Ada.Streams;
 
 private with System.Atomic_Counters;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type (<>) is private;
@@ -130,7 +131,11 @@ private
    type Holder is new Ada.Finalization.Controlled with record
       Reference : Shared_Holder_Access;
       Busy      : Natural := 0;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Holder);
+
    for Holder'Read use Read;
    for Holder'Write use Write;
 
index 19a6659e8947410016ede234dc8ee40fd5aa9299..5999a2c2d308bec8e9afc9a9a9d8837383d4bfdd 100644 (file)
@@ -31,6 +31,7 @@ with Ada.Containers.Generic_Array_Sort;
 with Ada.Unchecked_Deallocation;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Indefinite_Vectors with
   SPARK_Mode => Off
@@ -2649,6 +2650,31 @@ is
       end if;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Vector)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 2220d939678f5c5366ef75bd5ffb9c916bcf9908..1f15722319a4cdf55b4d26d21a7c6b7a95b79f66 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 with Ada.Containers.Helpers;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Index_Type is range <>;
@@ -393,7 +394,10 @@ private
       Elements : Elements_Access := null;
       Last     : Extended_Index := No_Index;
       TC       : aliased Tamper_Counts;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Vector);
 
    overriding procedure Adjust (Container : in out Vector);
    overriding procedure Finalize (Container : in out Vector);
index 76ff751561621a9e9654623707ef4f83843e42f9..78f93f02b9d6aafa326e0a515933d7e63d8d0442 100644 (file)
@@ -31,6 +31,7 @@ with Ada.Unchecked_Conversion;
 with Ada.Unchecked_Deallocation;
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Multiway_Trees with
   SPARK_Mode => Off
@@ -1858,6 +1859,49 @@ is
       Process (Position.Node.Element);
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Tree)
+   is
+      use System.Put_Images;
+
+      procedure Rec (Position : Cursor);
+      --  Recursive routine operating on cursors
+
+      procedure Rec (Position : Cursor) is
+         First_Time : Boolean := True;
+      begin
+         Array_Before (S);
+
+         for X in Iterate_Children (V, Position) loop
+            if First_Time then
+               First_Time := False;
+            else
+               Array_Between (S);
+            end if;
+
+            Element_Type'Put_Image (S, Element (X));
+            if Child_Count (X) > 0 then
+               Simple_Array_Between (S);
+               Rec (X);
+            end if;
+         end loop;
+
+         Array_After (S);
+      end Rec;
+
+   begin
+      if First_Child (Root (V)) = No_Element then
+         Array_Before (S);
+         Array_After (S);
+      else
+         Rec (First_Child (Root (V)));
+      end if;
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 46934a113c04ab05c9fba3ab69efa55bb2fcc7c6..a1f51affbf42376c0e505df61eb2f8808f4ba333 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 with Ada.Containers.Helpers;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type is private;
@@ -400,7 +401,10 @@ private
       Root  : aliased Root_Node_Type;
       TC    : aliased Tamper_Counts;
       Count : Count_Type := 0;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Tree);
 
    overriding procedure Adjust (Container : in out Tree);
 
index 4106d58ff4ed8b1ae6b9115cb9a21cd69d21c16f..15d08f57b6036cb586f9972483435e2688ee81a8 100644 (file)
@@ -38,6 +38,7 @@ with Ada.Containers.Red_Black_Trees.Generic_Keys;
 pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Keys);
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Ordered_Maps with
   SPARK_Mode => Off
@@ -1214,6 +1215,36 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Map)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+
+      procedure Put_Key_Value (Position : Cursor);
+      procedure Put_Key_Value (Position : Cursor) is
+      begin
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Key_Type'Put_Image (S, Key (Position));
+         Put_Arrow (S);
+         Element_Type'Put_Image (S, Element (Position));
+      end Put_Key_Value;
+
+   begin
+      Array_Before (S);
+      Iterate (V, Put_Key_Value'Access);
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 524aa048fc0d59f15af98862c52739676cb1e098..f80836e96eac84969264633944b2006264dc4789 100644 (file)
@@ -36,6 +36,7 @@ with Ada.Iterator_Interfaces;
 private with Ada.Containers.Red_Black_Trees;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Key_Type is private;
@@ -259,7 +260,10 @@ private
 
    type Map is new Ada.Finalization.Controlled with record
       Tree : Tree_Types.Tree_Type;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Map);
 
    overriding procedure Adjust (Container : in out Map);
 
index c02a9f1540e666655959cafa78ec34e568bb4deb..c7db472e50baee8536155cc223df78a85a538130 100644 (file)
@@ -39,6 +39,7 @@ with Ada.Containers.Red_Black_Trees.Generic_Set_Operations;
 pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Set_Operations);
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Ordered_Multisets with
   SPARK_Mode => Off
@@ -1565,6 +1566,31 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index 9c6c3ae8d982c6075590fdf9e588a73712f6cd80..95aec73ea2646003205ddc32715b7171015c85ef 100644 (file)
@@ -34,6 +34,7 @@
 private with Ada.Containers.Red_Black_Trees;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 with Ada.Iterator_Interfaces;
 
 generic
@@ -472,7 +473,10 @@ private
 
    type Set is new Ada.Finalization.Controlled with record
       Tree : Tree_Types.Tree_Type;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set);
 
    overriding procedure Adjust (Container : in out Set);
 
index 15b59dd4bc55cef271e0c7b0d96042553539a0b9..8a648e889e118e14b1dce4818c622fcc4d703b22 100644 (file)
@@ -41,6 +41,7 @@ with Ada.Containers.Red_Black_Trees.Generic_Set_Operations;
 pragma Elaborate_All (Ada.Containers.Red_Black_Trees.Generic_Set_Operations);
 
 with System; use type System.Address;
+with System.Put_Images;
 
 package body Ada.Containers.Ordered_Sets with
   SPARK_Mode => Off
@@ -1580,6 +1581,31 @@ is
       end;
    end Query_Element;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set)
+   is
+      First_Time : Boolean := True;
+      use System.Put_Images;
+   begin
+      Array_Before (S);
+
+      for X of V loop
+         if First_Time then
+            First_Time := False;
+         else
+            Simple_Array_Between (S);
+         end if;
+
+         Element_Type'Put_Image (S, X);
+      end loop;
+
+      Array_After (S);
+   end Put_Image;
+
    ----------
    -- Read --
    ----------
index c08d4957d99e1e7769ff7c710509bcdffe172175..a5577e9e85876897448d94728822ad4206cbea5d 100644 (file)
@@ -37,6 +37,7 @@ with Ada.Containers.Helpers;
 private with Ada.Containers.Red_Black_Trees;
 private with Ada.Finalization;
 private with Ada.Streams;
+private with Ada.Strings.Text_Output;
 
 generic
    type Element_Type is private;
@@ -342,7 +343,10 @@ private
 
    type Set is new Ada.Finalization.Controlled with record
       Tree : Tree_Types.Tree_Type;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Set);
 
    overriding procedure Adjust (Container : in out Set);
 
index 9fb6c5ad3e5b0451f37beb1094c4b225cae4425f..663d4ba99069be5490b1f9762007dc61127f1836 100644 (file)
@@ -35,6 +35,8 @@ with Ada.Strings.UTF_Encoding.Wide_Strings;
 with Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
 package body Ada.Strings.Text_Output.Buffers is
 
+   type Chunk_Access is access all Chunk;
+
    function New_Buffer
      (Indent_Amount : Natural := Default_Indent_Amount;
       Chunk_Length : Positive := Default_Chunk_Length) return Buffer
@@ -46,13 +48,20 @@ package body Ada.Strings.Text_Output.Buffers is
       end return;
    end New_Buffer;
 
+   --  We need type conversions of Chunk_Access values in the following two
+   --  procedures, because the one in Text_Output has Storage_Size => 0,
+   --  because Text_Output is Pure. We do not run afoul of 13.11.2(16/3),
+   --  which requires the allocation and deallocation to have the same pool,
+   --  because the allocation in Full_Method and the deallocation in Destroy
+   --  use the same access type, and therefore the same pool.
+
    procedure Destroy (S : in out Buffer) is
       procedure Free is new Unchecked_Deallocation (Chunk, Chunk_Access);
-      Cur : Chunk_Access := S.Initial_Chunk.Next;
+      Cur : Chunk_Access := Chunk_Access (S.Initial_Chunk.Next);
    begin
       while Cur /= null loop
          declare
-            Temp : constant Chunk_Access := Cur.Next;
+            Temp : constant Chunk_Access := Chunk_Access (Cur.Next);
          begin
             Free (Cur);
             Cur := Temp;
@@ -66,7 +75,8 @@ package body Ada.Strings.Text_Output.Buffers is
    begin
       pragma Assert (S.Cur_Chunk.Next = null);
       pragma Assert (S.Last = S.Cur_Chunk.Chars'Length);
-      S.Cur_Chunk.Next := new Chunk (S.Chunk_Length);
+      S.Cur_Chunk.Next :=
+        Text_Output.Chunk_Access (Chunk_Access'(new Chunk (S.Chunk_Length)));
       S.Cur_Chunk := S.Cur_Chunk.Next;
       S.Num_Extra_Chunks := @ + 1;
       S.Last := 0;
index b5a8f97157033ccf751ee39fe7e9a3fcecb7b5f9..2011408218a3314c715bab2f072c9cc0bc9d728c 100644 (file)
@@ -142,6 +142,7 @@ package body Ada.Strings.Text_Output.Utils is
 
          S.Cur_Chunk.Chars (S.Last + 1 .. S.Last + Item'Length) := Item;
          S.Last := S.Last + Item'Length;
+         S.Column := S.Column + Item'Length;
          Full (S);
          --  ???Seems like maybe we shouldn't call Full until we have MORE
          --  characters. But then we can't pass Chunk_Length => 1 to
@@ -175,6 +176,7 @@ package body Ada.Strings.Text_Output.Utils is
 
          S.Cur_Chunk.Chars (S.Last + 1 .. S.Last + Item'Length) := Item;
          S.Last := S.Last + Item'Length;
+         S.Column := S.Column + Item'Length;
       else
          Put_UTF_8_Outline (S, Item);
       end if;
@@ -191,7 +193,6 @@ package body Ada.Strings.Text_Output.Utils is
                Put_UTF_8 (S, Item (Line_Start .. Index - 1));
             end if;
             New_Line (S);
-            S.Column := 1;
             Line_Start := Index + 1;
          end if;
 
index 28d7eca77c6a698b6339279b29aba253f10a0da8..5056080d4bf3f87335704d270b2992864e3b2e67 100644 (file)
@@ -29,7 +29,7 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-package Ada.Strings.Text_Output.Utils with Preelaborate is
+package Ada.Strings.Text_Output.Utils with Pure is
 
    --  This package provides utility functions on Sink'Class. These are
    --  intended for use by Put_Image attributes, both the default versions
@@ -70,7 +70,8 @@ package Ada.Strings.Text_Output.Utils with Preelaborate is
    --  Send data that is already UTF-8 encoded (including 7-bit ASCII) to
    --  S. These are more efficient than Put_String.
 
-   procedure New_Line (S : in out Sink'Class) with Inline;
+   procedure New_Line (S : in out Sink'Class) with
+     Inline, Post => Column (S) = 1;
    --  Puts the new-line character.
 
    function Column (S : Sink'Class) return Positive with Inline;
index 988de424f80403c7fcc9580fe046ba66d403b7ca..7d1e6ddb727a2eb4af301f2c6af3be188a3899f8 100644 (file)
@@ -778,6 +778,16 @@ package body Ada.Strings.Unbounded is
       end if;
    end Overwrite;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Unbounded_String) is
+   begin
+      String'Put_Image (S, To_String (V));
+   end Put_Image;
+
    -----------------------
    -- Realloc_For_Chunk --
    -----------------------
index 3471dbb4a9f396a7f0492f12793a7cef04d06b20..7de9bbcbdc4ee800f63c9c322e80df410c077370 100644 (file)
@@ -41,6 +41,7 @@ pragma Assertion_Policy (Pre => Ignore);
 
 with Ada.Strings.Maps;
 with Ada.Finalization;
+private with Ada.Strings.Text_Output;
 
 --  The language-defined package Strings.Unbounded provides a private type
 --  Unbounded_String and a set of operations. An object of type
@@ -744,7 +745,11 @@ private
    type Unbounded_String is new AF.Controlled with record
       Reference : String_Access := Null_String'Access;
       Last      : Natural       := 0;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Unbounded_String);
+
    --  The Unbounded_String is using a buffered implementation to increase
    --  speed of the Append/Delete/Insert procedures. The Reference string
    --  pointer above contains the current string value and extra room at the
index 0ff34d817efe2601db4965da776f414834563cd5..54a2932c00c45ff397531c6f9c3b036aae1c1581 100644 (file)
@@ -1296,6 +1296,16 @@ package body Ada.Strings.Unbounded is
       end if;
    end Overwrite;
 
+   ---------------
+   -- Put_Image --
+   ---------------
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Unbounded_String) is
+   begin
+      String'Put_Image (S, To_String (V));
+   end Put_Image;
+
    ---------------
    -- Reference --
    ---------------
index 5a5ad93a6e40b7e1d5888dcb0e47692582762572..2cd81666fdca71ecf95cfe327833ab46a4b037d1 100644 (file)
@@ -78,6 +78,7 @@ pragma Assertion_Policy (Pre => Ignore);
 with Ada.Strings.Maps;
 private with Ada.Finalization;
 private with System.Atomic_Counters;
+private with Ada.Strings.Text_Output;
 
 package Ada.Strings.Unbounded with
   Initial_Condition => Length (Null_Unbounded_String) = 0
@@ -738,7 +739,10 @@ private
 
    type Unbounded_String is new AF.Controlled with record
       Reference : not null Shared_String_Access := Empty_Shared_String'Access;
-   end record;
+   end record with Put_Image => Put_Image;
+
+   procedure Put_Image
+     (S : in out Ada.Strings.Text_Output.Sink'Class; V : Unbounded_String);
 
    pragma Stream_Convert (Unbounded_String, To_Unbounded, To_String);
    --  Provide stream routines without dragging in Ada.Streams
index 924b55003c61effcc07f7cd89465933433cfd160..9eaf98a820cc34205e1b8565a1e17ce59e24677f 100644 (file)
@@ -32,7 +32,7 @@
 with Ada.Strings.UTF_Encoding;
 with Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
 
-package Ada.Strings.Text_Output with Preelaborate is
+package Ada.Strings.Text_Output with Pure is
 
    --  This package provides a "Sink" abstraction, to which characters of type
    --  Character, Wide_Character, and Wide_Wide_Character can be sent. This
@@ -48,7 +48,11 @@ package Ada.Strings.Text_Output with Preelaborate is
    --  extended. It is designed with particular extensions in mind, and these
    --  extensions are declared in child packages of this package, because they
    --  depend on implementation details in the private part of this
-   --  package. The primary extensions of Sink are:
+   --  package.
+   --
+   --  Users are not expected to extend type Sink.
+   --
+   --  The primary extensions of Sink are:
    --
    --     Buffer. The characters sent to a Buffer are stored in memory, and can
    --     be retrieved via Get functions. This is intended for the
@@ -141,15 +145,13 @@ package Ada.Strings.Text_Output with Preelaborate is
    --  slows things down, but increasing it doesn't gain much.
 
 private
-   type String_Access is access all String;
-
    --  For Buffer, the "internal buffer" mentioned above is implemented as a
    --  linked list of chunks. When the current chunk is full, we allocate a new
    --  one. For File, there is only one chunk. When it is full, we send the
    --  data to the file, and empty it.
 
    type Chunk;
-   type Chunk_Access is access all Chunk;
+   type Chunk_Access is access all Chunk with Storage_Size => 0;
    type Chunk (Length : Positive) is limited record
       Next : Chunk_Access := null;
       Chars : UTF_8_Lines (1 .. Length);
index 4ae612d0062f276493940cf65ae8828f84447d7d..e4b9e670ddfa533807561659e0864e359b07a6a6 100644 (file)
@@ -250,6 +250,11 @@ package body System.Put_Images is
       Put_7bit (S, ')');
    end Record_After;
 
+   procedure Put_Arrow (S : in out Sink'Class) is
+   begin
+      Put_UTF_8 (S, " => ");
+   end Put_Arrow;
+
    procedure Put_Image_Unknown (S : in out Sink'Class; Type_Name : String) is
    begin
       Put_UTF_8 (S, "{");
index 17e184a55393d7bc2376a3bc384e0783cd61b7ef..bf565079c96823a62532ad4f0f28852f56c67e52 100644 (file)
@@ -32,7 +32,7 @@
 with Ada.Strings.Text_Output;
 with System.Unsigned_Types;
 
-package System.Put_Images is
+package System.Put_Images with Pure is
 
    --  This package contains subprograms that are called by the generated code
    --  for the 'Put_Image attribute.
@@ -64,8 +64,8 @@ package System.Put_Images is
 
    type Byte is new Character with Alignment => 1;
    type Byte_String is array (Positive range <>) of Byte with Alignment => 1;
-   type Thin_Pointer is access all Byte;
-   type Fat_Pointer is access all Byte_String;
+   type Thin_Pointer is access all Byte with Storage_Size => 0;
+   type Fat_Pointer is access all Byte_String with Storage_Size => 0;
    procedure Put_Image_Thin_Pointer (S : in out Sink'Class; X : Thin_Pointer);
    procedure Put_Image_Fat_Pointer (S : in out Sink'Class; X : Fat_Pointer);
    --  Print "null", or the address of the designated object as an unsigned
@@ -95,6 +95,8 @@ package System.Put_Images is
    procedure Record_Between (S : in out Sink'Class);
    procedure Record_After (S : in out Sink'Class);
 
+   procedure Put_Arrow (S : in out Sink'Class);
+
    procedure Put_Image_Unknown (S : in out Sink'Class; Type_Name : String);
    --  For Put_Image of types that don't have the attribute, such as type
    --  Sink.