diff options
Diffstat (limited to 'gcc/ada/a-ciorse.ads')
-rw-r--r-- | gcc/ada/a-ciorse.ads | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/gcc/ada/a-ciorse.ads b/gcc/ada/a-ciorse.ads index c885b80478e..e0e95ede1b3 100644 --- a/gcc/ada/a-ciorse.ads +++ b/gcc/ada/a-ciorse.ads @@ -33,6 +33,7 @@ with Ada.Iterator_Interfaces; +private with Ada.Containers.Helpers; private with Ada.Containers.Red_Black_Trees; private with Ada.Finalization; private with Ada.Streams; @@ -298,17 +299,16 @@ package Ada.Containers.Indefinite_Ordered_Sets is type Key_Access is access all Key_Type; + package Impl is new Helpers.Generic_Implementation; + type Reference_Control_Type is - new Ada.Finalization.Controlled with + new Impl.Reference_Control_Type with record Container : Set_Access; Pos : Cursor; Old_Key : Key_Access; end record; - overriding procedure Adjust (Control : in out Reference_Control_Type); - pragma Inline (Adjust); - overriding procedure Finalize (Control : in out Reference_Control_Type); pragma Inline (Finalize); @@ -338,7 +338,7 @@ private type Node_Type; type Node_Access is access Node_Type; - type Element_Access is access Element_Type; + type Element_Access is access all Element_Type; type Node_Type is limited record Parent : Node_Access; @@ -361,7 +361,7 @@ private overriding procedure Finalize (Container : in out Set) renames Clear; use Red_Black_Trees; - use Tree_Types; + use Tree_Types, Tree_Types.Implementation; use Ada.Finalization; use Ada.Streams; @@ -397,16 +397,8 @@ private for Cursor'Read use Read; - type Reference_Control_Type is - new Controlled with record - Container : Set_Access; - end record; - - overriding procedure Adjust (Control : in out Reference_Control_Type); - pragma Inline (Adjust); - - overriding procedure Finalize (Control : in out Reference_Control_Type); - pragma Inline (Finalize); + subtype Reference_Control_Type is Implementation.Reference_Control_Type; + -- It is necessary to rename this here, so that the compiler can find it type Constant_Reference_Type (Element : not null access constant Element_Type) is @@ -430,13 +422,23 @@ private for Constant_Reference_Type'Write use Write; - Empty_Set : constant Set := - (Controlled with Tree => (First => null, - Last => null, - Root => null, - Length => 0, - Busy => 0, - Lock => 0)); + -- Three operations are used to optimize in the expansion of "for ... of" + -- loops: the Next(Cursor) procedure in the visible part, and the following + -- Pseudo_Reference and Get_Element_Access functions. See Sem_Ch5 for + -- details. + + function Pseudo_Reference + (Container : aliased Set'Class) return Reference_Control_Type; + pragma Inline (Pseudo_Reference); + -- Creates an object of type Reference_Control_Type pointing to the + -- container, and increments the Lock. Finalization of this object will + -- decrement the Lock. + + function Get_Element_Access + (Position : Cursor) return not null Element_Access; + -- Returns a pointer to the element designated by Position. + + Empty_Set : constant Set := (Controlled with others => <>); No_Element : constant Cursor := Cursor'(null, null); @@ -445,7 +447,8 @@ private record Container : Set_Access; Node : Node_Access; - end record; + end record + with Disable_Controlled => not T_Check; overriding procedure Finalize (Object : in out Iterator); |