-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move type operations to separate child package
ref #1126
- Loading branch information
Showing
210 changed files
with
1,152 additions
and
818 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
rflx/templates/rflx_generic_types-generic_operations.ads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
pragma Style_Checks ("N3aAbcdefhiIklnOprStux"); | ||
|
||
with {prefix}RFLX_Generic_Types.Generic_Operators; | ||
|
||
generic | ||
with package Operators is new {prefix}RFLX_Generic_Types.Generic_Operators (<>); | ||
package {prefix}RFLX_Generic_Types.Generic_Operations with | ||
SPARK_Mode, | ||
Annotate => | ||
(GNATprove, Always_Return) | ||
is | ||
use Operators; | ||
|
||
use type U64; | ||
|
||
function Extract | ||
(Buffer : Bytes_Ptr; | ||
First : Index; | ||
Last : Index; | ||
Off : Offset; | ||
Size : Positive; | ||
BO : Byte_Order) return U64 | ||
with | ||
Pre => | ||
(Buffer /= null | ||
and then First >= Buffer'First | ||
and then Last <= Buffer'Last | ||
and then Size in 1 .. U64'Size | ||
and then First <= Last | ||
and then Last - First <= Index'Last - 1 | ||
and then Length ((Offset'Pos (Off) + Size - 1) / Byte'Size) < Length (Last - First + 1) | ||
and then (Offset'Pos (Off) + Size - 1) / Byte'Size <= Natural'Size | ||
and then (Byte'Size - Natural (Offset'Pos (Off) mod Byte'Size)) < Long_Integer'Size - 1), | ||
Post => | ||
(if Size < U64'Size then Extract'Result < 2**Size); | ||
|
||
function Extract | ||
(Buffer : Bytes_Ptr; | ||
First : Index; | ||
Last : Index; | ||
Off : Offset; | ||
Size : Positive; | ||
BO : Byte_Order) return Base_Integer | ||
with | ||
Pre => | ||
(Buffer /= null | ||
and then First >= Buffer'First | ||
and then Last <= Buffer'Last | ||
and then Size in 1 .. 63 | ||
and then First <= Last | ||
and then Last - First <= Index'Last - 1 | ||
and then Length ((Offset'Pos (Off) + Size - 1) / Byte'Size) < Length (Last - First + 1) | ||
and then (Offset'Pos (Off) + Size - 1) / Byte'Size <= Natural'Size | ||
and then (Byte'Size - Natural (Offset'Pos (Off) mod Byte'Size)) < Long_Integer'Size - 1), | ||
Post => | ||
(U64 (Extract'Result) < 2**Size); | ||
|
||
procedure Insert | ||
(Val : U64; | ||
Buffer : Bytes_Ptr; | ||
First : Index; | ||
Last : Index; | ||
Off : Offset; | ||
Size : Positive; | ||
BO : Byte_Order) | ||
with | ||
Pre => | ||
(Buffer /= null | ||
and then First >= Buffer'First | ||
and then Last <= Buffer'Last | ||
and then Size in 1 .. U64'Size | ||
and then Fits_Into (Val, Size) | ||
and then First <= Last | ||
and then Last - First <= Index'Last - 1 | ||
and then Length ((Offset'Pos (Off) + Size - 1) / Byte'Size) < Length (Last - First + 1)), | ||
Post => | ||
(Buffer'First = Buffer.all'Old'First and Buffer'Last = Buffer.all'Old'Last); | ||
|
||
procedure Insert | ||
(Val : Base_Integer; | ||
Buffer : Bytes_Ptr; | ||
First : Index; | ||
Last : Index; | ||
Off : Offset; | ||
Size : Positive; | ||
BO : Byte_Order) | ||
with | ||
Pre => | ||
(Buffer /= null | ||
and then First >= Buffer'First | ||
and then Last <= Buffer'Last | ||
and then Size in 1 .. 63 | ||
and then Fits_Into (Val, Size) | ||
and then First <= Last | ||
and then Last - First <= Index'Last - 1 | ||
and then Length ((Offset'Pos (Off) + Size - 1) / Byte'Size) < Length (Last - First + 1)), | ||
Post => | ||
(Buffer'First = Buffer.all'Old'First and Buffer'Last = Buffer.all'Old'Last); | ||
|
||
end {prefix}RFLX_Generic_Types.Generic_Operations; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
generic | ||
package {prefix}RFLX_Generic_Types.Generic_Operators with | ||
SPARK_Mode, | ||
Annotate => | ||
(GNATprove, Always_Return) | ||
is | ||
|
||
function "+" (Left : Index; Right : Length) return Index is | ||
(Index (Length (Left) + Right)) | ||
with | ||
Pre => | ||
Length (Left) <= Length'Last - Right; | ||
|
||
function "-" (Left : Index; Right : Index) return Length is | ||
(Length (Left) - Length (Right)) | ||
with | ||
Pre => | ||
Length (Left) >= Length'First + Length (Right); | ||
|
||
function "-" (Left : Index; Right : Length) return Index is | ||
(Index (Length (Left) - Right)) | ||
with | ||
Pre => | ||
Right < Length'Last | ||
and then Length (Left) >= Length (Index'First) + Right; | ||
|
||
end {prefix}RFLX_Generic_Types.Generic_Operators; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.