Files
ww/selfhost/cmd/wcc/api.ww
Hojun-Cho c7d9dc92de selfhost: migrate tool sources to directory packages
Build w6a and w6l from package-main directories and expose the wcc backend through a narrow package API so w6c and wwdump no longer import implementation files. Retarget the remaining load-bearing fixtures and example sources to directory packages; retain the one intentional flat compiler collision as an explicitly composed raw unit.
2026-08-12 17:12:03 +09:00

41 lines
965 B
Plaintext

package wcc;
import syntax;
export fn compilefile(file: *syntax.node, testmode: i32, testmodule: str,
sepmode: i32, wwiout: str) i32 = {
let tc: syntax.tctx;
syntax.typesinit(&tc);
let ck: checker;
checkinit(&ck, &tc);
ck.istest = testmode;
if (testmodule.len > 0) { ck.testmodule = testmodule; };
ck.sepmode = sepmode;
checkfile(&ck, file);
if (ck.errs > 0) { return 1; };
if (wwiout.len > 0) {
if (wwiemit(&ck, file, wwiout) != 0) { return 1; };
};
let cg: cgen;
cgeninit(&cg);
cg.sepmode = sepmode;
if (wwiout.len > 0) { cg.sepisdep = 1i32; };
cgfile(&cg, file);
return 0;
};
export fn resolvefile(file: *syntax.node, verbose: i32,
nresolved: *i32, nunresolved: *i32) i32 = {
let tc: syntax.tctx;
syntax.typesinit(&tc);
let ck: checker;
checkinit(&ck, &tc);
ck.verbose = verbose;
checkfile(&ck, file);
*nresolved = ck.nresolved;
*nunresolved = ck.nunresolved;
if (ck.errs > 0 || ck.nunresolved > 0) { return 1; };
return 0;
};