From a89f45aa58f94302f348e7c1247169fbac2b99b5 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 4 May 2024 23:07:57 -0500 Subject: [PATCH] cl-typeck: Add isize/usize primitives --- compiler/cl-typeck/src/definition.rs | 6 ++++++ compiler/cl-typeck/src/definition/display.rs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/compiler/cl-typeck/src/definition.rs b/compiler/cl-typeck/src/definition.rs index 6d882c2..34829d7 100644 --- a/compiler/cl-typeck/src/definition.rs +++ b/compiler/cl-typeck/src/definition.rs @@ -148,6 +148,8 @@ pub enum Intrinsic { I64, // /// A 128-bit signed integer: `#[intrinsic = "i32"]` // I128, + /// A ptr-len signed integer: `#[intrinsic = "isize"]` + Isize, /// An 8-bit unsigned integer: `#[intrinsic = "u8"]` U8, /// A 16-bit unsigned integer: `#[intrinsic = "u16"]` @@ -158,6 +160,8 @@ pub enum Intrinsic { U64, // /// A 128-bit unsigned integer: `#[intrinsic = "u128"]` // U128, + /// A ptr-len unsigned integer: `#[intrinsic = "isize"]` + Usize, /// A boolean (`true` or `false`): `#[intrinsic = "bool"]` Bool, /// The unicode codepoint type: #[intrinsic = "char"] @@ -173,10 +177,12 @@ impl FromStr for Intrinsic { "i16" => Intrinsic::I16, "i32" => Intrinsic::I32, "i64" => Intrinsic::I64, + "isize" => Intrinsic::Isize, "u8" => Intrinsic::U8, "u16" => Intrinsic::U16, "u32" => Intrinsic::U32, "u64" => Intrinsic::U64, + "usize" => Intrinsic::Usize, "bool" => Intrinsic::Bool, "char" => Intrinsic::Char, _ => Err(())?, diff --git a/compiler/cl-typeck/src/definition/display.rs b/compiler/cl-typeck/src/definition/display.rs index 4d46e82..848074f 100644 --- a/compiler/cl-typeck/src/definition/display.rs +++ b/compiler/cl-typeck/src/definition/display.rs @@ -160,10 +160,12 @@ impl Display for Intrinsic { Intrinsic::I16 => f.write_str("i16"), Intrinsic::I32 => f.write_str("i32"), Intrinsic::I64 => f.write_str("i64"), + Intrinsic::Isize => f.write_str("isize"), Intrinsic::U8 => f.write_str("u8"), Intrinsic::U16 => f.write_str("u16"), Intrinsic::U32 => f.write_str("u32"), Intrinsic::U64 => f.write_str("u64"), + Intrinsic::Usize => f.write_str("usize"), Intrinsic::Bool => f.write_str("bool"), Intrinsic::Char => f.write_str("char"), }