From 07e060a972af9d75428567baca372cf7bc8abc78 Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Wed, 8 May 2024 21:44:11 -0600 Subject: [PATCH] hacking --- crates/library2/std/src/{ => mem}/buf.fe | 0 crates/library2/std/src/num.fe | 469 -------------------- crates/library2/std/src/num/int/extend.fe | 156 +++++++ crates/library2/std/src/num/int/mod.fe | 4 + crates/library2/std/src/num/int/ops.fe | 274 ++++++++++++ crates/library2/std/src/num/int/saturate.fe | 157 +++++++ crates/library2/std/src/num/int/truncate.fe | 157 +++++++ crates/library2/std/src/ops.fe | 211 --------- crates/library2/std/src/ops/bin.fe | 33 ++ crates/library2/std/src/ops/un.fe | 0 10 files changed, 781 insertions(+), 680 deletions(-) rename crates/library2/std/src/{ => mem}/buf.fe (100%) delete mode 100644 crates/library2/std/src/num.fe create mode 100644 crates/library2/std/src/num/int/extend.fe create mode 100644 crates/library2/std/src/num/int/mod.fe create mode 100644 crates/library2/std/src/num/int/ops.fe create mode 100644 crates/library2/std/src/num/int/saturate.fe create mode 100644 crates/library2/std/src/num/int/truncate.fe delete mode 100644 crates/library2/std/src/ops.fe create mode 100644 crates/library2/std/src/ops/bin.fe create mode 100644 crates/library2/std/src/ops/un.fe diff --git a/crates/library2/std/src/buf.fe b/crates/library2/std/src/mem/buf.fe similarity index 100% rename from crates/library2/std/src/buf.fe rename to crates/library2/std/src/mem/buf.fe diff --git a/crates/library2/std/src/num.fe b/crates/library2/std/src/num.fe deleted file mode 100644 index 041e8a49e9..0000000000 --- a/crates/library2/std/src/num.fe +++ /dev/null @@ -1,469 +0,0 @@ -pub type isize = i256 -pub type usize = u256 - -extern { - fn __u16_u8_saturate(_ x: u16) -> u8 - fn __u32_u8_saturate(_ x: u32) -> u8 - fn __u32_u16_saturate(_ x: u32) -> u16 - fn __u64_u8_saturate(_ x: u64) -> u8 - fn __u64_u16_saturate(_ x: u64) -> u16 - fn __u64_u32_saturate(_ x: u64) -> u32 - fn __u128_u8_saturate(_ x: u128) -> u8 - fn __u128_u16_saturate(_ x: u128) -> u16 - fn __u128_u32_saturate(_ x: u128) -> u32 - fn __u128_u64_saturate(_ x: u128) -> u64 - fn __u256_u8_saturate(_ x: u256) -> u8 - fn __u256_u16_saturate(_ x: u256) -> u16 - fn __u256_u32_saturate(_ x: u256) -> u32 - fn __u256_u64_saturate(_ x: u256) -> u64 - fn __u256_u128_saturate(_ x: u256) -> u128 - fn __i16_i8_saturate(_ x: i16) -> i8 - fn __i32_i8_saturate(_ x: i32) -> i8 - fn __i32_i16_saturate(_ x: i32) -> i16 - fn __i64_i8_saturate(_ x: i64) -> i8 - fn __i64_i16_saturate(_ x: i64) -> i16 - fn __i64_i32_saturate(_ x: i64) -> i32 - fn __i128_i8_saturate(_ x: i128) -> i8 - fn __i128_i16_saturate(_ x: i128) -> i16 - fn __i128_i32_saturate(_ x: i128) -> i32 - fn __i128_i64_saturate(_ x: i128) -> i64 - fn __i256_i8_saturate(_ x: i256) -> i8 - fn __i256_i16_saturate(_ x: i256) -> i16 - fn __i256_i32_saturate(_ x: i256) -> i32 - fn __i256_i64_saturate(_ x: i256) -> i64 - fn __i256_i128_saturate(_ x: i256) -> i128 - - fn __u16_u8_truncate(_ x: u16) -> u8 - fn __u32_u8_truncate(_ x: u32) -> u8 - fn __u32_u16_truncate(_ x: u32) -> u16 - fn __u64_u8_truncate(_ x: u64) -> u8 - fn __u64_u16_truncate(_ x: u64) -> u16 - fn __u64_u32_truncate(_ x: u64) -> u32 - fn __u128_u8_truncate(_ x: u128) -> u8 - fn __u128_u16_truncate(_ x: u128) -> u16 - fn __u128_u32_truncate(_ x: u128) -> u32 - fn __u128_u64_truncate(_ x: u128) -> u64 - fn __u256_u8_truncate(_ x: u256) -> u8 - fn __u256_u16_truncate(_ x: u256) -> u16 - fn __u256_u32_truncate(_ x: u256) -> u32 - fn __u256_u64_truncate(_ x: u256) -> u64 - fn __u256_u128_truncate(_ x: u256) -> u128 - fn __i16_i8_truncate(_ x: i16) -> i8 - fn __i32_i8_truncate(_ x: i32) -> i8 - fn __i32_i16_truncate(_ x: i32) -> i16 - fn __i64_i8_truncate(_ x: i64) -> i8 - fn __i64_i16_truncate(_ x: i64) -> i16 - fn __i64_i32_truncate(_ x: i64) -> i32 - fn __i128_i8_truncate(_ x: i128) -> i8 - fn __i128_i16_truncate(_ x: i128) -> i16 - fn __i128_i32_truncate(_ x: i128) -> i32 - fn __i128_i64_truncate(_ x: i128) -> i64 - fn __i256_i8_truncate(_ x: i256) -> i8 - fn __i256_i16_truncate(_ x: i256) -> i16 - fn __i256_i32_truncate(_ x: i256) -> i32 - fn __i256_i64_truncate(_ x: i256) -> i64 - fn __i256_i128_truncate(_ x: i256) -> i128 - - fn __u8_u16_extend(_ x: u8) -> u16 - fn __u8_u32_extend(_ x: u8) -> u32 - fn __u8_u64_extend(_ x: u8) -> u64 - fn __u8_u128_extend(_ x: u8) -> u128 - fn __u8_u256_extend(_ x: u8) -> u256 - fn __u16_u32_extend(_ x: u16) -> u32 - fn __u16_u64_extend(_ x: u16) -> u64 - fn __u16_u128_extend(_ x: u16) -> u128 - fn __u16_u256_extend(_ x: u16) -> u256 - fn __u32_u64_extend(_ x: u32) -> u64 - fn __u32_u128_extend(_ x: u32) -> u128 - fn __u32_u256_extend(_ x: u32) -> u256 - fn __u64_u128_extend(_ x: u64) -> u128 - fn __u64_u256_extend(_ x: u64) -> u256 - fn __u128_u256_extend(_ x: u128) -> u256 - fn __i8_i16_extend(_ x: i8) -> i16 - fn __i8_i32_extend(_ x: i8) -> i32 - fn __i8_i64_extend(_ x: i8) -> i64 - fn __i8_i128_extend(_ x: i8) -> i128 - fn __i8_i256_extend(_ x: i8) -> i256 - fn __i16_i32_extend(_ x: i16) -> i32 - fn __i16_i64_extend(_ x: i16) -> i64 - fn __i16_i128_extend(_ x: i16) -> i128 - fn __i16_i256_extend(_ x: i16) -> i256 - fn __i32_i64_extend(_ x: i32) -> i64 - fn __i32_i128_extend(_ x: i32) -> i128 - fn __i32_i256_extend(_ x: i32) -> i256 - fn __i64_i128_extend(_ x: i64) -> i128 - fn __i64_i256_extend(_ x: i64) -> i256 - fn __i128_i256_extend(_ x: i128) -> i256 -} - -pub trait Saturate { - fn saturate(self) -> Out -} - -impl Saturate for u16 { - fn saturate(self) -> u8 { __u16_u8_saturate(self) } -} - -impl Saturate for u32 { - fn saturate(self) -> u8 { __u32_u8_saturate(self) } -} - -impl Saturate for u32 { - fn saturate(self) -> u16 { __u32_u16_saturate(self) } -} - -impl Saturate for u64 { - fn saturate(self) -> u8 { __u64_u8_saturate(self) } -} - -impl Saturate for u64 { - fn saturate(self) -> u16 { __u64_u16_saturate(self) } -} - -impl Saturate for u64 { - fn saturate(self) -> u32 { __u64_u32_saturate(self) } -} - -impl Saturate for u128 { - fn saturate(self) -> u8 { __u128_u8_saturate(self) } -} - -impl Saturate for u128 { - fn saturate(self) -> u16 { __u128_u16_saturate(self) } -} - -impl Saturate for u128 { - fn saturate(self) -> u32 { __u128_u32_saturate(self) } -} - -impl Saturate for u128 { - fn saturate(self) -> u64 { __u128_u64_saturate(self) } -} - -impl Saturate for u256 { - fn saturate(self) -> u8 { __u256_u8_saturate(self) } -} - -impl Saturate for u256 { - fn saturate(self) -> u16 { __u256_u16_saturate(self) } -} - -impl Saturate for u256 { - fn saturate(self) -> u32 { __u256_u32_saturate(self) } -} - -impl Saturate for u256 { - fn saturate(self) -> u64 { __u256_u64_saturate(self) } -} - -impl Saturate for u256 { - fn saturate(self) -> u128 { __u256_u128_saturate(self) } -} - -impl Saturate for i16 { - fn saturate(self) -> i8 { __i16_i8_saturate(self) } -} - -impl Saturate for i32 { - fn saturate(self) -> i8 { __i32_i8_saturate(self) } -} - -impl Saturate for i32 { - fn saturate(self) -> i16 { __i32_i16_saturate(self) } -} - -impl Saturate for i64 { - fn saturate(self) -> i8 { __i64_i8_saturate(self) } -} - -impl Saturate for i64 { - fn saturate(self) -> i16 { __i64_i16_saturate(self) } -} - -impl Saturate for i64 { - fn saturate(self) -> i32 { __i64_i32_saturate(self) } -} - -impl Saturate for i128 { - fn saturate(self) -> i8 { __i128_i8_saturate(self) } -} - -impl Saturate for i128 { - fn saturate(self) -> i16 { __i128_i16_saturate(self) } -} - -impl Saturate for i128 { - fn saturate(self) -> i32 { __i128_i32_saturate(self) } -} - -impl Saturate for i128 { - fn saturate(self) -> i64 { __i128_i64_saturate(self) } -} - -impl Saturate for i256 { - fn saturate(self) -> i8 { __i256_i8_saturate(self) } -} - -impl Saturate for i256 { - fn saturate(self) -> i16 { __i256_i16_saturate(self) } -} - -impl Saturate for i256 { - fn saturate(self) -> i32 { __i256_i32_saturate(self) } -} - -impl Saturate for i256 { - fn saturate(self) -> i64 { __i256_i64_saturate(self) } -} - -impl Saturate for i256 { - fn saturate(self) -> i128 { __i256_i128_saturate(self) } -} - -pub trait Truncate { - fn truncate(self) -> Out -} - -impl Truncate for u16 { - fn truncate(self) -> u8 { __u16_u8_truncate(self) } -} - -impl Truncate for u32 { - fn truncate(self) -> u8 { __u32_u8_truncate(self) } -} - -impl Truncate for u32 { - fn truncate(self) -> u16 { __u32_u16_truncate(self) } -} - -impl Truncate for u64 { - fn truncate(self) -> u8 { __u64_u8_truncate(self) } -} - -impl Truncate for u64 { - fn truncate(self) -> u16 { __u64_u16_truncate(self) } -} - -impl Truncate for u64 { - fn truncate(self) -> u32 { __u64_u32_truncate(self) } -} - -impl Truncate for u128 { - fn truncate(self) -> u8 { __u128_u8_truncate(self) } -} - -impl Truncate for u128 { - fn truncate(self) -> u16 { __u128_u16_truncate(self) } -} - -impl Truncate for u128 { - fn truncate(self) -> u32 { __u128_u32_truncate(self) } -} - -impl Truncate for u128 { - fn truncate(self) -> u64 { __u128_u64_truncate(self) } -} - -impl Truncate for u256 { - fn truncate(self) -> u8 { __u256_u8_truncate(self) } -} - -impl Truncate for u256 { - fn truncate(self) -> u16 { __u256_u16_truncate(self) } -} - -impl Truncate for u256 { - fn truncate(self) -> u32 { __u256_u32_truncate(self) } -} - -impl Truncate for u256 { - fn truncate(self) -> u64 { __u256_u64_truncate(self) } -} - -impl Truncate for u256 { - fn truncate(self) -> u128 { __u256_u128_truncate(self) } -} - -impl Truncate for i16 { - fn truncate(self) -> i8 { __i16_i8_truncate(self) } -} - -impl Truncate for i32 { - fn truncate(self) -> i8 { __i32_i8_truncate(self) } -} - -impl Truncate for i32 { - fn truncate(self) -> i16 { __i32_i16_truncate(self) } -} - -impl Truncate for i64 { - fn truncate(self) -> i8 { __i64_i8_truncate(self) } -} - -impl Truncate for i64 { - fn truncate(self) -> i16 { __i64_i16_truncate(self) } -} - -impl Truncate for i64 { - fn truncate(self) -> i32 { __i64_i32_truncate(self) } -} - -impl Truncate for i128 { - fn truncate(self) -> i8 { __i128_i8_truncate(self) } -} - -impl Truncate for i128 { - fn truncate(self) -> i16 { __i128_i16_truncate(self) } -} - -impl Truncate for i128 { - fn truncate(self) -> i32 { __i128_i32_truncate(self) } -} - -impl Truncate for i128 { - fn truncate(self) -> i64 { __i128_i64_truncate(self) } -} - -impl Truncate for i256 { - fn truncate(self) -> i8 { __i256_i8_truncate(self) } -} - -impl Truncate for i256 { - fn truncate(self) -> i16 { __i256_i16_truncate(self) } -} - -impl Truncate for i256 { - fn truncate(self) -> i32 { __i256_i32_truncate(self) } -} - -impl Truncate for i256 { - fn truncate(self) -> i64 { __i256_i64_truncate(self) } -} - -impl Truncate for i256 { - fn truncate(self) -> i128 { __i256_i128_truncate(self) } -} - -pub trait Extend { - fn extend(self) -> Out -} - -impl Extend for u8 { - fn extend(self) -> u16 { __u8_u16_extend(self) } -} - -impl Extend for u8 { - fn extend(self) -> u32 { __u8_u32_extend(self) } -} - -impl Extend for u8 { - fn extend(self) -> u64 { __u8_u64_extend(self) } -} - -impl Extend for u8 { - fn extend(self) -> u128 { __u8_u128_extend(self) } -} - -impl Extend for u8 { - fn extend(self) -> u256 { __u8_u256_extend(self) } -} - -impl Extend for u16 { - fn extend(self) -> u32 { __u16_u32_extend(self) } -} - -impl Extend for u16 { - fn extend(self) -> u64 { __u16_u64_extend(self) } -} - -impl Extend for u16 { - fn extend(self) -> u128 { __u16_u128_extend(self) } -} - -impl Extend for u16 { - fn extend(self) -> u256 { __u16_u256_extend(self) } -} - -impl Extend for u32 { - fn extend(self) -> u64 { __u32_u64_extend(self) } -} - -impl Extend for u32 { - fn extend(self) -> u128 { __u32_u128_extend(self) } -} - -impl Extend for u32 { - fn extend(self) -> u256 { __u32_u256_extend(self) } -} - -impl Extend for u64 { - fn extend(self) -> u128 { __u64_u128_extend(self) } -} - -impl Extend for u64 { - fn extend(self) -> u256 { __u64_u256_extend(self) } -} - -impl Extend for u128 { - fn extend(self) -> u256 { __u128_u256_extend(self) } -} - -impl Extend for i8 { - fn extend(self) -> i16 { __i8_i16_extend(self) } -} - -impl Extend for i8 { - fn extend(self) -> i32 { __i8_i32_extend(self) } -} - -impl Extend for i8 { - fn extend(self) -> i64 { __i8_i64_extend(self) } -} - -impl Extend for i8 { - fn extend(self) -> i128 { __i8_i128_extend(self) } -} - -impl Extend for i8 { - fn extend(self) -> i256 { __i8_i256_extend(self) } -} - -impl Extend for i16 { - fn extend(self) -> i32 { __i16_i32_extend(self) } -} - -impl Extend for i16 { - fn extend(self) -> i64 { __i16_i64_extend(self) } -} - -impl Extend for i16 { - fn extend(self) -> i128 { __i16_i128_extend(self) } -} - -impl Extend for i16 { - fn extend(self) -> i256 { __i16_i256_extend(self) } -} - -impl Extend for i32 { - fn extend(self) -> i64 { __i32_i64_extend(self) } -} - -impl Extend for i32 { - fn extend(self) -> i128 { __i32_i128_extend(self) } -} - -impl Extend for i32 { - fn extend(self) -> i256 { __i32_i256_extend(self) } -} - -impl Extend for i64 { - fn extend(self) -> i128 { __i64_i128_extend(self) } -} - -impl Extend for i64 { - fn extend(self) -> i256 { __i64_i256_extend(self) } -} - -impl Extend for i128 { - fn extend(self) -> i256 { __i128_i256_extend(self) } -} \ No newline at end of file diff --git a/crates/library2/std/src/num/int/extend.fe b/crates/library2/std/src/num/int/extend.fe new file mode 100644 index 0000000000..ec3a2a989d --- /dev/null +++ b/crates/library2/std/src/num/int/extend.fe @@ -0,0 +1,156 @@ +extern { + fn __u8_u16_extend(_ x: u8) -> u16 + fn __u8_u32_extend(_ x: u8) -> u32 + fn __u8_u64_extend(_ x: u8) -> u64 + fn __u8_u128_extend(_ x: u8) -> u128 + fn __u8_u256_extend(_ x: u8) -> u256 + fn __u16_u32_extend(_ x: u16) -> u32 + fn __u16_u64_extend(_ x: u16) -> u64 + fn __u16_u128_extend(_ x: u16) -> u128 + fn __u16_u256_extend(_ x: u16) -> u256 + fn __u32_u64_extend(_ x: u32) -> u64 + fn __u32_u128_extend(_ x: u32) -> u128 + fn __u32_u256_extend(_ x: u32) -> u256 + fn __u64_u128_extend(_ x: u64) -> u128 + fn __u64_u256_extend(_ x: u64) -> u256 + fn __u128_u256_extend(_ x: u128) -> u256 + fn __i8_i16_extend(_ x: i8) -> i16 + fn __i8_i32_extend(_ x: i8) -> i32 + fn __i8_i64_extend(_ x: i8) -> i64 + fn __i8_i128_extend(_ x: i8) -> i128 + fn __i8_i256_extend(_ x: i8) -> i256 + fn __i16_i32_extend(_ x: i16) -> i32 + fn __i16_i64_extend(_ x: i16) -> i64 + fn __i16_i128_extend(_ x: i16) -> i128 + fn __i16_i256_extend(_ x: i16) -> i256 + fn __i32_i64_extend(_ x: i32) -> i64 + fn __i32_i128_extend(_ x: i32) -> i128 + fn __i32_i256_extend(_ x: i32) -> i256 + fn __i64_i128_extend(_ x: i64) -> i128 + fn __i64_i256_extend(_ x: i64) -> i256 + fn __i128_i256_extend(_ x: i128) -> i256 +} + +pub trait Extend { + fn extend(self) -> Out +} + +impl Extend for u8 { + fn extend(self) -> u16 { __u8_u16_extend(self) } +} + +impl Extend for u8 { + fn extend(self) -> u32 { __u8_u32_extend(self) } +} + +impl Extend for u8 { + fn extend(self) -> u64 { __u8_u64_extend(self) } +} + +impl Extend for u8 { + fn extend(self) -> u128 { __u8_u128_extend(self) } +} + +impl Extend for u8 { + fn extend(self) -> u256 { __u8_u256_extend(self) } +} + +impl Extend for u16 { + fn extend(self) -> u32 { __u16_u32_extend(self) } +} + +impl Extend for u16 { + fn extend(self) -> u64 { __u16_u64_extend(self) } +} + +impl Extend for u16 { + fn extend(self) -> u128 { __u16_u128_extend(self) } +} + +impl Extend for u16 { + fn extend(self) -> u256 { __u16_u256_extend(self) } +} + +impl Extend for u32 { + fn extend(self) -> u64 { __u32_u64_extend(self) } +} + +impl Extend for u32 { + fn extend(self) -> u128 { __u32_u128_extend(self) } +} + +impl Extend for u32 { + fn extend(self) -> u256 { __u32_u256_extend(self) } +} + +impl Extend for u64 { + fn extend(self) -> u128 { __u64_u128_extend(self) } +} + +impl Extend for u64 { + fn extend(self) -> u256 { __u64_u256_extend(self) } +} + +impl Extend for u128 { + fn extend(self) -> u256 { __u128_u256_extend(self) } +} + +impl Extend for i8 { + fn extend(self) -> i16 { __i8_i16_extend(self) } +} + +impl Extend for i8 { + fn extend(self) -> i32 { __i8_i32_extend(self) } +} + +impl Extend for i8 { + fn extend(self) -> i64 { __i8_i64_extend(self) } +} + +impl Extend for i8 { + fn extend(self) -> i128 { __i8_i128_extend(self) } +} + +impl Extend for i8 { + fn extend(self) -> i256 { __i8_i256_extend(self) } +} + +impl Extend for i16 { + fn extend(self) -> i32 { __i16_i32_extend(self) } +} + +impl Extend for i16 { + fn extend(self) -> i64 { __i16_i64_extend(self) } +} + +impl Extend for i16 { + fn extend(self) -> i128 { __i16_i128_extend(self) } +} + +impl Extend for i16 { + fn extend(self) -> i256 { __i16_i256_extend(self) } +} + +impl Extend for i32 { + fn extend(self) -> i64 { __i32_i64_extend(self) } +} + +impl Extend for i32 { + fn extend(self) -> i128 { __i32_i128_extend(self) } +} + +impl Extend for i32 { + fn extend(self) -> i256 { __i32_i256_extend(self) } +} + +impl Extend for i64 { + fn extend(self) -> i128 { __i64_i128_extend(self) } +} + +impl Extend for i64 { + fn extend(self) -> i256 { __i64_i256_extend(self) } +} + +impl Extend for i128 { + fn extend(self) -> i256 { __i128_i256_extend(self) } +} \ No newline at end of file diff --git a/crates/library2/std/src/num/int/mod.fe b/crates/library2/std/src/num/int/mod.fe new file mode 100644 index 0000000000..f6c23c39a3 --- /dev/null +++ b/crates/library2/std/src/num/int/mod.fe @@ -0,0 +1,4 @@ +/// Integer manipulation and operations. + +pub type isize = i256 +pub type usize = u256 \ No newline at end of file diff --git a/crates/library2/std/src/num/int/ops.fe b/crates/library2/std/src/num/int/ops.fe new file mode 100644 index 0000000000..65812fcd3b --- /dev/null +++ b/crates/library2/std/src/num/int/ops.fe @@ -0,0 +1,274 @@ +extern { + fn __invalid() -> ! +} + + +// Addition `x + y` + +pub trait Add { + fn add(self, rhs: RHS) -> Out +} + +impl Add for i8 { + fn add(self, rhs: Self) -> Self { __invalid() } +} + +impl Add for i16 { + fn add(self, rhs: Self) -> Self { __invalid() } +} + +impl Add for i32 { + fn add(self, rhs: Self) -> Self { __invalid() } +} + +impl Add for i64 { + fn add(self, rhs: Self) -> Self { __invalid() } +} + +impl Add for i128 { + fn add(self, rhs: Self) -> Self { __invalid() } +} + +impl Add for i256 { + fn add(self, rhs: Self) -> Self { __invalid() } +} + +impl Add for u8 { + fn add(self, rhs: Self) -> Self { __invalid() } +} + +impl Add for u16 { + fn add(self, rhs: Self) -> Self { __invalid() } +} + +impl Add for u32 { + fn add(self, rhs: Self) -> Self { __invalid() } +} + +impl Add for u64 { + fn add(self, rhs: Self) -> Self { __invalid() } +} + +impl Add for u128 { + fn add(self, rhs: Self) -> Self { __invalid() } +} + +impl Add for u256 { + fn add(self, rhs: Self) -> Self { __invalid() } +} + +// Subtraction `x - y` + +pub trait Sub { + fn sub(self, rhs: RHS) -> Out +} + +impl Sub for i8 { + fn sub(self, rhs: Self) -> Self { __invalid() } +} + +impl Sub for i16 { + fn sub(self, rhs: Self) -> Self { __invalid() } +} + +impl Sub for i32 { + fn sub(self, rhs: Self) -> Self { __invalid() } +} + +impl Sub for i64 { + fn sub(self, rhs: Self) -> Self { __invalid() } +} + +impl Sub for i128 { + fn sub(self, rhs: Self) -> Self { __invalid() } +} + +impl Sub for i256 { + fn sub(self, rhs: Self) -> Self { __invalid() } +} + +impl Sub for u8 { + fn sub(self, rhs: Self) -> Self { __invalid() } +} + +impl Sub for u16 { + fn sub(self, rhs: Self) -> Self { __invalid() } +} + +impl Sub for u32 { + fn sub(self, rhs: Self) -> Self { __invalid() } +} + +impl Sub for u64 { + fn sub(self, rhs: Self) -> Self { __invalid() } +} + +impl Sub for u128 { + fn sub(self, rhs: Self) -> Self { __invalid() } +} + +impl Sub for u256 { + fn sub(self, rhs: Self) -> Self { __invalid() } +} + +// Multiplication `x * y` + +pub trait Mul { + fn mul(self, rhs: RHS) -> Out +} + +impl Mul for i8 { + fn mul(self, rhs: Self) -> Self { __invalid() } +} + +impl Mul for i16 { + fn mul(self, rhs: Self) -> Self { __invalid() } +} + +impl Mul for i32 { + fn mul(self, rhs: Self) -> Self { __invalid() } +} + +impl Mul for i64 { + fn mul(self, rhs: Self) -> Self { __invalid() } +} + +impl Mul for i128 { + fn mul(self, rhs: Self) -> Self { __invalid() } +} + +impl Mul for i256 { + fn mul(self, rhs: Self) -> Self { __invalid() } +} + +impl Mul for u8 { + fn mul(self, rhs: Self) -> Self { __invalid() } +} + +impl Mul for u16 { + fn mul(self, rhs: Self) -> Self { __invalid() } +} + +impl Mul for u32 { + fn mul(self, rhs: Self) -> Self { __invalid() } +} + +impl Mul for u64 { + fn mul(self, rhs: Self) -> Self { __invalid() } +} + +impl Mul for u128 { + fn mul(self, rhs: Self) -> Self { __invalid() } +} + +impl Mul for u256 { + fn mul(self, rhs: Self) -> Self { __invalid() } +} + +// Division `x / y` + +pub trait Div { + fn div(self, rhs: RHS) -> Out +} + +impl Div for i8 { + fn div(self, rhs: Self) -> Self { __invalid() } +} + +impl Div for i16 { + fn div(self, rhs: Self) -> Self { __invalid() } +} + +impl Div for i32 { + fn div(self, rhs: Self) -> Self { __invalid() } +} + +impl Div for i64 { + fn div(self, rhs: Self) -> Self { __invalid() } +} + +impl Div for i128 { + fn div(self, rhs: Self) -> Self { __invalid() } +} + +impl Div for i256 { + fn div(self, rhs: Self) -> Self { __invalid() } +} + +impl Div for u8 { + fn div(self, rhs: Self) -> Self { __invalid() } +} + +impl Div for u16 { + fn div(self, rhs: Self) -> Self { __invalid() } +} + +impl Div for u32 { + fn div(self, rhs: Self) -> Self { __invalid() } +} + +impl Div for u64 { + fn div(self, rhs: Self) -> Self { __invalid() } +} + +impl Div for u128 { + fn div(self, rhs: Self) -> Self { __invalid() } +} + +impl Div for u256 { + fn div(self, rhs: Self) -> Self { __invalid() } +} + +// Exponentiation `x^y` + +pub trait Exp { + fn exp(self, rhs: RHS) -> Out +} + +impl Exp for i8 { + fn exp(self, rhs: Self) -> Self { __invalid() } +} + +impl Exp for i16 { + fn exp(self, rhs: Self) -> Self { __invalid() } +} + +impl Exp for i32 { + fn exp(self, rhs: Self) -> Self { __invalid() } +} + +impl Exp for i64 { + fn exp(self, rhs: Self) -> Self { __invalid() } +} + +impl Exp for i128 { + fn exp(self, rhs: Self) -> Self { __invalid() } +} + +impl Exp for i256 { + fn exp(self, rhs: Self) -> Self { __invalid() } +} + +impl Exp for u8 { + fn exp(self, rhs: Self) -> Self { __invalid() } +} + +impl Exp for u16 { + fn exp(self, rhs: Self) -> Self { __invalid() } +} + +impl Exp for u32 { + fn exp(self, rhs: Self) -> Self { __invalid() } +} + +impl Exp for u64 { + fn exp(self, rhs: Self) -> Self { __invalid() } +} + +impl Exp for u128 { + fn exp(self, rhs: Self) -> Self { __invalid() } +} + +impl Exp for u256 { + fn exp(self, rhs: Self) -> Self { __invalid() } +} diff --git a/crates/library2/std/src/num/int/saturate.fe b/crates/library2/std/src/num/int/saturate.fe new file mode 100644 index 0000000000..b43b2085bc --- /dev/null +++ b/crates/library2/std/src/num/int/saturate.fe @@ -0,0 +1,157 @@ +extern { + fn __u16_u8_saturate(_ x: u16) -> u8 + fn __u32_u8_saturate(_ x: u32) -> u8 + fn __u32_u16_saturate(_ x: u32) -> u16 + fn __u64_u8_saturate(_ x: u64) -> u8 + fn __u64_u16_saturate(_ x: u64) -> u16 + fn __u64_u32_saturate(_ x: u64) -> u32 + fn __u128_u8_saturate(_ x: u128) -> u8 + fn __u128_u16_saturate(_ x: u128) -> u16 + fn __u128_u32_saturate(_ x: u128) -> u32 + fn __u128_u64_saturate(_ x: u128) -> u64 + fn __u256_u8_saturate(_ x: u256) -> u8 + fn __u256_u16_saturate(_ x: u256) -> u16 + fn __u256_u32_saturate(_ x: u256) -> u32 + fn __u256_u64_saturate(_ x: u256) -> u64 + fn __u256_u128_saturate(_ x: u256) -> u128 + fn __i16_i8_saturate(_ x: i16) -> i8 + fn __i32_i8_saturate(_ x: i32) -> i8 + fn __i32_i16_saturate(_ x: i32) -> i16 + fn __i64_i8_saturate(_ x: i64) -> i8 + fn __i64_i16_saturate(_ x: i64) -> i16 + fn __i64_i32_saturate(_ x: i64) -> i32 + fn __i128_i8_saturate(_ x: i128) -> i8 + fn __i128_i16_saturate(_ x: i128) -> i16 + fn __i128_i32_saturate(_ x: i128) -> i32 + fn __i128_i64_saturate(_ x: i128) -> i64 + fn __i256_i8_saturate(_ x: i256) -> i8 + fn __i256_i16_saturate(_ x: i256) -> i16 + fn __i256_i32_saturate(_ x: i256) -> i32 + fn __i256_i64_saturate(_ x: i256) -> i64 + fn __i256_i128_saturate(_ x: i256) -> i128 +} + +pub trait Saturate { + fn saturate(self) -> Out +} + +impl Saturate for u16 { + fn saturate(self) -> u8 { __u16_u8_saturate(self) } +} + +impl Saturate for u32 { + fn saturate(self) -> u8 { __u32_u8_saturate(self) } +} + +impl Saturate for u32 { + fn saturate(self) -> u16 { __u32_u16_saturate(self) } +} + +impl Saturate for u64 { + fn saturate(self) -> u8 { __u64_u8_saturate(self) } +} + +impl Saturate for u64 { + fn saturate(self) -> u16 { __u64_u16_saturate(self) } +} + +impl Saturate for u64 { + fn saturate(self) -> u32 { __u64_u32_saturate(self) } +} + +impl Saturate for u128 { + fn saturate(self) -> u8 { __u128_u8_saturate(self) } +} + +impl Saturate for u128 { + fn saturate(self) -> u16 { __u128_u16_saturate(self) } +} + +impl Saturate for u128 { + fn saturate(self) -> u32 { __u128_u32_saturate(self) } +} + +impl Saturate for u128 { + fn saturate(self) -> u64 { __u128_u64_saturate(self) } +} + +impl Saturate for u256 { + fn saturate(self) -> u8 { __u256_u8_saturate(self) } +} + +impl Saturate for u256 { + fn saturate(self) -> u16 { __u256_u16_saturate(self) } +} + +impl Saturate for u256 { + fn saturate(self) -> u32 { __u256_u32_saturate(self) } +} + +impl Saturate for u256 { + fn saturate(self) -> u64 { __u256_u64_saturate(self) } +} + +impl Saturate for u256 { + fn saturate(self) -> u128 { __u256_u128_saturate(self) } +} + +impl Saturate for i16 { + fn saturate(self) -> i8 { __i16_i8_saturate(self) } +} + +impl Saturate for i32 { + fn saturate(self) -> i8 { __i32_i8_saturate(self) } +} + +impl Saturate for i32 { + fn saturate(self) -> i16 { __i32_i16_saturate(self) } +} + +impl Saturate for i64 { + fn saturate(self) -> i8 { __i64_i8_saturate(self) } +} + +impl Saturate for i64 { + fn saturate(self) -> i16 { __i64_i16_saturate(self) } +} + +impl Saturate for i64 { + fn saturate(self) -> i32 { __i64_i32_saturate(self) } +} + +impl Saturate for i128 { + fn saturate(self) -> i8 { __i128_i8_saturate(self) } +} + +impl Saturate for i128 { + fn saturate(self) -> i16 { __i128_i16_saturate(self) } +} + +impl Saturate for i128 { + fn saturate(self) -> i32 { __i128_i32_saturate(self) } +} + +impl Saturate for i128 { + fn saturate(self) -> i64 { __i128_i64_saturate(self) } +} + +impl Saturate for i256 { + fn saturate(self) -> i8 { __i256_i8_saturate(self) } +} + +impl Saturate for i256 { + fn saturate(self) -> i16 { __i256_i16_saturate(self) } +} + +impl Saturate for i256 { + fn saturate(self) -> i32 { __i256_i32_saturate(self) } +} + +impl Saturate for i256 { + fn saturate(self) -> i64 { __i256_i64_saturate(self) } +} + +impl Saturate for i256 { + fn saturate(self) -> i128 { __i256_i128_saturate(self) } +} + diff --git a/crates/library2/std/src/num/int/truncate.fe b/crates/library2/std/src/num/int/truncate.fe new file mode 100644 index 0000000000..25146e582e --- /dev/null +++ b/crates/library2/std/src/num/int/truncate.fe @@ -0,0 +1,157 @@ +extern { + fn __u16_u8_truncate(_ x: u16) -> u8 + fn __u32_u8_truncate(_ x: u32) -> u8 + fn __u32_u16_truncate(_ x: u32) -> u16 + fn __u64_u8_truncate(_ x: u64) -> u8 + fn __u64_u16_truncate(_ x: u64) -> u16 + fn __u64_u32_truncate(_ x: u64) -> u32 + fn __u128_u8_truncate(_ x: u128) -> u8 + fn __u128_u16_truncate(_ x: u128) -> u16 + fn __u128_u32_truncate(_ x: u128) -> u32 + fn __u128_u64_truncate(_ x: u128) -> u64 + fn __u256_u8_truncate(_ x: u256) -> u8 + fn __u256_u16_truncate(_ x: u256) -> u16 + fn __u256_u32_truncate(_ x: u256) -> u32 + fn __u256_u64_truncate(_ x: u256) -> u64 + fn __u256_u128_truncate(_ x: u256) -> u128 + fn __i16_i8_truncate(_ x: i16) -> i8 + fn __i32_i8_truncate(_ x: i32) -> i8 + fn __i32_i16_truncate(_ x: i32) -> i16 + fn __i64_i8_truncate(_ x: i64) -> i8 + fn __i64_i16_truncate(_ x: i64) -> i16 + fn __i64_i32_truncate(_ x: i64) -> i32 + fn __i128_i8_truncate(_ x: i128) -> i8 + fn __i128_i16_truncate(_ x: i128) -> i16 + fn __i128_i32_truncate(_ x: i128) -> i32 + fn __i128_i64_truncate(_ x: i128) -> i64 + fn __i256_i8_truncate(_ x: i256) -> i8 + fn __i256_i16_truncate(_ x: i256) -> i16 + fn __i256_i32_truncate(_ x: i256) -> i32 + fn __i256_i64_truncate(_ x: i256) -> i64 + fn __i256_i128_truncate(_ x: i256) -> i128 +} + +pub trait Truncate { + fn truncate(self) -> Out +} + +impl Truncate for u16 { + fn truncate(self) -> u8 { __u16_u8_truncate(self) } +} + +impl Truncate for u32 { + fn truncate(self) -> u8 { __u32_u8_truncate(self) } +} + +impl Truncate for u32 { + fn truncate(self) -> u16 { __u32_u16_truncate(self) } +} + +impl Truncate for u64 { + fn truncate(self) -> u8 { __u64_u8_truncate(self) } +} + +impl Truncate for u64 { + fn truncate(self) -> u16 { __u64_u16_truncate(self) } +} + +impl Truncate for u64 { + fn truncate(self) -> u32 { __u64_u32_truncate(self) } +} + +impl Truncate for u128 { + fn truncate(self) -> u8 { __u128_u8_truncate(self) } +} + +impl Truncate for u128 { + fn truncate(self) -> u16 { __u128_u16_truncate(self) } +} + +impl Truncate for u128 { + fn truncate(self) -> u32 { __u128_u32_truncate(self) } +} + +impl Truncate for u128 { + fn truncate(self) -> u64 { __u128_u64_truncate(self) } +} + +impl Truncate for u256 { + fn truncate(self) -> u8 { __u256_u8_truncate(self) } +} + +impl Truncate for u256 { + fn truncate(self) -> u16 { __u256_u16_truncate(self) } +} + +impl Truncate for u256 { + fn truncate(self) -> u32 { __u256_u32_truncate(self) } +} + +impl Truncate for u256 { + fn truncate(self) -> u64 { __u256_u64_truncate(self) } +} + +impl Truncate for u256 { + fn truncate(self) -> u128 { __u256_u128_truncate(self) } +} + +impl Truncate for i16 { + fn truncate(self) -> i8 { __i16_i8_truncate(self) } +} + +impl Truncate for i32 { + fn truncate(self) -> i8 { __i32_i8_truncate(self) } +} + +impl Truncate for i32 { + fn truncate(self) -> i16 { __i32_i16_truncate(self) } +} + +impl Truncate for i64 { + fn truncate(self) -> i8 { __i64_i8_truncate(self) } +} + +impl Truncate for i64 { + fn truncate(self) -> i16 { __i64_i16_truncate(self) } +} + +impl Truncate for i64 { + fn truncate(self) -> i32 { __i64_i32_truncate(self) } +} + +impl Truncate for i128 { + fn truncate(self) -> i8 { __i128_i8_truncate(self) } +} + +impl Truncate for i128 { + fn truncate(self) -> i16 { __i128_i16_truncate(self) } +} + +impl Truncate for i128 { + fn truncate(self) -> i32 { __i128_i32_truncate(self) } +} + +impl Truncate for i128 { + fn truncate(self) -> i64 { __i128_i64_truncate(self) } +} + +impl Truncate for i256 { + fn truncate(self) -> i8 { __i256_i8_truncate(self) } +} + +impl Truncate for i256 { + fn truncate(self) -> i16 { __i256_i16_truncate(self) } +} + +impl Truncate for i256 { + fn truncate(self) -> i32 { __i256_i32_truncate(self) } +} + +impl Truncate for i256 { + fn truncate(self) -> i64 { __i256_i64_truncate(self) } +} + +impl Truncate for i256 { + fn truncate(self) -> i128 { __i256_i128_truncate(self) } +} + diff --git a/crates/library2/std/src/ops.fe b/crates/library2/std/src/ops.fe deleted file mode 100644 index c7dc5ea9db..0000000000 --- a/crates/library2/std/src/ops.fe +++ /dev/null @@ -1,211 +0,0 @@ -extern { - fn __never() -> ! -} - -pub trait Add { - fn add(self, rhs: RHS) -> Out -} - -impl Add for i8 { - fn add(self, rhs: Self) -> Self { __never() } -} - -impl Add for i16 { - fn add(self, rhs: Self) -> Self { __never() } -} - -impl Add for i32 { - fn add(self, rhs: Self) -> Self { __never() } -} - -impl Add for i64 { - fn add(self, rhs: Self) -> Self { __never() } -} - -impl Add for i128 { - fn add(self, rhs: Self) -> Self { __never() } -} - -impl Add for i256 { - fn add(self, rhs: Self) -> Self { __never() } -} - -impl Add for u8 { - fn add(self, rhs: Self) -> Self { __never() } -} - -impl Add for u16 { - fn add(self, rhs: Self) -> Self { __never() } -} - -impl Add for u32 { - fn add(self, rhs: Self) -> Self { __never() } -} - -impl Add for u64 { - fn add(self, rhs: Self) -> Self { __never() } -} - -impl Add for u128 { - fn add(self, rhs: Self) -> Self { __never() } -} - -impl Add for u256 { - fn add(self, rhs: Self) -> Self { __never() } -} - -pub trait Sub { - fn sub(self, rhs: RHS) -> Out -} - -impl Sub for i8 { - fn sub(self, rhs: Self) -> Self { __never() } -} - -impl Sub for i16 { - fn sub(self, rhs: Self) -> Self { __never() } -} - -impl Sub for i32 { - fn sub(self, rhs: Self) -> Self { __never() } -} - -impl Sub for i64 { - fn sub(self, rhs: Self) -> Self { __never() } -} - -impl Sub for i128 { - fn sub(self, rhs: Self) -> Self { __never() } -} - -impl Sub for i256 { - fn sub(self, rhs: Self) -> Self { __never() } -} - -impl Sub for u8 { - fn sub(self, rhs: Self) -> Self { __never() } -} - -impl Sub for u16 { - fn sub(self, rhs: Self) -> Self { __never() } -} - -impl Sub for u32 { - fn sub(self, rhs: Self) -> Self { __never() } -} - -impl Sub for u64 { - fn sub(self, rhs: Self) -> Self { __never() } -} - -impl Sub for u128 { - fn sub(self, rhs: Self) -> Self { __never() } -} - -impl Sub for u256 { - fn sub(self, rhs: Self) -> Self { __never() } -} - -pub trait Mul { - fn mul(self, rhs: RHS) -> Out -} - -impl Mul for i8 { - fn mul(self, rhs: Self) -> Self { __never() } -} - -impl Mul for i16 { - fn mul(self, rhs: Self) -> Self { __never() } -} - -impl Mul for i32 { - fn mul(self, rhs: Self) -> Self { __never() } -} - -impl Mul for i64 { - fn mul(self, rhs: Self) -> Self { __never() } -} - -impl Mul for i128 { - fn mul(self, rhs: Self) -> Self { __never() } -} - -impl Mul for i256 { - fn mul(self, rhs: Self) -> Self { __never() } -} - -impl Mul for u8 { - fn mul(self, rhs: Self) -> Self { __never() } -} - -impl Mul for u16 { - fn mul(self, rhs: Self) -> Self { __never() } -} - -impl Mul for u32 { - fn mul(self, rhs: Self) -> Self { __never() } -} - -impl Mul for u64 { - fn mul(self, rhs: Self) -> Self { __never() } -} - -impl Mul for u128 { - fn mul(self, rhs: Self) -> Self { __never() } -} - -impl Mul for u256 { - fn mul(self, rhs: Self) -> Self { __never() } -} - -pub trait Div { - fn div(self, rhs: RHS) -> Out -} - -impl Div for i8 { - fn div(self, rhs: Self) -> Self { __never() } -} - -impl Div for i16 { - fn div(self, rhs: Self) -> Self { __never() } -} - -impl Div for i32 { - fn div(self, rhs: Self) -> Self { __never() } -} - -impl Div for i64 { - fn div(self, rhs: Self) -> Self { __never() } -} - -impl Div for i128 { - fn div(self, rhs: Self) -> Self { __never() } -} - -impl Div for i256 { - fn div(self, rhs: Self) -> Self { __never() } -} - -impl Div for u8 { - fn div(self, rhs: Self) -> Self { __never() } -} - -impl Div for u16 { - fn div(self, rhs: Self) -> Self { __never() } -} - -impl Div for u32 { - fn div(self, rhs: Self) -> Self { __never() } -} - -impl Div for u64 { - fn div(self, rhs: Self) -> Self { __never() } -} - -impl Div for u128 { - fn div(self, rhs: Self) -> Self { __never() } -} - -impl Div for u256 { - fn div(self, rhs: Self) -> Self { __never() } -} diff --git a/crates/library2/std/src/ops/bin.fe b/crates/library2/std/src/ops/bin.fe new file mode 100644 index 0000000000..74e41ecbb8 --- /dev/null +++ b/crates/library2/std/src/ops/bin.fe @@ -0,0 +1,33 @@ + + +pub trait Add { + fn add(self, rhs: RHS) -> Out +} + +pub trait Sub { + fn sub(self, rhs: RHS) -> Out +} + +pub trait Mul { + fn mul(self, rhs: RHS) -> Out +} + +pub trait Div { + fn div(self, rhs: RHS) -> Out +} + +pub trait Exp { + fn exp(self, rhs: RHS) -> Out +} + +pub trait Mod { + fn exp(self, rhs: RHS) -> Out +} + +pub trait Shl { + fn shl(self, shift: usize) +} + +pub trait Shr { + fn shr(self, shift: usize) +} diff --git a/crates/library2/std/src/ops/un.fe b/crates/library2/std/src/ops/un.fe new file mode 100644 index 0000000000..e69de29bb2