summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschinz <schinz@epfl.ch>2003-06-27 14:58:46 +0000
committerschinz <schinz@epfl.ch>2003-06-27 14:58:46 +0000
commitf03a35b6c3c57bc7084fc3d329dd1c6ba04e23d8 (patch)
tree3d7663667850e23e731ffeff00e7d913e064f47f
parentecd251a20eab9b60e092982dbf0951d354d03866 (diff)
downloadscala-f03a35b6c3c57bc7084fc3d329dd1c6ba04e23d8.tar.gz
scala-f03a35b6c3c57bc7084fc3d329dd1c6ba04e23d8.tar.bz2
scala-f03a35b6c3c57bc7084fc3d329dd1c6ba04e23d8.zip
- removed thisTypeMap, which is superseded by u...
- removed thisTypeMap, which is superseded by userTypeMap, added a way - to set a type map.
-rw-r--r--sources/scalac/ast/SubstTransformer.java38
1 files changed, 21 insertions, 17 deletions
diff --git a/sources/scalac/ast/SubstTransformer.java b/sources/scalac/ast/SubstTransformer.java
index e63a542d4c..cb64187c2b 100644
--- a/sources/scalac/ast/SubstTransformer.java
+++ b/sources/scalac/ast/SubstTransformer.java
@@ -18,6 +18,9 @@ import Tree.*;
import java.util.*;
+// TODO remove stacks of substitutions, since they never grow to more
+// than one element.
+
/**
* A transformer which performs symbol or type substitutions.
*
@@ -35,8 +38,7 @@ public class SubstTransformer extends Transformer {
protected LinkedList/*<Symbol[]>*/ tmfStack = new LinkedList();
protected LinkedList/*<Symbol[]>*/ tmaStack = new LinkedList();
- protected LinkedList/*<Symbol>*/ thisTypeFrom = new LinkedList();
- protected LinkedList/*<Symbol>*/ thisTypeTo = new LinkedList();
+ protected Type.Map userTypeMap = null;
final protected Type.Map typeMap =
new Type.Map() {
@@ -57,6 +59,16 @@ public class SubstTransformer extends Transformer {
return true;
}
+ public void setTypeMap(Type.Map map) {
+ assert userTypeMap == null;
+ userTypeMap = map;
+ }
+
+ public void clearTypeMap() {
+ assert userTypeMap != null;
+ userTypeMap = null;
+ }
+
protected void updateSymbolSubst() {
symbolMap.clear();
Iterator ssIt = ssStack.iterator();
@@ -67,11 +79,13 @@ public class SubstTransformer extends Transformer {
}
public void pushSymbolSubst(Map map) {
+ assert ssStack.size() == 0;
ssStack.addLast(map);
updateSymbolSubst();
}
public void popSymbolSubst() {
+ assert ssStack.size() == 1;
ssStack.removeLast();
updateSymbolSubst();
}
@@ -111,6 +125,8 @@ public class SubstTransformer extends Transformer {
}
public void pushTypeSubst(Symbol[] from, Type[] to) {
+ assert tmfStack.size() == 0;
+
assert from.length == to.length;
tmfStack.addLast(from);
tmaStack.addLast(to);
@@ -118,6 +134,8 @@ public class SubstTransformer extends Transformer {
}
public void popTypeSubst() {
+ assert tmfStack.size() == 1;
+
tmfStack.removeLast();
tmaStack.removeLast();
updateTypeSubst();
@@ -129,16 +147,6 @@ public class SubstTransformer extends Transformer {
updateTypeSubst();
}
- public void pushThisTypeSubst(Symbol from, Symbol to) {
- thisTypeFrom.addLast(from);
- thisTypeTo.addLast(to);
- }
-
- public void popThisTypeSubst() {
- thisTypeFrom.removeLast();
- thisTypeTo.removeLast();
- }
-
public Tree transform(Tree oldTree) {
Tree newTree = super.transform(oldTree);
if (oldTree.hasSymbol()) {
@@ -228,11 +236,7 @@ public class SubstTransformer extends Transformer {
//////////////////////////////////////////////////////////////////////
protected Type transformType(Type tp) {
- assert thisTypeFrom.size() == 1;
- Symbol thisFromSym = (Symbol)thisTypeFrom.getLast();
- Type thisToType = ((Symbol)thisTypeTo.getLast()).thisType();
-
- Type tp1 = tp.substThis(thisFromSym, thisToType);
+ Type tp1 = (userTypeMap != null ? userTypeMap.apply(tp) : tp);
Type tp2 = smApplier.apply(tp1);
Type tp3 = typeMap.apply(tp2);
return tp3;