Merge branch 'unify-test' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into unify-test
Merge
This commit is contained in:
commit
bd98bed5ca
@ -157,6 +157,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
if(!undefinedPairs.isEmpty()) {
|
||||
writeLog("UndefinedPairs; " + undefinedPairs);
|
||||
Set<Set<UnifyPair>> error = new HashSet<>();
|
||||
undefinedPairs = undefinedPairs.stream().map(x -> { x.setUndefinedPair(); return x;}).collect(Collectors.toCollection(HashSet::new));
|
||||
error.add(undefinedPairs);
|
||||
return error;
|
||||
}
|
||||
@ -296,7 +297,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
/*
|
||||
* Step 7: Filter empty sets;
|
||||
*/
|
||||
eqPrimePrimeSet = eqPrimePrimeSet.stream().filter(x -> isSolvedForm(x)).collect(Collectors.toCollection(HashSet::new));
|
||||
eqPrimePrimeSet = eqPrimePrimeSet.stream().filter(x -> isSolvedForm(x) || this.isUndefinedPairSet(x)).collect(Collectors.toCollection(HashSet::new));
|
||||
if (!eqPrimePrimeSet.isEmpty())
|
||||
writeLog("Result " + eqPrimePrimeSet.toString());
|
||||
return eqPrimePrimeSet;
|
||||
@ -362,7 +363,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
else {
|
||||
result.addAll(computeCartesianRecursive(elems, remainingSets, eq, fc, parallel));
|
||||
}
|
||||
if (!result.isEmpty()) {
|
||||
|
||||
if (!result.isEmpty() && !isUndefinedPairSetSet(result)) {
|
||||
if (variance == 1) {
|
||||
if (a.iterator().next().getLhsType().getName().equals("WL"))
|
||||
System.out.print("");
|
||||
@ -391,17 +393,30 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result)) {
|
||||
return result;
|
||||
}
|
||||
//else result.stream().filter(y -> !isUndefinedPairSet(y));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected boolean isUndefinedPairSet(Set<Set<UnifyPair>> s) {
|
||||
boolean res = true;
|
||||
if (s.size() ==1) {
|
||||
s.iterator().next().stream().forEach(x -> { res = res && x.isUndefinedPair(); return; });
|
||||
return res;
|
||||
}
|
||||
|
||||
protected boolean isUndefinedPairSet(Set<UnifyPair> s) {
|
||||
|
||||
Optional<Boolean> res = s.stream().map(x -> x.isUndefinedPair()).reduce((x,y)-> (x == y));
|
||||
if (res.isPresent()) { return res.get(); }
|
||||
else { return false; }
|
||||
}
|
||||
|
||||
protected boolean isUndefinedPairSetSet(Set<Set<UnifyPair>> s) {
|
||||
if (s.size() ==1) {
|
||||
Optional<Boolean> res = s.stream().map(x -> isUndefinedPairSet(x)).reduce((x,y)-> (x == y));
|
||||
if (res.isPresent()) { return res.get(); }
|
||||
else { return false; }
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
/**
|
||||
* Checks whether a set of pairs is in solved form.
|
||||
|
@ -63,7 +63,7 @@ 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());
|
||||
return new UnifyPair(this.apply(p.getLhsType()), this.apply(p.getRhsType()), p.getPairOp(), this, p);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -29,6 +29,18 @@ public class UnifyPair {
|
||||
private byte variance = 0;
|
||||
|
||||
private boolean undefinedPair = false;
|
||||
|
||||
/**
|
||||
* Unifier that generated this pair
|
||||
* PL 2018-03-15
|
||||
*/
|
||||
private Unifier unifier;
|
||||
|
||||
/**
|
||||
* Base on which the the unifier is applied
|
||||
* PL 2018-03-15
|
||||
*/
|
||||
private UnifyPair basePair;
|
||||
|
||||
private final int hashCode;
|
||||
|
||||
@ -47,6 +59,18 @@ public class UnifyPair {
|
||||
hashCode = 17 + 31 * lhs.hashCode() + 31 * rhs.hashCode() + 31 * pairOp.hashCode();
|
||||
}
|
||||
|
||||
public UnifyPair(UnifyType lhs, UnifyType rhs, PairOperator op, Unifier uni, UnifyPair base) {
|
||||
this.lhs = lhs;
|
||||
this.rhs = rhs;
|
||||
pairOp = op;
|
||||
unifier = uni;
|
||||
basePair = base;
|
||||
|
||||
|
||||
// Caching hashcode
|
||||
hashCode = 17 + 31 * lhs.hashCode() + 31 * rhs.hashCode() + 31 * pairOp.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type on the left hand side of the pair.
|
||||
*/
|
||||
@ -76,6 +100,10 @@ public class UnifyPair {
|
||||
variance = v;
|
||||
}
|
||||
|
||||
public void setUndefinedPair() {
|
||||
undefinedPair = true;
|
||||
}
|
||||
|
||||
public boolean isUndefinedPair() {
|
||||
return undefinedPair;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user