static int list_cmd(int argc, char **argv) { static struct option long_options[] = { { 0, 0, 0, 0 } }; const int next_cmd = scan_cmd(2, argc, argv); int c, index = 0; const char *spec = ""; while ((c = getopt_long(next_cmd, argv, spec, long_options, &index)) != -1) { switch (c) { case 0: // Set a flag break; case '?': fatal("unrecognised list option %s", argv[optind - 1]); default: abort(); } } lib_walk_index(lib_work(), list_walk_fn, NULL); argc -= next_cmd - 1; argv += next_cmd - 1; return argc > 1 ? process_command(argc, argv) : EXIT_SUCCESS; }
static void elab_use_clause(tree_t use, const elab_ctx_t *ctx) { tree_set_ident2(use, all_i); ident_t name = tree_ident(use); ident_t lname = ident_until(name, '.'); elab_ctx_t new_ctx = *ctx; new_ctx.library = elab_find_lib(lname, ctx); if (name == lname) lib_walk_index(new_ctx.library, elab_context_walk_fn, &new_ctx); else if (!elab_have_context(ctx->out, name)) elab_add_context(use, &new_ctx); }
static void link_context(tree_t ctx, FILE *deps, context_fn_t fn) { ident_t cname = tree_ident(ctx); ident_t lname = ident_until(cname, '.'); lib_t lib = lib_find(istr(lname), true, true); if (lib == NULL) fatal("cannot link library %s", istr(lname)); if (lname == cname) { lib_walk_params_t params = { .lib = lib, .deps = deps, .fn = fn }; lib_walk_index(lib, link_walk_lib, ¶ms); }
static void elab_copy_context(tree_t src, const elab_ctx_t *ctx) { const int nsrc = tree_contexts(src); for (int i = 0; i < nsrc; i++) { tree_t c = tree_context(src, i); if (tree_kind(c) != T_USE) continue; tree_set_ident2(c, all_i); ident_t name = tree_ident(c); ident_t lname = ident_until(name, '.'); elab_ctx_t new_ctx = *ctx; new_ctx.library = elab_find_lib(lname, ctx); if (name == lname) lib_walk_index(new_ctx.library, elab_context_walk_fn, &new_ctx); else if (!elab_have_context(ctx->out, name)) elab_add_context(c, &new_ctx); } }
static tree_t pick_arch(const loc_t *loc, ident_t name, lib_t *new_lib, const elab_ctx_t *ctx) { // When an explicit architecture name is not given select the most // recently analysed architecture of this entity lib_t lib = elab_find_lib(name, ctx); tree_t arch = lib_get_check_stale(lib, name); if ((arch == NULL) || (tree_kind(arch) != T_ARCH)) { arch = NULL; lib_search_params_t params = { lib, name, &arch }; lib_walk_index(lib, find_arch, ¶ms); if (arch == NULL) fatal_at(loc, "no suitable architecture for %s", istr(name)); } if (new_lib != NULL) *new_lib = lib; return arch; }