forked from JavaTX/JavaCompilerCore
modified: src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java
Fuer den Receiver wieder = eingefuegt. modified: src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java Kommentierung begonnen
This commit is contained in:
parent
5a00b70ea8
commit
fec83c3a62
@ -587,9 +587,13 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
RefTypeOrTPHOrWildcardOrGeneric retType = assumption.getReceiverType(resolver);
|
RefTypeOrTPHOrWildcardOrGeneric retType = assumption.getReceiverType(resolver);
|
||||||
methodConstraint.add(forMethod.name.equals("apply") ? //PL 2019-11-29: Tenaerer Operator eingefügt, weil bei Lambda-Ausdrücken keine Suntype FunN$$ existiert
|
methodConstraint.add(new Pair(forMethod.receiver.getType(), retType,
|
||||||
new Pair(forMethod.receiver.getType(), retType, PairOperator.EQUALSDOT)
|
PairOperator.EQUALSDOT));//PL 2020-03-17 SMALLERDOT in EQUALSDOT umgewandelt, weil alle geerbten Methoden in den jeweilen Klassen enthalten sind.
|
||||||
: new Pair(forMethod.receiver.getType(), retType, PairOperator.SMALLERDOT));
|
|
||||||
|
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ANFANG
|
||||||
|
//methodConstraint.add(new Pair(forMethod.receiverType, retType,
|
||||||
|
// PairOperator.EQUALSDOT));
|
||||||
|
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE
|
||||||
|
|
||||||
methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(),
|
methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(),
|
||||||
PairOperator.EQUALSDOT));
|
PairOperator.EQUALSDOT));
|
||||||
|
@ -457,7 +457,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
|
|
||||||
//Aufruf von computeCartesianRecursive ANFANG
|
//Aufruf von computeCartesianRecursive ANFANG
|
||||||
//writeLog("topLevelSets: " + topLevelSets.toString());
|
//writeLog("topLevelSets: " + topLevelSets.toString());
|
||||||
return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets), eq, oderConstraintsOutput, fc, parallel, rekTiefe, finalresult);
|
return computeCartesianRecursive(new ArrayList<>(topLevelSets), eq, oderConstraintsOutput, fc, parallel, rekTiefe, finalresult);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,10 +587,21 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
Set<Set<UnifyPair>> computeCartesianRecursive(Set<Set<UnifyPair>> fstElems, ArrayList<Set<? extends Set<UnifyPair>>> topLevelSets, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe, Boolean finalresult) {
|
* Computes the cartesian product of topLevelSets step by step.
|
||||||
|
* @param topLevelSets List of Sets of Sets, where a cartesian product have to be built
|
||||||
|
* Ex.: [{{a =. Integer}, {a = Object}}, {{a = Vector<b>, b =. Integer}, {a = Vector<b>, b =. Object}}]
|
||||||
|
* @param eq Original set of equations which should be unified
|
||||||
|
* @param oderConstraints Remaining or-constraints
|
||||||
|
* @param fc The finite closure
|
||||||
|
* @param parallel If the algorithm should be parallelized run
|
||||||
|
* @param rekTiefe Deep of recursive calls
|
||||||
|
* @param finalresult Gives if unify is not called from checkA
|
||||||
|
* @return The set of all principal type unifiers
|
||||||
|
*/
|
||||||
|
Set<Set<UnifyPair>> computeCartesianRecursive(ArrayList<Set<? extends Set<UnifyPair>>> topLevelSets, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe, Boolean finalresult) {
|
||||||
//ArrayList<Set<Set<UnifyPair>>> remainingSets = new ArrayList<>(topLevelSets);
|
//ArrayList<Set<Set<UnifyPair>>> remainingSets = new ArrayList<>(topLevelSets);
|
||||||
|
Set<Set<UnifyPair>> fstElems = new HashSet<>();
|
||||||
fstElems.addAll(topLevelSets.stream()
|
fstElems.addAll(topLevelSets.stream()
|
||||||
.filter(x -> x.size()==1)
|
.filter(x -> x.size()==1)
|
||||||
.map(y -> y.stream().findFirst().get())
|
.map(y -> y.stream().findFirst().get())
|
||||||
@ -617,6 +628,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Set<Set<UnifyPair>> result = new HashSet<>();
|
Set<Set<UnifyPair>> result = new HashSet<>();
|
||||||
int variance = 0;
|
int variance = 0;
|
||||||
|
|
||||||
|
/* Varianzbestimmung Anfang
|
||||||
|
* Oderconstraint, wenn entweder kein Basepair oder unterschiedliche Basepairs => oderConstraint = true;
|
||||||
|
* Varianz = 1 => Argumentvariable
|
||||||
|
* Varianz = -1 => Rückgabevariable
|
||||||
|
* Varianz = 0 => unklar
|
||||||
|
* Varianz = 2 => Operatoren oderConstraints */
|
||||||
ArrayList<UnifyPair> zeroNextElem = new ArrayList<>(nextSetasList.get(0));
|
ArrayList<UnifyPair> zeroNextElem = new ArrayList<>(nextSetasList.get(0));
|
||||||
UnifyPair fstBasePair = zeroNextElem.remove(0).getBasePair();
|
UnifyPair fstBasePair = zeroNextElem.remove(0).getBasePair();
|
||||||
Boolean oderConstraint = false;
|
Boolean oderConstraint = false;
|
||||||
@ -639,16 +656,15 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//variance = 2;
|
|
||||||
oderConstraint = true;
|
oderConstraint = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//variance = 2;
|
|
||||||
oderConstraint = true;
|
oderConstraint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oderConstraint) {//Varianz-Bestimmung Oder-Constraints
|
//Varianz-Bestimmung Oder-Constraints
|
||||||
|
if (oderConstraint) {
|
||||||
if (printtag) System.out.println("nextSetasList " + nextSetasList);
|
if (printtag) System.out.println("nextSetasList " + nextSetasList);
|
||||||
Optional<Integer> optVariance =
|
Optional<Integer> optVariance =
|
||||||
nextSetasList.iterator()
|
nextSetasList.iterator()
|
||||||
@ -661,20 +677,18 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
((PlaceholderType)x.getGroundBasePair().getLhsType()).getVariance())
|
((PlaceholderType)x.getGroundBasePair().getLhsType()).getVariance())
|
||||||
.findAny();
|
.findAny();
|
||||||
//Fuer Operatorenaufrufe wird variance auf 2 gesetzt.
|
//Fuer Operatorenaufrufe wird variance auf 2 gesetzt.
|
||||||
//da kein Receiver existiert also keon x.getGroundBasePair().getLhsType() instanceof PlaceholderType
|
//da kein Receiver existiert also kein x.getGroundBasePair().getLhsType() instanceof PlaceholderType
|
||||||
//Es werden alle Elemente des Kartesischen Produkts abgearbeitet
|
//Bei Varianz = 2 werden alle Elemente des Kartesischen Produkts abgearbeitet
|
||||||
variance = optVariance.isPresent() ? optVariance.get() : 2;
|
variance = optVariance.isPresent() ? optVariance.get() : 2;
|
||||||
}
|
}
|
||||||
|
/* Varianzbestimmung Ende */
|
||||||
|
|
||||||
if (!nextSetasList.iterator().hasNext())
|
|
||||||
System.out.print("");
|
|
||||||
if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1)
|
|
||||||
System.out.print("");
|
|
||||||
//writeLog("nextSetasList: " + nextSetasList.toString());
|
//writeLog("nextSetasList: " + nextSetasList.toString());
|
||||||
Set<UnifyPair> nextSetElem = nextSetasList.get(0);
|
Set<UnifyPair> nextSetElem = nextSetasList.get(0);
|
||||||
//writeLog("BasePair1: " + nextSetElem + " " + nextSetElem.iterator().next().getBasePair());
|
//writeLog("BasePair1: " + nextSetElem + " " + nextSetElem.iterator().next().getBasePair());
|
||||||
|
|
||||||
/* sameEqSet-Bestimmung: Wenn a = ty \in nextSet dann enthaelt sameEqSet alle Paare a < ty1 oder ty2 < a aus fstElems */
|
/* sameEqSet-Bestimmung: Wenn a = ty \in nextSet dann enthaelt sameEqSet
|
||||||
|
* alle Paare a < ty1 oder ty2 < a aus fstElems */
|
||||||
Set<UnifyPair> sameEqSet = new HashSet<>();
|
Set<UnifyPair> sameEqSet = new HashSet<>();
|
||||||
Optional<UnifyPair> optOrigPair = null;
|
Optional<UnifyPair> optOrigPair = null;
|
||||||
//if (variance != 2) {
|
//if (variance != 2) {
|
||||||
@ -710,14 +724,14 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
/* sameEqSet-Bestimmung Ende */
|
/* sameEqSet-Bestimmung Ende */
|
||||||
|
|
||||||
Set<UnifyPair> a = null;
|
Set<UnifyPair> a = null;
|
||||||
while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) {
|
while (nextSetasList.size() > 0) {
|
||||||
Set<UnifyPair> a_last = a;
|
Set<UnifyPair> a_last = a;
|
||||||
|
|
||||||
//Liste der Faelle für die parallele Verarbeitung
|
//Liste der Faelle für die parallele Verarbeitung
|
||||||
List<Set<UnifyPair>> nextSetasListRest = new ArrayList<>();
|
List<Set<UnifyPair>> nextSetasListRest = new ArrayList<>();
|
||||||
|
|
||||||
//Liste der Faelle, bei dem Receiver jeweils "? extends" enthaelt bzw. nicht enthaelt
|
//Liste der Faelle, bei dem Receiver jeweils "? extends" enthaelt bzw. nicht enthaelt
|
||||||
//In der Regel ein Element
|
//In der Regel is dies ein Element
|
||||||
List<Set<UnifyPair>> nextSetasListOderConstraints = new ArrayList<>();
|
List<Set<UnifyPair>> nextSetasListOderConstraints = new ArrayList<>();
|
||||||
|
|
||||||
writeLog("nextSet: " + nextSet.toString());
|
writeLog("nextSet: " + nextSet.toString());
|
||||||
|
Loading…
Reference in New Issue
Block a user