/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/** A scope represents an area of visibility in a Java program. The
* Scope class is a container for symbols which provides
* efficient access to symbols given their names. Scopes are implemented
* as hash tables with "open addressing" and "double hashing".
* Scopes can be nested; the next field of a scope points
* to its next outer scope. Nested scopes can share their hash tables.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
public class Scope {
/** The number of scopes that share this scope's hash table.
*/
private int shared;
/** Next enclosing scope (with whom this scope may share a hashtable)
*/
/** The scope's owner.
*/
/** A hash table for the scope's entries.
*/
/** Mask for hash codes, always equal to (table.length - 1).
*/
int hashMask;
/** A linear list that also contains all entries in
* reverse order of appearance (i.e later entries are pushed on top).
*/
/** The number of elements in this scope.
* This includes deleted elements, whose value is the sentinel.
*/
/** A list of scopes to be notified if items are to be removed from this scope.
*/
/** Use as a "not-found" result for lookup.
* Also used to mark deleted entries in the table.
*/
/** The hash table's initial size.
*/
/** A value for the empty scope.
*/
/** Construct a new scope, within scope next, with given owner, using
* given table. The table's length must be an exponent of 2.
*/
}
/** Convenience constructor used for dup and dupUnshared. */
}
/** Construct a new scope, within scope next, with given owner,
* using a fresh table of length INITIAL_SIZE.
*/
}
/** Construct a fresh scope within this scope, with same owner,
* which shares its table with the outer scope. Used in connection with
* method leave if scope access is stack-like in order to avoid allocation
* of fresh tables.
*/
}
/** Construct a fresh scope within this scope, with new owner,
* which shares its table with the outer scope. Used in connection with
* method leave if scope access is stack-like in order to avoid allocation
* of fresh tables.
*/
shared++;
// System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode());
// new Error().printStackTrace(System.out);
return result;
}
/** Construct a fresh scope within this scope, with same owner,
* with a new hash table, whose contents initially are those of
* the table of its outer scope.
*/
}
/** Remove all entries of this scope from its table, if shared
* with next.
*/
}
// System.out.println("====> leaving scope " + this.hashCode() + " owned by " + this.owner + " to " + next.hashCode());
// new Error().printStackTrace(System.out);
return next;
}
/** Double size of hash table.
*/
private void dble() {
}
}
int n = 0;
n++;
}
}
// We don't need to update nelems for shared inherited scopes,
// since that gets handled by leave().
nelems = n;
}
/** Enter symbol sym in this scope.
*/
}
}
/**
* 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.
*/
dble();
nelems++;
}
elems = e;
//notify listeners
}
}
}
public interface ScopeListener {
}
}
/** Remove symbol from this scope. Used when an inner class
* attribute tells us that the class isn't a package member.
*/
// remove e from table and shadowed list;
if (te == e)
else while (true) {
break;
}
}
// remove e from elems and sibling list
if (te == e)
else while (true) {
break;
}
}
//notify listeners
}
}
/** Enter symbol sym in this scope if not already there.
*/
}
/** Given a class, is there already a class with same fully
* qualified name in this (import) scope?
*/
e.scope == this;
e = e.next()) {
if (e.sym == c) return true;
}
return false;
}
return true;
}
};
/** Return the entry associated with given name, starting in
* this scope and proceeding outwards. If no entry was found,
* return the sentinel, which is characterized by having a null in
* both its scope and sym fields, whereas both fields are non-null
* for regular entries.
*/
}
return sentinel;
e = e.shadowed;
return e;
}
/*void dump (java.io.PrintStream out) {
out.println(this);
for (int l=0; l < table.length; l++) {
Entry le = table[l];
out.print("#"+l+": ");
if (le==sentinel) out.println("sentinel");
else if(le == null) out.println("null");
else out.println(""+le+" s:"+le.sym);
}
}*/
/** Look for slot in the table.
* We use open addressing with double hashing.
*/
int i = h & hashMask;
// The expression below is always odd, so it is guaranteed
// to be mutually prime with table.length, a power of 2.
int d = -1; // Index of a deleted item.
for (;;) {
if (e == null)
return d >= 0 ? d : i;
if (e == sentinel) {
// We have to keep searching even if we see a deleted item.
// However, remember the index in case we fail to find the name.
if (d < 0)
d = i;
return i;
i = (i + x) & hashMask;
}
}
return getElements(noFilter);
}
{
update();
}
public boolean hasNext() {
}
}
update();
return sym;
}
public void remove() {
throw new UnsupportedOperationException();
}
private void update() {
}
}
void skipToNextMatchingEntry() {
}
}
};
}
};
}
}
public boolean hasNext() {
}
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
}
}
}
}
/** A class for scope entries.
*/
public static class Entry {
/** The referenced symbol.
* sym == null iff this == sentinel
*/
/** An entry with the same hash code, or sentinel.
*/
/** Next entry in same scope.
*/
/** The entry's scope.
* scope == null iff this == sentinel
* for an entry in an import scope, this is the scope
* where the entry came from (i.e. was imported from).
*/
}
/** Return next entry with the same name as this entry, proceeding
* outwards if not found in this scope.
*/
return shadowed;
}
}
// The origin is only recorded for import scopes. For all
// other scope entries, the "enclosing" type is available
// from other sources. See Attr.visitSelect and
// Attr.visitIdent. Rather than throwing an assertion
// error, we return scope which will be the same as origin
// in many cases.
return scope;
}
}
super(owner);
}
}
}
}
}
super(owner);
}
}
// Register to be notified when imported items are removed
fromScope.addScopeListener(this);
}
}
}
/** An empty scope, into which you can't place anything. Used for
* the scope for a variable initializer.
*/
}
return new DelegatedScope(next);
}
return new DelegatedScope(next);
}
return next;
}
// only anonymous classes could be put here
}
// only anonymous classes could be put here
}
throw new AssertionError(sym);
}
}
}
/** A class scope adds capabilities to keep track of changes in related
* class scopes - this allows client to realize whether a class scope
* to this scope) or indirectly (i.e. because a new member has been
*/
}
that.addScopeListener(this);
mark++;
}
}
}
mark++;
}
}
mark++;
}
}
public int getMark() {
return mark;
}
sep = ",";
}
}
return new CompoundScopeIterator(subScopes) {
}
};
}
};
}
return new CompoundScopeIterator(subScopes) {
}
};
}
};
}
this.scopesToScan = scopesToScan;
update();
}
public boolean hasNext() {
return currentIterator != null;
}
if (!currentIterator.hasNext()) {
update();
}
return sym;
}
public void remove() {
throw new UnsupportedOperationException();
}
private void update() {
while (scopesToScan.nonEmpty()) {
if (currentIterator.hasNext()) return;
}
}
}
throw new UnsupportedOperationException();
}
throw new UnsupportedOperationException();
}
throw new UnsupportedOperationException();
}
throw new UnsupportedOperationException();
}
}
/** An error scope, for which the owner should be an error symbol. */
}
super(errSymbol);
}
}
}
else
return e;
}
}
}