From 51a2acdbafb56dc0df6bf868af52a79350e4ff40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Thu, 17 May 2018 11:42:03 +0200 Subject: [PATCH] modified: src/de/dhbwstuttgart/core/JavaTXCompiler.java modified: test/typeinference/UnifyTest.java --- src/de/dhbwstuttgart/core/JavaTXCompiler.java | 29 +++++++++++++++++-- test/typeinference/UnifyTest.java | 4 +-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/de/dhbwstuttgart/core/JavaTXCompiler.java index cbfb5e7e..1fdf6e86 100644 --- a/src/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -154,8 +154,33 @@ public class JavaTXCompiler { ((PlaceholderType)x.getRhsType()).disableWildcardtable(); } } - return x;HIER DIE JEWEILS RECHT BZW. LINKE SEITE AUF GLEICHE VARIANZ SETZEN WIE DIE JEWEILS ANDERE SEITE - }).collect(Collectors.toCollection(HashSet::new)); + return x;//HIER DIE JEWEILS RECHT BZW. LINKE SEITE AUF GLEICHE VARIANZ SETZEN WIE DIE JEWEILS ANDERE SEITE + })//.map( y -> { + if ((y.getLhsType() instanceof PlaceholderType) && (x.getRhsType() instanceof PlaceholderType)) { + + if (paraTypeVarNames.contains(x.getLhsType().getName())) { + ((PlaceholderType)x.getLhsType()).setVariance((byte)1); + ((PlaceholderType)x.getLhsType()).disableWildcardtable(); + } + if (returnTypeVarNames.contains(x.getLhsType().getName())) { + ((PlaceholderType)x.getLhsType()).setVariance((byte)-1); + ((PlaceholderType)x.getLhsType()).disableWildcardtable(); + } + } + if ((x.getRhsType() instanceof PlaceholderType)) { + if (paraTypeVarNames.contains(x.getRhsType().getName())) { + ((PlaceholderType)x.getRhsType()).setVariance((byte)1); + ((PlaceholderType)x.getRhsType()).disableWildcardtable(); + } + if (returnTypeVarNames.contains(x.getRhsType().getName())) { + ((PlaceholderType)x.getRhsType()).setVariance((byte)-1); + ((PlaceholderType)x.getRhsType()).disableWildcardtable(); + } + } + return x; + + if (y.getLhsType().getVariance() != 0) { y.getRhsType().setVariance(y.getLhsType().getVariance()); } }) + .collect(Collectors.toCollection(HashSet::new)); Set> result = unify.unifySequential(xConsSet, finiteClosure, logFile); //Set> result = unify.unify(xConsSet, finiteClosure); System.out.println("RESULT: " + result); diff --git a/test/typeinference/UnifyTest.java b/test/typeinference/UnifyTest.java index 41361751..ac7ef221 100644 --- a/test/typeinference/UnifyTest.java +++ b/test/typeinference/UnifyTest.java @@ -65,14 +65,14 @@ public class UnifyTest { } */ - + /* @Test public void matrix() throws IOException, ClassNotFoundException { execute(new File(rootDirectory+"Matrix.jav")); //JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+"Matrix.jav")); //compiler.generateBytecode(); } - + */ /* @Test public void vector() throws IOException, ClassNotFoundException {