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:
@@ -108,6 +108,28 @@ fn resolvewalk(c: *checker, n: *node) void = {
|
||||
let nm: str = n.str;
|
||||
if (nm.len > 0) {
|
||||
let s: *sym = scopelookup(c.cur, nm);
|
||||
// `pkg.Type` — strip the last dot prefix and look up
|
||||
// the leaf if `pkg` is a use-imported name. Mirrors
|
||||
// cmd/wcc/check.c resolve_typename.
|
||||
if (s == nil) {
|
||||
let dot: i32 = nm.len - 1;
|
||||
for (dot >= 0) {
|
||||
if (nm[dot] == 46u8) { break; };
|
||||
dot -= 1;
|
||||
};
|
||||
if (dot > 0) {
|
||||
let head: str;
|
||||
head.ptr = nm.ptr;
|
||||
head.len = dot;
|
||||
let m: *sym = scopelookup(c.cur, head);
|
||||
if (m != nil) {
|
||||
let leaf: str;
|
||||
leaf.ptr = nm.ptr + (dot + 1): u64;
|
||||
leaf.len = nm.len - (dot + 1);
|
||||
s = scopelookup(c.cur, leaf);
|
||||
};
|
||||
};
|
||||
};
|
||||
if (s == nil) {
|
||||
c.nunresolved += 1;
|
||||
if (c.verbose != 0) {
|
||||
|
||||
Reference in New Issue
Block a user