From 19a1ef40244e76c117a7f0ad3bab406bb7f54733 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Wed, 10 Jan 2018 10:53:07 +0100 Subject: [PATCH] =?UTF-8?q?Erste=20lauff=C3=A4hige=20aber=20unvollst=C3=A4?= =?UTF-8?q?ndige=20Version=20des=20UnifyWithoutWildcards?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/de/dhbwstuttgart/sat/asp/Clingo.java | 46 +++++++++++++++++++ .../dhbwstuttgart/sat/asp/model/ASPRule.java | 24 ++++++++++ .../dhbwstuttgart/sat/asp/model/ASPType.java | 4 -- .../sat/asp/parser/ASPParser.java | 17 +++++++ .../asp/parser/model/ParsedASPStatement.java | 7 +++ .../sat/asp/{ => writer}/ASPGenerator.java | 8 +--- .../sat/asp/{ => writer}/ASPWriter.java | 6 +-- .../{ => writer}/model/ASPGenericType.java | 7 +-- .../sat/asp/{ => writer}/model/ASPPair.java | 2 +- .../asp/{ => writer}/model/ASPPairEquals.java | 7 +-- .../{ => writer}/model/ASPPairSmaller.java | 11 +++-- .../{ => writer}/model/ASPPairSmallerDot.java | 7 +-- .../{ => writer}/model/ASPParameterList.java | 20 ++++---- .../asp/{ => writer}/model/ASPRefType.java | 7 +-- .../asp/{ => writer}/model/ASPStatement.java | 2 +- .../sat/asp/writer/model/ASPType.java | 4 ++ .../asp/{ => writer}/model/ASPTypeVar.java | 2 +- test/asp/ClingoTest.java | 46 +++++++++++++++++++ test/asp/typeinference/ASPTest.java | 2 +- test/asp/unifywithoutwildcards/ASPTests.java | 10 ++++ test/typeinference/JavaTXCompilerTest.java | 15 ------ 21 files changed, 193 insertions(+), 61 deletions(-) create mode 100644 src/de/dhbwstuttgart/sat/asp/Clingo.java create mode 100644 src/de/dhbwstuttgart/sat/asp/model/ASPRule.java delete mode 100644 src/de/dhbwstuttgart/sat/asp/model/ASPType.java create mode 100644 src/de/dhbwstuttgart/sat/asp/parser/ASPParser.java create mode 100644 src/de/dhbwstuttgart/sat/asp/parser/model/ParsedASPStatement.java rename src/de/dhbwstuttgart/sat/asp/{ => writer}/ASPGenerator.java (94%) rename src/de/dhbwstuttgart/sat/asp/{ => writer}/ASPWriter.java (67%) rename src/de/dhbwstuttgart/sat/asp/{ => writer}/model/ASPGenericType.java (53%) rename src/de/dhbwstuttgart/sat/asp/{ => writer}/model/ASPPair.java (90%) rename src/de/dhbwstuttgart/sat/asp/{ => writer}/model/ASPPairEquals.java (55%) rename src/de/dhbwstuttgart/sat/asp/{ => writer}/model/ASPPairSmaller.java (51%) rename src/de/dhbwstuttgart/sat/asp/{ => writer}/model/ASPPairSmallerDot.java (55%) rename src/de/dhbwstuttgart/sat/asp/{ => writer}/model/ASPParameterList.java (59%) rename src/de/dhbwstuttgart/sat/asp/{ => writer}/model/ASPRefType.java (68%) rename src/de/dhbwstuttgart/sat/asp/{ => writer}/model/ASPStatement.java (91%) create mode 100644 src/de/dhbwstuttgart/sat/asp/writer/model/ASPType.java rename src/de/dhbwstuttgart/sat/asp/{ => writer}/model/ASPTypeVar.java (83%) create mode 100644 test/asp/ClingoTest.java create mode 100644 test/asp/unifywithoutwildcards/ASPTests.java diff --git a/src/de/dhbwstuttgart/sat/asp/Clingo.java b/src/de/dhbwstuttgart/sat/asp/Clingo.java new file mode 100644 index 00000000..85f6dc56 --- /dev/null +++ b/src/de/dhbwstuttgart/sat/asp/Clingo.java @@ -0,0 +1,46 @@ +package de.dhbwstuttgart.sat.asp; + + +import org.apache.commons.io.IOUtils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class Clingo { + private final List input; + private static final List programFiles = new ArrayList<>(); + static{ + programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/basis.lp")); + programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/subst.lp")); + programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/reduce1.lp")); + programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/reduce2.lp")); + programFiles.add(new File("/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards/unify.lp")); + } + + public Clingo(List inputFiles){ + this.input = inputFiles; + } + + public String runClingo() throws IOException, InterruptedException { + String pathToClingo = + "/home/janulrich/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/clingo-5.2.1-linux-x86_64/clingo"; + List commands = new ArrayList<>(); + commands.add(pathToClingo); + commands.add("--outf=2"); //use JSON-Output + for(File file : input){ + commands.add(file.getPath()); + } + commands.addAll(programFiles.stream().map(f->f.getPath()).collect(Collectors.toList())); + Process clingo = new ProcessBuilder( commands.toArray(new String[0])).start(); + InputStream output = clingo.getInputStream(); + clingo.waitFor(); + String result = IOUtils.toString(output, StandardCharsets.UTF_8); + return result; + } +} diff --git a/src/de/dhbwstuttgart/sat/asp/model/ASPRule.java b/src/de/dhbwstuttgart/sat/asp/model/ASPRule.java new file mode 100644 index 00000000..41237547 --- /dev/null +++ b/src/de/dhbwstuttgart/sat/asp/model/ASPRule.java @@ -0,0 +1,24 @@ +package de.dhbwstuttgart.sat.asp.model; + +public enum ASPRule { + ASP_GENERIC_TYPE_NAME("genericType"), + ASP_PAIR_EQUALS_NAME("equals"), + ASP_PAIR_SMALLER_NAME("smaller"), + ASP_PAIR_SMALLER_DOT_NAME("smallerDot"), + ASP_PARAMLIST_NAME("param"), + ASP_PARAMLISTNUMERATION_NAME("paramNum"), + ASP_PARAMLIST_END_POINTER("null"), + ASP_TYPE("type") + ; + + private final String text; + + private ASPRule(final String text) { + this.text = text; + } + + @Override + public String toString() { + return text; + } +} diff --git a/src/de/dhbwstuttgart/sat/asp/model/ASPType.java b/src/de/dhbwstuttgart/sat/asp/model/ASPType.java deleted file mode 100644 index e703596c..00000000 --- a/src/de/dhbwstuttgart/sat/asp/model/ASPType.java +++ /dev/null @@ -1,4 +0,0 @@ -package de.dhbwstuttgart.sat.asp.model; - -public interface ASPType { -} diff --git a/src/de/dhbwstuttgart/sat/asp/parser/ASPParser.java b/src/de/dhbwstuttgart/sat/asp/parser/ASPParser.java new file mode 100644 index 00000000..c7be7dbc --- /dev/null +++ b/src/de/dhbwstuttgart/sat/asp/parser/ASPParser.java @@ -0,0 +1,17 @@ +package de.dhbwstuttgart.sat.asp.parser; + +import de.dhbwstuttgart.typeinference.result.ResultPair; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import java.util.HashSet; +import java.util.Set; + +public class ASPParser { + ResultSet parse(String result){ + Set ret = new HashSet<>(); + for(String pair : result.split(",")){ + + } + return new ResultSet(ret); + } +} \ No newline at end of file diff --git a/src/de/dhbwstuttgart/sat/asp/parser/model/ParsedASPStatement.java b/src/de/dhbwstuttgart/sat/asp/parser/model/ParsedASPStatement.java new file mode 100644 index 00000000..614bddb0 --- /dev/null +++ b/src/de/dhbwstuttgart/sat/asp/parser/model/ParsedASPStatement.java @@ -0,0 +1,7 @@ +package de.dhbwstuttgart.sat.asp.parser.model; + +public class ParsedASPStatement { + public ParsedASPStatement(String statement){ + + } +} diff --git a/src/de/dhbwstuttgart/sat/asp/ASPGenerator.java b/src/de/dhbwstuttgart/sat/asp/writer/ASPGenerator.java similarity index 94% rename from src/de/dhbwstuttgart/sat/asp/ASPGenerator.java rename to src/de/dhbwstuttgart/sat/asp/writer/ASPGenerator.java index 1b942ad0..002e3c7f 100644 --- a/src/de/dhbwstuttgart/sat/asp/ASPGenerator.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/ASPGenerator.java @@ -1,9 +1,8 @@ -package de.dhbwstuttgart.sat.asp; +package de.dhbwstuttgart.sat.asp.writer; -import de.dhbwstuttgart.exceptions.DebugException; import de.dhbwstuttgart.exceptions.NotImplementedException; import de.dhbwstuttgart.parser.scope.JavaClassName; -import de.dhbwstuttgart.sat.asp.model.*; +import de.dhbwstuttgart.sat.asp.writer.model.*; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory; @@ -11,13 +10,10 @@ import de.dhbwstuttgart.syntaxtree.type.*; import de.dhbwstuttgart.typeinference.constraints.Constraint; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.Pair; -import de.dhbwstuttgart.typeinference.unify.model.UnifyType; -import java.sql.Ref; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Optional; public class ASPGenerator { ASPWriter writer = new ASPWriter(); diff --git a/src/de/dhbwstuttgart/sat/asp/ASPWriter.java b/src/de/dhbwstuttgart/sat/asp/writer/ASPWriter.java similarity index 67% rename from src/de/dhbwstuttgart/sat/asp/ASPWriter.java rename to src/de/dhbwstuttgart/sat/asp/writer/ASPWriter.java index 4d33cbbf..450950d9 100644 --- a/src/de/dhbwstuttgart/sat/asp/ASPWriter.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/ASPWriter.java @@ -1,8 +1,6 @@ -package de.dhbwstuttgart.sat.asp; +package de.dhbwstuttgart.sat.asp.writer; -import de.dhbwstuttgart.sat.asp.model.ASPRefType; -import de.dhbwstuttgart.sat.asp.model.ASPStatement; -import de.dhbwstuttgart.sat.asp.model.ASPType; +import de.dhbwstuttgart.sat.asp.writer.model.ASPStatement; import java.util.HashSet; diff --git a/src/de/dhbwstuttgart/sat/asp/model/ASPGenericType.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPGenericType.java similarity index 53% rename from src/de/dhbwstuttgart/sat/asp/model/ASPGenericType.java rename to src/de/dhbwstuttgart/sat/asp/writer/model/ASPGenericType.java index 26e6ea02..57619edf 100644 --- a/src/de/dhbwstuttgart/sat/asp/model/ASPGenericType.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPGenericType.java @@ -1,7 +1,8 @@ -package de.dhbwstuttgart.sat.asp.model; +package de.dhbwstuttgart.sat.asp.writer.model; + +import de.dhbwstuttgart.sat.asp.model.ASPRule; public class ASPGenericType implements ASPType{ - public static final String ASP_GENERIC_TYPE_NAME = "genericType"; private final String name; public ASPGenericType(String name){ @@ -9,6 +10,6 @@ public class ASPGenericType implements ASPType{ } public String toString(){ - return ASP_GENERIC_TYPE_NAME + "(" + name + ")"; + return ASPRule.ASP_GENERIC_TYPE_NAME + "(" + name + ")"; } } diff --git a/src/de/dhbwstuttgart/sat/asp/model/ASPPair.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPair.java similarity index 90% rename from src/de/dhbwstuttgart/sat/asp/model/ASPPair.java rename to src/de/dhbwstuttgart/sat/asp/writer/model/ASPPair.java index bbd3ff3f..662f995c 100644 --- a/src/de/dhbwstuttgart/sat/asp/model/ASPPair.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPair.java @@ -1,4 +1,4 @@ -package de.dhbwstuttgart.sat.asp.model; +package de.dhbwstuttgart.sat.asp.writer.model; public abstract class ASPPair { public final ASPType leftSide; diff --git a/src/de/dhbwstuttgart/sat/asp/model/ASPPairEquals.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairEquals.java similarity index 55% rename from src/de/dhbwstuttgart/sat/asp/model/ASPPairEquals.java rename to src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairEquals.java index b67920bd..8806f2ce 100644 --- a/src/de/dhbwstuttgart/sat/asp/model/ASPPairEquals.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairEquals.java @@ -1,13 +1,14 @@ -package de.dhbwstuttgart.sat.asp.model; +package de.dhbwstuttgart.sat.asp.writer.model; + +import de.dhbwstuttgart.sat.asp.model.ASPRule; public class ASPPairEquals extends ASPPair{ - private final static String ASP_PAIR_EQUALS_NAME = "equals"; public ASPPairEquals(ASPType ls, ASPType rs){ super(ls, rs); } @Override protected String getRuleName() { - return ASP_PAIR_EQUALS_NAME; + return ASPRule.ASP_PAIR_EQUALS_NAME.toString(); } } diff --git a/src/de/dhbwstuttgart/sat/asp/model/ASPPairSmaller.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmaller.java similarity index 51% rename from src/de/dhbwstuttgart/sat/asp/model/ASPPairSmaller.java rename to src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmaller.java index 882054cc..f57170f6 100644 --- a/src/de/dhbwstuttgart/sat/asp/model/ASPPairSmaller.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmaller.java @@ -1,13 +1,16 @@ -package de.dhbwstuttgart.sat.asp.model; +package de.dhbwstuttgart.sat.asp.writer.model; + +import de.dhbwstuttgart.sat.asp.model.ASPRule; + +import java.util.Map; public class ASPPairSmaller extends ASPPair{ - private final static String ASP_PAIR_SMALLER_NAME = "smaller"; public ASPPairSmaller(ASPType ls, ASPType rs){ super(ls, rs); } @Override protected String getRuleName() { - return ASP_PAIR_SMALLER_NAME; + return ASPRule.ASP_PAIR_SMALLER_NAME.toString(); } -} +} \ No newline at end of file diff --git a/src/de/dhbwstuttgart/sat/asp/model/ASPPairSmallerDot.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmallerDot.java similarity index 55% rename from src/de/dhbwstuttgart/sat/asp/model/ASPPairSmallerDot.java rename to src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmallerDot.java index 0e6598c1..e8482bfc 100644 --- a/src/de/dhbwstuttgart/sat/asp/model/ASPPairSmallerDot.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmallerDot.java @@ -1,13 +1,14 @@ -package de.dhbwstuttgart.sat.asp.model; +package de.dhbwstuttgart.sat.asp.writer.model; + +import de.dhbwstuttgart.sat.asp.model.ASPRule; public class ASPPairSmallerDot extends ASPPair{ - private final static String ASP_PAIR_SMALLER_NAME = "smallerDot"; public ASPPairSmallerDot(ASPType ls, ASPType rs){ super(ls, rs); } @Override protected String getRuleName() { - return ASP_PAIR_SMALLER_NAME; + return ASPRule.ASP_PAIR_SMALLER_DOT_NAME.toString(); } } diff --git a/src/de/dhbwstuttgart/sat/asp/model/ASPParameterList.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPParameterList.java similarity index 59% rename from src/de/dhbwstuttgart/sat/asp/model/ASPParameterList.java rename to src/de/dhbwstuttgart/sat/asp/writer/model/ASPParameterList.java index 46eed10a..3c176e49 100644 --- a/src/de/dhbwstuttgart/sat/asp/model/ASPParameterList.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPParameterList.java @@ -1,18 +1,14 @@ -package de.dhbwstuttgart.sat.asp.model; +package de.dhbwstuttgart.sat.asp.writer.model; -import de.dhbwstuttgart.sat.asp.ASPGenerator; -import de.dhbwstuttgart.sat.asp.ASPWriter; +import de.dhbwstuttgart.sat.asp.model.ASPRule; +import de.dhbwstuttgart.sat.asp.writer.ASPGenerator; +import de.dhbwstuttgart.sat.asp.writer.ASPWriter; import de.dhbwstuttgart.syntaxtree.factory.NameGenerator; -import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Set; public class ASPParameterList { - private final static String ASP_PARAMLIST_NAME = "param"; - private final static String ASP_PARAMLISTNUMERATION_NAME = "paramNum"; - private final static String ASP_PARAMLIST_END_POINTER = "null"; public final String name; private final List types; @@ -20,7 +16,7 @@ public class ASPParameterList { int paramNum = 0; this.types = types; if(types.size() == 0){ - name = ASP_PARAMLIST_END_POINTER; + name = ASPRule.ASP_PARAMLIST_END_POINTER.toString(); }else{ name = newName(); String nextPointer = name; @@ -29,10 +25,10 @@ public class ASPParameterList { ASPType t = it.next(); String param = nextPointer + "," + t.toString() + ","; nextPointer = newName(); - if(! it.hasNext())nextPointer = ASP_PARAMLIST_END_POINTER; + if(! it.hasNext())nextPointer = ASPRule.ASP_PARAMLIST_END_POINTER.toString(); param += nextPointer; - writer.add(new ASPStatement(ASP_PARAMLIST_NAME + "(" + param + ")")); - writer.add(new ASPStatement(ASP_PARAMLISTNUMERATION_NAME + "(" + name + "," +t + "," + paramNum + ")")); + writer.add(new ASPStatement(ASPRule.ASP_PARAMLIST_NAME + "(" + param + ")")); + writer.add(new ASPStatement(ASPRule.ASP_PARAMLISTNUMERATION_NAME + "(" + name + "," +t + "," + paramNum + ")")); paramNum++; //paramDefinitions.add(new ASPStatement(ASP_PARAMLIST_NAME + "(" + param + ")")); } diff --git a/src/de/dhbwstuttgart/sat/asp/model/ASPRefType.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPRefType.java similarity index 68% rename from src/de/dhbwstuttgart/sat/asp/model/ASPRefType.java rename to src/de/dhbwstuttgart/sat/asp/writer/model/ASPRefType.java index ba318876..6491ff33 100644 --- a/src/de/dhbwstuttgart/sat/asp/model/ASPRefType.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPRefType.java @@ -1,7 +1,8 @@ -package de.dhbwstuttgart.sat.asp.model; +package de.dhbwstuttgart.sat.asp.writer.model; + +import de.dhbwstuttgart.sat.asp.model.ASPRule; public class ASPRefType implements ASPType { - public static final String ASP_TYPE = "type"; private final ASPParameterList params; private final String name; @@ -15,6 +16,6 @@ public class ASPRefType implements ASPType { } public String toString(){ - return ASP_TYPE + "(" + name +"," + params.name + ")"; + return ASPRule.ASP_TYPE + "(" + name +"," + params.name + ")"; } } diff --git a/src/de/dhbwstuttgart/sat/asp/model/ASPStatement.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPStatement.java similarity index 91% rename from src/de/dhbwstuttgart/sat/asp/model/ASPStatement.java rename to src/de/dhbwstuttgart/sat/asp/writer/model/ASPStatement.java index 8e4a1d35..76bb63e8 100644 --- a/src/de/dhbwstuttgart/sat/asp/model/ASPStatement.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPStatement.java @@ -1,4 +1,4 @@ -package de.dhbwstuttgart.sat.asp.model; +package de.dhbwstuttgart.sat.asp.writer.model; public class ASPStatement { private final String stmt; diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPType.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPType.java new file mode 100644 index 00000000..da694218 --- /dev/null +++ b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPType.java @@ -0,0 +1,4 @@ +package de.dhbwstuttgart.sat.asp.writer.model; + +public interface ASPType { +} diff --git a/src/de/dhbwstuttgart/sat/asp/model/ASPTypeVar.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPTypeVar.java similarity index 83% rename from src/de/dhbwstuttgart/sat/asp/model/ASPTypeVar.java rename to src/de/dhbwstuttgart/sat/asp/writer/model/ASPTypeVar.java index e2f87636..4b07d30b 100644 --- a/src/de/dhbwstuttgart/sat/asp/model/ASPTypeVar.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPTypeVar.java @@ -1,4 +1,4 @@ -package de.dhbwstuttgart.sat.asp.model; +package de.dhbwstuttgart.sat.asp.writer.model; public class ASPTypeVar implements ASPType{ private final String name; diff --git a/test/asp/ClingoTest.java b/test/asp/ClingoTest.java new file mode 100644 index 00000000..dbfa70d8 --- /dev/null +++ b/test/asp/ClingoTest.java @@ -0,0 +1,46 @@ +package asp; + +import de.dhbwstuttgart.parser.NullToken; +import de.dhbwstuttgart.sat.asp.writer.ASPGenerator; +import de.dhbwstuttgart.sat.asp.Clingo; +import de.dhbwstuttgart.syntaxtree.ClassOrInterface; +import de.dhbwstuttgart.syntaxtree.factory.ASTFactory; +import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; +import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; +import de.dhbwstuttgart.typeinference.constraints.Pair; +import de.dhbwstuttgart.typeinference.unify.model.PairOperator; +import org.junit.Test; + +import java.io.*; +import java.util.*; + +public class ClingoTest { + public static final String rootDirectory = "~/Sync/HiwiJob/ResearchPapers/MasterarbeitStadelmeier/asp/unifyWithoutWildcards"; + public static final String tempDirectory = "/tmp/"; + + @Test + public void test() throws IOException, InterruptedException { + String content = ""; + content = new ASPGenerator(this.getPairs(), this.getFC()).getASP(); + + PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8"); + writer.println(content); + writer.close(); + + Clingo clingo = new Clingo(Arrays.asList(new File(tempDirectory + "test.lp"))); + System.out.println(clingo.runClingo()); + } + + public Collection getFC() { + Set ret = new HashSet<>(); + ret.add(ASTFactory.createObjectClass()); + ret.add(ASTFactory.createClass(java.util.List.class)); + return ret; + } + + public ConstraintSet getPairs() { + ConstraintSet ret = new ConstraintSet<>(); + ret.addUndConstraint(new Pair(TypePlaceholder.fresh(new NullToken()), ASTFactory.createObjectType(), PairOperator.SMALLERDOT)); + return ret; + } +} diff --git a/test/asp/typeinference/ASPTest.java b/test/asp/typeinference/ASPTest.java index 5074e4f3..b41d9405 100644 --- a/test/asp/typeinference/ASPTest.java +++ b/test/asp/typeinference/ASPTest.java @@ -1,7 +1,7 @@ package asp.typeinference; import de.dhbwstuttgart.core.JavaTXCompiler; -import de.dhbwstuttgart.sat.asp.ASPGenerator; +import de.dhbwstuttgart.sat.asp.writer.ASPGenerator; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; diff --git a/test/asp/unifywithoutwildcards/ASPTests.java b/test/asp/unifywithoutwildcards/ASPTests.java new file mode 100644 index 00000000..80e7bb78 --- /dev/null +++ b/test/asp/unifywithoutwildcards/ASPTests.java @@ -0,0 +1,10 @@ +package asp.unifywithoutwildcards; + +import org.junit.Test; + +public class ASPTests { + @Test + public void test(){ + + } +} diff --git a/test/typeinference/JavaTXCompilerTest.java b/test/typeinference/JavaTXCompilerTest.java index fbbed9af..f4622954 100644 --- a/test/typeinference/JavaTXCompilerTest.java +++ b/test/typeinference/JavaTXCompilerTest.java @@ -1,29 +1,15 @@ package typeinference; import de.dhbwstuttgart.core.JavaTXCompiler; -import de.dhbwstuttgart.parser.scope.JavaClassName; -import de.dhbwstuttgart.sat.asp.ASPGenerator; -import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.SourceFile; -import de.dhbwstuttgart.syntaxtree.factory.ASTFactory; -import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory; import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; import de.dhbwstuttgart.typedeployment.TypeInsert; import de.dhbwstuttgart.typedeployment.TypeInsertFactory; -import de.dhbwstuttgart.typeinference.constraints.Constraint; -import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; -import de.dhbwstuttgart.typeinference.constraints.Pair; import de.dhbwstuttgart.typeinference.result.ResultSet; -import de.dhbwstuttgart.typeinference.typeAlgo.TYPE; -import de.dhbwstuttgart.typeinference.unify.TypeUnify; -import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure; -import de.dhbwstuttgart.typeinference.unify.model.UnifyPair; import org.junit.Test; import java.io.File; import java.io.IOException; -import java.net.URL; -import java.net.URLClassLoader; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -32,7 +18,6 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; public class JavaTXCompilerTest {