| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- S Y S T E M . V A L U E _ I _ S P E C -- |
| 6 |
-- -- |
| 7 |
-- B o d y -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 2022-2025, Free Software Foundation, Inc. -- |
| 10 |
-- -- |
| 11 |
-- GNAT is free software; you can redistribute it and/or modify it under -- |
| 12 |
-- terms of the GNU General Public License as published by the Free Soft- -- |
| 13 |
-- ware Foundation; either version 3, or (at your option) any later ver- -- |
| 14 |
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
| 15 |
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
| 16 |
-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
| 17 |
-- -- |
| 18 |
-- As a special exception under Section 7 of GPL version 3, you are granted -- |
| 19 |
-- additional permissions described in the GCC Runtime Library Exception, -- |
| 20 |
-- version 3.1, as published by the Free Software Foundation. -- |
| 21 |
-- -- |
| 22 |
-- You should have received a copy of the GNU General Public License and -- |
| 23 |
-- a copy of the GCC Runtime Library Exception along with this program; -- |
| 24 |
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
| 25 |
-- <http://www.gnu.org/licenses/>. -- |
| 26 |
-- -- |
| 27 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 28 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 29 |
-- -- |
| 30 |
------------------------------------------------------------------------------ |
| 31 |
|
| 32 |
pragma Assertion_Policy (Pre => Ignore, |
| 33 |
Post => Ignore, |
| 34 |
Contract_Cases => Ignore, |
| 35 |
Ghost => Ignore, |
| 36 |
Subprogram_Variant => Ignore); |
| 37 |
|
| 38 |
package body System.Value_I_Spec is |
| 39 |
|
| 40 |
----------------------------------- |
| 41 |
-- Prove_Scan_Only_Decimal_Ghost -- |
| 42 |
----------------------------------- |
| 43 |
|
| 44 |
procedure Prove_Scan_Only_Decimal_Ghost (Str : String; Val : Int) is |
| 45 |
Non_Blank : constant Positive := First_Non_Space_Ghost |
| 46 |
(Str, Str'First, Str'Last); |
| 47 |
pragma Assert (Str (Str'First + 1) /= ' '); |
| 48 |
pragma Assert |
| 49 |
(if Val < 0 then Non_Blank = Str'First |
| 50 |
else |
| 51 |
Str (Str'First) = ' ' |
| 52 |
and then Non_Blank = Str'First + 1); |
| 53 |
Minus : constant Boolean := Str (Non_Blank) = '-'; |
| 54 |
Fst_Num : constant Positive := |
| 55 |
(if Minus then Non_Blank + 1 else Non_Blank); |
| 56 |
pragma Assert (Fst_Num = Str'First + 1); |
| 57 |
Uval : constant Uns := Abs_Uns_Of_Int (Val); |
| 58 |
|
| 59 |
procedure Prove_Conversion_Is_Identity (Val : Int; Uval : Uns) |
| 60 |
with |
| 61 |
Pre => Minus = (Val < 0) |
| 62 |
and then Uval = Abs_Uns_Of_Int (Val), |
| 63 |
Post => Uns_Is_Valid_Int (Minus, Uval) |
| 64 |
and then Is_Int_Of_Uns (Minus, Uval, Val); |
| 65 |
-- Local proof of the unicity of the signed representation |
| 66 |
|
| 67 |
procedure Prove_Conversion_Is_Identity (Val : Int; Uval : Uns) is null; |
| 68 |
|
| 69 |
-- Start of processing for Prove_Scan_Only_Decimal_Ghost |
| 70 |
|
| 71 |
begin |
| 72 |
Prove_Conversion_Is_Identity (Val, Uval); |
| 73 |
pragma Assert |
| 74 |
(U_Spec.Is_Raw_Unsigned_Format_Ghost (Str (Fst_Num .. Str'Last))); |
| 75 |
pragma Assert |
| 76 |
(U_Spec.Scan_Split_No_Overflow_Ghost (Str, Fst_Num, Str'Last)); |
| 77 |
U_Spec.Lemma_Exponent_Unsigned_Ghost_Base (Uval, 0, 10); |
| 78 |
pragma Assert |
| 79 |
(U_Spec.Raw_Unsigned_No_Overflow_Ghost (Str, Fst_Num, Str'Last)); |
| 80 |
pragma Assert (Only_Space_Ghost |
| 81 |
(Str, U_Spec.Raw_Unsigned_Last_Ghost |
| 82 |
(Str, Fst_Num, Str'Last), Str'Last)); |
| 83 |
pragma Assert (Is_Integer_Ghost (Str)); |
| 84 |
pragma Assert (Is_Value_Integer_Ghost (Str, Val)); |
| 85 |
end Prove_Scan_Only_Decimal_Ghost; |
| 86 |
|
| 87 |
end System.Value_I_Spec; |