From 5c99bf09ab8ef4fbe5e29c55541b3f7cf28b9844 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 23 Feb 2025 03:29:15 -0600 Subject: [PATCH] stdlib: Make stdlib not error out w/ undefined symbols, add ranges. --- stdlib/std.cl | 2 ++ stdlib/std/num.cl | 12 ++++++------ stdlib/std/range.cl | 9 +++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 stdlib/std/range.cl diff --git a/stdlib/std.cl b/stdlib/std.cl index 910d940..ccaad72 100644 --- a/stdlib/std.cl +++ b/stdlib/std.cl @@ -8,5 +8,7 @@ pub mod num; pub mod str; +pub mod range; + #[cfg("test")] mod test; diff --git a/stdlib/std/num.cl b/stdlib/std/num.cl index f19ec4d..b58cc16 100644 --- a/stdlib/std/num.cl +++ b/stdlib/std/num.cl @@ -278,9 +278,9 @@ pub mod ops { } impl usize { - pub const MIN: Self = __march_ptr_width_unsigned_min(); - pub const MAX: Self = __march_ptr_width_unsigned_max(); - pub const BIT_WIDTH: u32 = __march_ptr_width_bits(); + pub const MIN: Self = (); // __march_ptr_width_unsigned_min(); // TODO: intrinsics + pub const MAX: Self = (); // __march_ptr_width_unsigned_max(); // TODO: intrinsics + pub const BIT_WIDTH: u32 = (); // __march_ptr_width_bits(); // TODO: intrinsics pub fn default() -> Self { 0 } @@ -512,9 +512,9 @@ pub mod ops { } impl isize { - pub const MIN: Self = __march_ptr_width_signed_min(); - pub const MAX: Self = __march_ptr_width_signed_max(); - pub const BIT_WIDTH: u32 = __march_ptr_width_bits(); + pub const MIN: Self = (); // __march_ptr_width_signed_min(); // TODO: intrinsics + pub const MAX: Self = (); // __march_ptr_width_signed_max(); // TODO: intrinsics + pub const BIT_WIDTH: u32 = (); // __march_ptr_width_bits(); // TODO: intrinsics pub fn default() -> Self { 0 } diff --git a/stdlib/std/range.cl b/stdlib/std/range.cl new file mode 100644 index 0000000..e083563 --- /dev/null +++ b/stdlib/std/range.cl @@ -0,0 +1,9 @@ +//! Iterable ranges + +/// An Exclusive Range `a .. b` iterates from a to b, excluding b +#[intrinsic = "range_exc", T] +struct RangeExc(T, T) + +/// An Inclusive Range `a ..= b` iterates from a to b, including b +#[intrinsic = "range_inc", T] +struct RangeInc(T, T)