static void module_prepare_empty_mocks(struct module **mod) { struct globalctx *gctx = calloc(1, sizeof(struct globalctx)); globalctx_init(gctx); struct stage *stage = calloc(1, sizeof(struct stage)); error e = stage_load(gctx, stage, "bootstrap/mockempty/mockempty.n"); assert(!e); *mod = stage->entry_point; }
static void module_prepare_mocks(struct module **mod) { struct globalctx *gctx = calloc(1, sizeof(struct globalctx)); globalctx_init(gctx); struct stage *stage = calloc(1, sizeof(struct stage)); error e = stage_load(gctx, stage, "bootstrap/mockbasic/mockbasic.n"); if (e && g_env.stderr != stderr) { fflush(g_env.stderr); fprintf(stderr, "%s", g_env.stderr_mem); } assert(!e); *mod = stage->entry_point; }
void gserver(int ch) { switch(ch) {case 1: shoot(); break; case 2: shoot_build(); break; case 3: cleardevice(); stage_load(); break; }; }
int main(int argc, char **argv) { env_init(); if (argc != 2) { fprintf(g_env.stderr, "Usage: %s <main.n>\n", argv[0]); exit(1); } g_opt.verbose = false; g_opt.compile = true; g_opt.compiler = "gcc"; g_opt.ccache = "ccache"; g_opt.cflags = ""; if (getenv("NCC_VERBOSE")) { g_opt.verbose = atoi(getenv("NCC_VERBOSE")) != 0; } if (getenv("NCC_COMPILE")) { g_opt.compile = atoi(getenv("NCC_COMPILE")) != 0; } if (getenv("NCC_COMPILER")) { g_opt.compiler = strdup(getenv("NCC_COMPILER")); } if (getenv("NCC_CFLAGS")) { g_opt.cflags = strdup(getenv("NCC_CFLAGS")); } timeit_enable = false; if (getenv("NCC_TIMEIT")) { timeit_enable = true; } timeit_init(); BEGTIMEIT(TIMEIT_MAIN); int status = system("ccache --version &> /dev/null"); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { g_opt.ccache = ""; } struct globalctx gctx; globalctx_init(&gctx); struct stage stage = { 0 }; error e = stage_load(&gctx, &stage, argv[1]); EXCEPT(e); for (size_t n = 0; n < stage.sorted_count; ++n) { const struct module *mod = stage.sorted[n]; e = generate(mod->root); EXCEPT(e); } ENDTIMEIT(true, TIMEIT_MAIN); if (timeit_enable) { timeit_print(g_env.stderr); fprintf(g_env.stderr, "\n" "%.0f k nodes (approx)\n" "%.0f k nodes / sec (approx)\n", timeits[TIMEIT_TYPE_INFERENCE].count * .001, timeits[TIMEIT_TYPE_INFERENCE].count * .001 / timeits[TIMEIT_MAIN].time); } if (!g_opt.compile) { return 0; } char template[] = "/tmp/nccXXXXXX";