From 13c70148a8b81ce7695031fc7121ddc121b29565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Tue, 13 Mar 2018 08:46:25 +0100 Subject: [PATCH] modified: ../../src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java modified: ../../src/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java modified: ../javFiles/Matrix.jav mul1 und add ergaenzt. Fehler bei elementAt: Liefert Object als Returntyp --- src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java | 5 ++++- .../typeinference/unify/model/OrderingUnifyPair.java | 3 ++- test/javFiles/Matrix.jav | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 977516b1..f8af5dd7 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -362,7 +362,10 @@ public class TypeUnifyTask extends RecursiveTask>> { } if (!result.isEmpty()) { if (variance == 1) { - if (a.equals(a_next) || (oup.compare(a, a_next) == 1)) { + if (a.iterator().next().getLhsType().getName().equals("WL")) + System.out.print(""); + if (a.equals(a_next) || + (oup.compare(a, a_next) == 1)) { System.out.print(""); break; } diff --git a/src/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java b/src/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java index c382cdff..0aa99683 100644 --- a/src/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java +++ b/src/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java @@ -117,7 +117,8 @@ public class OrderingUnifyPair extends Ordering> { Stream rseq = righteq.stream(); //right.filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT)); BinaryOperator> combiner = (x,y) -> { x.putAll(y); return x;}; HashMap hm = rseq.reduce(new HashMap(), (x, y)-> { x.put(y.getLhsType(),y); return x; }, combiner); - lseq = lseq.filter(x -> !(hm.get(x.getLhsType()) == null)); + lseq = lseq.filter(x -> !(hm.get(x.getLhsType()) == null));//NOCHMALS UEBERPRUEFEN!!!! + lseq = lseq.filter(x -> !x.equals(hm.get(x.getLhsType()))); //Elemente die gleich sind muessen nicht verglichen werden Optional si = lseq.map(x -> compareEq(x, hm.get(x.getLhsType()))).reduce((x,y)-> { if (x == y) return x; else return 0; } ); if (!si.isPresent()) return 0; else return si.get(); diff --git a/test/javFiles/Matrix.jav b/test/javFiles/Matrix.jav index e1183535..e8178ad4 100644 --- a/test/javFiles/Matrix.jav +++ b/test/javFiles/Matrix.jav @@ -3,6 +3,8 @@ import java.lang.Integer; import java.lang.Boolean; class Matrix extends Vector> { + Integer mul1(Integer x, Integer y) { return x;} + Integer add(Integer x, Integer y) { return x;} mul(m) { var ret = new Matrix(); var i = 0; @@ -14,8 +16,8 @@ class Matrix extends Vector> { var erg = 0; var k = 0; while(k < v1.size()) { - erg = erg + v1.elementAt(k) - * m.elementAt(k).elementAt(j); + erg = add(erg, mul1(v1.elementAt(k), + m.elementAt(k).elementAt(j))); k++; } v2.addElement(new Integer(erg)); j++; }