From dad9e587635c69cf180bd8d4f94b962c06a595ff Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Tue, 17 Jul 2018 19:56:01 +0200 Subject: [PATCH] Fehler beheben --- src/de/dhbwstuttgart/core/JavaTXCompiler.java | 1 - .../SyntaxTreeGenerator/FCGenerator.java | 15 ++++++++++++++- src/de/dhbwstuttgart/sat/asp/ASPUnify.java | 19 +++++++++++-------- .../sat/asp/parser/ASPParser.java | 3 ++- test/asp/ClingoTest.java | 4 ++-- test/asp/gencay/GeneratorTest.java | 3 +-- .../withWildcards/JavaTXCompilerASPTest.java | 5 ++++- test/asp/withWildcards/ProduceFC.java | 1 - 8 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/de/dhbwstuttgart/core/JavaTXCompiler.java index 0a73ef6e..ec596b25 100644 --- a/src/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -8,7 +8,6 @@ import de.dhbwstuttgart.parser.SyntaxTreeGenerator.SyntaxTreeGenerator; import de.dhbwstuttgart.parser.antlr.Java8Parser.CompilationUnitContext; import de.dhbwstuttgart.parser.scope.JavaClassName; import de.dhbwstuttgart.sat.asp.ASPUnify; -import de.dhbwstuttgart.sat.asp.ASPUnifyWithoutWildcards; import de.dhbwstuttgart.sat.asp.parser.ASPParser; import de.dhbwstuttgart.sat.asp.writer.ASPFactory; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/FCGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/FCGenerator.java index 0da69ba1..371efe39 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/FCGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator/FCGenerator.java @@ -26,6 +26,18 @@ public class FCGenerator { return toFC(availableClasses).stream().map(t -> UnifyTypeFactory.convert(t)).collect(Collectors.toSet()); } + /* + Hier entstehen unnötige Typpaare + wenn es mehrere Vererbungsketten gibt + Beispiel: + * X < Y + * X < Y + Will man dies aber rausnehmen, muss man die andere Kette umbenennen. + Schwierig/Unmöglich, dank mehrfachvererbung + * Z < X < Y + * Z < X < Y + + */ public static Collection toFC(Collection availableClasses) throws ClassNotFoundException { HashMap pairs = new HashMap<>(); TypePrinter printer = new TypePrinter(); @@ -135,13 +147,14 @@ public class FCGenerator { * X < Y * so bekommen sie hier den gleichen Namen zugewiesen und werden in der HashMap aussortiert * X < Y - */ + private static class TypePrinterExcludingTPHs extends TypePrinter{ @Override public String visit(TypePlaceholder typePlaceholder) { return "TPH"; } } + */ /** * Tauscht die GTVs in einem Typ gegen die entsprechenden Typen in der übergebenen Map aus. diff --git a/src/de/dhbwstuttgart/sat/asp/ASPUnify.java b/src/de/dhbwstuttgart/sat/asp/ASPUnify.java index d5236890..0e815ffc 100644 --- a/src/de/dhbwstuttgart/sat/asp/ASPUnify.java +++ b/src/de/dhbwstuttgart/sat/asp/ASPUnify.java @@ -14,15 +14,17 @@ import java.util.stream.Collectors; public class ASPUnify { private final List input; private static final List programFiles = new ArrayList<>(); + + private static final String aspDirectory = System.getProperty("user.dir")+"/asp/"; static{ - programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/complete/fc.lp")); - programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/complete/reduceRules.lp")); - programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/complete/adaptRules.lp")); - programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/complete/step4.lp")); - programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/complete/subst.lp")); - programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/complete/unifikation.lp")); - programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/complete/cartesian.lp")); - programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/complete/result.lp")); + programFiles.add(new File(aspDirectory + "fc.lp")); + programFiles.add(new File(aspDirectory + "reduceRules.lp")); + programFiles.add(new File(aspDirectory + "adaptRules.lp")); + programFiles.add(new File(aspDirectory + "step4.lp")); + programFiles.add(new File(aspDirectory + "subst.lp")); + programFiles.add(new File(aspDirectory + "unifikation.lp")); + programFiles.add(new File(aspDirectory + "cartesian.lp")); + programFiles.add(new File(aspDirectory + "result.lp")); } public ASPUnify(List inputFiles){ @@ -52,6 +54,7 @@ public class ASPUnify { InputStream output = clingo.getInputStream(); clingo.waitFor(); String result = IOUtils.toString(output, StandardCharsets.UTF_8); + System.out.println(result); return result; } } diff --git a/src/de/dhbwstuttgart/sat/asp/parser/ASPParser.java b/src/de/dhbwstuttgart/sat/asp/parser/ASPParser.java index 7a43a123..7e5b45e6 100644 --- a/src/de/dhbwstuttgart/sat/asp/parser/ASPParser.java +++ b/src/de/dhbwstuttgart/sat/asp/parser/ASPParser.java @@ -173,7 +173,8 @@ public class ASPParser extends ASPResultBaseListener { String tp1 = e.parameterList().value(0).getText(); String tp2 = e.parameterList().value(1).getText(); if(tphs.contains(tp1) && tphs.contains(tp2)){ - ret.add(new PairTPHEqualTPH((TypePlaceholder) types.get(tp1), (TypePlaceholder) types.get(tp2))); + //Diese kann man ignorieren. Sollten eigentlich nicht auftauchen + //ret.add(new PairTPHEqualTPH((TypePlaceholder) types.get(tp1), (TypePlaceholder) types.get(tp2))); }else if(tphs.contains(tp1)){ if(types.containsKey(tp2)) ret.add(new PairTPHequalRefTypeOrWildcardType((TypePlaceholder) types.get(tp1), types.get(tp2))); diff --git a/test/asp/ClingoTest.java b/test/asp/ClingoTest.java index ade2029b..7b6f8c1c 100644 --- a/test/asp/ClingoTest.java +++ b/test/asp/ClingoTest.java @@ -1,7 +1,7 @@ package asp; import de.dhbwstuttgart.parser.NullToken; -import de.dhbwstuttgart.sat.asp.ASPUnifyWithoutWildcards; +import de.dhbwstuttgart.sat.asp.ASPUnify; import de.dhbwstuttgart.sat.asp.parser.ASPParser; import de.dhbwstuttgart.sat.asp.writer.ASPFactory; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; @@ -29,7 +29,7 @@ public class ClingoTest { writer.println(content); writer.close(); - ASPUnifyWithoutWildcards clingo = new ASPUnifyWithoutWildcards(Arrays.asList(new File(tempDirectory + "test.lp"))); + ASPUnify clingo = new ASPUnify(Arrays.asList(new File(tempDirectory + "test.lp"))); String result = clingo.runClingo(); System.out.println(result); ResultSet resultSet = ASPParser.parse(result, Arrays.asList(testType)); diff --git a/test/asp/gencay/GeneratorTest.java b/test/asp/gencay/GeneratorTest.java index 5c3f0a9f..5394b18a 100644 --- a/test/asp/gencay/GeneratorTest.java +++ b/test/asp/gencay/GeneratorTest.java @@ -1,6 +1,5 @@ package asp.gencay; -import asp.UnifyWithoutWildcards; import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.parser.scope.JavaClassName; import de.dhbwstuttgart.sat.asp.writer.ASPFactoryAlternative; @@ -17,7 +16,7 @@ import org.junit.Test; import java.util.*; -public class GeneratorTest extends UnifyWithoutWildcards{ +public class GeneratorTest { @Test public void simple() throws ClassNotFoundException { ConstraintSet testSet = new ConstraintSet<>(); diff --git a/test/asp/withWildcards/JavaTXCompilerASPTest.java b/test/asp/withWildcards/JavaTXCompilerASPTest.java index e2faa589..dd2fd9f7 100644 --- a/test/asp/withWildcards/JavaTXCompilerASPTest.java +++ b/test/asp/withWildcards/JavaTXCompilerASPTest.java @@ -24,6 +24,7 @@ public class JavaTXCompilerASPTest { public static final String rootDirectory = System.getProperty("user.dir")+"/test/javFiles/"; + /* @Test public void finiteClosure() throws IOException, ClassNotFoundException, InterruptedException { execute(new File(rootDirectory+"fc.jav")); @@ -69,10 +70,12 @@ public class JavaTXCompilerASPTest { public void packageTests() throws IOException, ClassNotFoundException, InterruptedException { execute(new File(rootDirectory+"Package.jav")); } + */ @Test public void vector() throws IOException, ClassNotFoundException, InterruptedException { execute(new File(rootDirectory+"Vector.jav")); } + /* @Test public void lambdaRunnable() throws IOException, ClassNotFoundException, InterruptedException { execute(new File(rootDirectory+"LambdaRunnable.jav")); @@ -85,7 +88,7 @@ public class JavaTXCompilerASPTest { public void addLong() throws IOException, ClassNotFoundException, InterruptedException { execute(new File(rootDirectory+"AddLong.jav")); } - + */ private static class TestResultSet{ } diff --git a/test/asp/withWildcards/ProduceFC.java b/test/asp/withWildcards/ProduceFC.java index c6883921..8b6f3d16 100644 --- a/test/asp/withWildcards/ProduceFC.java +++ b/test/asp/withWildcards/ProduceFC.java @@ -1,6 +1,5 @@ package asp.withWildcards; -import de.dhbwstuttgart.sat.asp.ASPUnifyWithoutWildcards; import de.dhbwstuttgart.sat.asp.Clingo; import de.dhbwstuttgart.sat.asp.writer.ASPFactory; import de.dhbwstuttgart.syntaxtree.ClassOrInterface;