diff --git a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java index 609600cd..2f705c67 100644 --- a/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java +++ b/src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java @@ -254,7 +254,7 @@ public class TYPEStmt implements StatementVisitor{ numeric = new Constraint<>(); 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.getType(), integer, PairOperator.SMALLERDOT)); + numeric.add(new Pair(integer, binary.getType(), PairOperator.SMALLERDOT)); numericAdditionOrStringConcatenation.add(numeric); } //PL eingefuegt 2018-07-17 @@ -262,7 +262,7 @@ public class TYPEStmt implements StatementVisitor{ numeric = new Constraint<>(); 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.getType(), longg, PairOperator.SMALLERDOT)); + numeric.add(new Pair(longg, binary.getType(), PairOperator.SMALLERDOT)); numericAdditionOrStringConcatenation.add(numeric); } //PL eingefuegt 2018-07-17 @@ -270,7 +270,7 @@ public class TYPEStmt implements StatementVisitor{ numeric = new Constraint<>(); 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.getType(), floatt, PairOperator.SMALLERDOT)); + numeric.add(new Pair(floatt, binary.getType(), PairOperator.SMALLERDOT)); numericAdditionOrStringConcatenation.add(numeric); } //PL eingefuegt 2018-07-17 @@ -278,7 +278,7 @@ public class TYPEStmt implements StatementVisitor{ numeric = new Constraint<>(); 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.getType(), doublee, PairOperator.SMALLERDOT)); + numeric.add(new Pair(doublee, binary.getType(), PairOperator.SMALLERDOT)); numericAdditionOrStringConcatenation.add(numeric); } /* PL auskommentiert Anfang 2018-07-17 @@ -298,7 +298,7 @@ public class TYPEStmt implements StatementVisitor{ Constraint stringConcat = new Constraint<>(); stringConcat.add(new Pair(binary.lexpr.getType(), string, PairOperator.EQUALSDOT)); stringConcat.add(new Pair(binary.rexpr.getType(), string, PairOperator.EQUALSDOT)); - stringConcat.add(new Pair(binary.getType(), string, PairOperator.EQUALSDOT)); + stringConcat.add(new Pair(string, binary.getType(), PairOperator.EQUALSDOT)); numericAdditionOrStringConcatenation.add(stringConcat); } } diff --git a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 08e57905..801cae50 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -508,39 +508,41 @@ public class TypeUnifyTask extends RecursiveTask>> { if (!result.isEmpty() && !res.isEmpty() && !isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) { //Alle Variablen bestimmen die nicht hinzugefügt wurden in a - List vars_a = a.stream().filter(x -> !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName()) + List vars_a = a.stream().filter(x -> (x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName()) ||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName()))).map(y -> (PlaceholderType)y.getLhsType()).collect(Collectors.toCollection(ArrayList::new)); Set fstElemRes = res.iterator().next(); Set 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 - List varsLast_a = a_last.stream().filter(x -> !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName()) + List varsLast_a = a_last.stream().filter(x -> (x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName()) ||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName()))).map(y -> (PlaceholderType)y.getLhsType()).collect(Collectors.toCollection(ArrayList::new)); //erstes Element genügt, da vars immer auf die gleichen Elemente zugeordnet werden muessen Set fstElemResult = result.iterator().next(); Set compResult = fstElemResult.stream().filter(x -> varsLast_a.contains(((PlaceholderType)x.getLhsType()))).collect(Collectors.toCollection(HashSet::new));; if (variance == 1) { - if (oup.compare(compResult, compRes) == -1) { + int resOfCompare = oup.compare(compResult, compRes); + if (resOfCompare == -1) { writeLog("Geloescht result: " + result); result = res; } else { - if (oup.compare(compResult, compRes) == 0) { + if (resOfCompare == 0) { result.addAll(res); } //else { - if (oup.compare(compResult, compRes) == 1) { + if (resOfCompare == 1) { writeLog("Geloescht res: " + res); //result = result; }}} else { if (variance == -1) { - if (oup.compare(compResult, compRes) == 1) { + int resOfCompare = oup.compare(compResult, compRes); + if (resOfCompare == 1) { writeLog("Geloescht result: " + result); result = res; } else { - if (oup.compare(compResult, compRes) == 0) { + if (resOfCompare == 0) { result.addAll(res); } else { - if (oup.compare(compResult, compRes) == -1) { + if (resOfCompare == -1) { writeLog("Geloescht res: " + res); //result = result; }}}}