modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java - Hastables fuer greater und smaller eingefuehrt - ? extends/super a <. a = -1 hinzugefuegt
This commit is contained in:
parent
eb43a616e2
commit
fa42a69374
@ -827,7 +827,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Set<UnifyPair> compRes = fstElemRes.stream().filter(x -> vars_a.contains(((PlaceholderType)x.getLhsType()))).collect(Collectors.toCollection(HashSet::new));
|
Set<UnifyPair> compRes = fstElemRes.stream().filter(x -> vars_a.contains(((PlaceholderType)x.getLhsType()))).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
|
||||||
//Alle Variablen bestimmen die nicht hinzugefügt wurden in a_last
|
//Alle Variablen bestimmen die nicht hinzugefügt wurden in a_last
|
||||||
System.out.println(a_last);
|
//System.out.println(a_last);
|
||||||
a_last.forEach(x -> {writeLog("a_last_elem:" + x + " basepair: " + x.getBasePair());});
|
a_last.forEach(x -> {writeLog("a_last_elem:" + x + " basepair: " + x.getBasePair());});
|
||||||
List<PlaceholderType> varsLast_a =
|
List<PlaceholderType> varsLast_a =
|
||||||
a_last.stream().filter(x -> ((x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
a_last.stream().filter(x -> ((x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
||||||
@ -900,7 +900,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Iterator<Set<UnifyPair>> nextSetasListIt = new ArrayList<Set<UnifyPair>>(nextSetasList).iterator();
|
Iterator<Set<UnifyPair>> nextSetasListIt = new ArrayList<Set<UnifyPair>>(nextSetasList).iterator();
|
||||||
if (variance == 1) {
|
if (variance == 1) {
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
writeLog("a: " + a.toString());
|
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
|
||||||
while (nextSetasListIt.hasNext()) {
|
while (nextSetasListIt.hasNext()) {
|
||||||
Set<UnifyPair> a_next = nextSetasListIt.next();
|
Set<UnifyPair> a_next = nextSetasListIt.next();
|
||||||
if (a.equals(a_next) ||
|
if (a.equals(a_next) ||
|
||||||
@ -916,7 +916,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
else { if (variance == -1) {
|
else { if (variance == -1) {
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
writeLog("a: " + a.toString());
|
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
|
||||||
while (nextSetasListIt.hasNext()) {
|
while (nextSetasListIt.hasNext()) {
|
||||||
Set<UnifyPair> a_next = nextSetasListIt.next();
|
Set<UnifyPair> a_next = nextSetasListIt.next();
|
||||||
if (a.equals(a_next) ||
|
if (a.equals(a_next) ||
|
||||||
@ -931,8 +931,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (variance == 0) {
|
else if (variance == 0) {
|
||||||
|
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
writeLog("a: " + rekTiefe + " variance: " + variance + a.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* auskommentiert um alle Max und min Betrachtung auszuschalten ENDE */
|
/* auskommentiert um alle Max und min Betrachtung auszuschalten ENDE */
|
||||||
|
@ -53,6 +53,16 @@ implements IFiniteClosure {
|
|||||||
*/
|
*/
|
||||||
private Set<UnifyPair> pairs;
|
private Set<UnifyPair> pairs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hastable fuer die greater-Werte, damit sie nicht doppelt berechnet werden muessen
|
||||||
|
*/
|
||||||
|
Hashtable<hashKeyType, Set<UnifyType>> greaterHash = new Hashtable<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hastable fuer die smaller-Werte, damit sie nicht doppelt berechnet werden muessen
|
||||||
|
*/
|
||||||
|
Hashtable<hashKeyType, Set<UnifyType>> smallerHash = new Hashtable<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance using the inheritance tree defined in the pairs.
|
* Creates a new instance using the inheritance tree defined in the pairs.
|
||||||
*/
|
*/
|
||||||
@ -106,12 +116,29 @@ implements IFiniteClosure {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<UnifyType> smaller(UnifyType type, Set<UnifyType> fBounded) {
|
public Set<UnifyType> smaller(UnifyType type, Set<UnifyType> fBounded) {
|
||||||
|
|
||||||
|
Set<UnifyType> ret;
|
||||||
|
if ((ret = smallerHash.get(new hashKeyType(type))) != null) {
|
||||||
|
//System.out.println(greaterHash);
|
||||||
|
return new HashSet<>(ret);
|
||||||
|
}
|
||||||
|
|
||||||
if(type instanceof FunNType)
|
if(type instanceof FunNType)
|
||||||
return computeSmallerFunN((FunNType) type, fBounded);
|
return computeSmallerFunN((FunNType) type, fBounded);
|
||||||
|
|
||||||
Set<Pair<UnifyType,Set<UnifyType>>> ts = new HashSet<>();
|
Set<Pair<UnifyType,Set<UnifyType>>> ts = new HashSet<>();
|
||||||
ts.add(new Pair<>(type, fBounded));
|
ts.add(new Pair<>(type, fBounded));
|
||||||
return computeSmaller(ts);
|
Set<UnifyType> result = computeSmaller(ts);
|
||||||
|
smallerHash.put(new hashKeyType(type), result);
|
||||||
|
/*
|
||||||
|
try {
|
||||||
|
logFile.write("\ntype: " + type + "\nret: " + ret + "\nresult: " + result);//"smallerHash: " + greaterHash.toString());
|
||||||
|
logFile.flush();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.err.println("no LogFile");
|
||||||
|
}*/
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -205,6 +232,13 @@ implements IFiniteClosure {
|
|||||||
//Eingefuegt PL 2018-05-24 F-Bounded Problematik
|
//Eingefuegt PL 2018-05-24 F-Bounded Problematik
|
||||||
public Set<UnifyType> greater(UnifyType type, Set<UnifyType> fBounded) {
|
public Set<UnifyType> greater(UnifyType type, Set<UnifyType> fBounded) {
|
||||||
|
|
||||||
|
Set<UnifyType> ret;
|
||||||
|
if ((ret = greaterHash.get(new hashKeyType(type))) != null) {
|
||||||
|
//System.out.println(greaterHash);
|
||||||
|
return new HashSet<>(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(type instanceof FunNType) {
|
if(type instanceof FunNType) {
|
||||||
return computeGreaterFunN((FunNType) type, fBounded);
|
return computeGreaterFunN((FunNType) type, fBounded);
|
||||||
}
|
}
|
||||||
@ -300,6 +334,16 @@ implements IFiniteClosure {
|
|||||||
//System.out.println("");
|
//System.out.println("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
greaterHash.put(new hashKeyType(type), result);
|
||||||
|
/*
|
||||||
|
try {
|
||||||
|
logFile.write("\ntype: " + type + "\nret: " + ret + "\nresult: " + result);//"greaterHash: " + greaterHash.toString());
|
||||||
|
logFile.flush();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.err.println("no LogFile");
|
||||||
|
}*/
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,9 +678,16 @@ implements IFiniteClosure {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((right instanceof PlaceholderType) && (left instanceof WildcardType)) {
|
if (right instanceof PlaceholderType) {//&& (left instanceof WildcardType)) {PL geloescht 2019-01-15 analog zu oben
|
||||||
|
if ((left instanceof WildcardType) //PL eingefuegt 2019-01-15 analog zu oben
|
||||||
|
&& ((ex = ((WildcardType)left).wildcardedType) instanceof PlaceholderType)
|
||||||
|
&& ((PlaceholderType)right).getName().equals(((PlaceholderType)ex).getName())) {// ? extends a <. a oder ? super a <. a
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
UnifyPair up = new UnifyPair(left, right, pairop);
|
UnifyPair up = new UnifyPair(left, right, pairop);
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask();
|
TypeUnifyTask unifyTask = new TypeUnifyTask();
|
||||||
HashSet<UnifyPair> hs = new HashSet<>();
|
HashSet<UnifyPair> hs = new HashSet<>();
|
||||||
|
Loading…
Reference in New Issue
Block a user