summaryrefslogtreecommitdiff
path: root/gcc/ada/a-comutr.ads
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/a-comutr.ads')
-rw-r--r--gcc/ada/a-comutr.ads40
1 files changed, 28 insertions, 12 deletions
diff --git a/gcc/ada/a-comutr.ads b/gcc/ada/a-comutr.ads
index 3ea29452929..918edfdd8aa 100644
--- a/gcc/ada/a-comutr.ads
+++ b/gcc/ada/a-comutr.ads
@@ -32,6 +32,8 @@
------------------------------------------------------------------------------
with Ada.Iterator_Interfaces;
+
+private with Ada.Containers.Helpers;
private with Ada.Finalization;
private with Ada.Streams;
@@ -333,6 +335,10 @@ private
-- thus guaranteeing that (unchecked) conversions between access types
-- designating each kind of node type is a meaningful conversion.
+ use Ada.Containers.Helpers;
+ package Implementation is new Generic_Implementation;
+ use Implementation;
+
type Tree_Node_Type;
type Tree_Node_Access is access all Tree_Node_Type;
pragma Convention (C, Tree_Node_Access);
@@ -386,8 +392,7 @@ private
type Tree is new Controlled with record
Root : aliased Root_Node_Type;
- Busy : Natural := 0;
- Lock : Natural := 0;
+ TC : aliased Tamper_Counts;
Count : Count_Type := 0;
end record;
@@ -429,16 +434,8 @@ private
for Cursor'Read use Read;
- type Reference_Control_Type is
- new Controlled with record
- Container : Tree_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
@@ -484,6 +481,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 Tree'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_Tree : constant Tree := (Controlled with others => <>);
No_Element : constant Cursor := (others => <>);