forked from JavaTX/JavaCompilerCore
modified: ../../../../main/java/de/dhbwstuttgart/core/JavaTXCompiler.java
Variance aller Argumente in Oderconstraints auf 1 gesetzt muss nochmals ueberarbeitet werden modified: ../../../../main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java Returntypen von Operatoren sind \doteq gestezt modified: ../../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java Bei Variance = 2 parallel abgearbeitet geloescht, dass nicht nochmals bearbeitet werden.
This commit is contained in:
parent
b68004a214
commit
28400c8bde
@ -480,11 +480,11 @@ public class JavaTXCompiler {
|
|||||||
final ConstraintSet<Pair> cons = getConstraints();
|
final ConstraintSet<Pair> cons = getConstraints();
|
||||||
Set<Set<UnifyPair>> results = new HashSet<>();
|
Set<Set<UnifyPair>> results = new HashSet<>();
|
||||||
try {
|
try {
|
||||||
Writer logFile = new OutputStreamWriter(new NullOutputStream());
|
Writer logFile = //new OutputStreamWriter(new NullOutputStream());
|
||||||
// new FileWriter(new
|
// new FileWriter(new
|
||||||
// File(System.getProperty("user.dir")+"/src/test/resources/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName()));
|
// File(System.getProperty("user.dir")+"/src/test/resources/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName()));
|
||||||
//new FileWriter(new File(System.getProperty("user.dir") + "/logFiles/" + "log_"
|
new FileWriter(new File(System.getProperty("user.dir") + "/logFiles/" + "log_"
|
||||||
// + sourceFiles.keySet().iterator().next().getName()));
|
+ sourceFiles.keySet().iterator().next().getName()));
|
||||||
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses, logFile, classLoader);
|
IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses, logFile, classLoader);
|
||||||
System.out.println(finiteClosure);
|
System.out.println(finiteClosure);
|
||||||
ConstraintSet<UnifyPair> unifyCons = UnifyTypeFactory.convert(cons);
|
ConstraintSet<UnifyPair> unifyCons = UnifyTypeFactory.convert(cons);
|
||||||
@ -501,6 +501,7 @@ public class JavaTXCompiler {
|
|||||||
|
|
||||||
};
|
};
|
||||||
logFile.write("Unify:" + unifyCons.toString());
|
logFile.write("Unify:" + unifyCons.toString());
|
||||||
|
System.out.println("Unify:" + unifyCons.toString());
|
||||||
unifyCons = unifyCons.map(distributeInnerVars);
|
unifyCons = unifyCons.map(distributeInnerVars);
|
||||||
logFile.write("\nUnify_distributeInnerVars: " + unifyCons.toString());
|
logFile.write("\nUnify_distributeInnerVars: " + unifyCons.toString());
|
||||||
TypeUnify unify = new TypeUnify();
|
TypeUnify unify = new TypeUnify();
|
||||||
@ -597,6 +598,21 @@ public class JavaTXCompiler {
|
|||||||
return x;// HIER DIE JEWEILS RECHT BZW. LINKE SEITE AUF GLEICHE VARIANZ SETZEN WIE DIE
|
return x;// HIER DIE JEWEILS RECHT BZW. LINKE SEITE AUF GLEICHE VARIANZ SETZEN WIE DIE
|
||||||
// JEWEILS ANDERE SEITE
|
// JEWEILS ANDERE SEITE
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//PL 2020-02-05 alle Oder-Constraints Receiver und Parameter werden auf variance 1 gesetzt
|
||||||
|
//Es wird davon ausgegangen, dass in OderConstraints in Bedingungen für Parameter die Typen der Argumente links stehen
|
||||||
|
//und die Typen der Rückgabewerte immer rechts stehen
|
||||||
|
|
||||||
|
unifyCons.getOderConstraints().forEach(z -> z.forEach(y -> y.forEach(x -> {
|
||||||
|
if ((x.getLhsType() instanceof PlaceholderType) && x.getPairOp().compareTo(PairOperator.SMALLERDOT) == 0) {
|
||||||
|
((PlaceholderType) x.getLhsType()).setVariance((byte)1);
|
||||||
|
}
|
||||||
|
else if ((x.getRhsType() instanceof PlaceholderType) && x.getPairOp().compareTo(PairOperator.EQUALSDOT) == 0) {
|
||||||
|
((PlaceholderType) x.getRhsType()).setVariance((byte)-1);
|
||||||
|
}
|
||||||
|
})));
|
||||||
|
|
||||||
|
System.out.println("Unify nach Oder-Constraints-Anpassung:" + unifyCons.toString());
|
||||||
Set<PlaceholderType> varianceTPHold;
|
Set<PlaceholderType> varianceTPHold;
|
||||||
Set<PlaceholderType> varianceTPH = new HashSet<>();
|
Set<PlaceholderType> varianceTPH = new HashSet<>();
|
||||||
varianceTPH = varianceInheritanceConstraintSet(unifyCons);
|
varianceTPH = varianceInheritanceConstraintSet(unifyCons);
|
||||||
|
@ -159,6 +159,8 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
//Es wird in OderConstraints davon ausgegangen dass die Bedingungen für die Typen der Argumente links stehen
|
||||||
|
//und die Typen der Rückgabewerte immer rechts stehen (vgl. JavaTXCompiler)
|
||||||
public void visit(MethodCall methodCall) {
|
public void visit(MethodCall methodCall) {
|
||||||
methodCall.receiver.accept(this);
|
methodCall.receiver.accept(this);
|
||||||
//Overloading:
|
//Overloading:
|
||||||
@ -222,6 +224,8 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
//Es wird in OderConstraints davon ausgegangen dass die Bedingungen für die Typen der Argumente links stehen
|
||||||
|
//und die Typen der Rückgabewerte immer rechts stehen (vgl. JavaTXCompiler)
|
||||||
public void visit(BinaryExpr binary) {
|
public void visit(BinaryExpr binary) {
|
||||||
binary.lexpr.accept(this);
|
binary.lexpr.accept(this);
|
||||||
binary.rexpr.accept(this);
|
binary.rexpr.accept(this);
|
||||||
@ -248,7 +252,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), bytee, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.getType(), integer, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.getType(), integer, PairOperator.EQUALSDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
//PL eingefuegt 2018-07-17
|
//PL eingefuegt 2018-07-17
|
||||||
@ -256,7 +260,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), shortt, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), shortt, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), shortt, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), shortt, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.getType(), integer, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.getType(), integer, PairOperator.EQUALSDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
//PL eingefuegt 2018-07-17
|
//PL eingefuegt 2018-07-17
|
||||||
@ -264,7 +268,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), integer, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), integer, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), integer, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), integer, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(integer, binary.getType(), PairOperator.SMALLERDOT));
|
numeric.add(new Pair(integer, binary.getType(), PairOperator.EQUALSDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
//PL eingefuegt 2018-07-17
|
//PL eingefuegt 2018-07-17
|
||||||
@ -272,7 +276,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), longg, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), longg, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), longg, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), longg, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(longg, binary.getType(), PairOperator.SMALLERDOT));
|
numeric.add(new Pair(longg, binary.getType(), PairOperator.EQUALSDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
//PL eingefuegt 2018-07-17
|
//PL eingefuegt 2018-07-17
|
||||||
@ -280,7 +284,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(floatt, binary.getType(), PairOperator.SMALLERDOT));
|
numeric.add(new Pair(floatt, binary.getType(), PairOperator.EQUALSDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
//PL eingefuegt 2018-07-17
|
//PL eingefuegt 2018-07-17
|
||||||
@ -288,7 +292,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(doublee, binary.getType(), PairOperator.SMALLERDOT));
|
numeric.add(new Pair(doublee, binary.getType(), PairOperator.EQUALSDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
/* PL auskommentiert Anfang 2018-07-17
|
/* PL auskommentiert Anfang 2018-07-17
|
||||||
@ -362,7 +366,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
constraintsSet.addUndConstraint(new Pair(binary.lexpr.getType(), number, PairOperator.SMALLERNEQDOT));
|
constraintsSet.addUndConstraint(new Pair(binary.lexpr.getType(), number, PairOperator.SMALLERNEQDOT));
|
||||||
constraintsSet.addUndConstraint(new Pair(binary.rexpr.getType(), number, PairOperator.SMALLERNEQDOT));
|
constraintsSet.addUndConstraint(new Pair(binary.rexpr.getType(), number, PairOperator.SMALLERNEQDOT));
|
||||||
//Rückgabetyp ist Boolean
|
//Rückgabetyp ist Boolean
|
||||||
constraintsSet.addUndConstraint(new Pair(bool, binary.getType(), PairOperator.SMALLERDOT));
|
constraintsSet.addUndConstraint(new Pair(bool, binary.getType(), PairOperator.EQUALSDOT));
|
||||||
|
|
||||||
//auskommentiert PL 2018-05-24
|
//auskommentiert PL 2018-05-24
|
||||||
//constraintsSet.addUndConstraint(new Pair(binary.lexpr.getType(), number, PairOperator.SMALLERDOT));
|
//constraintsSet.addUndConstraint(new Pair(binary.lexpr.getType(), number, PairOperator.SMALLERDOT));
|
||||||
@ -374,7 +378,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
The equality operators may be used to compare two operands that are convertible (§5.1.8) to numeric type, or two operands of type boolean or Boolean, or two operands that are each of either reference type or the null type. All other cases result in a compile-time error.
|
The equality operators may be used to compare two operands that are convertible (§5.1.8) to numeric type, or two operands of type boolean or Boolean, or two operands that are each of either reference type or the null type. All other cases result in a compile-time error.
|
||||||
*/
|
*/
|
||||||
//Der Equals Operator geht mit fast allen Typen, daher werden hier keine Constraints gesetzt
|
//Der Equals Operator geht mit fast allen Typen, daher werden hier keine Constraints gesetzt
|
||||||
constraintsSet.addUndConstraint(new Pair(bool, binary.getType(), PairOperator.SMALLERDOT));
|
constraintsSet.addUndConstraint(new Pair(bool, binary.getType(), PairOperator.EQUALSDOT));
|
||||||
}else{
|
}else{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -1068,7 +1068,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
while (!nextSetasListRest.isEmpty()) {
|
while (!nextSetasListRest.isEmpty()) {
|
||||||
Set<UnifyPair> nSaL = nextSetasListRest.remove(0);
|
Set<UnifyPair> nSaL = nextSetasListRest.remove(0);
|
||||||
//nextSetasList.remove(nSaL);
|
nextSetasList.remove(nSaL); //PL einkommentiert 20-02-03
|
||||||
Set<UnifyPair> newEq = new HashSet<>(eq);
|
Set<UnifyPair> newEq = new HashSet<>(eq);
|
||||||
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
Set<Set<UnifyPair>> newElems = new HashSet<>(elems);
|
||||||
List<Set<Set<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
List<Set<Set<UnifyPair>>> newOderConstraints = new ArrayList<>(oderConstraints);
|
||||||
@ -1445,7 +1445,7 @@ 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());
|
||||||
}
|
}
|
||||||
|
//2020-02-02: if (variance ==2) Hier Aufruf von filterOverriding einfuegen
|
||||||
writeLog("Return computeCR: " + result.toString());
|
writeLog("Return computeCR: " + result.toString());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user