Faithful port of ref/hare/types/arch+x86_64.ha:16-26. SIZE_MAX is the no-cast `def SIZE_MAX: size = U64_MAX;` — size is in the unsigned class and 8B on amd64, so the u64->size init coerces without a cast (#113); UINTPTR_MAX keeps Hare's explicit `U64_MAX: uintptr` since uintptr is outside the unsigned class. Probe 958_types_sizelim_run asserts MIN==0, MAX==U64_MAX, and arithmetic usability for both types. INT_MIN/MAX + UINT_MIN/MAX deferred to #114 (ww int=8B vs Hare 4B on amd64 leaves the value open); RUNE_MAX deferred to #112 (no \U lexer). combined.ww regenerated for all 5 selfhost tools + smoke.combined.ww (all embed lib/types).
36 lines
1002 B
Plaintext
36 lines
1002 B
Plaintext
// types — integer limits. Mirrors Hare's types::limits (I8_MAX, …)
|
|
// platform-fixed for amd64. Numeric helpers live in lib/math, matching
|
|
// Hare's split between types::limits and math::.
|
|
|
|
package types;
|
|
|
|
def I8_MAX: i8 = 127;
|
|
def I16_MAX: i16 = 32767;
|
|
def I32_MAX: i32 = 2147483647;
|
|
def I64_MAX: i64 = 9223372036854775807;
|
|
|
|
def I8_MIN: i8 = -128;
|
|
def I16_MIN: i16 = -32768;
|
|
def I32_MIN: i32 = -2147483648;
|
|
def I64_MIN: i64 = -9223372036854775808;
|
|
|
|
def U8_MAX: u8 = 255;
|
|
def U16_MAX: u16 = 65535;
|
|
def U32_MAX: u32 = 4294967295;
|
|
def U64_MAX: u64 = 18446744073709551615;
|
|
|
|
def U8_MIN: u8 = 0;
|
|
def U16_MIN: u16 = 0;
|
|
def U32_MIN: u32 = 0;
|
|
def U64_MIN: u64 = 0;
|
|
|
|
// size is 8B on amd64; no cast needed (size ∈ unsigned class per #113).
|
|
def SIZE_MIN: size = U64_MIN;
|
|
def SIZE_MAX: size = U64_MAX;
|
|
|
|
// uintptr not in the unsigned class, so the cast is required (Hare's form).
|
|
def UINTPTR_MIN: uintptr = U64_MIN: uintptr;
|
|
def UINTPTR_MAX: uintptr = U64_MAX: uintptr;
|
|
|
|
def RUNE_MIN: rune = '\0';
|