Esempio n. 1
0
  /**
   * Remove symbol from this scope. Used when an inner class attribute tells us that the class isn't
   * a package member.
   */
  public void remove(Symbol sym) {
    assert shared == 0;
    Entry e = lookup(sym.name);
    while (e.scope == this && e.sym != sym) e = e.next();
    if (e.scope == null) return;

    // remove e from table and shadowed list;
    Entry te = table[sym.name.index & hashMask];
    if (te == e) table[sym.name.index & hashMask] = e.shadowed;
    else
      while (true) {
        if (te.shadowed == e) {
          te.shadowed = e.shadowed;
          break;
        }
        te = te.shadowed;
      }

    // remove e from elems and sibling list
    te = elems;
    if (te == e) elems = e.sibling;
    else
      while (true) {
        if (te.sibling == e) {
          te.sibling = e.sibling;
          break;
        }
        te = te.sibling;
      }
  }
Esempio n. 2
0
 /** Copy the given entry and all entries shadowed by it to table */
 private void copy(Entry e) {
   if (e.sym != null) {
     copy(e.shadowed);
     int hash = e.sym.name.index & hashMask;
     e.shadowed = table[hash];
     table[hash] = e;
   }
 }
Esempio n. 3
0
 /** Enter symbol sym in this scope if not already there.不存在的时候再放,这个enter就相当于hashmap的put */
 public void enterIfAbsent(Symbol sym) {
   assert shared == 0;
   Entry e = lookup(sym.name);
   while (e.scope == this && e.sym.kind != sym.kind) e = e.next();
   if (e.scope != this) enter(sym);
 }