|
4 | 4 | /// See the following link for more information on how extensible properties for primitive operations work:
|
5 | 5 | /// <https://flux-rs.github.io/flux/guide/specifications.html#extensible-properties-for-primitive-ops>
|
6 | 6 | #[flux::defs {
|
| 7 | + fn char_to_int(x:char) -> int { |
| 8 | + cast(x) |
| 9 | + } |
| 10 | +
|
7 | 11 | property ShiftRightByFour[>>](x, y) {
|
8 | 12 | 16 * [>>](x, 4) == x
|
9 | 13 | }
|
10 | 14 |
|
11 |
| - property MaskBy15[&](x, y) { |
12 |
| - [&](x, y) <= y |
| 15 | + property MaskLess[&](x, y) { |
| 16 | + [&](x, y) <= x && [&](x, y) <= y |
| 17 | + } |
| 18 | +
|
| 19 | + property ShiftLeft[<<](n, k) { |
| 20 | + 0 < k => n <= [<<](n, k) |
| 21 | + } |
| 22 | +
|
| 23 | + fn is_ascii_uppercase(n: int) -> bool { |
| 24 | + cast('A') <= n && n <= cast('Z') |
| 25 | + } |
| 26 | +
|
| 27 | + fn is_ascii_lowercase(n: int) -> bool { |
| 28 | + cast('a') <= n && n <= cast('z') |
| 29 | + } |
| 30 | +
|
| 31 | + fn to_ascii_uppercase(n: int) -> int { |
| 32 | + n - (cast(is_ascii_lowercase(n)) * 32) |
| 33 | + } |
| 34 | +
|
| 35 | + fn to_ascii_lowercase(n: int) -> int { |
| 36 | + n + (cast(is_ascii_uppercase(n)) * 32) |
| 37 | + } |
| 38 | +
|
| 39 | + property BitXor0[^](x, y) { |
| 40 | + (y == 0) => [^](x, y) == x |
| 41 | + } |
| 42 | +
|
| 43 | + property BitXor32[^](x, y) { |
| 44 | + (is_ascii_lowercase(x) && y == 32) => [^](x, y) == x - 32 |
| 45 | + } |
| 46 | +
|
| 47 | + property BitOr0[|](x, y) { |
| 48 | + (y == 0) => [|](x, y) == x |
| 49 | + } |
| 50 | +
|
| 51 | + property BitOr32[|](x, y) { |
| 52 | + (is_ascii_uppercase(x) && y == 32) => [|](x, y) == x + 32 |
| 53 | + } |
| 54 | +
|
| 55 | +}] |
| 56 | +#[flux::specs { |
| 57 | + mod hash { |
| 58 | + mod sip { |
| 59 | + struct Hasher { |
| 60 | + k0: u64, |
| 61 | + k1: u64, |
| 62 | + length: usize, // how many bytes we've processed |
| 63 | + state: State, // hash State |
| 64 | + tail: u64, // unprocessed bytes le |
| 65 | + ntail: usize{v: v <= 8}, // how many bytes in tail are valid |
| 66 | + _marker: PhantomData<S>, |
| 67 | + } |
| 68 | + } |
| 69 | +
|
| 70 | + impl BuildHasherDefault { |
| 71 | + #[trusted(reason="https://github.com/flux-rs/flux/issues/1185")] |
| 72 | + fn new() -> Self; |
| 73 | + } |
| 74 | + } |
| 75 | +
|
| 76 | + impl Hasher for hash::sip::Hasher { |
| 77 | + fn write(self: &mut Self, msg: &[u8]) ensures self: Self; // mut-ref-unfolding |
| 78 | + } |
| 79 | +
|
| 80 | + impl Clone for hash::BuildHasherDefault { |
| 81 | + #[trusted(reason="https://github.com/flux-rs/flux/issues/1185")] |
| 82 | + fn clone(self: &Self) -> Self; |
| 83 | + } |
| 84 | +
|
| 85 | + impl Debug for time::Duration { |
| 86 | + #[trusted(reason="modular arithmetic invariant inside nested fmt_decimal")] |
| 87 | + fn fmt(self: &Self, f: &mut fmt::Formatter) -> fmt::Result; |
13 | 88 | }
|
14 | 89 | }]
|
15 | 90 | const _: () = {};
|
0 commit comments