summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-07-26 10:33:54 +0000
committerpaltherr <paltherr@epfl.ch>2003-07-26 10:33:54 +0000
commite39c6c0e624f3a4b20ddbc5796b70e2225dfaca5 (patch)
tree1c2dda29c9d95f9251e612cbc1903bc27fdfed61 /sources
parentd73289451bd3e7a357f1147f69c49fc2644c376e (diff)
downloadscala-e39c6c0e624f3a4b20ddbc5796b70e2225dfaca5.tar.gz
scala-e39c6c0e624f3a4b20ddbc5796b70e2225dfaca5.tar.bz2
scala-e39c6c0e624f3a4b20ddbc5796b70e2225dfaca5.zip
- Added methods getSymbols and getTypes
- Added some assertions in insertion methods - Added case ThisType in method apply - Removed TODO PolyType in method apply
Diffstat (limited to 'sources')
-rw-r--r--sources/scalac/symtab/SymbolSubstTypeMap.java35
1 files changed, 34 insertions, 1 deletions
diff --git a/sources/scalac/symtab/SymbolSubstTypeMap.java b/sources/scalac/symtab/SymbolSubstTypeMap.java
index f99cbbb1b0..b18c5e67cd 100644
--- a/sources/scalac/symtab/SymbolSubstTypeMap.java
+++ b/sources/scalac/symtab/SymbolSubstTypeMap.java
@@ -13,6 +13,8 @@ import java.util.Map;
import java.util.HashMap;
import java.util.Set;
+import ch.epfl.lamp.util.ForwardingMap;
+
import scalac.util.Debug;
/** A type map that substitues symbols and types for symbols. */
@@ -56,11 +58,13 @@ public class SymbolSubstTypeMap extends Type.Map {
}
public void insertSymbol(Symbol key, Symbol value) {
+ assert !symbols.containsKey(key) : Debug.show(key);
assert !types.containsKey(key) : Debug.show(key);
symbols.put(key, value);
}
public void insertSymbol(Map map) {
+ assert checkLeftContainsNoKeyFromRight(symbols, map);
assert checkLeftContainsNoKeyFromRight(types, map);
symbols.putAll(map);
}
@@ -81,6 +85,18 @@ public class SymbolSubstTypeMap extends Type.Map {
return (Symbol)symbols.get(key);
}
+ public Map getSymbols() {
+ return new ForwardingMap(symbols) {
+ public Object put(Object key, Object value) {
+ insertSymbol((Symbol)key, (Symbol)value);
+ return null;
+ }
+ public void putAll(Map map) {
+ insertSymbol(map);
+ }
+ };
+ }
+
//########################################################################
// Public Methods - Inserting and removing symbol to type substitutions
@@ -91,11 +107,13 @@ public class SymbolSubstTypeMap extends Type.Map {
public void insertType(Symbol key, Type value) {
assert !symbols.containsKey(key) : Debug.show(key);
+ assert !types.containsKey(key) : Debug.show(key);
types.put(key, value);
}
public void insertType(Map map) {
assert checkLeftContainsNoKeyFromRight(symbols, map);
+ assert checkLeftContainsNoKeyFromRight(types, map);
types.putAll(map);
}
@@ -115,6 +133,18 @@ public class SymbolSubstTypeMap extends Type.Map {
return (Type)types.get(key);
}
+ public Map getTypes() {
+ return new ForwardingMap(types) {
+ public Object put(Object key, Object value) {
+ insertType((Symbol)key, (Type)value);
+ return null;
+ }
+ public void putAll(Map map) {
+ insertType(map);
+ }
+ };
+ }
+
//########################################################################
// Public Methods - Applying the substitutions
@@ -139,7 +169,10 @@ public class SymbolSubstTypeMap extends Type.Map {
return Type.singleType(apply(prefix), (Symbol)value);
}
- // TODO what should we do with PolyTypes?
+ case ThisType(Symbol symbol):
+ Object value = symbols.get(symbol);
+ if (value == null) return super.map(type);
+ return Type.ThisType((Symbol)value);
default:
return super.map(type);