begin
-- Record aggregate case
- if Is_Record_Type (Etype (N)) then
+ if Is_Record_Type (Etype (N))
+ and then not Is_Private_Type (Etype (N))
+ then
Expand_Record_Aggregate (N);
elsif Has_Aspect (Etype (N), Aspect_Aggregate) then
Insert (Container, No_Element, New_Item, Count);
end Append;
+ ---------------
+ -- Append_One --
+ ---------------
+
+ procedure Append_One
+ (Container : in out List;
+ New_Item : Element_Type)
+ is
+ begin
+ Insert (Container, No_Element, New_Item, 1);
+ end Append_One;
+
------------
-- Assign --
------------
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
-
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_List,
+ Add_Unnamed => Append_One);
pragma Preelaborable_Initialization (List);
type Cursor is private;
New_Item : Element_Type;
Count : Count_Type := 1);
+ procedure Append_One
+ (Container : in out List;
+ New_Item : Element_Type);
+
procedure Delete
(Container : in out List;
Position : in out Cursor;
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Map,
+ Add_Named => Insert);
pragma Preelaborable_Initialization (Map);
type Set (Capacity : Count_Type; Modulus : Hash_Type) is tagged private
with Constant_Indexing => Constant_Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Set,
+ Add_Unnamed => Include);
pragma Preelaborable_Initialization (Set);
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Map,
+ Add_Named => Insert);
pragma Preelaborable_Initialization (Map);
type Set (Capacity : Count_Type) is tagged private
with Constant_Indexing => Constant_Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Set,
+ Add_Unnamed => Include);
pragma Preelaborable_Initialization (Set);
Insert (Container, No_Element, New_Item, Count);
end Append;
+ ---------------
+ -- Append_One --
+ ---------------
+
+ procedure Append_One
+ (Container : in out List;
+ New_Item : Element_Type)
+ is
+ begin
+ Insert (Container, No_Element, New_Item, 1);
+ end Append_One;
+
------------
-- Assign --
------------
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_List,
+ Add_Unnamed => Append_One);
pragma Preelaborable_Initialization (List);
New_Item : Element_Type;
Count : Count_Type := 1);
+ procedure Append_One
+ (Container : in out List;
+ New_Item : Element_Type);
+
procedure Delete
(Container : in out List;
Position : in out Cursor;
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Map,
+ Add_Named => Insert);
pragma Preelaborable_Initialization (Map);
type Set is tagged private
with Constant_Indexing => Constant_Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Set,
+ Add_Unnamed => Include);
pragma Preelaborable_Initialization (Set);
with Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Map,
+ Add_Named => Insert);
pragma Preelaborable_Initialization (Map);
type Set is tagged private with
Constant_Indexing => Constant_Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Set,
+ Add_Unnamed => Include);
pragma Preelaborable_Initialization (Set);
Container.Insert (Container.Last + 1, New_Item, Count);
end Append;
+ ----------------
+ -- Append_One --
+ ----------------
+
+ procedure Append_One (Container : in out Vector;
+ New_Item : Element_Type)
+ is
+ begin
+ Insert (Container, Last_Index (Container) + 1, New_Item, 1);
+ end Append_One;
+
--------------
-- Capacity --
--------------
return Index_Type'First;
end First_Index;
+ -----------------
+ -- New_Vector --
+ -----------------
+
+ function New_Vector (First, Last : Index_Type) return Vector
+ is
+ begin
+ return (To_Vector (Count_Type (Last - First + 1)));
+ end New_Vector;
+
---------------------
-- Generic_Sorting --
---------------------
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Vector,
+ Add_Unnamed => Append_One,
+ New_Indexed => New_Vector,
+ Assign_Indexed => Replace_Element);
pragma Preelaborable_Initialization (Vector);
overriding function "=" (Left, Right : Vector) return Boolean;
+ function New_Vector (First, Last : Index_Type) return Vector
+ with Pre => First = Index_Type'First;
+ -- Ada_2020 aggregate operation.
+
function To_Vector (Length : Count_Type) return Vector;
function To_Vector
New_Item : Element_Type;
Count : Count_Type := 1);
+ procedure Append_One (Container : in out Vector;
+ New_Item : Element_Type);
+ -- Ada_2020 aggregate operation.
+
procedure Insert_Space
(Container : in out Vector;
Before : Extended_Index;
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Map,
+ Add_Named => Insert);
pragma Preelaborable_Initialization (Map);
with
Constant_Indexing => Constant_Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Set,
+ Add_Unnamed => Include);
pragma Preelaborable_Initialization (Set);
end if;
end Append;
+ ----------------
+ -- Append_One --
+ ----------------
+
+ procedure Append_One (Container : in out Vector;
+ New_Item : Element_Type)
+ is
+ begin
+ Insert (Container, Last_Index (Container) + 1, New_Item, 1);
+ end Append_One;
+
----------------------
-- Append_Slow_Path --
----------------------
end;
end First_Element;
+ -----------------
+ -- New_Vector --
+ -----------------
+
+ function New_Vector (First, Last : Index_Type) return Vector
+ is
+ begin
+ return (To_Vector (Count_Type (Last - First + 1)));
+ end New_Vector;
+
-----------------
-- First_Index --
-----------------
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Vector,
+ Add_Unnamed => Append_One,
+ New_Indexed => New_Vector,
+ Assign_Indexed => Replace_Element);
pragma Preelaborable_Initialization (Vector);
overriding function "=" (Left, Right : Vector) return Boolean;
+ function New_Vector (First, Last : Index_Type) return Vector
+ with Pre => First = Index_Type'First;
+
function To_Vector (Length : Count_Type) return Vector;
function To_Vector
New_Item : Element_Type;
Count : Count_Type := 1);
+ procedure Append_One (Container : in out Vector;
+ New_Item : Element_Type);
+
procedure Insert_Space
(Container : in out Vector;
Before : Extended_Index;
end if;
end Append;
+ ----------------
+ -- Append_One --
+ ----------------
+
+ procedure Append_One (Container : in out Vector;
+ New_Item : Element_Type)
+ is
+ begin
+ Insert (Container, Last_Index (Container) + 1, New_Item, 1);
+ end Append_One;
+
----------------------
-- Append_Slow_Path --
----------------------
return Index_Type'First;
end First_Index;
+ -----------------
+ -- New_Vector --
+ -----------------
+
+ function New_Vector (First, Last : Index_Type) return Vector
+ is
+ begin
+ return (To_Vector (Count_Type (Last - First + 1)));
+ end New_Vector;
+
---------------------
-- Generic_Sorting --
---------------------
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Vector,
+ Add_Unnamed => Append_One,
+ New_Indexed => New_Vector,
+ Assign_Indexed => Replace_Element);
+
pragma Preelaborable_Initialization (Vector);
-- Vector type, to be instantiated by users of this package. If an object
-- of type Vector is not otherwise initialized, it is initialized to
-- Source is removed from Source and inserted into Target in the original
-- order. The length of Source is 0 after a successful call to Move.
+ function New_Vector (First, Last : Index_Type) return Vector
+ with Pre => First = Index_Type'First;
+ -- Ada_2020 aggregate operation.
+
procedure Insert
(Container : in out Vector;
Before : Extended_Index;
-- Equivalent to Insert (Container, Last_Index (Container) + 1, New_Item,
-- Count).
+ procedure Append_One (Container : in out Vector;
+ New_Item : Element_Type);
+ -- Ada_2020 aggregate operation.
+
procedure Insert_Space
(Container : in out Vector;
Before : Extended_Index;
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
- Iterator_Element => Element_Type;
+ Iterator_Element => Element_Type,
+ Aggregate => (Empty => Empty_Map,
+ Add_Named => Insert);
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
with Constant_Indexing => Constant_Reference,
Default_Iterator => Iterate,
Iterator_Element => Element_Type;
+ -- Aggregate => (Empty => Empty_Set,
+ -- Add_Unnamed => Include);
pragma Preelaborable_Initialization (Set);
-- Predicates that establish the legality of each possible operation in
-- an Aggregate aspect.
- function Valid_Empty (E : Entity_Id) return Boolean;
- function Valid_Add_Named (E : Entity_Id) return Boolean;
- function Valid_Add_Unnamed (E : Entity_Id) return Boolean;
- function Valid_New_Indexed (E : Entity_Id) return Boolean;
-
- -- Note: The legality rules for Assign_Indexed are the same as for
- -- Add_Named.
+ function Valid_Empty (E : Entity_Id) return Boolean;
+ function Valid_Add_Named (E : Entity_Id) return Boolean;
+ function Valid_Add_Unnamed (E : Entity_Id) return Boolean;
+ function Valid_New_Indexed (E : Entity_Id) return Boolean;
+ function Valid_Assign_Indexed (E : Entity_Id) return Boolean;
generic
with function Pred (Id : Node_Id) return Boolean;
procedure Resolve_Operation (Subp_Id : Node_Id);
-- Common processing to resolve each aggregate operation.
+ ------------------------
+ -- Valid_Assign_Index --
+ ------------------------
+
+ function Valid_Assign_Indexed (E : Entity_Id) return Boolean is
+ begin
+ -- The profile must be the same as for Add_Named, with the added
+ -- requirement that the key_type be a discrete type.
+
+ if Valid_Add_Named (E) then
+ return Is_Discrete_Type (Etype (Next_Formal (First_Formal (E))));
+ else
+ return False;
+ end if;
+ end Valid_Assign_Indexed;
+
-----------------
-- Valid_Emoty --
-----------------
procedure Resolve_Named is new Resolve_Operation (Valid_Add_Named);
procedure Resolve_Indexed is new Resolve_Operation (Valid_New_Indexed);
procedure Resolve_Assign_Indexed
- is new Resolve_Operation (Valid_Add_Named);
+ is new Resolve_Operation
+ (Valid_Assign_Indexed);
begin
Assoc := First (Component_Associations (Expr));