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

modified:   src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java
variance von Pairs geloescht.
This commit is contained in:
pl@gohorb.ba-horb.de 2020-02-06 15:27:51 +01:00
parent a5662cdd9a
commit 23384f413d
2 changed files with 2 additions and 31 deletions

View File

@ -308,8 +308,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
nOfUnify++; nOfUnify++;
writeLog(nOfUnify.toString() + " Unifikation: " + eq.toString()); writeLog(nOfUnify.toString() + " Unifikation: " + eq.toString());
writeLog(nOfUnify.toString() + " Oderconstraints: " + oderConstraints.toString()); writeLog(nOfUnify.toString() + " Oderconstraints: " + oderConstraints.toString());
//eq = eq.stream().map(x -> {x.setVariance((byte)-1); return x;}).collect(Collectors.toCollection(HashSet::new));
/* /*
* Variancen auf alle Gleichungen vererben * Variancen auf alle Gleichungen vererben
*/ */
@ -2033,7 +2032,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
protected Set<Set<UnifyPair>> unifyCase1(UnifyPair pair, IFiniteClosure fc) { protected Set<Set<UnifyPair>> unifyCase1(UnifyPair pair, IFiniteClosure fc) {
PlaceholderType a = (PlaceholderType)pair.getLhsType(); PlaceholderType a = (PlaceholderType)pair.getLhsType();
UnifyType thetaPrime = pair.getRhsType(); UnifyType thetaPrime = pair.getRhsType();
byte variance = pair.getVariance();
Set<Set<UnifyPair>> result = new HashSet<>(); Set<Set<UnifyPair>> result = new HashSet<>();
@ -2158,7 +2156,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
} }
resultPrime.addAll(substitutionSet); resultPrime.addAll(substitutionSet);
//writeLog("Substitution: " + substitutionSet.toString()); //writeLog("Substitution: " + substitutionSet.toString());
resultPrime = resultPrime.stream().map(x -> { x.setVariance(variance); return x;}).collect(Collectors.toCollection(HashSet::new));
result.add(resultPrime); result.add(resultPrime);
//writeLog("Result: " + resultPrime.toString()); //writeLog("Result: " + resultPrime.toString());
//writeLog("MAX: " + oup.max(resultPrime.iterator()).toString()); //writeLog("MAX: " + oup.max(resultPrime.iterator()).toString());
@ -2177,7 +2174,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
private Set<Set<UnifyPair>> unifyCase2(UnifyPair pair, IFiniteClosure fc) { private Set<Set<UnifyPair>> unifyCase2(UnifyPair pair, IFiniteClosure fc) {
PlaceholderType a = (PlaceholderType) pair.getLhsType(); PlaceholderType a = (PlaceholderType) pair.getLhsType();
ExtendsType extThetaPrime = (ExtendsType) pair.getRhsType(); ExtendsType extThetaPrime = (ExtendsType) pair.getRhsType();
byte variance = pair.getVariance();
Set<Set<UnifyPair>> result = new HashSet<>(); Set<Set<UnifyPair>> result = new HashSet<>();
UnifyType aPrime = PlaceholderType.freshPlaceholder(); UnifyType aPrime = PlaceholderType.freshPlaceholder();
@ -2192,7 +2188,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
resultPrime = new HashSet<>(); resultPrime = new HashSet<>();
resultPrime.add(new UnifyPair(a, extAPrime, PairOperator.EQUALSDOT, pair.getSubstitution(), pair)); resultPrime.add(new UnifyPair(a, extAPrime, PairOperator.EQUALSDOT, pair.getSubstitution(), pair));
resultPrime.add(new UnifyPair(aPrime, thetaPrime, PairOperator.SMALLERDOT, pair.getSubstitution(), pair)); resultPrime.add(new UnifyPair(aPrime, thetaPrime, PairOperator.SMALLERDOT, pair.getSubstitution(), pair));
resultPrime = resultPrime.stream().map(x -> { x.setVariance(variance); return x;}).collect(Collectors.toCollection(HashSet::new));
result.add(resultPrime); result.add(resultPrime);
//writeLog("Result: " + resultPrime.toString()); //writeLog("Result: " + resultPrime.toString());
return result; return result;
@ -2205,7 +2200,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
PlaceholderType a = (PlaceholderType) pair.getLhsType(); PlaceholderType a = (PlaceholderType) pair.getLhsType();
a.reversVariance(); a.reversVariance();
SuperType subThetaPrime = (SuperType) pair.getRhsType(); SuperType subThetaPrime = (SuperType) pair.getRhsType();
byte variance = pair.getVariance();
Set<Set<UnifyPair>> result = new HashSet<>(); Set<Set<UnifyPair>> result = new HashSet<>();
UnifyType aPrime = PlaceholderType.freshPlaceholder(); UnifyType aPrime = PlaceholderType.freshPlaceholder();
@ -2221,7 +2215,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
resultPrime = new HashSet<>(); resultPrime = new HashSet<>();
resultPrime.add(new UnifyPair(a, supAPrime, PairOperator.EQUALSDOT, pair.getSubstitution(), pair)); resultPrime.add(new UnifyPair(a, supAPrime, PairOperator.EQUALSDOT, pair.getSubstitution(), pair));
resultPrime.add(new UnifyPair(thetaPrime, aPrime, PairOperator.SMALLERDOT, pair.getSubstitution(), pair)); resultPrime.add(new UnifyPair(thetaPrime, aPrime, PairOperator.SMALLERDOT, pair.getSubstitution(), pair));
resultPrime = resultPrime.stream().map(x -> { x.setVariance(variance); return x;}).collect(Collectors.toCollection(HashSet::new));
result.add(resultPrime); result.add(resultPrime);
//writeLog(resultPrime.toString()); //writeLog(resultPrime.toString());
@ -2234,7 +2227,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
private Set<Set<UnifyPair>> unifyCase5(UnifyPair pair, IFiniteClosure fc) { private Set<Set<UnifyPair>> unifyCase5(UnifyPair pair, IFiniteClosure fc) {
UnifyType theta = pair.getLhsType(); UnifyType theta = pair.getLhsType();
PlaceholderType a = (PlaceholderType) pair.getRhsType(); PlaceholderType a = (PlaceholderType) pair.getRhsType();
byte variance = pair.getVariance();
Set<Set<UnifyPair>> result = new HashSet<>(); Set<Set<UnifyPair>> result = new HashSet<>();
boolean allGen = theta.getTypeParams().size() > 0; boolean allGen = theta.getTypeParams().size() > 0;
@ -2298,7 +2290,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
resultPrime.add(new UnifyPair(a, thetaS, PairOperator.EQUALSDOT, pair.getSubstitution(), pair)); resultPrime.add(new UnifyPair(a, thetaS, PairOperator.EQUALSDOT, pair.getSubstitution(), pair));
else else
resultPrime.add(new UnifyPair(a, thetaS.setTypeParams(new TypeParams(freshTphs)), PairOperator.EQUALSDOT, pair.getSubstitution(), pair)); resultPrime.add(new UnifyPair(a, thetaS.setTypeParams(new TypeParams(freshTphs)), PairOperator.EQUALSDOT, pair.getSubstitution(), pair));
resultPrime = resultPrime.stream().map(x -> { x.setVariance(variance); return x;}).collect(Collectors.toCollection(HashSet::new));
result.add(resultPrime); result.add(resultPrime);
//writeLog("FBOUNDED2: " + pair.getfBounded()); //writeLog("FBOUNDED2: " + pair.getfBounded());
//writeLog("resultPrime Theta < a: " + greater + pair + "THETA: " + theta + "FBOUNDED: " + pair.getfBounded() + " " + resultPrime.toString()); //writeLog("resultPrime Theta < a: " + greater + pair + "THETA: " + theta + "FBOUNDED: " + pair.getfBounded() + " " + resultPrime.toString());
@ -2313,8 +2304,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
private Set<Set<UnifyPair>> unifyCase8(UnifyPair pair, IFiniteClosure fc) { private Set<Set<UnifyPair>> unifyCase8(UnifyPair pair, IFiniteClosure fc) {
UnifyType theta = pair.getLhsType(); UnifyType theta = pair.getLhsType();
PlaceholderType a = (PlaceholderType) pair.getRhsType(); PlaceholderType a = (PlaceholderType) pair.getRhsType();
byte variance = pair.getVariance(); Set<Set<UnifyPair>> result = new HashSet<>();
Set<Set<UnifyPair>> result = new HashSet<>();
//for(UnifyType thetaS : fc.grArg(theta)) { //for(UnifyType thetaS : fc.grArg(theta)) {
Set<UnifyPair> resultPrime = new HashSet<>(); Set<UnifyPair> resultPrime = new HashSet<>();
resultPrime.add(new UnifyPair(a, theta, PairOperator.EQUALSDOT, pair.getSubstitution(), pair)); resultPrime.add(new UnifyPair(a, theta, PairOperator.EQUALSDOT, pair.getSubstitution(), pair));
@ -2334,7 +2324,6 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
resultPrime = new HashSet<>(); resultPrime = new HashSet<>();
resultPrime.add(new UnifyPair(a, new SuperType(freshTph), PairOperator.EQUALSDOT, pair.getSubstitution(), pair)); resultPrime.add(new UnifyPair(a, new SuperType(freshTph), PairOperator.EQUALSDOT, pair.getSubstitution(), pair));
resultPrime.add(new UnifyPair(freshTph, theta, PairOperator.SMALLERDOT, pair.getSubstitution(), pair)); resultPrime.add(new UnifyPair(freshTph, theta, PairOperator.SMALLERDOT, pair.getSubstitution(), pair));
resultPrime = resultPrime.stream().map(x -> { x.setVariance(variance); return x;}).collect(Collectors.toCollection(HashSet::new));
result.add(resultPrime); result.add(resultPrime);
//writeLog(resultPrime.toString()); //writeLog(resultPrime.toString());
//} //}

View File

@ -28,15 +28,6 @@ public class UnifyPair {
* The operator that determines the relation between the left and right hand side type. * The operator that determines the relation between the left and right hand side type.
*/ */
private PairOperator pairOp; private PairOperator pairOp;
/** wieder loesecn wird nicht mehr benoetigt PL 2018-03-31
* variance shows the variance of the pair
* -1: contravariant
* 1 covariant
* 0 invariant
* PL 2018-03-21
*/
private byte variance = 0;
private boolean undefinedPair = false; private boolean undefinedPair = false;
@ -83,7 +74,6 @@ public class UnifyPair {
pairOp = op; pairOp = op;
substitution = uni; substitution = uni;
basePair = base; basePair = base;
this.variance = variance;
// Caching hashcode // Caching hashcode
@ -125,14 +115,6 @@ public class UnifyPair {
substitution.addAll(sup); substitution.addAll(sup);
} }
public byte getVariance() {
return variance;
}
public void setVariance(byte v) {
variance = v;
}
public void setUndefinedPair() { public void setUndefinedPair() {
undefinedPair = true; undefinedPair = true;
} }