示例#1
0
文件: elab.c 项目: sylphase/nvc
static void elab_add_context(tree_t t, const elab_ctx_t *ctx)
{
   ident_t cname = tree_ident(t);
   ident_t lname = ident_until(cname, '.');

   lib_t lib = elab_find_lib(lname, ctx);

   tree_t unit = lib_get(lib, cname);
   if (unit == NULL)
      fatal_at(tree_loc(t), "cannot find unit %s", istr(cname));
   else if (tree_kind(unit) == T_PACKAGE) {
      elab_copy_context(unit, ctx);

      ident_t name = tree_ident(unit);

      ident_t body_i = ident_prefix(name, ident_new("body"), '-');
      tree_t body = lib_get(lib, body_i);
      if (body != NULL)
         elab_copy_context(unit, ctx);
   }

   // Always use real library name rather than WORK alias
   tree_set_ident(t, tree_ident(unit));

   tree_add_context(ctx->out, t);
}
示例#2
0
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);
}
示例#3
0
文件: elab.c 项目: sylphase/nvc
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);
   }
}
示例#4
0
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, &params);

      if (arch == NULL)
         fatal_at(loc, "no suitable architecture for %s", istr(name));
   }

   if (new_lib != NULL)
      *new_lib = lib;

   return arch;
}