modified: src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java

? ext theta bei smaller eingefuegt

	modified:   src/de/dhbwstuttgart/typeinference/unify/model/Unifier.java
basiPair und Subsitution nur noch gefuegt, wen wirk etwas eingesetzt wurde

	modified:   src/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java
unifier umbenannt in substitution
getBasePair und getSubsitutuon eingefuegt
This commit is contained in:
Martin Plümicke 2018-04-01 17:07:58 +02:00
parent 5680f913ef
commit 117106a7b3
3 changed files with 28 additions and 7 deletions

View File

@ -315,7 +315,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet);
try {
//List<Set<UnifyPair>>
nextSetasList = oup.sortedCopy(nextSet);//new ArrayList<>(nextSet);
//nextSetasList = oup.sortedCopy(nextSet);//new ArrayList<>(nextSet);
}
catch (java.lang.IllegalArgumentException e) {
System.out.print("");
@ -815,6 +815,16 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
//List<UnifyType> freshTphs = new ArrayList<>(); PL 18-02-06 in die For-Schleife verschoben
for (UnifyType tq : thetaQs) {
Set<UnifyType> smaller = fc.smaller(unifier.apply(tq));
//eingefuegt PL 2018-03-29 Anfang ? ext. theta hinzufuegen
Set<UnifyType> smaller_ext = smaller.stream()
.map(x -> {
BinaryOperator<HashMap<PlaceholderType,PlaceholderType>> combiner = (aa,b) -> { aa.putAll(b); return aa;};
HashMap<PlaceholderType,PlaceholderType> hm = x.getInvolvedPlaceholderTypes().stream()
.reduce(new HashMap<PlaceholderType,PlaceholderType>(),
(aa, b)-> { aa.put(b,PlaceholderType.freshPlaceholder()); return aa; }, combiner);
return new ExtendsType (x.accept(new freshPlaceholder(), hm));}).collect(Collectors.toCollection(HashSet::new));
smaller.addAll(smaller_ext);
//eingefuegt PL 2018-03-29 Ende ? ext. theta hinzufuegen
for(UnifyType theta : smaller) {
List<UnifyType> freshTphs = new ArrayList<>();
Set<UnifyPair> resultPrime = new HashSet<>();

View File

@ -63,7 +63,12 @@ public class Unifier implements Function<UnifyType, UnifyType>, Iterable<Entry<P
* @return A new pair where the left and right-hand side are applied
*/
public UnifyPair apply(UnifyPair p) {
return new UnifyPair(this.apply(p.getLhsType()), this.apply(p.getRhsType()), p.getPairOp(), this, p);
UnifyType newLhs = this.apply(p.getLhsType());
UnifyType newRhs = this.apply(p.getRhsType());
if (!(p.getLhsType().equals(newLhs)) || !(p.getRhsType().equals(newRhs))) {//Die Anwedung von this hat was veraendert PL 2018-04-01
return new UnifyPair(newLhs, newRhs, p.getPairOp(), this, p);
}
return new UnifyPair(newLhs, newRhs, p.getPairOp(), p.getSubstitution(), p.getBasePair());
}
/**

View File

@ -26,7 +26,7 @@ public class UnifyPair {
*/
private PairOperator pairOp;
/**
/** wieder loesecn wird nicht mehr benoetigt PL 2018-03-31
* variance shows the variance of the pair
* -1: contravariant
* 1 covariant
@ -38,10 +38,10 @@ public class UnifyPair {
private boolean undefinedPair = false;
/**
* Unifier that generated this pair
* Unifier/substitute that generated this pair
* PL 2018-03-15
*/
private Unifier unifier;
private Unifier substitution;
/**
* Base on which the the unifier is applied
@ -70,7 +70,7 @@ public class UnifyPair {
this.lhs = lhs;
this.rhs = rhs;
pairOp = op;
unifier = uni;
substitution = uni;
basePair = base;
this.variance = variance;
@ -111,7 +111,13 @@ public class UnifyPair {
public void setUndefinedPair() {
undefinedPair = true;
}
public Unifier getSubstitution() {
return substitution;
}
public UnifyPair getBasePair() {
return basePair;
}
public boolean isUndefinedPair() {
return undefinedPair;
}