lib: extract rt module from os, sweep imports
Hare puts runtime allocation in rt::, not os:: (ref/hare/rt/malloc.ha:27,
README). ww's `@symbol("rt_alloc") fn alloc(n: u64) *void;` lived at
lib/os/os.ww as a historical bootstrap shortcut; this commit relocates
it to a new lib/rt/malloc.ww and sweeps every site that depended on
`import os` for the alloc decl over to `import rt`.
This is commit 1 of 3 in the lib/rt extraction (#35):
1. (this) move decl, sweep imports — preserves shape
2. rename rt_alloc → rt_malloc (#38)
3. nullable return type + OOM-propagating builtin lowering (#39)
No rename here. Symbol stays rt_alloc, function stays `alloc`, return
stays *void. Behavior identical — same ffi resolution outcome, just
sourced from a different module file. The rt::ensure runtime helper at
selfhost/rt/ensure.ww is its own compilation unit with a local decl and
is untouched.
Side effect: every wcc cgen file used `rt` as a local *node variable
name for "return type." `import rt;` shadows the module, so each
selfhost/cmd/wcc/{check,cgenstmt,cgenexpr,cgenutil}.ww site renamed
to `rtyp`. Mechanical follow-through; only the wcc module-import was
forced to do this rename.
Verified 132/132 + 995_self_rebuild byte-identity (5 wwstage tools
round-trip byte-identical).
This commit is contained in:
@@ -171,10 +171,10 @@ fn cgtryprop(c: *cgen, n: *node) void = {
|
||||
};
|
||||
};
|
||||
if (cname.len > 0) {
|
||||
let rt: *node = fnretlookupmod(c, cname, cmod);
|
||||
if (rt != nil) {
|
||||
if (rt.kind == nkind.N_TTAGGED) {
|
||||
let first: *node = rt.list;
|
||||
let rtyp: *node = fnretlookupmod(c, cname, cmod);
|
||||
if (rtyp != nil) {
|
||||
if (rtyp.kind == nkind.N_TTAGGED) {
|
||||
let first: *node = rtyp.list;
|
||||
if (first != nil) {
|
||||
if (isstrtype(c, first)) {
|
||||
succisstr = true;
|
||||
@@ -227,10 +227,10 @@ fn cgtryunw(c: *cgen, n: *node) void = {
|
||||
};
|
||||
};
|
||||
if (cname.len > 0) {
|
||||
let rt: *node = fnretlookupmod(c, cname, cmod);
|
||||
if (rt != nil) {
|
||||
if (rt.kind == nkind.N_TTAGGED) {
|
||||
let first: *node = rt.list;
|
||||
let rtyp: *node = fnretlookupmod(c, cname, cmod);
|
||||
if (rtyp != nil) {
|
||||
if (rtyp.kind == nkind.N_TTAGGED) {
|
||||
let first: *node = rtyp.list;
|
||||
if (first != nil) {
|
||||
if (isstrtype(c, first)) {
|
||||
succisstr = true;
|
||||
@@ -607,8 +607,8 @@ fn cgident(c: *cgen, n: *node) void = {
|
||||
// in one go, so a body-less FFI binding emits the C symbol
|
||||
// it was declared with via @symbol(), not the ww-side ident.
|
||||
// Bare ident → same-module by ww's resolver, hint with c.curmod.
|
||||
let rt: *node = fnretlookup(c, nm);
|
||||
if (rt != nil) {
|
||||
let rtyp: *node = fnretlookup(c, nm);
|
||||
if (rtyp != nil) {
|
||||
emitline("\tLEAQ\t");
|
||||
emitfnname(c, nm, c.curmod);
|
||||
emitline("(SB), AX\n");
|
||||
@@ -3421,8 +3421,8 @@ fn cgcall(c: *cgen, n: *node) void = {
|
||||
};
|
||||
};
|
||||
};
|
||||
let rt: *node = fnretlookupmod(c, calleename, cmod);
|
||||
if (isstrtype(c, rt)) {
|
||||
let rtyp: *node = fnretlookupmod(c, calleename, cmod);
|
||||
if (isstrtype(c, rtyp)) {
|
||||
emitline("\tMOVQ\tDX, BX\n");
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user