diff options
author | paltherr <paltherr@epfl.ch> | 2003-07-27 15:58:10 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-07-27 15:58:10 +0000 |
commit | 59f320de1d5f50adc491dcc8cefd71334f3129dd (patch) | |
tree | 307864b5000153a92d71f7bc3238f08f8765afc2 /sources/scalac | |
parent | 6b56b4b59019716621524ff2b5e52d397cd153ae (diff) | |
download | scala-59f320de1d5f50adc491dcc8cefd71334f3129dd.tar.gz scala-59f320de1d5f50adc491dcc8cefd71334f3129dd.tar.bz2 scala-59f320de1d5f50adc491dcc8cefd71334f3129dd.zip |
- Made field Entry.owner final
- Added method cloneScope
Diffstat (limited to 'sources/scalac')
-rw-r--r-- | sources/scalac/symtab/Scope.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sources/scalac/symtab/Scope.java b/sources/scalac/symtab/Scope.java index 64e06b61e6..477144cd3a 100644 --- a/sources/scalac/symtab/Scope.java +++ b/sources/scalac/symtab/Scope.java @@ -77,18 +77,19 @@ public class Scope { /** The owner of the entry; */ - public Scope owner; + public final Scope owner; Entry(Symbol sym, Scope owner) { - if (sym == null) throw new ApplicationError(); this.sym = sym; this.owner = owner; this.next = owner.elems; + if (sym == null) throw new ApplicationError(); owner.elems = this; } private Entry() { this.sym = Symbol.NONE; + this.owner = null; } public Entry setSymbol(Symbol sym) { @@ -154,6 +155,16 @@ public class Scope { enter(members[i]); } + /** Returns a new scope with the same content as this one. */ + public Scope cloneScope() { + int size = 0; + Scope clone = new Scope(); + for (Entry e = elems; e != Entry.NONE; e = e.next, size++) + new Entry(e.sym, clone); + if (size >= MIN_HASH) clone.createHash(); + return clone; + } + /** the number of entries in this scope */ int size() { |