1 pragma Spark_Mode
(On
);
4 type Element_Type
is private;
6 package Predicate8_Pkg
is
7 pragma Annotate
(GNATprove
, Terminating
, Predicate8_Pkg
);
9 subtype Small_Natural
is Natural range 0 .. Natural'Last / 2;
10 subtype Small_Positive
is Natural range 1 .. Natural'Last / 2;
12 type Element_Array_Type
is array (Small_Positive
range <>) of Element_Type
;
14 type Ring_Buffer_Type
(Max_Size
: Small_Positive
) is private
15 with Default_Initial_Condition
=> Empty
(Ring_Buffer_Type
);
18 (Buffer
: in Ring_Buffer_Type
) return Boolean;
21 (Buffer
: in Ring_Buffer_Type
) return Boolean;
24 (Buffer
: in Ring_Buffer_Type
) return Natural;
27 (Buffer
: in Ring_Buffer_Type
) return Natural;
30 (Buffer
: in Ring_Buffer_Type
) return Element_Type
32 Pre
=> not Empty
(Buffer
);
35 (Buffer
: in Ring_Buffer_Type
) return Element_Type
37 Pre
=> not Empty
(Buffer
);
40 (Buffer
: in out Ring_Buffer_Type
;
41 Element
: out Element_Type
)
43 Pre
=> not Empty
(Buffer
) and
45 Post
=> not Full
(Buffer
) and then
46 Element
= First
(Buffer
'Old) and then
47 Size
(Buffer
) = Size
(Buffer
'Old) - 1;
50 (Buffer
: in out Ring_Buffer_Type
;
51 Element
: in Element_Type
)
53 Pre
=> not Full
(Buffer
),
54 Post
=> not Empty
(Buffer
) and then
55 Last
(Buffer
) = Element
and then
56 Size
(Buffer
) = Size
(Buffer
'Old) + 1;
59 (Buffer
: in out Ring_Buffer_Type
)
61 Post
=> Empty
(Buffer
) and then
62 not Full
(Buffer
) and then
66 type Ring_Buffer_Type
(Max_Size
: Small_Positive
) is record
67 Count
: Small_Natural
:= 0;
68 Head
: Small_Positive
:= 1;
69 Tail
: Small_Positive
:= Max_Size
;
70 Items
: Element_Array_Type
(1 .. Max_Size
);
72 with Dynamic_Predicate
=>
73 (Max_Size
<= Small_Positive
'Last and
77 ((Count
= 0 and Tail
= Max_Size
and Head
= 1) or
78 (Count
= Max_Size
+ Tail
- Head
+ 1) or
79 (Count
= Tail
- Head
+ 1)));