wcc: c-side mangles private decls; main exempt as entry-point convention

This commit is contained in:
2026-05-11 15:29:29 +09:00
parent 895f221b6c
commit e301a198f4
7 changed files with 153 additions and 25 deletions

View File

@@ -94,6 +94,27 @@ skipws(Lex *l)
continue;
}
if (c == '/' && lpeek(l, 1) == '/') {
lget(l); lget(l); /* consume '//' */
/* `// MODULE: foo` directive emitted by the ww
* driver before each source-file's section in
* combined.ww. Captured so cgen can mangle
* non-exported symbols by module. */
if (lpeek(l, 0) == ' '
&& lpeek(l, 1) == 'M' && lpeek(l, 2) == 'O'
&& lpeek(l, 3) == 'D' && lpeek(l, 4) == 'U'
&& lpeek(l, 5) == 'L' && lpeek(l, 6) == 'E'
&& lpeek(l, 7) == ':' && lpeek(l, 8) == ' ') {
for (int i = 0; i < 9; i++) lget(l);
u64 start = l->pos;
while ((c = lpeek(l, 0)) >= 0
&& c != '\n' && c != '\r')
lget(l);
u64 n = l->pos - start;
char *m = amalloc(l->a, n + 1);
memcpy(m, l->src + start, n);
m[n] = '\0';
l->module = m;
}
while ((c = lpeek(l, 0)) >= 0 && c != '\n')
lget(l);
continue;