File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,17 @@ package Xoshiro128 with SPARK_Mode => On is
30
30
Global => null ,
31
31
Depends => (To_Float'Result => Value);
32
32
33
- type Generator is limited private ;
33
+ type Generator is private ;
34
+
35
+ function Is_Initialized (S : Generator) return Boolean
36
+ with Ghost ;
34
37
35
38
procedure Next (S : in out Generator; Value : out Unsigned_32)
36
39
with Inline_Always,
37
40
Global => null ,
38
- Depends => (S => S, Value => S);
41
+ Depends => (S => S, Value => S),
42
+ Pre => Is_Initialized (S),
43
+ Post => Is_Initialized (S) and S'Old /= S;
39
44
40
45
procedure Reset (S : out Generator; Seed : Unsigned_64)
41
46
with Global => null ,
@@ -47,4 +52,7 @@ private
47
52
type Generator is array (0 .. 3 ) of Unsigned_32
48
53
with Default_Component_Value => 0 ;
49
54
55
+ function Is_Initialized (S : Generator) return Boolean is
56
+ (for some I in S'Range => S (I) /= 0 );
57
+
50
58
end Xoshiro128 ;
Original file line number Diff line number Diff line change @@ -27,12 +27,17 @@ package Xoshiro256 with SPARK_Mode => On is
27
27
Global => null ,
28
28
Depends => (To_Float'Result => Value);
29
29
30
- type Generator is limited private ;
30
+ type Generator is private ;
31
+
32
+ function Is_Initialized (S : Generator) return Boolean
33
+ with Ghost ;
31
34
32
35
procedure Next (S : in out Generator; Value : out Unsigned_64)
33
36
with Inline_Always,
34
37
Global => null ,
35
- Depends => (S => S, Value => S);
38
+ Depends => (S => S, Value => S),
39
+ Pre => Is_Initialized (S),
40
+ Post => Is_Initialized (S) and S'Old /= S;
36
41
37
42
procedure Reset (S : out Generator; Seed : Unsigned_64)
38
43
with Global => null ,
@@ -44,4 +49,7 @@ private
44
49
type Generator is array (0 .. 3 ) of Unsigned_64
45
50
with Default_Component_Value => 0 ;
46
51
52
+ function Is_Initialized (S : Generator) return Boolean is
53
+ (for some I in S'Range => S (I) /= 0 );
54
+
47
55
end Xoshiro256 ;
You can’t perform that action at this time.
0 commit comments