示例#1
0
/* make direct links to the latest update */
static void
commit_update(D_Scope *st, D_SymHash *sh) {
    int i;
    D_Sym *s;

    for (i = 0; i < sh->syms.n; i++)
        for (s = sh->syms.v[i]; s; s = s->next)
            s->update_of = current_D_Sym(st, s);
}
示例#2
0
文件: symtab.c 项目: PDelak/intent
D_Sym *
find_D_Sym_in_Scope(D_Scope *st, D_Scope *cur, char *name, char *end) {
  int len = end ? end - name : strlen(name);
  uint h = strhashl(name, len);
  D_Sym *s = find_D_Sym_in_Scope_internal(cur, name, len, h);
  if (s)
    return current_D_Sym(st, s);
  return NULL;
}
示例#3
0
文件: symtab.c 项目: PDelak/intent
D_Sym *
find_global_D_Sym(D_Scope *st, char *name, char *end) {
  D_Sym *s;
  int len = end ? end - name : strlen(name);
  uint h = strhashl(name, len);
  D_Scope *cur = st;
  while (cur->up) cur = cur->search;
  s = find_D_Sym_internal(cur, name, len, h);
  if (s)
    return current_D_Sym(st, s);
  return NULL;
}
示例#4
0
D_Sym *
update_D_Sym(D_Scope *st, D_Sym *sym, int sizeof_D_Sym) {
    D_Sym *s;

    sym = current_D_Sym(st, sym);
    s = MALLOC(sizeof_D_Sym);
    memcpy(s, sym, sizeof(D_Sym));
    if (sym->update_of) sym = sym->update_of;
    s->update_of = sym;
    s->next = st->updates;
    st->updates = s;
    return s;
}
示例#5
0
文件: symtab.c 项目: PDelak/intent
D_Sym *
update_additional_D_Sym(D_Scope *st, D_Sym *sym, int sizeof_D_Sym) {
  D_Sym *s;

  sym = current_D_Sym(st, sym);
  s = reinterpret_cast<D_Sym*>(MALLOC(sizeof_D_Sym));
  memcpy(s, sym, sizeof(D_Sym));
  if (sym->update_of) sym = sym->update_of;
  s->update_of = sym;
  s->next = st->updates;
  st->updates = s;
  return s;
}
示例#6
0
D_Sym *
find_sym_internal(D_Scope *top, D_Scope *cur, char *name, int len, uint h) {
    D_Sym *ll;

    if (!cur)
        return NULL;
    if (cur->hash)
        ll = cur->hash->syms.v[h % cur->hash->syms.n];
    else
        ll = cur->ll;
    while (ll) {
        if (ll->hash == h && ll->len == len && !strncmp(ll->name, name, len))
            break;
        ll = ll->next;
    }
    if (!ll) {
        if (cur->search)
            return find_sym_internal(top, cur->search, name, len, h);
        return ll;
    }
    return current_D_Sym(top, ll);
}