diff options
Diffstat (limited to 'gcc/ada/a-cobove.ads')
-rw-r--r-- | gcc/ada/a-cobove.ads | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/gcc/ada/a-cobove.ads b/gcc/ada/a-cobove.ads index 3bd1843d7b3..c3157029344 100644 --- a/gcc/ada/a-cobove.ads +++ b/gcc/ada/a-cobove.ads @@ -33,6 +33,7 @@ with Ada.Iterator_Interfaces; +with Ada.Containers.Helpers; private with Ada.Streams; private with Ada.Finalization; @@ -43,6 +44,7 @@ generic with function "=" (Left, Right : Element_Type) return Boolean is <>; package Ada.Containers.Bounded_Vectors is + pragma Annotate (CodePeer, Skip_Analysis); pragma Pure; pragma Remote_Types; @@ -364,6 +366,10 @@ private pragma Inline (Next); pragma Inline (Previous); + use Ada.Containers.Helpers; + package Implementation is new Generic_Implementation; + use Implementation; + use Ada.Streams; use Ada.Finalization; @@ -373,8 +379,7 @@ private type Vector (Capacity : Count_Type) is tagged record Elements : Elements_Array (1 .. Capacity) := (others => <>); Last : Extended_Index := No_Index; - Busy : Natural := 0; - Lock : Natural := 0; + TC : aliased Tamper_Counts; end record; procedure Write @@ -409,15 +414,8 @@ private for Cursor'Read use Read; - type Reference_Control_Type is new Controlled with record - Container : Vector_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 @@ -461,6 +459,25 @@ private for Reference_Type'Write use Write; + -- 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 Exp_Ch5 for + -- details. + + function Pseudo_Reference + (Container : aliased Vector'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. + + type Element_Access is access all Element_Type with + Storage_Size => 0; + + function Get_Element_Access + (Position : Cursor) return not null Element_Access; + -- Returns a pointer to the element designated by Position. + Empty_Vector : constant Vector := (Capacity => 0, others => <>); No_Element : constant Cursor := Cursor'(null, Index_Type'First); @@ -470,7 +487,8 @@ private record Container : Vector_Access; Index : Index_Type'Base; - end record; + end record + with Disable_Controlled => not T_Check; overriding procedure Finalize (Object : in out Iterator); |