hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit b78d1b41f02c219f9c07120e13d6b28378e73970
parent 5d31fd8dabbd15182b616d14f570e717130de48d
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sat, 16 Jan 2021 11:56:31 -0500

types: initial commit

Diffstat:
Atypes/arch+aarch64.ha | 23+++++++++++++++++++++++
Atypes/arch+x86_64.ha | 23+++++++++++++++++++++++
Atypes/classes.ha | 42++++++++++++++++++++++++++++++++++++++++++
Atypes/limits.ha | 48++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 136 insertions(+), 0 deletions(-)

diff --git a/types/arch+aarch64.ha b/types/arch+aarch64.ha @@ -0,0 +1,23 @@ +// Minimum value which can be stored in an int type. +export def INT_MIN: int = I32_MIN; + +// Maximum value which can be stored in an int type. +export def INT_MAX: int = I32_MAX; + +// Minimum value which can be stored in a uint type +export def UINT_MIN: uint = U32_MIN; + +// Maximum value which can be stored in a uint type. +export def UINT_MAX: uint = U32_MAX; + +// Minimum value which can be stored in a size type +export def SIZE_MIN: size = U64_MIN; + +// Maximum value which can be stored in a size type. +export def SIZE_MAX: size = U64_MAX; + +// Minimum value which can be stored in a uintptr type +export def UINTPTR_MIN: uintptr = U64_MIN; + +// Maximum value which can be stored in a uintptr type. +export def UINTPTR_MAX: uintptr = U64_MAX; diff --git a/types/arch+x86_64.ha b/types/arch+x86_64.ha @@ -0,0 +1,23 @@ +// Minimum value which can be stored in an int type. +export def INT_MIN: int = I32_MIN; + +// Maximum value which can be stored in an int type. +export def INT_MAX: int = I32_MAX; + +// Minimum value which can be stored in a uint type +export def UINT_MIN: uint = U32_MIN; + +// Maximum value which can be stored in a uint type. +export def UINT_MAX: uint = U32_MAX; + +// Minimum value which can be stored in a size type +export def SIZE_MIN: size = U64_MIN; + +// Maximum value which can be stored in a size type. +export def SIZE_MAX: size = U64_MAX; + +// Minimum value which can be stored in a uintptr type +export def UINTPTR_MIN: uintptr = U64_MIN; + +// Maximum value which can be stored in a uintptr type. +export def UINTPTR_MAX: uintptr = U64_MAX; diff --git a/types/classes.ha b/types/classes.ha @@ -0,0 +1,42 @@ +// A tagged union of all signed integer types +export type signed = (i8 | i16 | i32 | i64 | int); + +// A tagged union of all unsigned integer types, excluding uintptr +export type unsigned = (u8 | u16 | u32 | u64 | uint | size); + +// A tagged union of all integer types +export type integer = (...signed | ...unsigned); + +// A tagged union of all floating point numeric types +export type floating = (f32 | f64); + +// A tagged union of all numeric types +export type numeric = (...integer | ...floating); + +// A type representing the internal structure of strings, useful for low-level +// string manipulation. +export type string = struct { + // UTF-8 encoded octets, plus a NUL terminator. + data: *[*]u8, + + // The length capacity, in octets of UTF-8 data, not including the NUL + // terminator + length: size, + + // The allocated capacity, in octets of UTF-8 data, not including the + // NUL terminator + capacity: size, +}; + +// A type representing the internal structure of slices, useful for low-level +// slice manipulation. +export type slice = struct { + // The slice contents + data: *void, + + // The allocated capacity (in members) of data + capacity: size, + + // The number of members of the slice + length: size, +}; diff --git a/types/limits.ha b/types/limits.ha @@ -0,0 +1,48 @@ +// Minimum value which can be stored in an i8 type. +export def I8_MIN: i8 = -128i8; + +// Maximum value which can be stored in an i8 type. +export def I8_MAX: i8 = 127i8; + +// Minimum value which can be stored in an i16 type. +export def I16_MIN: i16 = -32708i16; + +// Maximum value which can be stored in an i16 type. +export def I16_MAX: i16 = 32707i16; + +// Minimum value which can be stored in an i32 type. +export def I32_MIN: i32 = -2147483648i32; + +// Maximum value which can be stored in an i32 type. +export def I32_MAX: i32 = 2147483647i32; + +// Minimum value which can be stored in an i64 type +export def I64_MIN: i64 = -9223372036854775808i64; + +// Maximum value which can be stored in an i64 type. +export def I64_MAX: i64 = 9223372036854775807i64; + + +// Minimum value which can be stored in a u8 type. +export def U8_MIN: u8 = 0u8; + +// Maximum value which can be stored in a u8 type. +export def U8_MAX: u8 = 256u8; + +// Minimum value which can be stored in a u16 type +export def U16_MIN: u16 = 0u16; + +// Maximum value which can be stored in a u16 type. +export def U16_MAX: u16 = 65535u16; + +// Minimum value which can be stored in a u32 type +export def U32_MIN: u32 = 0u32; + +// Maximum value which can be stored in a u32 type. +export def U32_MAX: u32 = 4294967295u32; + +// Minimum value which can be stored in a u64 type +export def U64_MIN: u64 = 0u64; + +// Maximum value which can be stored in a u64 type. +export def U64_MAX: u64 = 18446744073709551615u64;