os: graduate filesize/readall/writeall to (i64 | oserror)
`type oserror = i64` carries -errno (Hare's errors::errno-shaped named-i64). The three convenience wrappers move off the i64 = -1 sentinel and onto the tagged-union surface. Callers updated across the selfhost (wwdump, w6c, w6a, w6l, ww driver). The slurp paths in w6c/w6a/w6l/wwdump now match on the filesize and readall results; the ELF-emitting writeall sites in w6a/obj.ww are wrapped through two small local helpers (`wrn` for "wrote N bytes ok?", `wrdrop` for fire-and-forget) so the existing 11-callsite write loop stays readable. selfhost/test/smoke.ww kept using raw os.read instead of os.readall: the 990 cgen-match probe compiles smoke.ww standalone (no `use` expansion), and cross-module type references like `os.oserror` can't be resolved in that mode. Two selfhost-side gaps surfaced and got plugged: - lib/ww/parse/parse.ww parsetype now collapses dotted type names (`pkg.Type` → single N_TNAME with the joined string), mirroring C parsetype's dotted-path loop. Local `joindotted` helper because there's no arena-based string-concat in the selfhost lib yet. - selfhost/cmd/wcc/check.ww name-resolver applies the dotted-prefix rule from cmd/wcc/check.c's resolve_typename: split at the last dot, look up the head as a `use` import, then the leaf as a type.
This commit is contained in:
@@ -90,10 +90,20 @@ export fn emitelf(l: *lnk, fd: i32, base: u64, entry: u64) i32 = {
|
||||
wru64(hdr, 112u64, TEXT_OFF); // p_align
|
||||
|
||||
// Write [0..0x1000) then .text.
|
||||
let n1: i64 = os.writeall(fd, hdr, TEXT_OFF);
|
||||
let r1: (i64 | os.oserror) = os.writeall(fd, hdr, TEXT_OFF);
|
||||
let n1: i64 = 0i64;
|
||||
match (r1) {
|
||||
case let v: i64 => n1 = v;
|
||||
case let e: os.oserror => return -1;
|
||||
};
|
||||
if (n1 != TEXT_OFF: i64) { return -1; };
|
||||
if (l.textlen > 0u64) {
|
||||
let n2: i64 = os.writeall(fd, l.text, l.textlen);
|
||||
let r2: (i64 | os.oserror) = os.writeall(fd, l.text, l.textlen);
|
||||
let n2: i64 = 0i64;
|
||||
match (r2) {
|
||||
case let v: i64 => n2 = v;
|
||||
case let e: os.oserror => return -1;
|
||||
};
|
||||
if (n2 != l.textlen: i64) { return -1; };
|
||||
};
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user