Files
ww/selfhost/cmd/wcc/err.ww
Hojun-Cho 1ac1d985f6 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.
2026-05-12 00:45:18 +09:00

38 lines
815 B
Plaintext

// selfhost/cmd/wcc/err.ww — port of cmd/wcc/err.c.
//
// Diagnostics. Plan 9 style: short, no levels beyond fatal/error/warn.
// Output goes through os.write so we don't pull in libc stdio.
use os;
use fmt;
type pos = struct {
file: str,
line: i32,
col: i32,
};
let nerrors: i32 = 0;
let nwarnings: i32 = 0;
export fn fatal(msg: str) void = {
fmt.errorln(msg);
os.exit(1);
};
export fn errorf(p: pos, msg: str) void = {
os.write(2, p.file.ptr, p.file.len: u64);
os.write(2, ": error: ".ptr, 9u64);
os.write(2, msg.ptr, msg.len: u64);
os.write(2, "\n".ptr, 1u64);
nerrors += 1;
};
export fn warnf(p: pos, msg: str) void = {
os.write(2, p.file.ptr, p.file.len: u64);
os.write(2, ": warning: ".ptr, 11u64);
os.write(2, msg.ptr, msg.len: u64);
os.write(2, "\n".ptr, 1u64);
nwarnings += 1;
};