Files
zig/stage0/main.c
Motiejus Jakštys 5700b742d2 stage0: add --verbose-intern-pool flag and IP dumper
Add verbose_intern_pool.c/h for dumping the C sema's InternPool
entries. Integrate as --verbose-intern-pool flag in zig0, mirroring
the Zig compiler's flag.

Fix InternPool.zig dump crash on locals with zero-capacity items
(skip empty locals in dumpStatsFallible and dumpAllFallible).

Update CLAUDE.md with IP debugging tools documentation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-25 20:37:34 +00:00

65 lines
1.5 KiB
C

#include "common.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int zig0RunFile(
const char* fname, bool verbose_air, bool verbose_intern_pool, char** msg);
static void usage(const char* argv0) {
fprintf(stderr,
"Usage: %s [--verbose-air] [--verbose-intern-pool] program.zig\n",
argv0);
}
int main(int argc, char** argv) {
bool verbose_air = false;
bool verbose_intern_pool = false;
const char* fname = NULL;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--verbose-air") == 0) {
verbose_air = true;
} else if (strcmp(argv[i], "--verbose-intern-pool") == 0) {
verbose_intern_pool = true;
} else if (argv[i][0] == '-') {
fprintf(stderr, "Unknown option: %s\n", argv[i]);
usage(argv[0]);
return 1;
} else if (fname == NULL) {
fname = argv[i];
} else {
fprintf(stderr, "Unexpected argument: %s\n", argv[i]);
usage(argv[0]);
return 1;
}
}
if (fname == NULL) {
usage(argv[0]);
return 1;
}
char* msg;
switch (zig0RunFile(fname, verbose_air, verbose_intern_pool, &msg)) {
case 0:
return 0;
break;
case 1:
fprintf(stderr, "panic: %s\n", msg);
free(msg);
return 0;
break;
case 2:
fprintf(stderr, "interpreter error: %s\n", msg);
free(msg);
return 1;
break;
case 3:
return 1;
break;
}
}