[multiple changes]
2011-12-12 Tristan Gingold <gingold@adacore.com> * mlib-tgt-specific-xi.adb: (Get_Target_Prefix): Simplify code. 2011-12-12 Thomas Quinot <quinot@adacore.com> * par_sco.adb: Adjust dominant marker for branches of CASE statements. 2011-12-12 Thomas Quinot <quinot@adacore.com> * gsocket.h, s-oscons-tmplt.c: Ensure we do not include any system header file prior to redefining FD_SETSIZE. 2011-12-12 Ed Schonberg <schonberg@adacore.com> * sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): In a generic context the aspect expressions may not have been preanalyzed if there was no previous freeze point, so the expressions must be preanalyzed now, and there is no conformance to check for visibility changes. 2011-12-12 Matthew Heaney <heaney@adacore.com> * a-convec.adb, a-coinve.adb, a-cobove.adb (Iterator): Use subtype Index_Type'Base for Index component (Finalize): Remove unnecessary access check (First, Last): Cursor return value depends on iterator index value (Iterate): Use start position as iterator index value (Next, Previous): Forward to corresponding cursor-based operation. * a-cborma.adb (Iterate): Properly initialize iterator object (with 0 as node index). From-SVN: r182226
This commit is contained in:
parent
7520518f73
commit
e8bd500e2d
|
@ -1,3 +1,36 @@
|
|||
2011-12-12 Tristan Gingold <gingold@adacore.com>
|
||||
|
||||
* mlib-tgt-specific-xi.adb: (Get_Target_Prefix): Simplify code.
|
||||
|
||||
2011-12-12 Thomas Quinot <quinot@adacore.com>
|
||||
|
||||
* par_sco.adb: Adjust dominant marker for branches of CASE
|
||||
statements.
|
||||
|
||||
2011-12-12 Thomas Quinot <quinot@adacore.com>
|
||||
|
||||
* gsocket.h, s-oscons-tmplt.c: Ensure we do not include any system
|
||||
header file prior to redefining FD_SETSIZE.
|
||||
|
||||
2011-12-12 Ed Schonberg <schonberg@adacore.com>
|
||||
|
||||
* sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): In
|
||||
a generic context the aspect expressions may not have been
|
||||
preanalyzed if there was no previous freeze point, so the
|
||||
expressions must be preanalyzed now, and there is no conformance
|
||||
to check for visibility changes.
|
||||
|
||||
2011-12-12 Matthew Heaney <heaney@adacore.com>
|
||||
|
||||
* a-convec.adb, a-coinve.adb, a-cobove.adb (Iterator): Use
|
||||
subtype Index_Type'Base for Index component (Finalize): Remove
|
||||
unnecessary access check (First, Last): Cursor return value
|
||||
depends on iterator index value (Iterate): Use start position as
|
||||
iterator index value (Next, Previous): Forward to corresponding
|
||||
cursor-based operation.
|
||||
* a-cborma.adb (Iterate): Properly initialize iterator object (with 0
|
||||
as node index).
|
||||
|
||||
2011-12-12 Robert Dewar <dewar@adacore.com>
|
||||
|
||||
* par_sco.adb, scos.ads, put_scos.adb, get_scos.adb: Minor reformatting.
|
||||
|
|
|
@ -935,7 +935,7 @@ package body Ada.Containers.Bounded_Ordered_Maps is
|
|||
return It : constant Iterator :=
|
||||
(Limited_Controlled with
|
||||
Container => Container'Unrestricted_Access,
|
||||
Node => Container.First)
|
||||
Node => 0)
|
||||
do
|
||||
B := B + 1;
|
||||
end return;
|
||||
|
|
|
@ -38,7 +38,7 @@ package body Ada.Containers.Bounded_Vectors is
|
|||
Vector_Iterator_Interfaces.Reversible_Iterator with
|
||||
record
|
||||
Container : Vector_Access;
|
||||
Index : Index_Type;
|
||||
Index : Index_Type'Base;
|
||||
end record;
|
||||
|
||||
overriding procedure Finalize (Object : in out Iterator);
|
||||
|
@ -667,14 +667,9 @@ package body Ada.Containers.Bounded_Vectors is
|
|||
--------------
|
||||
|
||||
procedure Finalize (Object : in out Iterator) is
|
||||
B : Natural renames Object.Container.Busy;
|
||||
begin
|
||||
if Object.Container /= null then
|
||||
declare
|
||||
B : Natural renames Object.Container.all.Busy;
|
||||
begin
|
||||
B := B - 1;
|
||||
end;
|
||||
end if;
|
||||
B := B - 1;
|
||||
end Finalize;
|
||||
|
||||
----------
|
||||
|
@ -740,10 +735,24 @@ package body Ada.Containers.Bounded_Vectors is
|
|||
|
||||
function First (Object : Iterator) return Cursor is
|
||||
begin
|
||||
if Is_Empty (Object.Container.all) then
|
||||
return No_Element;
|
||||
-- The value of the iterator object's Index component influences the
|
||||
-- behavior of the First (and Last) selector function.
|
||||
|
||||
-- When the Index component is No_Index, this means the iterator object
|
||||
-- was constructed without a start expression, in which case the
|
||||
-- (forward) iteration starts from the (logical) beginning of the entire
|
||||
-- sequence of items (corresponding to Container.First, for a forward
|
||||
-- iterator).
|
||||
|
||||
-- Otherwise, this is iteration over a partial sequence of items. When
|
||||
-- the Index component isn't No_Index, the iterator object was
|
||||
-- constructed with a start expression, that specifies the position from
|
||||
-- which the (forward) partial iteration begins.
|
||||
|
||||
if Object.Index = No_Index then
|
||||
return First (Object.Container.all);
|
||||
else
|
||||
return Cursor'(Object.Container, Index_Type'First);
|
||||
return Cursor'(Object.Container, Object.Index);
|
||||
end if;
|
||||
end First;
|
||||
|
||||
|
@ -1648,12 +1657,24 @@ package body Ada.Containers.Bounded_Vectors is
|
|||
(Container : Vector)
|
||||
return Vector_Iterator_Interfaces.Reversible_Iterator'Class
|
||||
is
|
||||
B : Natural renames Container'Unrestricted_Access.all.Busy;
|
||||
V : constant Vector_Access := Container'Unrestricted_Access;
|
||||
B : Natural renames V.Busy;
|
||||
|
||||
begin
|
||||
-- The value of its Index component influences the behavior of the First
|
||||
-- and Last selector functions of the iterator object. When the Index
|
||||
-- component is No_Index (as is the case here), this means the iterator
|
||||
-- object was constructed without a start expression. This is a complete
|
||||
-- iterator, meaning that the iteration starts from the (logical)
|
||||
-- beginning of the sequence of items.
|
||||
|
||||
-- Note: For a forward iterator, Container.First is the beginning, and
|
||||
-- for a reverse iterator, Container.Last is the beginning.
|
||||
|
||||
return It : constant Iterator :=
|
||||
Iterator'(Limited_Controlled with
|
||||
Container => Container'Unrestricted_Access,
|
||||
Index => Index_Type'First)
|
||||
(Limited_Controlled with
|
||||
Container => V,
|
||||
Index => No_Index)
|
||||
do
|
||||
B := B + 1;
|
||||
end return;
|
||||
|
@ -1662,14 +1683,51 @@ package body Ada.Containers.Bounded_Vectors is
|
|||
function Iterate
|
||||
(Container : Vector;
|
||||
Start : Cursor)
|
||||
return Vector_Iterator_Interfaces.Reversible_Iterator'class
|
||||
return Vector_Iterator_Interfaces.Reversible_Iterator'Class
|
||||
is
|
||||
B : Natural renames Container'Unrestricted_Access.all.Busy;
|
||||
V : constant Vector_Access := Container'Unrestricted_Access;
|
||||
B : Natural renames V.Busy;
|
||||
|
||||
begin
|
||||
-- It was formerly the case that when Start = No_Element, the partial
|
||||
-- iterator was defined to behave the same as for a complete iterator,
|
||||
-- and iterate over the entire sequence of items. However, those
|
||||
-- semantics were unintuitive and arguably error-prone (it is too easy
|
||||
-- to accidentally create an endless loop), and so they were changed,
|
||||
-- per the ARG meeting in Denver on 2011/11. However, there was no
|
||||
-- consensus about what positive meaning this corner case should have,
|
||||
-- and so it was decided to simply raise an exception. This does imply,
|
||||
-- however, that it is not possible to use a partial iterator to specify
|
||||
-- an empty sequence of items.
|
||||
|
||||
if Start.Container = null then
|
||||
raise Constraint_Error with
|
||||
"Start position for iterator equals No_Element";
|
||||
end if;
|
||||
|
||||
if Start.Container /= V then
|
||||
raise Program_Error with
|
||||
"Start cursor of Iterate designates wrong vector";
|
||||
end if;
|
||||
|
||||
if Start.Index > V.Last then
|
||||
raise Constraint_Error with
|
||||
"Start position for iterator equals No_Element";
|
||||
end if;
|
||||
|
||||
-- The value of its Index component influences the behavior of the First
|
||||
-- and Last selector functions of the iterator object. When the Index
|
||||
-- component is not No_Index (as is the case here), it means that this
|
||||
-- is a partial iteration, over a subset of the complete sequence of
|
||||
-- items. The iterator object was constructed with a start expression,
|
||||
-- indicating the position from which the iteration begins. Note that
|
||||
-- the start position has the same value irrespective of whether this is
|
||||
-- a forward or reverse iteration.
|
||||
|
||||
return It : constant Iterator :=
|
||||
Iterator'(Limited_Controlled with
|
||||
Container => Container'Unrestricted_Access,
|
||||
Index => Start.Index)
|
||||
(Limited_Controlled with
|
||||
Container => V,
|
||||
Index => Start.Index)
|
||||
do
|
||||
B := B + 1;
|
||||
end return;
|
||||
|
@ -1690,10 +1748,23 @@ package body Ada.Containers.Bounded_Vectors is
|
|||
|
||||
function Last (Object : Iterator) return Cursor is
|
||||
begin
|
||||
if Is_Empty (Object.Container.all) then
|
||||
return No_Element;
|
||||
-- The value of the iterator object's Index component influences the
|
||||
-- behavior of the Last (and First) selector function.
|
||||
|
||||
-- When the Index component is No_Index, this means the iterator object
|
||||
-- was constructed without a start expression, in which case the
|
||||
-- (reverse) iteration starts from the (logical) beginning of the entire
|
||||
-- sequence (corresponding to Container.Last, for a reverse iterator).
|
||||
|
||||
-- Otherwise, this is iteration over a partial sequence of items. When
|
||||
-- the Index component is not No_Index, the iterator object was
|
||||
-- constructed with a start expression, that specifies the position from
|
||||
-- which the (reverse) partial iteration begins.
|
||||
|
||||
if Object.Index = No_Index then
|
||||
return Last (Object.Container.all);
|
||||
else
|
||||
return Cursor'(Object.Container, Object.Container.Last);
|
||||
return Cursor'(Object.Container, Object.Index);
|
||||
end if;
|
||||
end Last;
|
||||
|
||||
|
@ -1811,11 +1882,16 @@ package body Ada.Containers.Bounded_Vectors is
|
|||
|
||||
function Next (Object : Iterator; Position : Cursor) return Cursor is
|
||||
begin
|
||||
if Position.Index = Object.Container.Last then
|
||||
return No_Element;
|
||||
else
|
||||
return (Object.Container, Position.Index + 1);
|
||||
if Position.Container = null then
|
||||
return No_Element;
|
||||
end if;
|
||||
|
||||
if Position.Container /= Object.Container then
|
||||
raise Program_Error with
|
||||
"Position cursor of Next designates wrong vector";
|
||||
end if;
|
||||
|
||||
return Next (Position);
|
||||
end Next;
|
||||
|
||||
procedure Next (Position : in out Cursor) is
|
||||
|
@ -1884,11 +1960,16 @@ package body Ada.Containers.Bounded_Vectors is
|
|||
|
||||
function Previous (Object : Iterator; Position : Cursor) return Cursor is
|
||||
begin
|
||||
if Position.Index > Index_Type'First then
|
||||
return (Object.Container, Position.Index - 1);
|
||||
else
|
||||
if Position.Container = null then
|
||||
return No_Element;
|
||||
end if;
|
||||
|
||||
if Position.Container /= Object.Container then
|
||||
raise Program_Error with
|
||||
"Position cursor of Previous designates wrong vector";
|
||||
end if;
|
||||
|
||||
return Previous (Position);
|
||||
end Previous;
|
||||
|
||||
-------------------
|
||||
|
|
|
@ -44,7 +44,7 @@ package body Ada.Containers.Indefinite_Vectors is
|
|||
Vector_Iterator_Interfaces.Reversible_Iterator with
|
||||
record
|
||||
Container : Vector_Access;
|
||||
Index : Index_Type;
|
||||
Index : Index_Type'Base;
|
||||
end record;
|
||||
|
||||
overriding procedure Finalize (Object : in out Iterator);
|
||||
|
@ -1109,14 +1109,9 @@ package body Ada.Containers.Indefinite_Vectors is
|
|||
end Finalize;
|
||||
|
||||
procedure Finalize (Object : in out Iterator) is
|
||||
B : Natural renames Object.Container.Busy;
|
||||
begin
|
||||
if Object.Container /= null then
|
||||
declare
|
||||
B : Natural renames Object.Container.all.Busy;
|
||||
begin
|
||||
B := B - 1;
|
||||
end;
|
||||
end if;
|
||||
B := B - 1;
|
||||
end Finalize;
|
||||
|
||||
----------
|
||||
|
@ -1185,9 +1180,26 @@ package body Ada.Containers.Indefinite_Vectors is
|
|||
end First;
|
||||
|
||||
function First (Object : Iterator) return Cursor is
|
||||
C : constant Cursor := (Object.Container, Index_Type'First);
|
||||
begin
|
||||
return C;
|
||||
-- The value of the iterator object's Index component influences the
|
||||
-- behavior of the First (and Last) selector function.
|
||||
|
||||
-- When the Index component is No_Index, this means the iterator object
|
||||
-- was constructed without a start expression, in which case the
|
||||
-- (forward) iteration starts from the (logical) beginning of the entire
|
||||
-- sequence of items (corresponding to Container.First, for a forward
|
||||
-- iterator).
|
||||
|
||||
-- Otherwise, this is iteration over a partial sequence of items. When
|
||||
-- the Index component isn't No_Index, the iterator object was
|
||||
-- constructed with a start expression, that specifies the position from
|
||||
-- which the (forward) partial iteration begins.
|
||||
|
||||
if Object.Index = No_Index then
|
||||
return First (Object.Container.all);
|
||||
else
|
||||
return Cursor'(Object.Container, Object.Index);
|
||||
end if;
|
||||
end First;
|
||||
|
||||
-------------------
|
||||
|
@ -2552,15 +2564,26 @@ package body Ada.Containers.Indefinite_Vectors is
|
|||
end Iterate;
|
||||
|
||||
function Iterate (Container : Vector)
|
||||
return Vector_Iterator_Interfaces.Reversible_Iterator'class
|
||||
return Vector_Iterator_Interfaces.Reversible_Iterator'Class
|
||||
is
|
||||
B : Natural renames Container'Unrestricted_Access.all.Busy;
|
||||
V : constant Vector_Access := Container'Unrestricted_Access;
|
||||
B : Natural renames V.Busy;
|
||||
|
||||
begin
|
||||
-- The value of its Index component influences the behavior of the First
|
||||
-- and Last selector functions of the iterator object. When the Index
|
||||
-- component is No_Index (as is the case here), this means the iterator
|
||||
-- object was constructed without a start expression. This is a complete
|
||||
-- iterator, meaning that the iteration starts from the (logical)
|
||||
-- beginning of the sequence of items.
|
||||
|
||||
-- Note: For a forward iterator, Container.First is the beginning, and
|
||||
-- for a reverse iterator, Container.Last is the beginning.
|
||||
|
||||
return It : constant Iterator :=
|
||||
(Limited_Controlled with
|
||||
Container => Container'Unrestricted_Access,
|
||||
Index => Index_Type'First)
|
||||
Container => V,
|
||||
Index => No_Index)
|
||||
do
|
||||
B := B + 1;
|
||||
end return;
|
||||
|
@ -2569,14 +2592,50 @@ package body Ada.Containers.Indefinite_Vectors is
|
|||
function Iterate
|
||||
(Container : Vector;
|
||||
Start : Cursor)
|
||||
return Vector_Iterator_Interfaces.Reversible_Iterator'class
|
||||
return Vector_Iterator_Interfaces.Reversible_Iterator'Class
|
||||
is
|
||||
B : Natural renames Container'Unrestricted_Access.all.Busy;
|
||||
V : constant Vector_Access := Container'Unrestricted_Access;
|
||||
B : Natural renames V.Busy;
|
||||
|
||||
begin
|
||||
-- It was formerly the case that when Start = No_Element, the partial
|
||||
-- iterator was defined to behave the same as for a complete iterator,
|
||||
-- and iterate over the entire sequence of items. However, those
|
||||
-- semantics were unintuitive and arguably error-prone (it is too easy
|
||||
-- to accidentally create an endless loop), and so they were changed,
|
||||
-- per the ARG meeting in Denver on 2011/11. However, there was no
|
||||
-- consensus about what positive meaning this corner case should have,
|
||||
-- and so it was decided to simply raise an exception. This does imply,
|
||||
-- however, that it is not possible to use a partial iterator to specify
|
||||
-- an empty sequence of items.
|
||||
|
||||
if Start.Container = null then
|
||||
raise Constraint_Error with
|
||||
"Start position for iterator equals No_Element";
|
||||
end if;
|
||||
|
||||
if Start.Container /= V then
|
||||
raise Program_Error with
|
||||
"Start cursor of Iterate designates wrong vector";
|
||||
end if;
|
||||
|
||||
if Start.Index > V.Last then
|
||||
raise Constraint_Error with
|
||||
"Start position for iterator equals No_Element";
|
||||
end if;
|
||||
|
||||
-- The value of its Index component influences the behavior of the First
|
||||
-- and Last selector functions of the iterator object. When the Index
|
||||
-- component is not No_Index (as is the case here), it means that this
|
||||
-- is a partial iteration, over a subset of the complete sequence of
|
||||
-- items. The iterator object was constructed with a start expression,
|
||||
-- indicating the position from which the iteration begins. Note that
|
||||
-- the start position has the same value irrespective of whether this is
|
||||
-- a forward or reverse iteration.
|
||||
|
||||
return It : constant Iterator :=
|
||||
(Limited_Controlled with
|
||||
Container => Container'Unrestricted_Access,
|
||||
Container => V,
|
||||
Index => Start.Index)
|
||||
do
|
||||
B := B + 1;
|
||||
|
@ -2597,9 +2656,25 @@ package body Ada.Containers.Indefinite_Vectors is
|
|||
end Last;
|
||||
|
||||
function Last (Object : Iterator) return Cursor is
|
||||
C : constant Cursor := (Object.Container, Object.Container.Last);
|
||||
begin
|
||||
return C;
|
||||
-- The value of the iterator object's Index component influences the
|
||||
-- behavior of the Last (and First) selector function.
|
||||
|
||||
-- When the Index component is No_Index, this means the iterator object
|
||||
-- was constructed without a start expression, in which case the
|
||||
-- (reverse) iteration starts from the (logical) beginning of the entire
|
||||
-- sequence (corresponding to Container.Last, for a reverse iterator).
|
||||
|
||||
-- Otherwise, this is iteration over a partial sequence of items. When
|
||||
-- the Index component is not No_Index, the iterator object was
|
||||
-- constructed with a start expression, that specifies the position from
|
||||
-- which the (reverse) partial iteration begins.
|
||||
|
||||
if Object.Index = No_Index then
|
||||
return Last (Object.Container.all);
|
||||
else
|
||||
return Cursor'(Object.Container, Object.Index);
|
||||
end if;
|
||||
end Last;
|
||||
|
||||
-----------------
|
||||
|
@ -2718,11 +2793,16 @@ package body Ada.Containers.Indefinite_Vectors is
|
|||
|
||||
function Next (Object : Iterator; Position : Cursor) return Cursor is
|
||||
begin
|
||||
if Position.Index = Object.Container.Last then
|
||||
return No_Element;
|
||||
else
|
||||
return (Object.Container, Position.Index + 1);
|
||||
if Position.Container = null then
|
||||
return No_Element;
|
||||
end if;
|
||||
|
||||
if Position.Container /= Object.Container then
|
||||
raise Program_Error with
|
||||
"Position cursor of Next designates wrong vector";
|
||||
end if;
|
||||
|
||||
return Next (Position);
|
||||
end Next;
|
||||
|
||||
procedure Next (Position : in out Cursor) is
|
||||
|
@ -2791,11 +2871,16 @@ package body Ada.Containers.Indefinite_Vectors is
|
|||
|
||||
function Previous (Object : Iterator; Position : Cursor) return Cursor is
|
||||
begin
|
||||
if Position.Index > Index_Type'First then
|
||||
return (Object.Container, Position.Index - 1);
|
||||
else
|
||||
if Position.Container = null then
|
||||
return No_Element;
|
||||
end if;
|
||||
|
||||
if Position.Container /= Object.Container then
|
||||
raise Program_Error with
|
||||
"Position cursor of Previous designates wrong vector";
|
||||
end if;
|
||||
|
||||
return Previous (Position);
|
||||
end Previous;
|
||||
|
||||
-------------------
|
||||
|
|
|
@ -41,16 +41,18 @@ package body Ada.Containers.Vectors is
|
|||
Vector_Iterator_Interfaces.Reversible_Iterator with
|
||||
record
|
||||
Container : Vector_Access;
|
||||
Index : Index_Type;
|
||||
Index : Index_Type'Base;
|
||||
end record;
|
||||
|
||||
overriding procedure Finalize (Object : in out Iterator);
|
||||
|
||||
overriding function First (Object : Iterator) return Cursor;
|
||||
overriding function Last (Object : Iterator) return Cursor;
|
||||
|
||||
overriding function Next
|
||||
(Object : Iterator;
|
||||
(Object : Iterator;
|
||||
Position : Cursor) return Cursor;
|
||||
|
||||
overriding function Previous
|
||||
(Object : Iterator;
|
||||
Position : Cursor) return Cursor;
|
||||
|
@ -782,14 +784,9 @@ package body Ada.Containers.Vectors is
|
|||
end Finalize;
|
||||
|
||||
procedure Finalize (Object : in out Iterator) is
|
||||
B : Natural renames Object.Container.Busy;
|
||||
begin
|
||||
if Object.Container /= null then
|
||||
declare
|
||||
B : Natural renames Object.Container.all.Busy;
|
||||
begin
|
||||
B := B - 1;
|
||||
end;
|
||||
end if;
|
||||
B := B - 1;
|
||||
end Finalize;
|
||||
|
||||
----------
|
||||
|
@ -855,10 +852,24 @@ package body Ada.Containers.Vectors is
|
|||
|
||||
function First (Object : Iterator) return Cursor is
|
||||
begin
|
||||
if Is_Empty (Object.Container.all) then
|
||||
return No_Element;
|
||||
-- The value of the iterator object's Index component influences the
|
||||
-- behavior of the First (and Last) selector function.
|
||||
|
||||
-- When the Index component is No_Index, this means the iterator object
|
||||
-- was constructed without a start expression, in which case the
|
||||
-- (forward) iteration starts from the (logical) beginning of the entire
|
||||
-- sequence of items (corresponding to Container.First, for a forward
|
||||
-- iterator).
|
||||
|
||||
-- Otherwise, this is iteration over a partial sequence of items. When
|
||||
-- the Index component isn't No_Index, the iterator object was
|
||||
-- constructed with a start expression, that specifies the position from
|
||||
-- which the (forward) partial iteration begins.
|
||||
|
||||
if Object.Index = No_Index then
|
||||
return First (Object.Container.all);
|
||||
else
|
||||
return (Object.Container, Index_Type'First);
|
||||
return Cursor'(Object.Container, Object.Index);
|
||||
end if;
|
||||
end First;
|
||||
|
||||
|
@ -2124,13 +2135,24 @@ package body Ada.Containers.Vectors is
|
|||
(Container : Vector)
|
||||
return Vector_Iterator_Interfaces.Reversible_Iterator'Class
|
||||
is
|
||||
B : Natural renames Container'Unrestricted_Access.all.Busy;
|
||||
V : constant Vector_Access := Container'Unrestricted_Access;
|
||||
B : Natural renames V.Busy;
|
||||
|
||||
begin
|
||||
-- The value of its Index component influences the behavior of the First
|
||||
-- and Last selector functions of the iterator object. When the Index
|
||||
-- component is No_Index (as is the case here), this means the iterator
|
||||
-- object was constructed without a start expression. This is a complete
|
||||
-- iterator, meaning that the iteration starts from the (logical)
|
||||
-- beginning of the sequence of items.
|
||||
|
||||
-- Note: For a forward iterator, Container.First is the beginning, and
|
||||
-- for a reverse iterator, Container.Last is the beginning.
|
||||
|
||||
return It : constant Iterator :=
|
||||
(Limited_Controlled with
|
||||
Container => Container'Unrestricted_Access,
|
||||
Index => Index_Type'First)
|
||||
Container => V,
|
||||
Index => No_Index)
|
||||
do
|
||||
B := B + 1;
|
||||
end return;
|
||||
|
@ -2141,12 +2163,48 @@ package body Ada.Containers.Vectors is
|
|||
Start : Cursor)
|
||||
return Vector_Iterator_Interfaces.Reversible_Iterator'class
|
||||
is
|
||||
B : Natural renames Container'Unrestricted_Access.all.Busy;
|
||||
V : constant Vector_Access := Container'Unrestricted_Access;
|
||||
B : Natural renames V.Busy;
|
||||
|
||||
begin
|
||||
-- It was formerly the case that when Start = No_Element, the partial
|
||||
-- iterator was defined to behave the same as for a complete iterator,
|
||||
-- and iterate over the entire sequence of items. However, those
|
||||
-- semantics were unintuitive and arguably error-prone (it is too easy
|
||||
-- to accidentally create an endless loop), and so they were changed,
|
||||
-- per the ARG meeting in Denver on 2011/11. However, there was no
|
||||
-- consensus about what positive meaning this corner case should have,
|
||||
-- and so it was decided to simply raise an exception. This does imply,
|
||||
-- however, that it is not possible to use a partial iterator to specify
|
||||
-- an empty sequence of items.
|
||||
|
||||
if Start.Container = null then
|
||||
raise Constraint_Error with
|
||||
"Start position for iterator equals No_Element";
|
||||
end if;
|
||||
|
||||
if Start.Container /= V then
|
||||
raise Program_Error with
|
||||
"Start cursor of Iterate designates wrong vector";
|
||||
end if;
|
||||
|
||||
if Start.Index > V.Last then
|
||||
raise Constraint_Error with
|
||||
"Start position for iterator equals No_Element";
|
||||
end if;
|
||||
|
||||
-- The value of its Index component influences the behavior of the First
|
||||
-- and Last selector functions of the iterator object. When the Index
|
||||
-- component is not No_Index (as is the case here), it means that this
|
||||
-- is a partial iteration, over a subset of the complete sequence of
|
||||
-- items. The iterator object was constructed with a start expression,
|
||||
-- indicating the position from which the iteration begins. Note that
|
||||
-- the start position has the same value irrespective of whether this is
|
||||
-- a forward or reverse iteration.
|
||||
|
||||
return It : constant Iterator :=
|
||||
(Limited_Controlled with
|
||||
Container => Container'Unrestricted_Access,
|
||||
Container => V,
|
||||
Index => Start.Index)
|
||||
do
|
||||
B := B + 1;
|
||||
|
@ -2168,10 +2226,23 @@ package body Ada.Containers.Vectors is
|
|||
|
||||
function Last (Object : Iterator) return Cursor is
|
||||
begin
|
||||
if Is_Empty (Object.Container.all) then
|
||||
return No_Element;
|
||||
-- The value of the iterator object's Index component influences the
|
||||
-- behavior of the Last (and First) selector function.
|
||||
|
||||
-- When the Index component is No_Index, this means the iterator object
|
||||
-- was constructed without a start expression, in which case the
|
||||
-- (reverse) iteration starts from the (logical) beginning of the entire
|
||||
-- sequence (corresponding to Container.Last, for a reverse iterator).
|
||||
|
||||
-- Otherwise, this is iteration over a partial sequence of items. When
|
||||
-- the Index component is not No_Index, the iterator object was
|
||||
-- constructed with a start expression, that specifies the position from
|
||||
-- which the (reverse) partial iteration begins.
|
||||
|
||||
if Object.Index = No_Index then
|
||||
return Last (Object.Container.all);
|
||||
else
|
||||
return (Object.Container, Object.Container.Last);
|
||||
return Cursor'(Object.Container, Object.Index);
|
||||
end if;
|
||||
end Last;
|
||||
|
||||
|
@ -2282,11 +2353,16 @@ package body Ada.Containers.Vectors is
|
|||
|
||||
function Next (Object : Iterator; Position : Cursor) return Cursor is
|
||||
begin
|
||||
if Position.Index < Object.Container.Last then
|
||||
return (Object.Container, Position.Index + 1);
|
||||
else
|
||||
if Position.Container = null then
|
||||
return No_Element;
|
||||
end if;
|
||||
|
||||
if Position.Container /= Object.Container then
|
||||
raise Program_Error with
|
||||
"Position cursor of Next designates wrong vector";
|
||||
end if;
|
||||
|
||||
return Next (Position);
|
||||
end Next;
|
||||
|
||||
procedure Next (Position : in out Cursor) is
|
||||
|
@ -2338,11 +2414,16 @@ package body Ada.Containers.Vectors is
|
|||
|
||||
function Previous (Object : Iterator; Position : Cursor) return Cursor is
|
||||
begin
|
||||
if Position.Index > Index_Type'First then
|
||||
return (Object.Container, Position.Index - 1);
|
||||
else
|
||||
if Position.Container = null then
|
||||
return No_Element;
|
||||
end if;
|
||||
|
||||
if Position.Container /= Object.Container then
|
||||
raise Program_Error with
|
||||
"Position cursor of Previous designates wrong vector";
|
||||
end if;
|
||||
|
||||
return Previous (Position);
|
||||
end Previous;
|
||||
|
||||
procedure Previous (Position : in out Cursor) is
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* *
|
||||
* C Header File *
|
||||
* *
|
||||
* Copyright (C) 2004-2010, Free Software Foundation, Inc. *
|
||||
* Copyright (C) 2004-2011, Free Software Foundation, Inc. *
|
||||
* *
|
||||
* GNAT is free software; you can redistribute it and/or modify it under *
|
||||
* terms of the GNU General Public License as published by the Free Soft- *
|
||||
|
@ -58,8 +58,11 @@
|
|||
/* For Tru64 */
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
/** No system header may be included prior to this point since on some targets
|
||||
** we need to redefine FD_SETSIZE.
|
||||
**/
|
||||
|
||||
/* Target-specific includes and definitions */
|
||||
|
||||
#if defined(__vxworks)
|
||||
#include <vxWorks.h>
|
||||
|
@ -163,6 +166,8 @@
|
|||
|
||||
#elif defined(VMS)
|
||||
#define FD_SETSIZE 4096
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#ifndef IN_RTS
|
||||
/* These DEC C headers are not available when building with GCC */
|
||||
#include <in.h>
|
||||
|
@ -173,6 +178,9 @@
|
|||
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined (__vxworks) && ! defined (__RTP__)
|
||||
#include <sys/times.h>
|
||||
#else
|
||||
|
@ -180,11 +188,11 @@
|
|||
#endif
|
||||
|
||||
/*
|
||||
* RTEMS has these .h files but not until you have built and installed
|
||||
* RTEMS. When building a C/C++ toolset, you also build the newlib C library.
|
||||
* So the build procedure for an RTEMS GNAT toolset requires that
|
||||
* you build a C/C++ toolset, then build and install RTEMS with
|
||||
* --enable-multilib, and finally build the Ada part of the toolset.
|
||||
* RTEMS has these .h files but not until you have built and installed RTEMS.
|
||||
* When building a C/C++ toolset, you also build the newlib C library, so the
|
||||
* build procedure for an RTEMS GNAT toolset requires that you build a C/C++
|
||||
* toolset, then build and install RTEMS with --enable-multilib, and finally
|
||||
* build the Ada part of the toolset.
|
||||
*/
|
||||
#if !(defined (VMS) || defined (__MINGW32__))
|
||||
#include <sys/socket.h>
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
-- GNAT COMPILER COMPONENTS --
|
||||
-- --
|
||||
-- M L I B . T G T. S P E C I F I C --
|
||||
-- (Bare Board Version) --
|
||||
-- --
|
||||
-- B o d y --
|
||||
-- --
|
||||
-- Copyright (C) 2003-2008, Free Software Foundation, Inc. --
|
||||
-- Copyright (C) 2003-2011, Free Software Foundation, Inc. --
|
||||
-- --
|
||||
-- GNAT is free software; you can redistribute it and/or modify it under --
|
||||
-- terms of the GNU General Public License as published by the Free Soft- --
|
||||
|
@ -139,33 +138,11 @@ package body MLib.Tgt.Specific is
|
|||
|
||||
function Get_Target_Prefix return String is
|
||||
Target_Name : constant String_Ptr := Sdefault.Target_Name;
|
||||
Index : Positive := Target_Name'First;
|
||||
|
||||
begin
|
||||
while Index < Target_Name'Last
|
||||
and then Target_Name (Index + 1) /= '-'
|
||||
loop
|
||||
Index := Index + 1;
|
||||
end loop;
|
||||
-- Target_name is the program prefix without '-' but with a trailing '/'
|
||||
|
||||
if Target_Name (Target_Name'First .. Index) = "avr" then
|
||||
return "avr-";
|
||||
elsif Target_Name (Target_Name'First .. Index) = "erc32" then
|
||||
return "erc32-elf-";
|
||||
elsif Target_Name (Target_Name'First .. Index) = "leon" then
|
||||
return "leon-elf-";
|
||||
elsif Target_Name (Target_Name'First .. Index) = "powerpc" then
|
||||
if Target_Name'Length >= 23 and then
|
||||
Target_Name (Target_Name'First .. Target_Name'First + 22) =
|
||||
"powerpc-unknown-eabispe"
|
||||
then
|
||||
return "powerpc-eabispe-";
|
||||
else
|
||||
return "powerpc-elf-";
|
||||
end if;
|
||||
else
|
||||
return "";
|
||||
end if;
|
||||
return Target_Name (Target_Name'First .. Target_Name'Last - 1) & '-';
|
||||
end Get_Target_Prefix;
|
||||
|
||||
--------------------------------------
|
||||
|
|
|
@ -1410,7 +1410,7 @@ package body Par_SCO is
|
|||
Set_Statement_Entry;
|
||||
|
||||
-- Process case branches, all of which are dominated by the
|
||||
-- CASE expression.
|
||||
-- CASE statement.
|
||||
|
||||
declare
|
||||
Alt : Node_Id;
|
||||
|
@ -1419,7 +1419,7 @@ package body Par_SCO is
|
|||
while Present (Alt) loop
|
||||
Traverse_Declarations_Or_Statements
|
||||
(L => Statements (Alt),
|
||||
D => ('S', Expression (N)));
|
||||
D => Current_Dominant);
|
||||
Next (Alt);
|
||||
end loop;
|
||||
end;
|
||||
|
|
|
@ -78,6 +78,8 @@ pragma Style_Checks ("M32766");
|
|||
** $ RUN xoscons
|
||||
**/
|
||||
|
||||
/* Feature macro definitions */
|
||||
|
||||
#if defined (__linux__) && !defined (_XOPEN_SOURCE)
|
||||
/** For Linux _XOPEN_SOURCE must be defined, otherwise IOV_MAX is not defined
|
||||
**/
|
||||
|
@ -93,6 +95,10 @@ pragma Style_Checks ("M32766");
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* Include gsocket.h before any system header so it can redefine FD_SETSIZE */
|
||||
|
||||
#include "gsocket.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
@ -130,8 +136,6 @@ pragma Style_Checks ("M32766");
|
|||
# include <vxWorks.h>
|
||||
#endif
|
||||
|
||||
#include "gsocket.h"
|
||||
|
||||
#ifdef DUMMY
|
||||
|
||||
# if defined (TARGET)
|
||||
|
|
|
@ -5872,7 +5872,20 @@ package body Sem_Ch13 is
|
|||
-- All other cases
|
||||
|
||||
else
|
||||
Preanalyze_Spec_Expression (End_Decl_Expr, T);
|
||||
-- In a generic context freeze nodes are not generated, and the
|
||||
-- aspect expressions have not been preanalyzed, so do it now.
|
||||
-- There are no conformance checks to perform in this case.
|
||||
|
||||
if No (T)
|
||||
and then Inside_A_Generic
|
||||
then
|
||||
Check_Aspect_At_Freeze_Point (ASN);
|
||||
return;
|
||||
|
||||
else
|
||||
Preanalyze_Spec_Expression (End_Decl_Expr, T);
|
||||
end if;
|
||||
|
||||
Err := not Fully_Conformant_Expressions (End_Decl_Expr, Freeze_Expr);
|
||||
end if;
|
||||
|
||||
|
|
Loading…
Reference in New Issue