forked from JavaTX/JavaCompilerCore
modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java Nur log-Ausgaben hinzugefuegt
This commit is contained in:
parent
d0a261f55c
commit
7d514d617c
@ -830,8 +830,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//erstes Element genügt, da vars immer auf die gleichen Elemente zugeordnet werden muessen
|
//erstes Element genügt, da vars immer auf die gleichen Elemente zugeordnet werden muessen
|
||||||
Set<UnifyPair> fstElemResult = result.iterator().next();
|
Set<UnifyPair> fstElemResult = result.iterator().next();
|
||||||
Set<UnifyPair> compResult = fstElemResult.stream().filter(x -> varsLast_a.contains(((PlaceholderType)x.getLhsType()))).collect(Collectors.toCollection(HashSet::new));;
|
Set<UnifyPair> compResult = fstElemResult.stream().filter(x -> varsLast_a.contains(((PlaceholderType)x.getLhsType()))).collect(Collectors.toCollection(HashSet::new));;
|
||||||
|
|
||||||
if (variance == 1) {
|
if (variance == 1) {
|
||||||
|
writeLog("a_last:" + a_last + " a: " + a);
|
||||||
|
writeLog("varsLast_a:" + varsLast_a + " vars_a: " + vars_a);
|
||||||
|
writeLog("compResult:" + compResult + " compRes: " + compRes);
|
||||||
int resOfCompare = oup.compare(compResult, compRes);
|
int resOfCompare = oup.compare(compResult, compRes);
|
||||||
if (resOfCompare == -1) {
|
if (resOfCompare == -1) {
|
||||||
writeLog("Geloescht result: " + result);
|
writeLog("Geloescht result: " + result);
|
||||||
@ -845,6 +847,9 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//result = result;
|
//result = result;
|
||||||
}}}
|
}}}
|
||||||
else { if (variance == -1) {
|
else { if (variance == -1) {
|
||||||
|
writeLog("a_last:" + a_last + " a: " + a);
|
||||||
|
writeLog("varsLast_a:" + varsLast_a + " vars_a: " + vars_a);
|
||||||
|
writeLog("compResult:" + compResult + " compRes: " + compRes);
|
||||||
int resOfCompare = oup.compare(compResult, compRes);
|
int resOfCompare = oup.compare(compResult, compRes);
|
||||||
if (resOfCompare == 1) {
|
if (resOfCompare == 1) {
|
||||||
writeLog("Geloescht result: " + result);
|
writeLog("Geloescht result: " + result);
|
||||||
@ -886,27 +891,33 @@ 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());
|
||||||
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) ||
|
||||||
(oup.compare(a, a_next) == 1)) {
|
(oup.compare(a, a_next) == 1)) {
|
||||||
|
writeLog("Removed: " + a_next.toString());
|
||||||
nextSetasList.remove(a_next);
|
nextSetasList.remove(a_next);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
writeLog("Not Removed: " + a_next.toString());
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { if (variance == -1) {
|
else { if (variance == -1) {
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
|
writeLog("a: " + 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) ||
|
||||||
(oup.compare(a, a_next) == -1)) {
|
(oup.compare(a, a_next) == -1)) {
|
||||||
nextSetasList.remove(0);
|
writeLog("Removed: " + a_next.toString());
|
||||||
|
nextSetasList.remove(a_next); //PL geaendert 2019-01-09
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
|
writeLog("Not Removed: " + a_next.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1670,13 +1681,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//eingefuegt PL 2019-01-03 ANFANG
|
//eingefuegt PL 2019-01-03 ANFANG
|
||||||
fc.setLogTrue();
|
//fc.setLogTrue();
|
||||||
writeLog("FBOUNDED: " + pair.getfBounded());
|
//writeLog("FBOUNDED: " + pair.getfBounded());
|
||||||
writeLog("Pair: " + pair);
|
//writeLog("Pair: " + pair);
|
||||||
Set<UnifyType> greater = fc.greater(theta, pair.getfBounded());
|
Set<UnifyType> greater = fc.greater(theta, pair.getfBounded());
|
||||||
writeLog("GREATER: " + greater + pair + "THETA: " + theta + "FBOUNDED: " + pair.getfBounded() + " ");
|
//writeLog("GREATER: " + greater + pair + "THETA: " + theta + "FBOUNDED: " + pair.getfBounded() + " ");
|
||||||
|
if (a.isWildcardable()) {
|
||||||
/*if (a.isWildcardable()) {
|
|
||||||
Set<UnifyType> greater_ext = greater.stream().filter(x -> !(x instanceof ExtendsType) && !(x instanceof SuperType))
|
Set<UnifyType> greater_ext = greater.stream().filter(x -> !(x instanceof ExtendsType) && !(x instanceof SuperType))
|
||||||
.map(x -> {
|
.map(x -> {
|
||||||
//BinaryOperator<HashMap<PlaceholderType,PlaceholderType>> combiner = (aa,b) -> { aa.putAll(b); return aa;}; //Variablenumbenennung rausgenommen
|
//BinaryOperator<HashMap<PlaceholderType,PlaceholderType>> combiner = (aa,b) -> { aa.putAll(b); return aa;}; //Variablenumbenennung rausgenommen
|
||||||
@ -1688,7 +1698,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
greater.addAll(greater_ext);
|
greater.addAll(greater_ext);
|
||||||
}
|
}
|
||||||
//eingefuegt PL 2019-01-03 ENDE
|
//eingefuegt PL 2019-01-03 ENDE
|
||||||
*/
|
|
||||||
//for(UnifyType thetaS : fc.greater(theta, pair.getfBounded())) {
|
//for(UnifyType thetaS : fc.greater(theta, pair.getfBounded())) {
|
||||||
for(UnifyType thetaS : greater) {
|
for(UnifyType thetaS : greater) {
|
||||||
Set<UnifyPair> resultPrime = new HashSet<>();
|
Set<UnifyPair> resultPrime = new HashSet<>();
|
||||||
@ -1726,7 +1736,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
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));
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,6 +223,7 @@ implements IFiniteClosure {
|
|||||||
// if T <* T' then sigma(T) <* sigma(T')
|
// if T <* T' then sigma(T) <* sigma(T')
|
||||||
Set<Node<UnifyType>> candidates = strInheritanceGraph.get(type.getName());
|
Set<Node<UnifyType>> candidates = strInheritanceGraph.get(type.getName());
|
||||||
|
|
||||||
|
/*
|
||||||
try {
|
try {
|
||||||
if (log) logFile.write(candidates.toString());
|
if (log) logFile.write(candidates.toString());
|
||||||
//log = false;
|
//log = false;
|
||||||
@ -230,6 +231,7 @@ implements IFiniteClosure {
|
|||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
System.err.println("no LogFile");
|
System.err.println("no LogFile");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
for(Node<UnifyType> candidate : candidates) {
|
for(Node<UnifyType> candidate : candidates) {
|
||||||
UnifyType theta1 = candidate.getContent();
|
UnifyType theta1 = candidate.getContent();
|
||||||
@ -240,10 +242,6 @@ implements IFiniteClosure {
|
|||||||
Optional<Unifier> optSigma = match.match(termList);
|
Optional<Unifier> optSigma = match.match(termList);
|
||||||
//PL 18-04-05 Unifier durch Matcher ersetzt ENDE
|
//PL 18-04-05 Unifier durch Matcher ersetzt ENDE
|
||||||
if(!optSigma.isPresent()) {
|
if(!optSigma.isPresent()) {
|
||||||
if ((type.getName().equals("java.util.Vector")) && (type instanceof ReferenceType) &&
|
|
||||||
(((ReferenceType)type).getTypeParams().get(0).getName().equals("java.lang.Integer"))) {
|
|
||||||
System.out.println(type.toString() + candidates);
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Unifier sigma = optSigma.get();
|
Unifier sigma = optSigma.get();
|
||||||
@ -258,6 +256,7 @@ implements IFiniteClosure {
|
|||||||
PairResultFBounded.add(new Pair<>(theta2.apply(sigma), fBoundedNew));
|
PairResultFBounded.add(new Pair<>(theta2.apply(sigma), fBoundedNew));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
try {
|
try {
|
||||||
if (log) logFile.write(PairResultFBounded.toString());
|
if (log) logFile.write(PairResultFBounded.toString());
|
||||||
log = false;
|
log = false;
|
||||||
@ -265,6 +264,7 @@ implements IFiniteClosure {
|
|||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
System.err.println("no LogFile");
|
System.err.println("no LogFile");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
for(Pair<UnifyType,Set<UnifyType>> pt : PairResultFBounded) {
|
for(Pair<UnifyType,Set<UnifyType>> pt : PairResultFBounded) {
|
||||||
UnifyType t = pt.getKey();
|
UnifyType t = pt.getKey();
|
||||||
Set<UnifyType> lfBounded = pt.getValue().get();
|
Set<UnifyType> lfBounded = pt.getValue().get();
|
||||||
|
@ -54,6 +54,20 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
|||||||
UnifyPair up;
|
UnifyPair up;
|
||||||
if (left instanceof WildcardType || right instanceof WildcardType) {
|
if (left instanceof WildcardType || right instanceof WildcardType) {
|
||||||
up = new UnifyPair(left, right, PairOperator.SMALLERDOTWC);
|
up = new UnifyPair(left, right, PairOperator.SMALLERDOTWC);
|
||||||
|
if (((left instanceof ExtendsType)
|
||||||
|
&& (((ExtendsType)left).getExtendedType().getName().equals("java.util.Vector"))
|
||||||
|
&& (((ReferenceType)((ExtendsType)left).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType)) ||
|
||||||
|
((right instanceof ExtendsType)
|
||||||
|
&& (((ExtendsType)right).getExtendedType().getName().equals("java.util.Vector"))
|
||||||
|
&& (((ReferenceType)((ExtendsType)right).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType)))
|
||||||
|
{
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
|
if (((right instanceof SuperType) && (((SuperType)right).getSuperedType().getName().equals("java.lang.Object")))
|
||||||
|
||((left instanceof SuperType) && (((SuperType)left).getSuperedType().getName().equals("java.lang.Object"))))
|
||||||
|
{
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
up = new UnifyPair(left, right, PairOperator.SMALLERDOT);
|
up = new UnifyPair(left, right, PairOperator.SMALLERDOT);
|
||||||
@ -67,6 +81,19 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
|||||||
else {
|
else {
|
||||||
if (left instanceof WildcardType || right instanceof WildcardType) {
|
if (left instanceof WildcardType || right instanceof WildcardType) {
|
||||||
up = new UnifyPair(right, left, PairOperator.SMALLERDOTWC);
|
up = new UnifyPair(right, left, PairOperator.SMALLERDOTWC);
|
||||||
|
if (((left instanceof ExtendsType)
|
||||||
|
&& (((ExtendsType)left).getExtendedType().getName().equals("java.util.Vector"))
|
||||||
|
&& (((ReferenceType)((ExtendsType)left).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType)) ||
|
||||||
|
((right instanceof ExtendsType)
|
||||||
|
&& (((ExtendsType)right).getExtendedType().getName().equals("java.util.Vector"))
|
||||||
|
&& (((ReferenceType)((ExtendsType)right).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType)))
|
||||||
|
{
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
|
if (right instanceof SuperType)
|
||||||
|
{
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
up = new UnifyPair(right, left, PairOperator.SMALLERDOT);
|
up = new UnifyPair(right, left, PairOperator.SMALLERDOT);
|
||||||
@ -87,6 +114,16 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
|||||||
* @see com.google.common.collect.Ordering#compare(java.lang.Object, java.lang.Object)
|
* @see com.google.common.collect.Ordering#compare(java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public int compare (Set<UnifyPair> left, Set<UnifyPair> right) {
|
public int compare (Set<UnifyPair> left, Set<UnifyPair> right) {
|
||||||
|
if ((left.size() == 1) && right.size() == 1) {
|
||||||
|
if (left.iterator().next().getLhsType().getName().equals("AFS")) {
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
|
if (((right.iterator().next().getRhsType() instanceof SuperType) && (((SuperType)right.iterator().next().getRhsType()).getSuperedType().getName().equals("java.lang.Object")))
|
||||||
|
||((left.iterator().next().getRhsType() instanceof SuperType) && (((SuperType)left.iterator().next().getRhsType()).getSuperedType().getName().equals("java.lang.Object"))))
|
||||||
|
{
|
||||||
|
System.out.println("");
|
||||||
|
}
|
||||||
|
}
|
||||||
Set<UnifyPair> lefteq = left.stream()
|
Set<UnifyPair> lefteq = left.stream()
|
||||||
.filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT))
|
.filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT))
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
|
@ -224,7 +224,7 @@ public class UnifyPair {
|
|||||||
if (rhs instanceof PlaceholderType) {
|
if (rhs instanceof PlaceholderType) {
|
||||||
ret = ret + ", " + new Integer(((PlaceholderType)rhs).getVariance()).toString();
|
ret = ret + ", " + new Integer(((PlaceholderType)rhs).getVariance()).toString();
|
||||||
}
|
}
|
||||||
return "(" + lhs + " " + pairOp + " " + rhs + ", " + ret + "])"; //+ ", [" + getfBounded().toString()+ "])";
|
return "(" + lhs + " " + pairOp + " " + rhs + ", " + ret + ")"; //+ ", [" + getfBounded().toString()+ "])";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user