forked from JavaTX/JavaCompilerCore
modified: src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java
modified: src/main/java/de/dhbwstuttgart/syntaxtree/visual/OutputGenerator.java modified: src/main/java/de/dhbwstuttgart/typeinference/constraints/Constraint.java modified: src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java modified: src/main/java/de/dhbwstuttgart/typeinference/constraints/Pair.java modified: src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java modified: src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java modified: src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java modified: src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
This commit is contained in:
parent
0c9612a2ea
commit
e699fc36ae
@ -152,12 +152,12 @@ public class UnifyTypeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//NEVER USED
|
//NEVER USED
|
||||||
public static Constraint<UnifyPair> convert(Constraint<Pair> constraint){
|
//public static Constraint<UnifyPair> convert(Constraint<Pair> constraint){
|
||||||
Constraint<UnifyPair> unifyPairConstraint = constraint.stream()
|
// Constraint<UnifyPair> unifyPairConstraint = constraint.stream()
|
||||||
.map(UnifyTypeFactory::convert)
|
// .map(UnifyTypeFactory::convert)
|
||||||
.collect(Collectors.toCollection( () -> new Constraint<UnifyPair> (constraint.isInherited(), convert(constraint.getExtendConstraint()))));
|
// .collect(Collectors.toCollection( () -> new Constraint<UnifyPair> (constraint.isInherited(), convert(constraint.getExtendConstraint()))));
|
||||||
return unifyPairConstraint;
|
// return unifyPairConstraint;
|
||||||
}
|
//}
|
||||||
|
|
||||||
public static UnifyPair convert(Pair p) {
|
public static UnifyPair convert(Pair p) {
|
||||||
UnifyPair ret = null;
|
UnifyPair ret = null;
|
||||||
|
@ -271,6 +271,7 @@ public class OutputGenerator implements ASTVisitor{
|
|||||||
public void visit(MethodCall methodCall) {
|
public void visit(MethodCall methodCall) {
|
||||||
methodCall.receiver.accept(this);
|
methodCall.receiver.accept(this);
|
||||||
out.append("."+methodCall.name);
|
out.append("."+methodCall.name);
|
||||||
|
out.append(" Signature: "+methodCall.signature);
|
||||||
methodCall.getArgumentList().accept(this);
|
methodCall.getArgumentList().accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,11 @@ public class Constraint<A> extends HashSet<A> {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Boolean isInherited = false;//wird nur für die Method-Constraints benoetigt
|
private Boolean isInherited = false;//wird nur für die Method-Constraints benoetigt
|
||||||
|
|
||||||
|
/*
|
||||||
|
* wird verwendet um bei der Codegenerierung die richtige Methoden - Signatur
|
||||||
|
* auszuwaehlen
|
||||||
|
*/
|
||||||
|
/*private*/ Set<A> methodSignatureConstraint = new HashSet<>();
|
||||||
|
|
||||||
private Constraint<A> extendConstraint = null;
|
private Constraint<A> extendConstraint = null;
|
||||||
|
|
||||||
@ -21,9 +26,10 @@ public class Constraint<A> extends HashSet<A> {
|
|||||||
this.isInherited = isInherited;
|
this.isInherited = isInherited;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Constraint(Boolean isInherited, Constraint<A> extendConstraint) {
|
public Constraint(Boolean isInherited, Constraint<A> extendConstraint, Set<A> methodSignatureConstraint) {
|
||||||
this.isInherited = isInherited;
|
this.isInherited = isInherited;
|
||||||
this.extendConstraint = extendConstraint;
|
this.extendConstraint = extendConstraint;
|
||||||
|
this.methodSignatureConstraint = methodSignatureConstraint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsInherited(Boolean isInherited) {
|
public void setIsInherited(Boolean isInherited) {
|
||||||
@ -41,6 +47,14 @@ public class Constraint<A> extends HashSet<A> {
|
|||||||
public void setExtendConstraint(Constraint<A> c) {
|
public void setExtendConstraint(Constraint<A> c) {
|
||||||
extendConstraint = c;
|
extendConstraint = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<A> getmethodSignatureConstraint() {
|
||||||
|
return methodSignatureConstraint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setmethodSignatureConstraint(Set<A> c) {
|
||||||
|
methodSignatureConstraint = c;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + "\nisInherited = " + isInherited
|
return super.toString() + "\nisInherited = " + isInherited
|
||||||
|
@ -77,7 +77,8 @@ public class ConstraintSet<A> {
|
|||||||
.map(o)
|
.map(o)
|
||||||
.collect(Collectors.toCollection((as.getExtendConstraint() != null)
|
.collect(Collectors.toCollection((as.getExtendConstraint() != null)
|
||||||
? () -> new Constraint<B> (as.isInherited(),
|
? () -> new Constraint<B> (as.isInherited(),
|
||||||
as.getExtendConstraint().stream().map(o).collect(Collectors.toCollection(Constraint::new)))
|
as.getExtendConstraint().stream().map(o).collect(Collectors.toCollection(Constraint::new)),
|
||||||
|
as.getmethodSignatureConstraint().stream().map(o).collect(Collectors.toCollection(HashSet::new)))
|
||||||
: () -> new Constraint<B> (as.isInherited())
|
: () -> new Constraint<B> (as.isInherited())
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ public class Pair implements Serializable
|
|||||||
public final RefTypeOrTPHOrWildcardOrGeneric TA2;
|
public final RefTypeOrTPHOrWildcardOrGeneric TA2;
|
||||||
|
|
||||||
private PairOperator eOperator = PairOperator.SMALLER;
|
private PairOperator eOperator = PairOperator.SMALLER;
|
||||||
|
private Boolean noUnification = false;
|
||||||
|
|
||||||
|
|
||||||
public Pair(RefTypeOrTPHOrWildcardOrGeneric TA1, RefTypeOrTPHOrWildcardOrGeneric TA2 )
|
public Pair(RefTypeOrTPHOrWildcardOrGeneric TA1, RefTypeOrTPHOrWildcardOrGeneric TA2 )
|
||||||
@ -31,7 +32,16 @@ public class Pair implements Serializable
|
|||||||
this(TA1,TA2);
|
this(TA1,TA2);
|
||||||
this.eOperator = eOp;
|
this.eOperator = eOp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Pair(RefTypeOrTPHOrWildcardOrGeneric TA1, RefTypeOrTPHOrWildcardOrGeneric TA2, PairOperator eOp, Boolean noUnification)
|
||||||
|
{
|
||||||
|
// Konstruktor
|
||||||
|
this(TA1,TA2);
|
||||||
|
this.eOperator = eOp;
|
||||||
|
this.noUnification = noUnification;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
// otth: Gibt ein Paar als String aus --> zum Debuggen und Vergleichen
|
// otth: Gibt ein Paar als String aus --> zum Debuggen und Vergleichen
|
||||||
|
@ -641,6 +641,10 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
//PL 2023-01-24: dafuer ? extends receiverType noch ergaenzt
|
//PL 2023-01-24: dafuer ? extends receiverType noch ergaenzt
|
||||||
extendsMethodConstraint.add(new Pair(forMethod.receiver.getType(), new ExtendsWildcardType(receiverType, receiverType.getOffset()), PairOperator.EQUALSDOT));
|
extendsMethodConstraint.add(new Pair(forMethod.receiver.getType(), new ExtendsWildcardType(receiverType, receiverType.getOffset()), PairOperator.EQUALSDOT));
|
||||||
|
|
||||||
|
//gegenseite Verschraenkung der beiden Mengen von Typannahmen
|
||||||
|
methodConstraint.setExtendConstraint(extendsMethodConstraint);
|
||||||
|
extendsMethodConstraint.setExtendConstraint(methodConstraint);
|
||||||
|
|
||||||
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ANFANG
|
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ANFANG
|
||||||
//methodConstraint.add(new Pair(forMethod.receiverType, retType,
|
//methodConstraint.add(new Pair(forMethod.receiverType, retType,
|
||||||
// PairOperator.EQUALSDOT));
|
// PairOperator.EQUALSDOT));
|
||||||
@ -655,6 +659,13 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
methodConstraint.addAll(parameterContraints);
|
methodConstraint.addAll(parameterContraints);
|
||||||
extendsMethodConstraint.addAll(parameterContraints);
|
extendsMethodConstraint.addAll(parameterContraints);
|
||||||
|
|
||||||
|
Set<Pair> methodSignatureConstraint = generatemethodSignatureConstraint(forMethod, assumption, info, resolver);
|
||||||
|
|
||||||
|
System.out.println("methodSignatureConstraint; " + methodSignatureConstraint);
|
||||||
|
|
||||||
|
methodConstraint.setmethodSignatureConstraint(methodSignatureConstraint);
|
||||||
|
extendsMethodConstraint.setmethodSignatureConstraint(methodSignatureConstraint);
|
||||||
|
|
||||||
Set<Constraint<Pair>> ret = new HashSet<>();
|
Set<Constraint<Pair>> ret = new HashSet<>();
|
||||||
ret.add(methodConstraint);
|
ret.add(methodConstraint);
|
||||||
ret.add(extendsMethodConstraint);
|
ret.add(extendsMethodConstraint);
|
||||||
@ -670,8 +681,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
RefTypeOrTPHOrWildcardOrGeneric argType = foMethod.arglist.getArguments().get(i).getType();
|
RefTypeOrTPHOrWildcardOrGeneric argType = foMethod.arglist.getArguments().get(i).getType();
|
||||||
RefTypeOrTPHOrWildcardOrGeneric assType = assumption.getArgTypes(resolver).get(i);
|
RefTypeOrTPHOrWildcardOrGeneric assType = assumption.getArgTypes(resolver).get(i);
|
||||||
|
|
||||||
//Zuordnung von MethoCall.signature (Argumenttypen) zu der Argumenttypen der ausgewaehlten Methode (assumption.params)
|
|
||||||
ret.add(new Pair(foMethod.signature.get(i), assumption.getArgTypes().get(i), PairOperator.EQUALSDOT));
|
|
||||||
|
|
||||||
ret.add(new Pair(argType, assType, PairOperator.SMALLERDOT));
|
ret.add(new Pair(argType, assType, PairOperator.SMALLERDOT));
|
||||||
|
|
||||||
@ -679,14 +689,26 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
// ret.add(new Pair(foMethod.argTypes.get(i), assType, PairOperator.EQUALSDOT));
|
// ret.add(new Pair(foMethod.argTypes.get(i), assType, PairOperator.EQUALSDOT));
|
||||||
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE
|
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE
|
||||||
}
|
}
|
||||||
|
|
||||||
//Zuordnung von MethodCall.signature(ReturnType) zu dem ReturnType der ausgewaehlten Methode (assumption.returnType)
|
|
||||||
System.out.println(foMethod.name);
|
|
||||||
ret.add(new Pair(foMethod.signature.get(foMethod.signature.size()-1), assumption.getReturnType(), PairOperator.EQUALSDOT));
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected Set<Pair> generatemethodSignatureConstraint(MethodCall foMethod, MethodAssumption assumption,
|
||||||
|
TypeInferenceBlockInformation info, GenericsResolver resolver) {
|
||||||
|
Set<Pair> ret = new HashSet<>();
|
||||||
|
|
||||||
|
for(int i = 0; i<foMethod.arglist.getArguments().size(); i++){
|
||||||
|
|
||||||
|
//Zuordnung von MethoCall.signature (Argumenttypen) zu der Argumenttypen der ausgewaehlten Methode (assumption.params)
|
||||||
|
ret.add(new Pair(foMethod.signature.get(i), assumption.getArgTypes().get(i), PairOperator.EQUALSDOT));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Zuordnung von MethodCall.signature(ReturnType) zu dem ReturnType der ausgewaehlten Methode (assumption.returnType)
|
||||||
|
System.out.println(foMethod.name);
|
||||||
|
ret.add(new Pair(foMethod.signature.get(foMethod.signature.size()-1), assumption.getReturnType(), PairOperator.EQUALSDOT));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<MethodAssumption> getMethods(String name, int numArgs, TypeInferenceBlockInformation info) {
|
public static List<MethodAssumption> getMethods(String name, int numArgs, TypeInferenceBlockInformation info) {
|
||||||
List<MethodAssumption> ret = new ArrayList<>();
|
List<MethodAssumption> ret = new ArrayList<>();
|
||||||
|
@ -683,7 +683,8 @@ public class RuleSet implements IRuleSet{
|
|||||||
x -> uni.apply(pair,x)).collect(Collectors.toCollection((b.getExtendConstraint() != null)
|
x -> uni.apply(pair,x)).collect(Collectors.toCollection((b.getExtendConstraint() != null)
|
||||||
? () -> new Constraint<UnifyPair>(
|
? () -> new Constraint<UnifyPair>(
|
||||||
b.isInherited(),
|
b.isInherited(),
|
||||||
b.getExtendConstraint().stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(Constraint::new)))
|
b.getExtendConstraint().stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(Constraint::new)),
|
||||||
|
b.getmethodSignatureConstraint().stream().map(x -> uni.apply(pair,x)).collect(Collectors.toCollection(HashSet::new)))
|
||||||
: () -> new Constraint<UnifyPair>(b.isInherited())
|
: () -> new Constraint<UnifyPair>(b.isInherited())
|
||||||
));
|
));
|
||||||
oderConstraints.replaceAll(oc -> oc.stream().map(applyUni).collect(Collectors.toCollection(HashSet::new)));
|
oderConstraints.replaceAll(oc -> oc.stream().map(applyUni).collect(Collectors.toCollection(HashSet::new)));
|
||||||
|
@ -34,7 +34,7 @@ public class TypeUnify2Task extends TypeUnifyTask {
|
|||||||
System.out.println("two");
|
System.out.println("two");
|
||||||
}
|
}
|
||||||
one = true;
|
one = true;
|
||||||
Set<Set<UnifyPair>> res = unify2(setToFlatten, eq, oderConstraintsField, fc, parallel, rekTiefeField);
|
Set<Set<UnifyPair>> res = unify2(setToFlatten, eq, oderConstraintsField, fc, parallel, rekTiefeField, false);
|
||||||
/*if (isUndefinedPairSetSet(res)) {
|
/*if (isUndefinedPairSetSet(res)) {
|
||||||
return new HashSet<>(); }
|
return new HashSet<>(); }
|
||||||
else
|
else
|
||||||
|
@ -260,7 +260,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
ArrayList<Set<Constraint<UnifyPair>>> remainingOderconstraints = oderConstraintsField.stream()
|
ArrayList<Set<Constraint<UnifyPair>>> remainingOderconstraints = oderConstraintsField.stream()
|
||||||
.filter(x -> x.size()>1)
|
.filter(x -> x.size()>1)
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField);
|
Set<Set<UnifyPair>> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, false);
|
||||||
noOfThread--;
|
noOfThread--;
|
||||||
try {
|
try {
|
||||||
logFile.close();
|
logFile.close();
|
||||||
@ -305,7 +305,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
* @param fc The finite closure
|
* @param fc The finite closure
|
||||||
* @return The set of all principal type unifiers
|
* @return The set of all principal type unifiers
|
||||||
*/
|
*/
|
||||||
protected Set<Set<UnifyPair>> unify(final Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) {
|
protected Set<Set<UnifyPair>> unify(final Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe, boolean sameEq) {
|
||||||
//Set<UnifyPair> aas = eq.stream().filter(x -> x.getLhsType().getName().equals("AA") //&& x.getPairOp().equals(PairOperator.SMALLERDOT)
|
//Set<UnifyPair> aas = eq.stream().filter(x -> x.getLhsType().getName().equals("AA") //&& x.getPairOp().equals(PairOperator.SMALLERDOT)
|
||||||
// ).collect(Collectors.toCollection(HashSet::new));
|
// ).collect(Collectors.toCollection(HashSet::new));
|
||||||
//writeLog(nOfUnify.toString() + " AA: " + aas.toString());
|
//writeLog(nOfUnify.toString() + " AA: " + aas.toString());
|
||||||
@ -484,12 +484,12 @@ 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 ArrayList<>(topLevelSets), eq, oderConstraintsOutput, fc, parallel, rekTiefe);
|
return computeCartesianRecursive(new ArrayList<>(topLevelSets), eq, oderConstraintsOutput, fc, parallel, rekTiefe, sameEq);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Set<Set<UnifyPair>> unify2(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) {
|
Set<Set<UnifyPair>> unify2(Set<Set<UnifyPair>> setToFlatten, Set<UnifyPair> eq, List<Set<Constraint<UnifyPair>>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe, boolean sameEq) {
|
||||||
//Aufruf von computeCartesianRecursive ENDE
|
//Aufruf von computeCartesianRecursive ENDE
|
||||||
|
|
||||||
//keine Ahnung woher das kommt
|
//keine Ahnung woher das kommt
|
||||||
@ -578,12 +578,12 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(eqPrimePrime.isPresent()) {
|
else if(eqPrimePrime.isPresent()) {
|
||||||
Set<Set<UnifyPair>> unifyres = unifyres1 = unify(eqPrimePrime.get(), newOderConstraints, fc, parallel, rekTiefe);
|
Set<Set<UnifyPair>> unifyres = unifyres1 = unify(eqPrimePrime.get(), newOderConstraints, fc, parallel, rekTiefe, sameEq);
|
||||||
|
|
||||||
eqPrimePrimeSet.addAll(unifyres);
|
eqPrimePrimeSet.addAll(unifyres);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Set<Set<UnifyPair>> unifyres = unifyres2 = unify(eqPrime, newOderConstraints, fc, parallel, rekTiefe);
|
Set<Set<UnifyPair>> unifyres = unifyres2 = unify(eqPrime, newOderConstraints, fc, parallel, rekTiefe, sameEq);
|
||||||
|
|
||||||
|
|
||||||
eqPrimePrimeSet.addAll(unifyres);
|
eqPrimePrimeSet.addAll(unifyres);
|
||||||
@ -625,7 +625,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
* @param rekTiefe Deep of recursive calls
|
* @param rekTiefe Deep of recursive calls
|
||||||
* @return The set of all principal type unifiers
|
* @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) {
|
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 sameEq) {
|
||||||
|
|
||||||
//oneElems: Alle 1-elementigen Mengen, die nur ein Paar
|
//oneElems: Alle 1-elementigen Mengen, die nur ein Paar
|
||||||
//a <. theta, theta <. a oder a =. theta enthalten
|
//a <. theta, theta <. a oder a =. theta enthalten
|
||||||
@ -639,7 +639,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Optional<Set<? extends Set<UnifyPair>>> optNextSet = topLevelSets.stream().filter(x -> x.size()>1).findAny();
|
Optional<Set<? extends Set<UnifyPair>>> optNextSet = topLevelSets.stream().filter(x -> x.size()>1).findAny();
|
||||||
|
|
||||||
if (!optNextSet.isPresent()) {//Alle Elemente sind 1-elementig
|
if (!optNextSet.isPresent()) {//Alle Elemente sind 1-elementig
|
||||||
Set<Set<UnifyPair>> result = unify2(oneElems, eq, oderConstraints, fc, parallel, rekTiefe);
|
Set<Set<UnifyPair>> result = unify2(oneElems, eq, oderConstraints, fc, parallel, rekTiefe, sameEq);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -705,7 +705,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
x.getPairOp() == PairOperator.EQUALSDOT)
|
x.getPairOp() == PairOperator.EQUALSDOT)
|
||||||
.map(x ->
|
.map(x ->
|
||||||
((PlaceholderType)x.getGroundBasePair().getLhsType()).getVariance())
|
((PlaceholderType)x.getGroundBasePair().getLhsType()).getVariance())
|
||||||
.findAny();
|
.reduce((n,m) -> { if ((n == 0) && (m==0)) return 0;
|
||||||
|
else if (n !=0) return n; //es muss mindestens eine Variance != 0 sein
|
||||||
|
else return m;
|
||||||
|
});
|
||||||
//Fuer Operatorenaufrufe wird variance auf 2 gesetzt.
|
//Fuer Operatorenaufrufe wird variance auf 2 gesetzt.
|
||||||
//da kein Receiver existiert also kein x.getGroundBasePair().getLhsType() instanceof PlaceholderType
|
//da kein Receiver existiert also kein x.getGroundBasePair().getLhsType() instanceof PlaceholderType
|
||||||
//Bei Varianz = 2 werden alle Elemente des Kartesischen Produkts abgearbeitet
|
//Bei Varianz = 2 werden alle Elemente des Kartesischen Produkts abgearbeitet
|
||||||
@ -1150,10 +1153,17 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//noOfThread++;
|
//noOfThread++;
|
||||||
} else {//parallel = false oder MaxNoOfThreads ist erreicht, sequentiell weiterarbeiten
|
} else {//parallel = false oder MaxNoOfThreads ist erreicht, sequentiell weiterarbeiten
|
||||||
elems.add(a); //PL 2019-01-16 muss das wirklich hin steht schon in Zeile 859 ja braucht man siehe Zeile 859
|
elems.add(a); //PL 2019-01-16 muss das wirklich hin steht schon in Zeile 859 ja braucht man siehe Zeile 859
|
||||||
res = unify2(elems, eq, oderConstraints, fc, parallel, rekTiefe);
|
res = unify2(elems, eq, oderConstraints, fc, parallel, rekTiefe, sameEq);
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
//Ab hier alle parallele Berechnungen wieder zusammengeführt.
|
//Ab hier alle parallele Berechnungen wieder zusammengeführt.
|
||||||
|
Set<UnifyPair> methodSignatureConstraint =
|
||||||
|
oderConstraint ?
|
||||||
|
((Constraint<UnifyPair>)a).getmethodSignatureConstraint()
|
||||||
|
: new HashSet<>();
|
||||||
|
if (oderConstraint) {
|
||||||
|
System.out.println("ERSTELLUNG: " +methodSignatureConstraint);
|
||||||
|
}
|
||||||
if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) {
|
if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) {
|
||||||
//wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen
|
//wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen
|
||||||
result = res;
|
result = res;
|
||||||
@ -1482,6 +1492,17 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//}
|
//}
|
||||||
//else result.stream().filter(y -> !isUndefinedPairSet(y));
|
//else result.stream().filter(y -> !isUndefinedPairSet(y));
|
||||||
writeLog("res: " + res.toString());
|
writeLog("res: " + res.toString());
|
||||||
|
if (oderConstraint && !sameEq && !isUndefinedPairSetSet(result)) {
|
||||||
|
System.out.println("methodSignatureConstraint Return: " + methodSignatureConstraint);
|
||||||
|
result.forEach(x -> x.addAll(methodSignatureConstraint));
|
||||||
|
/*
|
||||||
|
result = result.stream().map(
|
||||||
|
x -> { Optional<Set<UnifyPair>> help = rules.subst(x);
|
||||||
|
return help.isPresent() ?
|
||||||
|
help.get():
|
||||||
|
x; }).collect(Collectors.toSet());
|
||||||
|
*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//2020-02-02: if (variance ==2) Hier Aufruf von filterOverriding einfuegen
|
//2020-02-02: if (variance ==2) Hier Aufruf von filterOverriding einfuegen
|
||||||
writeLog("Return computeCR: " + result.toString());
|
writeLog("Return computeCR: " + result.toString());
|
||||||
@ -1521,7 +1542,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
unitedSubst.addAll(sameEq.getAllBases());
|
unitedSubst.addAll(sameEq.getAllBases());
|
||||||
localEq.add(new UnifyPair(aPair.getRhsType(), sameEq.getRhsType(), sameEq.getPairOp(), unitedSubst, null));
|
localEq.add(new UnifyPair(aPair.getRhsType(), sameEq.getRhsType(), sameEq.getPairOp(), unitedSubst, null));
|
||||||
finalresult = false;
|
finalresult = false;
|
||||||
Set<Set<UnifyPair>> localRes = unify(localEq, new ArrayList<>(), fc, false, 0);
|
Set<Set<UnifyPair>> localRes = unify(localEq, new ArrayList<>(), fc, false, 0, true);
|
||||||
finalresult = true;
|
finalresult = true;
|
||||||
if (isUndefinedPairSetSet(localRes)) {
|
if (isUndefinedPairSetSet(localRes)) {
|
||||||
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
||||||
@ -1539,7 +1560,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
unitedSubst.addAll(sameEq.getAllBases());
|
unitedSubst.addAll(sameEq.getAllBases());
|
||||||
localEq.add(new UnifyPair(sameEq.getLhsType(), aPair.getRhsType(), sameEq.getPairOp(), unitedSubst, null));
|
localEq.add(new UnifyPair(sameEq.getLhsType(), aPair.getRhsType(), sameEq.getPairOp(), unitedSubst, null));
|
||||||
finalresult = false;
|
finalresult = false;
|
||||||
Set<Set<UnifyPair>> localRes = unify(localEq, new ArrayList<>(), fc, false, 0);
|
Set<Set<UnifyPair>> localRes = unify(localEq, new ArrayList<>(), fc, false, 0, true);
|
||||||
finalresult = true;
|
finalresult = true;
|
||||||
if (isUndefinedPairSetSet(localRes)) {
|
if (isUndefinedPairSetSet(localRes)) {
|
||||||
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
if (result.isEmpty() || isUndefinedPairSetSet(result)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user