store result of transformations for further refs.

* anchored annotation nodes that generate anchored result
   nodes will only processed once. further references to the
   anchor will directly link to the result.
This commit is contained in:
Felix Krause 2018-01-22 21:03:19 +01:00
parent 18994c5806
commit 210fda21f9
11 changed files with 286 additions and 51 deletions

View File

@ -0,0 +1 @@
@@concat with node properties

View File

@ -0,0 +1,3 @@
- !foo @@concat [a, b]
- &a @@concat [do, re]
- &b !bar @@concat [*a, mi]

View File

@ -0,0 +1,9 @@
+STR
+DOC
+SEQ
=VAL <!foo> :ab
=VAL &a :dore
=VAL &b <!bar> :doremi
-SEQ
-DOC
-STR

View File

@ -9,17 +9,23 @@ package body Yaml.Events.Context is
use type Store.Anchor_Cursor;
use type Store.Element_Cursor;
procedure Free_Array is new Ada.Unchecked_Deallocation
procedure Free_Scope_Array is new Ada.Unchecked_Deallocation
(Scope_Array, Scope_Array_Pointer);
procedure Free_Data_Array is new Ada.Unchecked_Deallocation
(Data_Array, Data_Array_Pointer);
procedure Free_Symbol_Table is new Ada.Unchecked_Deallocation
(Symbol_Tables.Map, Symbol_Table_Pointer);
function Create (External : Store.Reference := Store.New_Store)
return Reference is
((Ada.Finalization.Controlled with Data =>
new Instance'(Refcount_Base with Document_Data => Store.New_Store,
new Instance'(Refcount_Base with Generated_Data => null,
Generated_Data_Count => 0,
Document_Data => Store.New_Store,
Stream_Data => Store.New_Store,
Transformed_Data => Store.New_Store,
External_Data => External,
Local_Scopes => null, Local_Scope_Count => 0)));
@ -32,6 +38,9 @@ package body Yaml.Events.Context is
function Document_Store (Object : Reference) return Store.Accessor is
(Object.Data.Document_Data.Value);
function Transformed_Store (Object : Reference) return Store.Accessor is
(Object.Data.Transformed_Data.Value);
function Local_Store (Object : Reference; Position : Local_Scope_Cursor)
return Store.Accessor is
begin
@ -49,8 +58,8 @@ package body Yaml.Events.Context is
function Local_Store_Ref (Object : Reference; Position : Local_Scope_Cursor)
return Store.Optional_Reference is
begin
if (Object.Data.Local_Scopes = null or
Object.Data.Local_Scope_Count < Natural (Position)) then
if Object.Data.Local_Scopes = null or
Object.Data.Local_Scope_Count < Natural (Position) then
return Store.Null_Reference;
elsif Object.Data.Local_Scopes (Positive (Position)).Events =
Store.Null_Reference then
@ -60,6 +69,38 @@ package body Yaml.Events.Context is
return Object.Data.Local_Scopes (Positive (Position)).Events;
end Local_Store_Ref;
function Generated_Store (Object : Reference;
Position : Generated_Store_Cursor)
return Store.Accessor is
begin
if Object.Data.Generated_Data = null or
Object.Data.Generated_Data_Count < Natural (Position) then
raise Constraint_Error with "no generated store at this position";
elsif Object.Data.Generated_Data (Positive (Position)) =
Store.Null_Reference then
raise Program_Error with
"internal error: expected generated store at position" &
Position'Img;
end if;
return Object.Data.Generated_Data (Positive (Position)).Value;
end Generated_Store;
function Generated_Store_Ref (Object : Reference;
Position : Generated_Store_Cursor)
return Store.Optional_Reference is
begin
if Object.Data.Generated_Data = null or
Object.Data.Generated_Data_Count < Natural (Position) then
return Store.Null_Reference;
elsif Object.Data.Generated_Data (Positive (Position)) =
Store.Null_Reference then
raise Program_Error with
"internal error: expected generated store at position" &
Position'Img;
end if;
return Object.Data.Generated_Data (Positive (Position));
end Generated_Store_Ref;
procedure Grow_Scopes (Object : in out Instance) is
begin
if Object.Local_Scopes = null then
@ -71,7 +112,7 @@ package body Yaml.Events.Context is
begin
New_Array (Object.Local_Scopes'Range) :=
Object.Local_Scopes.all;
Free_Array (Object.Local_Scopes);
Free_Scope_Array (Object.Local_Scopes);
Object.Local_Scopes := New_Array;
end;
end if;
@ -113,6 +154,42 @@ package body Yaml.Events.Context is
end loop;
end Release_Local_Store;
procedure Create_Generated_Store (Object : Reference;
Position : out Generated_Store_Cursor) is
begin
if Object.Data.Generated_Data = null then
Object.Data.Generated_Data := new Data_Array (1 .. 16);
elsif Object.Data.Generated_Data_Count =
Object.Data.Generated_Data'Last then
declare
New_Array : constant not null Data_Array_Pointer :=
new Data_Array (1 .. Object.Data.Generated_Data_Count * 2);
begin
New_Array (Object.Data.Generated_Data'Range) :=
Object.Data.Generated_Data.all;
Free_Data_Array (Object.Data.Generated_Data);
Object.Data.Generated_Data := New_Array;
end;
end if;
Object.Data.Generated_Data_Count := Object.Data.Generated_Data_Count + 1;
Object.Data.Generated_Data (Object.Data.Generated_Data_Count) :=
Store.New_Store.Optional;
Position := Generated_Store_Cursor (Object.Data.Generated_Data_Count);
end Create_Generated_Store;
procedure Release_Generated_Store (Object : Reference;
Position : Generated_Store_Cursor) is
begin
Object.Data.Generated_Data (Positive (Position)) := Store.Null_Reference;
while Object.Data.Generated_Data_Count > 0 and then
(Object.Data.Generated_Data (Object.Data.Generated_Data_Count) =
Store.Null_Reference) loop
Object.Data.Generated_Data_Count :=
Object.Data.Generated_Data_Count - 1;
end loop;
end Release_Generated_Store;
procedure Create_Symbol (Object : Reference;
Scope : Local_Scope_Cursor;
Name : Text.Reference;
@ -172,7 +249,40 @@ package body Yaml.Events.Context is
function Position (Object : Reference; Alias : Text.Reference) return Cursor
is
Pos : Store.Anchor_Cursor := Store.No_Anchor;
function Resolved (Position : Cursor) return Cursor is
begin
return Pos : Cursor := Position do
declare
Target_Event : constant Event := First (Pos);
begin
if Target_Event.Kind = Annotation_Start and then
Target_Event.Annotation_Properties.Anchor /= Text.Empty then
declare
Resolved_Target : constant Store.Anchor_Cursor :=
Object.Data.Transformed_Data.Value.Find
(Target_Event.Annotation_Properties.Anchor);
begin
if Resolved_Target /= Store.No_Anchor then
Pos.Target := Object.Data.Transformed_Data.Optional;
Pos.Anchored_Position := Resolved_Target;
Pos.Element_Position := Store.No_Element;
end if;
end;
end if;
end;
end return;
end Resolved;
begin
for Index in reverse 1 .. Object.Data.Generated_Data_Count loop
Pos := Object.Data.Generated_Data (Index).Value.Find (Alias);
if Pos /= Store.No_Anchor then
return Resolved ((Target => Object.Data.Generated_Data (Index),
Anchored_Position => Pos,
Element_Position => Events.Store.No_Element,
Target_Location => Generated));
end if;
end loop;
for Index in reverse 1 .. Object.Data.Local_Scope_Count loop
if Object.Data.Local_Scopes (Index).Symbols /= null then
declare
@ -180,17 +290,18 @@ package body Yaml.Events.Context is
Object.Data.Local_Scopes (Index).Symbols.Find (Alias);
begin
if Symbol_Tables.Has_Element (Symbol_Pos) then
return Symbol_Tables.Element (Symbol_Pos);
return Resolved (Symbol_Tables.Element (Symbol_Pos));
end if;
end;
end if;
if Object.Data.Local_Scopes (Index).Events /= Store.Null_Reference then
Pos := Object.Data.Local_Scopes (Index).Events.Value.Find (Alias);
if Pos /= Store.No_Anchor then
return (Target => Object.Data.Local_Scopes (Index).Events,
Anchored_Position => Pos,
Element_Position => Events.Store.No_Element,
Target_Location => Local);
return Resolved
((Target => Object.Data.Local_Scopes (Index).Events,
Anchored_Position => Pos,
Element_Position => Events.Store.No_Element,
Target_Location => Local));
end if;
end if;
end loop;
@ -202,22 +313,22 @@ package body Yaml.Events.Context is
if Pos = Store.No_Anchor then
return No_Element;
else
return (Target => Object.Data.External_Data.Optional,
Anchored_Position => Pos,
Element_Position => Events.Store.No_Element,
Target_Location => External);
return Resolved ((Target => Object.Data.External_Data.Optional,
Anchored_Position => Pos,
Element_Position => Events.Store.No_Element,
Target_Location => External));
end if;
else
return (Target => Object.Data.Stream_Data.Optional,
Anchored_Position => Pos,
Element_Position => Events.Store.No_Element,
Target_Location => Stream);
return Resolved ((Target => Object.Data.Stream_Data.Optional,
Anchored_Position => Pos,
Element_Position => Events.Store.No_Element,
Target_Location => Stream));
end if;
else
return (Target => Object.Data.Document_Data.Optional,
Anchored_Position => Pos,
Element_Position => Events.Store.No_Element,
Target_Location => Document);
return Resolved ((Target => Object.Data.Document_Data.Optional,
Anchored_Position => Pos,
Element_Position => Events.Store.No_Element,
Target_Location => Document));
end if;
end Position;
@ -267,7 +378,10 @@ package body Yaml.Events.Context is
Free_Symbol_Table (Object.Local_Scopes (Index).Symbols);
end if;
end loop;
Free_Array (Object.Local_Scopes);
Free_Scope_Array (Object.Local_Scopes);
end if;
if Object.Generated_Data /= null then
Free_Data_Array (Object.Generated_Data);
end if;
end Finalize;

View File

@ -10,10 +10,11 @@ package Yaml.Events.Context is
type Cursor is private;
type Local_Scope_Cursor is private;
type Generated_Store_Cursor is private;
type Symbol_Cursor is private;
type Location_Type is (Local, Document, Stream, External, None);
type Location_Type is (Generated, Local, Document, Stream, External, None);
function Create (External : Store.Reference := Store.New_Store)
return Reference;
@ -21,10 +22,17 @@ package Yaml.Events.Context is
function External_Store (Object : Reference) return Store.Accessor;
function Stream_Store (Object : Reference) return Store.Accessor;
function Document_Store (Object : Reference) return Store.Accessor;
function Transformed_Store (Object : Reference) return Store.Accessor;
function Local_Store (Object : Reference; Position : Local_Scope_Cursor)
return Store.Accessor;
function Local_Store_Ref (Object : Reference; Position : Local_Scope_Cursor)
return Store.Optional_Reference;
function Generated_Store (Object : Reference;
Position : Generated_Store_Cursor)
return Store.Accessor;
function Generated_Store_Ref (Object : Reference;
Position : Generated_Store_Cursor)
return Store.Optional_Reference;
function Position (Object : Reference; Alias : Text.Reference) return Cursor;
function Location (Position : Cursor) return Location_Type;
@ -36,6 +44,11 @@ package Yaml.Events.Context is
procedure Release_Local_Store (Object : Reference;
Position : Local_Scope_Cursor);
procedure Create_Generated_Store (Object : Reference;
Position : out Generated_Store_Cursor);
procedure Release_Generated_Store (Object : Reference;
Position : Generated_Store_Cursor);
procedure Create_Symbol (Object : Reference;
Scope : Local_Scope_Cursor;
Name : Text.Reference;
@ -88,15 +101,21 @@ private
type Scope_Array is array (Positive range <>) of Local_Scope;
type Scope_Array_Pointer is access Scope_Array;
type Data_Array is array (Positive range <>) of Store.Optional_Reference;
type Data_Array_Pointer is access Data_Array;
type Instance is limited new Refcount_Base with record
Document_Data, Stream_Data, External_Data : Store.Reference;
Generated_Data : Data_Array_Pointer;
Document_Data, Stream_Data, External_Data, Transformed_Data :
Store.Reference;
Local_Scopes : Scope_Array_Pointer := null;
Local_Scope_Count : Natural := 0;
Local_Scope_Count, Generated_Data_Count : Natural := 0;
end record;
overriding procedure Finalize (Object : in out Instance);
type Local_Scope_Cursor is new Natural;
type Generated_Store_Cursor is new Natural;
type Symbol_Cursor is new Symbol_Tables.Cursor;

View File

@ -49,17 +49,18 @@ package body Yaml.Transformator.Annotation.Concatenation is
Context => Processor_Context, others => <>);
end New_Concatenation;
procedure Initial (Object : in out Instance'Class; E : Event) is
procedure Initial (Object : in out Instance; E : Event) is
begin
if E.Kind /= Annotation_Start then
raise Stream_Error with
"unexpected token (expected annotation start): " & E.Kind'Img;
end if;
Object.Node_Properties := E.Annotation_Properties;
Object.Current.Start_Position := E.Start_Position;
Object.State := After_Annotation_Start'Access;
end Initial;
procedure After_Annotation_Start (Object : in out Instance'Class; E : Event) is
procedure After_Annotation_Start (Object : in out Instance; E : Event) is
begin
if E.Kind /= Annotation_End then
raise Annotation_Error with
@ -68,7 +69,7 @@ package body Yaml.Transformator.Annotation.Concatenation is
Object.State := After_Annotation_End'Access;
end After_Annotation_Start;
procedure After_Annotation_End (Object : in out Instance'Class; E : Event) is
procedure After_Annotation_End (Object : in out Instance; E : Event) is
begin
if E.Kind /= Sequence_Start then
raise Annotation_Error with
@ -77,7 +78,7 @@ package body Yaml.Transformator.Annotation.Concatenation is
Object.State := After_List_Start'Access;
end After_Annotation_End;
procedure After_List_Start (Object : in out Instance'Class; E : Event) is
procedure After_List_Start (Object : in out Instance; E : Event) is
begin
case E.Kind is
when Scalar =>
@ -112,31 +113,33 @@ package body Yaml.Transformator.Annotation.Concatenation is
case Referred.Kind is
when Scalar =>
Object.Builder :=
new Text.Builder.Reference'(Text.Builder.Create (Object.Pool));
new Text.Builder.Reference'(Text.Builder.Create
(Object.Pool));
Object.Builder.Append (Referred.Content.Value);
Object.State := After_String'Access;
when Sequence_Start =>
Object.Depth := 1;
Object.Current := Event'(Kind => Sequence_Start,
Collection_Style => Any,
Collection_Properties => Default_Properties,
Collection_Properties =>
Object.Node_Properties,
others => <>);
Object.Current_Exists := True;
Object.State := After_Sequence'Access;
Object.Current_Aliased := Stream.Optional;
when others =>
raise Annotation_Error with
"@concat requires a list of scalars or sequences";
"@@concat requires a list of scalars or sequences";
end case;
end;
end;
when others =>
raise Annotation_Error with
"@concat requires a list of scalars or sequences";
"@@concat requires a list of scalars or sequences";
end case;
end After_List_Start;
procedure In_Sequence (Object : in out Instance'Class; E : Event) is
procedure In_Sequence (Object : in out Instance; E : Event) is
begin
case E.Kind is
when Sequence_Start =>
@ -157,7 +160,7 @@ package body Yaml.Transformator.Annotation.Concatenation is
end case;
end In_Sequence;
procedure After_Sequence (Object : in out Instance'Class; E : Event) is
procedure After_Sequence (Object : in out Instance; E : Event) is
begin
case E.Kind is
when Sequence_Start =>
@ -206,7 +209,7 @@ package body Yaml.Transformator.Annotation.Concatenation is
end case;
end After_Sequence;
procedure After_String (Object : in out Instance'Class; E : Event) is
procedure After_String (Object : in out Instance; E : Event) is
procedure Free is new Ada.Unchecked_Deallocation
(Text.Builder.Reference, Builder_Pointer);
begin
@ -240,7 +243,7 @@ package body Yaml.Transformator.Annotation.Concatenation is
end;
when Sequence_End =>
Object.Current := (Kind => Scalar, Scalar_Style => Any,
Scalar_Properties => Default_Properties,
Scalar_Properties => Object.Node_Properties,
Start_Position => Object.Current.Start_Position,
End_Position => E.End_Position,
Content => Object.Builder.Lock);
@ -254,7 +257,7 @@ package body Yaml.Transformator.Annotation.Concatenation is
end case;
end After_String;
procedure After_List_End (Object : in out Instance'Class; E : Event) is
procedure After_List_End (Object : in out Instance; E : Event) is
begin
raise Constraint_Error with
"unexpected input to @@concat (already finished)";

View File

@ -19,21 +19,22 @@ package Yaml.Transformator.Annotation.Concatenation is
Swallows_Previous : out Boolean)
return not null Pointer;
private
type State_Type is not null access procedure (Object : in out Instance'Class;
type State_Type is not null access procedure (Object : in out Instance;
E : Event);
procedure Initial (Object : in out Instance'Class; E : Event);
procedure After_Annotation_Start (Object : in out Instance'Class; E : Event);
procedure After_Annotation_End (Object : in out Instance'Class; E : Event);
procedure After_List_Start (Object : in out Instance'Class; E : Event);
procedure In_Sequence (Object : in out Instance'Class; E : Event);
procedure After_Sequence (Object : in out Instance'Class; E : Event);
procedure After_String (Object : in out Instance'Class; E : Event);
procedure After_List_End (Object : in out Instance'Class; E : Event);
procedure Initial (Object : in out Instance; E : Event);
procedure After_Annotation_Start (Object : in out Instance; E : Event);
procedure After_Annotation_End (Object : in out Instance; E : Event);
procedure After_List_Start (Object : in out Instance; E : Event);
procedure In_Sequence (Object : in out Instance; E : Event);
procedure After_Sequence (Object : in out Instance; E : Event);
procedure After_String (Object : in out Instance; E : Event);
procedure After_List_End (Object : in out Instance; E : Event);
type Builder_Pointer is access Text.Builder.Reference;
type Instance is limited new Transformator.Instance with record
Node_Properties : Properties;
Builder : Builder_Pointer;
Context : Events.Context.Reference;
Pool : Text.Pool.Reference;

View File

@ -45,6 +45,13 @@ package body Yaml.Transformator.Annotation_Processor is
Free_Transformator (Object.Annotations
(Object.Annotation_Count).Impl);
Object.Annotation_Count := Object.Annotation_Count - 1;
if Object.Annotation_Count = 0 and Object.Next_Event_Storage = Yes then
if Object.Current_State = Existing then
Object.Next_Event_Storage := Finishing;
else
Object.Next_Event_Storage := No;
end if;
end if;
end if;
end Finalize_Finished_Annotation_Impl;
@ -188,6 +195,12 @@ package body Yaml.Transformator.Annotation_Processor is
Annotation.Maps.No_Element);
begin
Grow_Annotations (Object.Annotations, Object.Annotation_Count);
if Object.Annotation_Count = 1 then
Object.Next_Event_Storage :=
(if E.Annotation_Properties.Anchor /= Text.Empty then
Searching else No);
end if;
declare
Swallows_Previous : Boolean := False;
Impl : constant Transformator.Pointer :=
@ -328,6 +341,33 @@ package body Yaml.Transformator.Annotation_Processor is
end;
end if;
end Update_Exists_In_Output;
procedure Update_Next_Storage (E : Event) is
begin
case Object.Next_Event_Storage is
when Searching =>
if (case E.Kind is
when Annotation_Start =>
E.Annotation_Properties.Anchor /= Text.Empty,
when Mapping_Start | Sequence_Start =>
E.Collection_Properties.Anchor /= Text.Empty,
when Scalar =>
E.Scalar_Properties.Anchor /= Text.Empty,
when others => False) then
Object.Context.Transformed_Store.Memorize (E);
Object.Next_Event_Storage := Yes;
else
Object.Next_Event_Storage := No;
end if;
when Finishing =>
Object.Context.Transformed_Store.Memorize (E);
Object.Next_Event_Storage := No;
when Yes =>
Object.Context.Transformed_Store.Memorize (E);
when No => null;
end case;
end Update_Next_Storage;
begin
case Object.Current_State is
when Existing | Releasing_Held_Back =>
@ -348,6 +388,7 @@ package body Yaml.Transformator.Annotation_Processor is
Events.Context.Retrieve (Pos).Optional;
return Ret : constant Event :=
Object.Current_Stream.Value.Next do
Update_Next_Storage (Ret);
case Ret.Kind is
when Scalar =>
Object.Current_Stream.Clear;
@ -371,10 +412,12 @@ package body Yaml.Transformator.Annotation_Processor is
when others => null;
end case;
return Ret : constant Event := Object.Current do
Update_Next_Storage (Ret);
Look_For_Additional_Element;
end return;
when Localizing_Alias =>
return Ret : constant Event := Object.Current_Stream.Value.Next do
Update_Next_Storage (Ret);
case Ret.Kind is
when Mapping_Start | Sequence_Start =>
Object.Stream_Depth := Object.Stream_Depth + 1;
@ -392,6 +435,7 @@ package body Yaml.Transformator.Annotation_Processor is
raise Constraint_Error with "no event to retrieve";
else
return Ret : constant Event := Object.Current do
Update_Next_Storage (Ret);
Object.Current := (Kind => Document_End, others => <>);
end return;
end if;

View File

@ -40,6 +40,8 @@ private
Swallowing_Document_End, Localizing_Alias,
Absent);
type Next_Event_Storage_Type is (No, Searching, Finishing, Yes);
type Instance is limited new Transformator.Instance with record
Context : Events.Context.Reference;
Pool : Text.Pool.Reference;
@ -50,6 +52,7 @@ private
Annotations : not null Node_Array_Pointer := new Node_Array (1 .. 16);
Levels : not null Level_Array_Pointer := new Level_Array (1 .. 64);
May_Finish_Transformation : Boolean := False;
Next_Event_Storage : Next_Event_Storage_Type := No;
end record;
overriding procedure Finalize (Object : in out Instance);

View File

@ -35,6 +35,19 @@ package body Yaml.Events.Store is
"cannot manipulate event queue while a Stream_Instance exists";
end if;
case Item.Kind is
when Annotation_Start =>
if Item.Annotation_Properties.Anchor /= Text.Empty then
Object.Anchor_Map.Include
(Item.Annotation_Properties.Anchor,
(Position => Object.Length + 1, Has_Been_Output => False));
elsif Object.Depth = 0 and not Force then
return;
end if;
if Object.Depth = After_Annotation_End then
Object.Depth := 1;
else
Object.Depth := Object.Depth + 1;
end if;
when Scalar =>
if Item.Scalar_Properties.Anchor /= Text.Empty then
Object.Anchor_Map.Include
@ -44,6 +57,9 @@ package body Yaml.Events.Store is
elsif Object.Depth = 0 and not Force then
return;
end if;
if Object.Depth = After_Annotation_End then
Object.Depth := 0;
end if;
when Mapping_Start =>
if Item.Collection_Properties.Anchor /= Text.Empty then
Object.Anchor_Map.Include
@ -53,7 +69,11 @@ package body Yaml.Events.Store is
elsif Object.Depth = 0 and not Force then
return;
end if;
Object.Depth := Object.Depth + 1;
if Object.Depth = After_Annotation_End then
Object.Depth := 1;
else
Object.Depth := Object.Depth + 1;
end if;
when Sequence_Start =>
if Item.Collection_Properties.Anchor /= Text.Empty then
Object.Anchor_Map.Include
@ -63,15 +83,29 @@ package body Yaml.Events.Store is
elsif Object.Depth = 0 and not Force then
return;
end if;
Object.Depth := Object.Depth + 1;
if Object.Depth = After_Annotation_End then
Object.Depth := 1;
else
Object.Depth := Object.Depth + 1;
end if;
when Mapping_End | Sequence_End =>
if Object.Depth = 0 and not Force then
return;
end if;
Object.Depth := Object.Depth - 1;
when Annotation_End =>
if Object.Depth = 0 and not Force then
return;
end if;
Object.Depth := Object.Depth - 1;
if Object.Depth = 0 then
Object.Depth := After_Annotation_End;
end if;
when others =>
if Object.Depth = 0 and not Force then
return;
elsif Object.Depth = After_Annotation_End then
Object.Depth := 0;
end if;
end case;
if Object.Length = Object.Data.all'Length then

View File

@ -88,11 +88,15 @@ private
type Anchor_Cursor is new Anchor_To_Index.Cursor;
type Element_Cursor is new Natural;
subtype Depth_Type is Integer with Static_Predicate =>
Depth_Type = Integer'First or Depth_Type >= 0;
After_Annotation_End : constant Depth_Type := Integer'First;
type Instance is limited new Event_Holder with record
Anchor_Map : Anchor_To_Index.Map;
Stream_Count : Natural := 0;
Depth : Natural := 0;
Depth : Depth_Type := 0;
end record;
type Reference is new Ada.Finalization.Controlled with record