public Entry lookup(Name name, Filter<Symbol> sf) { Entry e = table[getIndex(name)]; if (e == null || e == sentinel) return sentinel; while (e.scope != null && (e.sym.name != name || !sf.accepts(e.sym))) e = e.shadowed; return e; }
public Entry lookup(Name name, Filter<Symbol> sf) { Entry e = table[getIndex(name)]; if (e == null || e == sentinel) return sentinel; while (e.scope != null && (e.sym.name != name || !sf.accepts(e.sym))) e = e.shadowed; return e; }
/** Double size of hash table. */ private void dble() { Assert.check(shared == 0); Entry[] oldtable = table; Entry[] newtable = new Entry[oldtable.length * 2]; for (Scope s = this; s != null; s = s.next) { if (s.table == oldtable) { Assert.check(s == this || s.shared != 0); s.table = newtable; s.hashMask = newtable.length - 1; } } int n = 0; for (int i = oldtable.length; --i >= 0; ) { Entry e = oldtable[i]; if (e != null && e != sentinel) { table[getIndex(e.sym.name)] = e; n++; } } // We don't need to update nelems for shared inherited scopes, // since that gets handled by leave(). nelems = n; }
/** Double size of hash table. */ private void dble() { Assert.check(shared == 0); Entry[] oldtable = table; Entry[] newtable = new Entry[oldtable.length * 2]; for (Scope s = this; s != null; s = s.next) { if (s.table == oldtable) { Assert.check(s == this || s.shared != 0); s.table = newtable; s.hashMask = newtable.length - 1; } } int n = 0; for (int i = oldtable.length; --i >= 0; ) { Entry e = oldtable[i]; if (e != null && e != sentinel) { table[getIndex(e.sym.name)] = e; n++; } } // We don't need to update nelems for shared inherited scopes, // since that gets handled by leave(). nelems = n; }
/** Remove all entries of this scope from its table, if shared * with next. */ public Scope leave() { Assert.check(shared == 0); if (table != next.table) return next; while (elems != null) { int hash = getIndex(elems.sym.name); Entry e = table[hash]; Assert.check(e == elems, elems.sym); table[hash] = elems.shadowed; elems = elems.sibling; } Assert.check(next.shared > 0); next.shared--; next.nelems = nelems; // System.out.println("====> leaving scope " + this.hashCode() + " owned by " + this.owner + " to " + next.hashCode()); // new Error().printStackTrace(System.out); return next; }
/** Remove all entries of this scope from its table, if shared * with next. */ public Scope leave() { Assert.check(shared == 0); if (table != next.table) return next; while (elems != null) { int hash = getIndex(elems.sym.name); Entry e = table[hash]; Assert.check(e == elems, elems.sym); table[hash] = elems.shadowed; elems = elems.sibling; } Assert.check(next.shared > 0); next.shared--; next.nelems = nelems; // System.out.println("====> leaving scope " + this.hashCode() + " owned by " + this.owner + " to " + next.hashCode()); // new Error().printStackTrace(System.out); return next; }
int i = getIndex(sym.name); Entry te = table[i]; if (te == e)
int i = getIndex(sym.name); Entry te = table[i]; if (te == e)
/** * Enter symbol sym in this scope, but mark that it comes from * given scope `s' accessed through `origin'. The last two * arguments are only used in import scopes. */ public void enter(Symbol sym, Scope s, Scope origin, boolean staticallyImported) { Assert.check(shared == 0); if (nelems * 3 >= hashMask * 2) dble(); int hash = getIndex(sym.name); Entry old = table[hash]; if (old == null) { old = sentinel; nelems++; } Entry e = makeEntry(sym, old, elems, s, origin, staticallyImported); table[hash] = e; elems = e; //notify listeners for (List<ScopeListener> l = listeners; l.nonEmpty(); l = l.tail) { l.head.symbolAdded(sym, this); } }
/** * Enter symbol sym in this scope, but mark that it comes from * given scope `s' accessed through `origin'. The last two * arguments are only used in import scopes. */ public void enter(Symbol sym, Scope s, Scope origin, boolean staticallyImported) { Assert.check(shared == 0); if (nelems * 3 >= hashMask * 2) dble(); int hash = getIndex(sym.name); Entry old = table[hash]; if (old == null) { old = sentinel; nelems++; } Entry e = makeEntry(sym, old, elems, s, origin, staticallyImported); table[hash] = e; elems = e; //notify listeners for (List<ScopeListener> l = listeners; l.nonEmpty(); l = l.tail) { l.head.symbolAdded(sym, this); } }