modified: ../../src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
modified: ../../src/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java Minimum funktion soweit
This commit is contained in:
parent
ccc16fd22b
commit
9862df9e63
@ -312,13 +312,18 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
ArrayList<Set<UnifyPair>> nextSetasList = new ArrayList<>(nextSet);
|
||||
Set<Set<UnifyPair>> result = new HashSet<>();
|
||||
int i = 0;
|
||||
Set<UnifyPair> a_next = oup.min(nextSetasList.iterator());
|
||||
Set<UnifyPair> a_next;
|
||||
if (nextSetasList.size()>1)
|
||||
a_next = oup.min(nextSetasList.iterator());
|
||||
else a_next = nextSetasList.iterator().next();
|
||||
while (nextSetasList.size() != 0) {
|
||||
Set<UnifyPair> a = a_next;
|
||||
//writeLog("nextSet: " + nextSetasList.toString()+ "\n");
|
||||
nextSetasList.remove(a);
|
||||
if (nextSetasList.size() > 0)
|
||||
a_next = oup.min(nextSetasList.iterator());
|
||||
if (nextSetasList.size()>1)
|
||||
a_next = oup.min(nextSetasList.iterator());
|
||||
else a_next = nextSetasList.iterator().next();
|
||||
//PL 2018-03-01
|
||||
//TODO: 1. Maximum und Minimum unterscheiden
|
||||
//TODO: 2. compare noch für alle Elmemente die nicht X =. ty sind erweitern
|
||||
|
@ -26,8 +26,16 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
||||
public OrderingUnifyPair(IFiniteClosure fc) {
|
||||
this.fc = fc;
|
||||
}
|
||||
|
||||
public int compare (UnifyPair left, UnifyPair right) {
|
||||
public int compareEq (UnifyPair left, UnifyPair right) {
|
||||
if (right.getRhsType() instanceof ExtendsType || right.getRhsType() instanceof SuperType) {
|
||||
return fc.compare(left.getRhsType(), right.getRhsType(), PairOperator.SMALLERDOTWC);
|
||||
}
|
||||
else {
|
||||
return fc.compare(left.getRhsType(), right.getRhsType(), PairOperator.SMALLERDOT);
|
||||
}
|
||||
}
|
||||
/*
|
||||
public int compareEq (UnifyPair left, UnifyPair right) {
|
||||
if (left == null || right == null)
|
||||
System.out.println("Fehler");
|
||||
if (left.getLhsType() instanceof PlaceholderType) {
|
||||
@ -37,6 +45,7 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
||||
return fc.compare(left.getLhsType(), right.getLhsType(), left.getPairOp());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public Pair<Integer,Set<UnifyPair>> compare (UnifyType left, UnifyType right) {
|
||||
UnifyPair up = new UnifyPair(left, right, PairOperator.SMALLERDOT);
|
||||
@ -108,7 +117,7 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
||||
BinaryOperator<HashMap<UnifyType,UnifyPair>> combiner = (x,y) -> { x.putAll(y); return x;};
|
||||
HashMap<UnifyType,UnifyPair> hm = rseq.reduce(new HashMap<UnifyType,UnifyPair>(), (x, y)-> { x.put(y.getLhsType(),y); return x; }, combiner);
|
||||
lseq = lseq.filter(x -> !(hm.get(x.getLhsType()) == null));
|
||||
Optional<Integer> si = lseq.map(x -> compare(x, hm.get(x.getLhsType()))).reduce((x,y)-> { if (x == y) return x; else return 0; } );
|
||||
Optional<Integer> si = lseq.map(x -> compareEq(x, hm.get(x.getLhsType()))).reduce((x,y)-> { if (x == y) return x; else return 0; } );
|
||||
if (!si.isPresent()) return 0;
|
||||
else return si.get();
|
||||
}
|
||||
@ -132,13 +141,13 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
||||
if (leftlewc.iterator().next().getLhsType() instanceof PlaceholderType) {
|
||||
hm = rsleuni.stream().reduce(new HashMap<UnifyType,UnifyPair>(), (x, y)-> { x.put(y.getLhsType(),y); return x; }, combiner);
|
||||
Stream<UnifyPair> lslewcstr = lsleuni.stream().filter(x -> !(hm.get(x.getLhsType()) == null));
|
||||
si = lslewcstr.map(x -> compare(x, hm.get(x.getLhsType()))).reduce((x,y)-> { if (x == y) return x; else return 0; } );
|
||||
si = lslewcstr.map(x -> fc.compare(x.getRhsType(), hm.get(x.getLhsType()).getRhsType(), PairOperator.SMALLERDOTWC)).reduce((x,y)-> { if (x == y) return x; else return 0; } );
|
||||
}
|
||||
//4. Fall
|
||||
else {
|
||||
hm = rsleuni.stream().reduce(new HashMap<UnifyType,UnifyPair>(), (x, y)-> { x.put(y.getRhsType(),y); return x; }, combiner);
|
||||
Stream<UnifyPair> lslewcstr = lsleuni.stream().filter(x -> !(hm.get(x.getRhsType()) == null));
|
||||
si = lslewcstr.map(x -> compare(x, hm.get(x.getRhsType()))).reduce((x,y)-> { if (x == y) return x; else return 0; } );
|
||||
si = lslewcstr.map(x -> fc.compare(x.getLhsType(), hm.get(x.getRhsType()).getLhsType(), PairOperator.SMALLERDOTWC)).reduce((x,y)-> { if (x == y) return x; else return 0; } );
|
||||
}
|
||||
if (!si.isPresent()) return 0;
|
||||
else return si.get();
|
||||
|
Loading…
Reference in New Issue
Block a user