langtools/src/share/classes/com/sun/tools/javac/code/Scope.java
author jjg
Wed, 17 Nov 2010 15:07:43 -0800
changeset 7329 8a5601394af4
parent 7206 02edd110358f
child 7615 8bc078486f2b
permissions -rw-r--r--
7000973: isBogus needs to be called on the to-be-returned entry, not on the current entry Reviewed-by: jjg Contributed-by: jan.lahoda@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1264
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.javac.code;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.tools.javac.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.util.Iterator;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
/** A scope represents an area of visibility in a Java program. The
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 *  Scope class is a container for symbols which provides
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 *  efficient access to symbols given their names. Scopes are implemented
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
    34
 *  as hash tables with "open addressing" and "double hashing".
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
    35
 *  Scopes can be nested; the next field of a scope points
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 *  to its next outer scope. Nested scopes can share their hash tables.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    38
 *  <p><b>This is NOT part of any supported API.
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    39
 *  If you write code that depends on this, you do so at your own risk.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 *  This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 *  deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
public class Scope {
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
    /** The number of scopes that share this scope's hash table.
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
    private int shared;
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
    /** Next enclosing scope (with whom this scope may share a hashtable)
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
    public Scope next;
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /** The scope's owner.
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    public Symbol owner;
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
    /** A hash table for the scope's entries.
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     */
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
    59
    Entry[] table;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    /** Mask for hash codes, always equal to (table.length - 1).
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    int hashMask;
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /** A linear list that also contains all entries in
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     *  reverse order of appearance (i.e later entries are pushed on top).
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    public Entry elems;
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    /** The number of elements in this scope.
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
    71
     * This includes deleted elements, whose value is the sentinel.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     */
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
    73
    int nelems = 0;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
6709
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    75
    /** A timestamp - useful to quickly check whether a scope has changed or not
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    76
     */
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    77
    public ScopeCounter scopeCounter;
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    78
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    79
    static ScopeCounter dummyCounter = new ScopeCounter() {
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    80
        @Override
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    81
        public void inc() {
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    82
            //do nothing
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    83
        }
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    84
    };
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    85
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    86
    public static class ScopeCounter {
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    87
        protected static final Context.Key<ScopeCounter> scopeCounterKey =
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    88
            new Context.Key<ScopeCounter>();
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    89
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    90
        public static ScopeCounter instance(Context context) {
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    91
            ScopeCounter instance = context.get(scopeCounterKey);
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    92
            if (instance == null)
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    93
                instance = new ScopeCounter(context);
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    94
            return instance;
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    95
        }
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    96
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    97
        protected ScopeCounter(Context context) {
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    98
            context.put(scopeCounterKey, this);
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
    99
        }
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   100
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   101
        private ScopeCounter() {};
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   102
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   103
        private long val = 0;
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   104
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   105
        public void inc() {
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   106
            val++;
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   107
        }
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   108
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   109
        public long val() {
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   110
            return val;
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   111
        }
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   112
    }
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   113
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   114
    /** Use as a "not-found" result for lookup.
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   115
     * Also used to mark deleted entries in the table.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    private static final Entry sentinel = new Entry(null, null, null, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
    /** The hash table's initial size.
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
    private static final int INITIAL_SIZE = 0x10;
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
    /** A value for the empty scope.
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     */
6709
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   125
    public static final Scope emptyScope = new Scope(null, null, new Entry[]{}, dummyCounter);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    /** Construct a new scope, within scope next, with given owner, using
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     *  given table. The table's length must be an exponent of 2.
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     */
6709
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   130
    private Scope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        this.next = next;
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        assert emptyScope == null || owner != null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        this.owner = owner;
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        this.table = table;
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        this.hashMask = table.length - 1;
6709
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   136
        this.scopeCounter = scopeCounter;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   139
    /** Convenience constructor used for dup and dupUnshared. */
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   140
    private Scope(Scope next, Symbol owner, Entry[] table) {
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   141
        this(next, owner, table, next.scopeCounter);
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   142
        this.nelems = next.nelems;
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   143
    }
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   144
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
    /** Construct a new scope, within scope next, with given owner,
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     *  using a fresh table of length INITIAL_SIZE.
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
    public Scope(Symbol owner) {
6709
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   149
        this(owner, dummyCounter);
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   150
    }
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   151
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   152
    protected Scope(Symbol owner, ScopeCounter scopeCounter) {
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   153
        this(null, owner, new Entry[INITIAL_SIZE], scopeCounter);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
    /** Construct a fresh scope within this scope, with same owner,
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
     *  which shares its table with the outer scope. Used in connection with
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
     *  method leave if scope access is stack-like in order to avoid allocation
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
     *  of fresh tables.
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
    public Scope dup() {
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   162
        return dup(this.owner);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
    /** Construct a fresh scope within this scope, with new owner,
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
     *  which shares its table with the outer scope. Used in connection with
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     *  method leave if scope access is stack-like in order to avoid allocation
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     *  of fresh tables.
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
    public Scope dup(Symbol newOwner) {
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   171
        Scope result = new Scope(this, newOwner, this.table);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
        shared++;
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
        // System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode());
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
        // new Error().printStackTrace(System.out);
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
        return result;
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
    /** Construct a fresh scope within this scope, with same owner,
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
     *  with a new hash table, whose contents initially are those of
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
     *  the table of its outer scope.
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
    public Scope dupUnshared() {
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   183
        return new Scope(this, this.owner, this.table.clone());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
    /** Remove all entries of this scope from its table, if shared
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
     *  with next.
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
    public Scope leave() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
        assert shared == 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
        if (table != next.table) return next;
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        while (elems != null) {
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   193
            int hash = getIndex(elems.sym.name);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
            Entry e = table[hash];
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
            assert e == elems : elems.sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
            table[hash] = elems.shadowed;
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
            elems = elems.sibling;
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        assert next.shared > 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        next.shared--;
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   201
        next.nelems = nelems;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        // System.out.println("====> leaving scope " + this.hashCode() + " owned by " + this.owner + " to " + next.hashCode());
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        // new Error().printStackTrace(System.out);
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        return next;
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
    /** Double size of hash table.
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
    private void dble() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
        assert shared == 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        Entry[] oldtable = table;
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        Entry[] newtable = new Entry[oldtable.length * 2];
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
        for (Scope s = this; s != null; s = s.next) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
            if (s.table == oldtable) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
                assert s == this || s.shared != 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
                s.table = newtable;
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
                s.hashMask = newtable.length - 1;
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
        }
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   220
        int n = 0;
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   221
        for (int i = oldtable.length; --i >= 0; ) {
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   222
            Entry e = oldtable[i];
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   223
            if (e != null && e != sentinel && ! e.isBogus()) {
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   224
                table[getIndex(e.sym.name)] = e;
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   225
                n++;
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   226
            }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
        }
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   228
        // We don't need to update nelems for shared inherited scopes,
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   229
        // since that gets handled by leave().
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   230
        nelems = n;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    /** Enter symbol sym in this scope.
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
    public void enter(Symbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        assert shared == 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
        enter(sym, this);
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
    public void enter(Symbol sym, Scope s) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
        enter(sym, s, s);
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
     * Enter symbol sym in this scope, but mark that it comes from
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
     * given scope `s' accessed through `origin'.  The last two
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
     * arguments are only used in import scopes.
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
    public void enter(Symbol sym, Scope s, Scope origin) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
        assert shared == 0;
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   251
        if (nelems * 3 >= hashMask * 2)
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   252
            dble();
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   253
        int hash = getIndex(sym.name);
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   254
        Entry old = table[hash];
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   255
        if (old == null) {
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   256
            old = sentinel;
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   257
            nelems++;
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   258
        }
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   259
        Entry e = makeEntry(sym, old, elems, s, origin);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
        table[hash] = e;
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
        elems = e;
6709
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   262
        scopeCounter.inc();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
    Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
        return new Entry(sym, shadowed, sibling, scope);
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
    /** Remove symbol from this scope.  Used when an inner class
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     *  attribute tells us that the class isn't a package member.
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
    public void remove(Symbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
        assert shared == 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
        Entry e = lookup(sym.name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
        if (e.scope == null) return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
6709
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   277
        scopeCounter.inc();
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   278
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
        // remove e from table and shadowed list;
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   280
        int i = getIndex(sym.name);
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   281
        Entry te = table[i];
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
        if (te == e)
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   283
            table[i] = e.shadowed;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
        else while (true) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   285
            if (te.shadowed == e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   286
                te.shadowed = e.shadowed;
06bc494ca11e Initial load
duke
parents:
diff changeset
   287
                break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   288
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   289
            te = te.shadowed;
06bc494ca11e Initial load
duke
parents:
diff changeset
   290
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
06bc494ca11e Initial load
duke
parents:
diff changeset
   292
        // remove e from elems and sibling list
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
        te = elems;
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
        if (te == e)
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
            elems = e.sibling;
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
        else while (true) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
            if (te.sibling == e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
                te.sibling = e.sibling;
06bc494ca11e Initial load
duke
parents:
diff changeset
   299
                break;
06bc494ca11e Initial load
duke
parents:
diff changeset
   300
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   301
            te = te.sibling;
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   304
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
    /** Enter symbol sym in this scope if not already there.
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   307
    public void enterIfAbsent(Symbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   308
        assert shared == 0;
06bc494ca11e Initial load
duke
parents:
diff changeset
   309
        Entry e = lookup(sym.name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
        while (e.scope == this && e.sym.kind != sym.kind) e = e.next();
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
        if (e.scope != this) enter(sym);
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   313
06bc494ca11e Initial load
duke
parents:
diff changeset
   314
    /** Given a class, is there already a class with same fully
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
     *  qualified name in this (import) scope?
06bc494ca11e Initial load
duke
parents:
diff changeset
   316
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   317
    public boolean includes(Symbol c) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   318
        for (Scope.Entry e = lookup(c.name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   319
             e.scope == this;
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
             e = e.next()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   321
            if (e.sym == c) return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   322
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   323
        return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   325
6591
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   326
    static final Filter<Symbol> noFilter = new Filter<Symbol>() {
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   327
        public boolean accepts(Symbol s) {
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   328
            return true;
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   329
        }
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   330
    };
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   331
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   332
    /** Return the entry associated with given name, starting in
06bc494ca11e Initial load
duke
parents:
diff changeset
   333
     *  this scope and proceeding outwards. If no entry was found,
06bc494ca11e Initial load
duke
parents:
diff changeset
   334
     *  return the sentinel, which is characterized by having a null in
06bc494ca11e Initial load
duke
parents:
diff changeset
   335
     *  both its scope and sym fields, whereas both fields are non-null
06bc494ca11e Initial load
duke
parents:
diff changeset
   336
     *  for regular entries.
06bc494ca11e Initial load
duke
parents:
diff changeset
   337
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   338
    public Entry lookup(Name name) {
6591
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   339
        return lookup(name, noFilter);
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   340
    }
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   341
    public Entry lookup(Name name, Filter<Symbol> sf) {
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   342
        Entry e = table[getIndex(name)];
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   343
        if (e == null || e == sentinel)
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   344
            return sentinel;
6591
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   345
        while (e.scope != null && (e.sym.name != name || !sf.accepts(e.sym)))
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
            e = e.shadowed;
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
        return e;
06bc494ca11e Initial load
duke
parents:
diff changeset
   348
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   349
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   350
    /*void dump (java.io.PrintStream out) {
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   351
        out.println(this);
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   352
        for (int l=0; l < table.length; l++) {
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   353
            Entry le = table[l];
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   354
            out.print("#"+l+": ");
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   355
            if (le==sentinel) out.println("sentinel");
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   356
            else if(le == null) out.println("null");
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   357
            else out.println(""+le+" s:"+le.sym);
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   358
        }
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   359
    }*/
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   360
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   361
    /** Look for slot in the table.
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   362
     *  We use open addressing with double hashing.
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   363
     */
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   364
    int getIndex (Name name) {
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   365
        int h = name.hashCode();
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   366
        int i = h & hashMask;
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   367
        // The expression below is always odd, so it is guaranteed
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   368
        // be be mutually prime with table.length, a power of 2.
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   369
        int x = hashMask - ((h + (h >> 16)) << 1);
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   370
        int d = -1; // Index of a deleted item.
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   371
        for (;;) {
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   372
            Entry e = table[i];
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   373
            if (e == null)
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   374
                return d >= 0 ? d : i;
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   375
            if (e == sentinel) {
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   376
                // We have to keep searching even if we see a deleted item.
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   377
                // However, remember the index in case we fail to find the name.
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   378
                if (d < 0)
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   379
                    d = i;
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   380
            } else if (e.sym.name == name)
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   381
                return i;
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   382
            i = (i + x) & hashMask;
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   383
        }
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   384
    }
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   385
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   386
    public Iterable<Symbol> getElements() {
6591
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   387
        return getElements(noFilter);
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   388
    }
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   389
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   390
    public Iterable<Symbol> getElements(final Filter<Symbol> sf) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   391
        return new Iterable<Symbol>() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   392
            public Iterator<Symbol> iterator() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   393
                return new Iterator<Symbol>() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   394
                    private Scope currScope = Scope.this;
06bc494ca11e Initial load
duke
parents:
diff changeset
   395
                    private Scope.Entry currEntry = elems;
06bc494ca11e Initial load
duke
parents:
diff changeset
   396
                    {
06bc494ca11e Initial load
duke
parents:
diff changeset
   397
                        update();
06bc494ca11e Initial load
duke
parents:
diff changeset
   398
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   399
06bc494ca11e Initial load
duke
parents:
diff changeset
   400
                    public boolean hasNext() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   401
                        return currEntry != null;
06bc494ca11e Initial load
duke
parents:
diff changeset
   402
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   403
06bc494ca11e Initial load
duke
parents:
diff changeset
   404
                    public Symbol next() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   405
                        Symbol sym = (currEntry == null ? null : currEntry.sym);
6591
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   406
                        if (currEntry != null) {
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   407
                            currEntry = currEntry.sibling;
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   408
                        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   409
                        update();
06bc494ca11e Initial load
duke
parents:
diff changeset
   410
                        return sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
   411
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   412
06bc494ca11e Initial load
duke
parents:
diff changeset
   413
                    public void remove() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   414
                        throw new UnsupportedOperationException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   415
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   416
06bc494ca11e Initial load
duke
parents:
diff changeset
   417
                    private void update() {
6591
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   418
                        skipToNextMatchingEntry();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   419
                        while (currEntry == null && currScope.next != null) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   420
                            currScope = currScope.next;
06bc494ca11e Initial load
duke
parents:
diff changeset
   421
                            currEntry = currScope.elems;
6591
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   422
                            skipToNextMatchingEntry();
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   423
                        }
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   424
                    }
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   425
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   426
                    void skipToNextMatchingEntry() {
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   427
                        while (currEntry != null && !sf.accepts(currEntry.sym)) {
a953c8c6b85e 6337171: javac should create bridge methods when type variable bounds restricted
mcimadamore
parents: 5847
diff changeset
   428
                            currEntry = currEntry.sibling;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   429
                        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   430
                    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   431
                };
06bc494ca11e Initial load
duke
parents:
diff changeset
   432
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   433
        };
06bc494ca11e Initial load
duke
parents:
diff changeset
   434
06bc494ca11e Initial load
duke
parents:
diff changeset
   435
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   436
06bc494ca11e Initial load
duke
parents:
diff changeset
   437
    public String toString() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   438
        StringBuilder result = new StringBuilder();
06bc494ca11e Initial load
duke
parents:
diff changeset
   439
        result.append("Scope[");
06bc494ca11e Initial load
duke
parents:
diff changeset
   440
        for (Scope s = this; s != null ; s = s.next) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   441
            if (s != this) result.append(" | ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   442
            for (Entry e = s.elems; e != null; e = e.sibling) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   443
                if (e != s.elems) result.append(", ");
06bc494ca11e Initial load
duke
parents:
diff changeset
   444
                result.append(e.sym);
06bc494ca11e Initial load
duke
parents:
diff changeset
   445
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   446
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   447
        result.append("]");
06bc494ca11e Initial load
duke
parents:
diff changeset
   448
        return result.toString();
06bc494ca11e Initial load
duke
parents:
diff changeset
   449
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   450
06bc494ca11e Initial load
duke
parents:
diff changeset
   451
    /** A class for scope entries.
06bc494ca11e Initial load
duke
parents:
diff changeset
   452
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   453
    public static class Entry {
06bc494ca11e Initial load
duke
parents:
diff changeset
   454
06bc494ca11e Initial load
duke
parents:
diff changeset
   455
        /** The referenced symbol.
06bc494ca11e Initial load
duke
parents:
diff changeset
   456
         *  sym == null   iff   this == sentinel
06bc494ca11e Initial load
duke
parents:
diff changeset
   457
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   458
        public Symbol sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
   459
06bc494ca11e Initial load
duke
parents:
diff changeset
   460
        /** An entry with the same hash code, or sentinel.
06bc494ca11e Initial load
duke
parents:
diff changeset
   461
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   462
        private Entry shadowed;
06bc494ca11e Initial load
duke
parents:
diff changeset
   463
06bc494ca11e Initial load
duke
parents:
diff changeset
   464
        /** Next entry in same scope.
06bc494ca11e Initial load
duke
parents:
diff changeset
   465
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   466
        public Entry sibling;
06bc494ca11e Initial load
duke
parents:
diff changeset
   467
06bc494ca11e Initial load
duke
parents:
diff changeset
   468
        /** The entry's scope.
06bc494ca11e Initial load
duke
parents:
diff changeset
   469
         *  scope == null   iff   this == sentinel
06bc494ca11e Initial load
duke
parents:
diff changeset
   470
         *  for an entry in an import scope, this is the scope
06bc494ca11e Initial load
duke
parents:
diff changeset
   471
         *  where the entry came from (i.e. was imported from).
06bc494ca11e Initial load
duke
parents:
diff changeset
   472
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   473
        public Scope scope;
06bc494ca11e Initial load
duke
parents:
diff changeset
   474
06bc494ca11e Initial load
duke
parents:
diff changeset
   475
        public Entry(Symbol sym, Entry shadowed, Entry sibling, Scope scope) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   476
            this.sym = sym;
06bc494ca11e Initial load
duke
parents:
diff changeset
   477
            this.shadowed = shadowed;
06bc494ca11e Initial load
duke
parents:
diff changeset
   478
            this.sibling = sibling;
06bc494ca11e Initial load
duke
parents:
diff changeset
   479
            this.scope = scope;
06bc494ca11e Initial load
duke
parents:
diff changeset
   480
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   481
06bc494ca11e Initial load
duke
parents:
diff changeset
   482
        /** Return next entry with the same name as this entry, proceeding
06bc494ca11e Initial load
duke
parents:
diff changeset
   483
         *  outwards if not found in this scope.
06bc494ca11e Initial load
duke
parents:
diff changeset
   484
         */
06bc494ca11e Initial load
duke
parents:
diff changeset
   485
        public Entry next() {
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   486
            return shadowed;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   487
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   488
06bc494ca11e Initial load
duke
parents:
diff changeset
   489
        public Scope getOrigin() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   490
            // The origin is only recorded for import scopes.  For all
06bc494ca11e Initial load
duke
parents:
diff changeset
   491
            // other scope entries, the "enclosing" type is available
06bc494ca11e Initial load
duke
parents:
diff changeset
   492
            // from other sources.  See Attr.visitSelect and
06bc494ca11e Initial load
duke
parents:
diff changeset
   493
            // Attr.visitIdent.  Rather than throwing an assertion
06bc494ca11e Initial load
duke
parents:
diff changeset
   494
            // error, we return scope which will be the same as origin
06bc494ca11e Initial load
duke
parents:
diff changeset
   495
            // in many cases.
06bc494ca11e Initial load
duke
parents:
diff changeset
   496
            return scope;
06bc494ca11e Initial load
duke
parents:
diff changeset
   497
        }
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   498
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   499
        protected boolean isBogus () { return false; }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   500
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   501
06bc494ca11e Initial load
duke
parents:
diff changeset
   502
    public static class ImportScope extends Scope {
06bc494ca11e Initial load
duke
parents:
diff changeset
   503
06bc494ca11e Initial load
duke
parents:
diff changeset
   504
        public ImportScope(Symbol owner) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   505
            super(owner);
06bc494ca11e Initial load
duke
parents:
diff changeset
   506
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   507
06bc494ca11e Initial load
duke
parents:
diff changeset
   508
        @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   509
        Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   510
            return new ImportEntry(sym, shadowed, sibling, scope, origin);
06bc494ca11e Initial load
duke
parents:
diff changeset
   511
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   512
06bc494ca11e Initial load
duke
parents:
diff changeset
   513
        public Entry lookup(Name name) {
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   514
            Entry e = table[getIndex(name)];
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   515
            if (e == null)
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   516
                return sentinel;
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   517
            while (e.isBogus())
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   518
                e = e.shadowed;
06bc494ca11e Initial load
duke
parents:
diff changeset
   519
            return e;
06bc494ca11e Initial load
duke
parents:
diff changeset
   520
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   521
06bc494ca11e Initial load
duke
parents:
diff changeset
   522
        static class ImportEntry extends Entry {
06bc494ca11e Initial load
duke
parents:
diff changeset
   523
            private Scope origin;
06bc494ca11e Initial load
duke
parents:
diff changeset
   524
06bc494ca11e Initial load
duke
parents:
diff changeset
   525
            ImportEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   526
                super(sym, shadowed, sibling, scope);
06bc494ca11e Initial load
duke
parents:
diff changeset
   527
                this.origin = origin;
06bc494ca11e Initial load
duke
parents:
diff changeset
   528
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   529
            public Entry next() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   530
                Entry e = super.shadowed;
7329
8a5601394af4 7000973: isBogus needs to be called on the to-be-returned entry, not on the current entry
jjg
parents: 7206
diff changeset
   531
                while (e.isBogus())
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   532
                    e = e.shadowed;
06bc494ca11e Initial load
duke
parents:
diff changeset
   533
                return e;
06bc494ca11e Initial load
duke
parents:
diff changeset
   534
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   535
06bc494ca11e Initial load
duke
parents:
diff changeset
   536
            @Override
06bc494ca11e Initial load
duke
parents:
diff changeset
   537
            public Scope getOrigin() { return origin; }
7206
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   538
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   539
            /**
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   540
             * Is this a bogus inner-class import?
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   541
             * An inner class {@code Outer$Inner.class} read from a class file
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   542
             * starts out in a package scope under the name {@code Outer$Inner},
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   543
             * which (if star-imported) gets copied to the import scope.
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   544
             * When the InnerClasses attribute is processed, the ClassSymbol
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   545
             * is renamed in place (to {@code Inner}), and the owner changed
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   546
             * to the {@code Outer} class.  The ImportScope still has the old
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   547
             * Entry that was created and hashed as {@code "Outer$Inner"},
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   548
             * but whose name was changed to {@code "Inner"}.  This violates
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   549
             * the invariants for the Scope hash table, and so is pretty bogus.
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   550
             * When the symbol was renamed, it should have been removed from
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   551
             * the import scope (and not just the package scope); however,
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   552
             * doing so is difficult.  A better fix would be to change
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   553
             * import scopes to indirectly reference package symbols, rather
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   554
             * than copy from them.
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   555
             * Until then, we detect and skip the bogus entries using this test.
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   556
             */
02edd110358f 6998063: new Scope impl to fix Scope performance issues
jjg
parents: 7079
diff changeset
   557
            protected boolean isBogus () { return sym.owner != scope.owner; }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   558
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   559
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   560
06bc494ca11e Initial load
duke
parents:
diff changeset
   561
    /** An empty scope, into which you can't place anything.  Used for
06bc494ca11e Initial load
duke
parents:
diff changeset
   562
     *  the scope for a variable initializer.
06bc494ca11e Initial load
duke
parents:
diff changeset
   563
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   564
    public static class DelegatedScope extends Scope {
06bc494ca11e Initial load
duke
parents:
diff changeset
   565
        Scope delegatee;
06bc494ca11e Initial load
duke
parents:
diff changeset
   566
        public static final Entry[] emptyTable = new Entry[0];
06bc494ca11e Initial load
duke
parents:
diff changeset
   567
06bc494ca11e Initial load
duke
parents:
diff changeset
   568
        public DelegatedScope(Scope outer) {
6709
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   569
            super(outer, outer.owner, emptyTable, outer.scopeCounter);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   570
            delegatee = outer;
06bc494ca11e Initial load
duke
parents:
diff changeset
   571
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   572
        public Scope dup() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   573
            return new DelegatedScope(next);
06bc494ca11e Initial load
duke
parents:
diff changeset
   574
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   575
        public Scope dupUnshared() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   576
            return new DelegatedScope(next);
06bc494ca11e Initial load
duke
parents:
diff changeset
   577
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   578
        public Scope leave() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   579
            return next;
06bc494ca11e Initial load
duke
parents:
diff changeset
   580
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   581
        public void enter(Symbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   582
            // only anonymous classes could be put here
06bc494ca11e Initial load
duke
parents:
diff changeset
   583
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   584
        public void enter(Symbol sym, Scope s) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   585
            // only anonymous classes could be put here
06bc494ca11e Initial load
duke
parents:
diff changeset
   586
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   587
        public void remove(Symbol sym) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   588
            throw new AssertionError(sym);
06bc494ca11e Initial load
duke
parents:
diff changeset
   589
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   590
        public Entry lookup(Name name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   591
            return delegatee.lookup(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   592
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   593
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   594
6709
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   595
    /** A class scope, for which a scope counter should be provided */
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   596
    public static class ClassScope extends Scope {
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   597
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   598
        ClassScope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) {
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   599
            super(next, owner, table, scopeCounter);
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   600
        }
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   601
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   602
        public ClassScope(Symbol owner, ScopeCounter scopeCounter) {
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   603
            super(owner, scopeCounter);
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   604
        }
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   605
    }
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   606
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   607
    /** An error scope, for which the owner should be an error symbol. */
06bc494ca11e Initial load
duke
parents:
diff changeset
   608
    public static class ErrorScope extends Scope {
06bc494ca11e Initial load
duke
parents:
diff changeset
   609
        ErrorScope(Scope next, Symbol errSymbol, Entry[] table) {
6709
ade773eb432d 6980862: too aggressive compiler optimization causes stale results of Types.implementation()
mcimadamore
parents: 6591
diff changeset
   610
            super(next, /*owner=*/errSymbol, table, dummyCounter);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   611
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   612
        public ErrorScope(Symbol errSymbol) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   613
            super(errSymbol);
06bc494ca11e Initial load
duke
parents:
diff changeset
   614
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   615
        public Scope dup() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   616
            return new ErrorScope(this, owner, table);
06bc494ca11e Initial load
duke
parents:
diff changeset
   617
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   618
        public Scope dupUnshared() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   619
            return new ErrorScope(this, owner, table.clone());
06bc494ca11e Initial load
duke
parents:
diff changeset
   620
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   621
        public Entry lookup(Name name) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   622
            Entry e = super.lookup(name);
06bc494ca11e Initial load
duke
parents:
diff changeset
   623
            if (e.scope == null)
06bc494ca11e Initial load
duke
parents:
diff changeset
   624
                return new Entry(owner, null, null, null);
06bc494ca11e Initial load
duke
parents:
diff changeset
   625
            else
06bc494ca11e Initial load
duke
parents:
diff changeset
   626
                return e;
06bc494ca11e Initial load
duke
parents:
diff changeset
   627
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   628
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   629
}