ww: implement package initialization

This commit is contained in:
2026-08-14 19:02:35 +09:00
parent 72e890d5aa
commit c6bec0914d
24 changed files with 5279 additions and 1009 deletions

View File

@@ -349,12 +349,20 @@ struct Node {
const char *usealias; /* N_USE: explicit file-local alias, or NULL. */
const char *usepkgname; /* N_USE: imported declared package name,
* independent of the visible binding in `str`. */
int useblank; /* N_USE: `_` spelling; no source binding. */
const char *pkgname; /* declared package name for this source/export
* section; independent of canonical `module`. */
int sourceid; /* lexical source-file scope within the parsed
* owner unit; module-reset/module boundaries
* advance it deterministically. */
int used; /* N_USE: checker observed this file-local binding. */
int initfn; /* special source `fn init`, absent from scope/API. */
int initsynthetic; /* compiler-owned variable helper/package task. */
int runtimeinit; /* module let lowered through an init helper. */
u64 initorder; /* 1-based variable or init-function order. */
const char *linksym; /* raw compiler-private assembler symbol. */
Node *refdecl; /* checker-resolved value declaration. */
u64 initmark; /* checker-private initializer walk mark. */
int imported; /* M1 #22: decl reached through an
* `//ww:module <path>` import boundary
* (vs root/primary). Gates the root-only
@@ -616,6 +624,7 @@ struct Checker {
* any OTHER empty alloc has no element-type hint
* and must fail to infer (harec check.c:1801).
* Set by clet around its cexpr, NULL elsewhere. */
const char *package_init_symbol; /* canonical action-owned hidden task. */
};
void check_init(Checker*, Arena*);