lib: rename stdlib surface to Hare names; add endian/math

Sweeping rename so the lib/ surface mirrors Hare's stdlib spellings.
- ascii: rune-taking predicates; ishex -> isxdigit
- bufio: rinit -> init; take1/takeline -> readbyte/readline
- bytes: indexsub -> index
- encoding/utf8: runelen -> runesz
- errors: eEOF/eShortRead/... -> eof/underread/...
- fmt: errln -> errorln; println/fprintln return i64
- os: readfull/writefull -> readall/writeall; unlink -> remove
- path: isabs -> abs; drop lastindex (now strings.rbyteindex)
- strconv: u64toa/i64toa -> u64tos/i64tos; parse64/parseu64 -> stoi64/stou64
- strings: drop len/isempty; equal -> compare; indexbyte -> byteindex; +rbyteindex
- types: drop numeric helpers (moved to math)
- new lib/endian (htonu16/ntohu16), lib/math (absi32/absi64)
- net: drop htons (use endian.htonu16)

Callers in selfhost/, lib/ww/, cmd/w6c/cgen.c, and test/wcc/700_e2e.c
updated to match.
This commit is contained in:
2026-05-12 00:45:18 +09:00
parent 35421f2561
commit 1ac1d985f6
37 changed files with 597 additions and 568 deletions

View File

@@ -1,6 +1,6 @@
// types — integer limits and helpers, the seed module that the
// rest of the stdlib depends on. Plan 9-flavoured: the names are
// short and the constants are platform-fixed (we are amd64 only).
// 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::.
def I8_MAX: i8 = 127;
def I16_MAX: i16 = 32767;
@@ -16,33 +16,3 @@ def U8_MAX: u8 = 255;
def U16_MAX: u16 = 65535;
def U32_MAX: u32 = 4294967295;
def U64_MAX: u64 = 18446744073709551615;
export fn mini32(a: i32, b: i32) i32 = {
if (a < b) { return a; };
return b;
};
export fn maxi32(a: i32, b: i32) i32 = {
if (a > b) { return a; };
return b;
};
export fn mini64(a: i64, b: i64) i64 = {
if (a < b) { return a; };
return b;
};
export fn maxi64(a: i64, b: i64) i64 = {
if (a > b) { return a; };
return b;
};
export fn absi32(x: i32) i32 = {
if (x < 0) { return -x; };
return x;
};
export fn absi64(x: i64) i64 = {
if (x < 0) { return -x; };
return x;
};