- Enable module_root for sema unit tests in stages_test.zig, matching the Zig compiler which always creates std even with std_mod=null. The first 5 tests still pass since they only use pre-interned refs. - Add analyzeMemoizedStateC infrastructure for resolving std.builtin BuiltinDecl entries (ExportOptions, CallingConvention, Type, etc.). Not yet triggered — the trigger path requires matching the Zig compiler's exact module loading order. - Add --module-root flag to zig0 CLI for debugging IP entry comparison between the Zig compiler and C sema. - Fix cppcheck warning: remove redundant !fi.is_inline check (already guarded by early return above). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
72 lines
1.8 KiB
C
72 lines
1.8 KiB
C
#include "common.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
int zig0RunFile(const char* fname, const char* module_root_override,
|
|
bool verbose_air, bool verbose_intern_pool, char** msg);
|
|
|
|
static void usage(const char* argv0) {
|
|
fprintf(stderr,
|
|
"Usage: %s [--verbose-air] [--verbose-intern-pool] "
|
|
"[--module-root DIR] program.zig\n",
|
|
argv0);
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
bool verbose_air = false;
|
|
bool verbose_intern_pool = false;
|
|
const char* fname = NULL;
|
|
const char* module_root = 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 (strcmp(argv[i], "--module-root") == 0) {
|
|
if (i + 1 < argc)
|
|
module_root = argv[++i];
|
|
} 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;
|
|
int code = zig0RunFile(
|
|
fname, module_root, verbose_air, verbose_intern_pool, &msg);
|
|
switch (code) {
|
|
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;
|
|
}
|
|
}
|