summaryrefslogtreecommitdiff
path: root/sources/scalac
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-05-06 11:01:56 +0000
committerpaltherr <paltherr@epfl.ch>2003-05-06 11:01:56 +0000
commit3db933967d05b4a06c275462d4f07b61db9a462f (patch)
tree5844a50cd4d6bebaf8cc473d3bfc1bda753a50c5 /sources/scalac
parent99becce923f570b1a398f99371e2af4088ec52e7 (diff)
downloadscala-3db933967d05b4a06c275462d4f07b61db9a462f.tar.gz
scala-3db933967d05b4a06c275462d4f07b61db9a462f.tar.bz2
scala-3db933967d05b4a06c275462d4f07b61db9a462f.zip
- Added method contains
- Added second method iterator - Added assert in method enter to prevent entering two symbols with the same name
Diffstat (limited to 'sources/scalac')
-rw-r--r--sources/scalac/symtab/Scope.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/sources/scalac/symtab/Scope.java b/sources/scalac/symtab/Scope.java
index f1fa915c55..c205342011 100644
--- a/sources/scalac/symtab/Scope.java
+++ b/sources/scalac/symtab/Scope.java
@@ -178,11 +178,25 @@ public class Scope {
/** enter a symbol
*/
public Scope enter(Symbol sym) {
+ assert lookupEntry(sym.name).owner != this : Debug.show(sym);
return enter(new Entry(sym, this));
}
public Scope enterOrOverload(Symbol sym) {
Entry e = lookupEntry(sym.name);
+ /* !!!
+ if (e == Entry.NONE) {
+ return enter(sym);
+ } else {
+ sym = e.sym.overloadWith(sym);
+ if (e.owner == this) {
+ e.setSymbol(sym);
+ return this;
+ } else {
+ return enter(new Entry(sym, this));
+ }
+ }
+ */
if (e.owner == this && (sym.flags & Modifiers.PRIVATE) == 0) {
e.setSymbol(e.sym.overloadWith(sym));
return this;
@@ -229,6 +243,17 @@ public class Scope {
elemsCache = null;
}
+ public boolean contains(Symbol sym) {
+ Entry e = lookupEntry(sym.name);
+ if (e.sym == sym) return true;
+ switch (e.sym.type()) {
+ case OverloadedType(Symbol[] alts, _):
+ for (int i = 0; i < alts.length; i++)
+ if (alts[i] == sym) return true;
+ }
+ return false;
+ }
+
/** lookup a symbol
*/
public Symbol lookup(Name name) {
@@ -267,6 +292,11 @@ public class Scope {
*/
public SymbolIterator iterator() { return new MySymbols(); }
+ public SymbolIterator iterator(boolean unload) {
+ SymbolIterator iterator = iterator();
+ return unload ? new UnloadIterator(iterator) : iterator;
+ }
+
class MySymbols extends SymbolIterator {
private int index;