w6c+selfhost: cross-module same-leaf type disambiguation via Sym.mod
This commit is contained in:
@@ -1340,6 +1340,14 @@ parsefile(Parser *p)
|
||||
Node *file = newnode(p->a, N_FILE, pp);
|
||||
Node *head = NULL, *tail = NULL;
|
||||
while (p->cur.kind != TK_EOF) {
|
||||
/* Stamp the lex's current `// MODULE: foo` directive on the
|
||||
* decl BEFORE parsing. cgen uses this for name-mangling and
|
||||
* check uses it for cross-module type disambiguation. Capture
|
||||
* before parsing so the closing `expect(SEMI)` doesn't
|
||||
* accidentally advance the lexer past the *next* `// MODULE:`
|
||||
* directive — that would stamp this decl with the next
|
||||
* module's name. */
|
||||
const char *mod = p->l->module;
|
||||
Node *attrs = parseattrs(p);
|
||||
int exp = accept(p, TK_EXPORT);
|
||||
Node *d = NULL;
|
||||
@@ -1363,10 +1371,7 @@ parsefile(Parser *p)
|
||||
advance(p);
|
||||
continue;
|
||||
}
|
||||
/* Stamp the lex's current `// MODULE: foo` directive on the
|
||||
* decl. cgen uses it to mangle non-exported names so two
|
||||
* modules can each privately define `cstrlen`/`streq`/etc. */
|
||||
if (d != NULL) d->module = p->l->module;
|
||||
if (d != NULL) d->module = mod;
|
||||
if (head == NULL) head = d;
|
||||
else tail->next = d;
|
||||
tail = d;
|
||||
|
||||
Reference in New Issue
Block a user