From e8388e2748a74ae66ace9805fe6329cc0bef3166 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Wed, 7 Mar 2018 22:42:05 +0100 Subject: [PATCH] =?UTF-8?q?Aufr=C3=A4umen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sat/asp/writer/ASPFactory.java | 6 - .../sat/asp/writer/ASPGenerator.java | 104 ------------------ .../asp/writer/{model => }/ASPStatement.java | 2 +- .../sat/asp/writer/ASPWriter.java | 2 - .../sat/asp/writer/model/ASPFCType.java | 14 --- .../sat/asp/writer/model/ASPGenericType.java | 25 ----- .../sat/asp/writer/model/ASPPair.java | 24 ---- .../sat/asp/writer/model/ASPPairEquals.java | 15 --- .../sat/asp/writer/model/ASPPairSmaller.java | 17 --- .../asp/writer/model/ASPPairSmallerDot.java | 15 --- .../asp/writer/model/ASPParameterList.java | 45 -------- .../sat/asp/writer/model/ASPRefType.java | 26 ----- .../sat/asp/writer/model/ASPType.java | 5 - .../sat/asp/writer/model/ASPTypeVar.java | 27 ----- 14 files changed, 1 insertion(+), 326 deletions(-) delete mode 100644 src/de/dhbwstuttgart/sat/asp/writer/ASPGenerator.java rename src/de/dhbwstuttgart/sat/asp/writer/{model => }/ASPStatement.java (91%) delete mode 100644 src/de/dhbwstuttgart/sat/asp/writer/model/ASPFCType.java delete mode 100644 src/de/dhbwstuttgart/sat/asp/writer/model/ASPGenericType.java delete mode 100644 src/de/dhbwstuttgart/sat/asp/writer/model/ASPPair.java delete mode 100644 src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairEquals.java delete mode 100644 src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmaller.java delete mode 100644 src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmallerDot.java delete mode 100644 src/de/dhbwstuttgart/sat/asp/writer/model/ASPParameterList.java delete mode 100644 src/de/dhbwstuttgart/sat/asp/writer/model/ASPRefType.java delete mode 100644 src/de/dhbwstuttgart/sat/asp/writer/model/ASPType.java delete mode 100644 src/de/dhbwstuttgart/sat/asp/writer/model/ASPTypeVar.java diff --git a/src/de/dhbwstuttgart/sat/asp/writer/ASPFactory.java b/src/de/dhbwstuttgart/sat/asp/writer/ASPFactory.java index ab6ef51b..8afce74c 100644 --- a/src/de/dhbwstuttgart/sat/asp/writer/ASPFactory.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/ASPFactory.java @@ -4,18 +4,12 @@ import de.dhbwstuttgart.exceptions.NotImplementedException; import de.dhbwstuttgart.parser.SyntaxTreeGenerator.FCGenerator; import de.dhbwstuttgart.sat.asp.ASPStringConverter; import de.dhbwstuttgart.sat.asp.model.ASPRule; -import de.dhbwstuttgart.sat.asp.writer.model.ASPStatement; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; import de.dhbwstuttgart.syntaxtree.factory.NameGenerator; -import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory; 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.result.PairTPHEqualTPH; -import de.dhbwstuttgart.typeinference.result.PairTPHequalRefTypeOrWildcardType; -import de.dhbwstuttgart.typeinference.result.PairTPHsmallerTPH; -import de.dhbwstuttgart.typeinference.result.ResultSetVisitor; import de.dhbwstuttgart.typeinference.unify.model.PairOperator; import java.util.*; diff --git a/src/de/dhbwstuttgart/sat/asp/writer/ASPGenerator.java b/src/de/dhbwstuttgart/sat/asp/writer/ASPGenerator.java deleted file mode 100644 index a3752fcc..00000000 --- a/src/de/dhbwstuttgart/sat/asp/writer/ASPGenerator.java +++ /dev/null @@ -1,104 +0,0 @@ -package de.dhbwstuttgart.sat.asp.writer; - -import de.dhbwstuttgart.exceptions.NotImplementedException; -import de.dhbwstuttgart.parser.SyntaxTreeGenerator.FCGenerator; -import de.dhbwstuttgart.sat.asp.ASPStringConverter; -import de.dhbwstuttgart.sat.asp.writer.model.*; -import de.dhbwstuttgart.syntaxtree.ClassOrInterface; -import de.dhbwstuttgart.syntaxtree.GenericTypeVar; -import de.dhbwstuttgart.syntaxtree.type.*; -import de.dhbwstuttgart.typeinference.constraints.Constraint; -import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; -import de.dhbwstuttgart.typeinference.constraints.Pair; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -public class ASPGenerator { - ASPWriter writer = new ASPWriter(); -/* - public ASPGenerator(ConstraintSet constraints, Collection fcClasses) throws ClassNotFoundException { - List> constraints1 = constraints.cartesianProduct().iterator().next(); - List constraintPairs = new ArrayList<>(); - for(Constraint constraint : constraints1){ - constraintPairs.addAll(constraint); - } - asp = toASP(constraintPairs, FCGenerator.toFC(fcClasses)); - } - */ - - public String getASP(){ - return ""; - } - - private String toASP(List constraintSet, Collection fc){ - TypeConverter converter = new TypeConverter(); - for(Pair fcp : fc){ - //Wenn dieser Cast fehlschlägt stimmt etwas nicht. Alle Paare in der FC müssen smaller Operatoren haen - convert(fcp); - } - for(Pair cons : constraintSet){ - convert(cons); - } - - return writer.getASPFile(); - } - - private ASPPair convert(Pair pair){ - TypeConverter converter = new TypeConverter(); - ASPType ls = pair.TA1.acceptTV(converter); - ASPType rs = pair.TA2.acceptTV(converter); - if(pair.OperatorEqual()){ - return new ASPPairEquals(ls, rs,writer); - }else if(pair.OperatorSmallerDot()){ - return new ASPPairSmallerDot(ls, rs, writer); - }else if(pair.OperatorSmaller()){ - //Diese Cast müssen auch immer funktionieren, da in smaller Constraints nur RefTypes vorkommen - return new ASPPairSmaller(new ASPFCType((ASPRefType) ls), new ASPFCType((ASPRefType) rs), writer); - }else throw new NotImplementedException(); - } - - private ASPRefType convert(ClassOrInterface cl){ - List paramList = new ArrayList<>(); - for(GenericTypeVar gtv : cl.getGenerics()){ - paramList.add(new ASPGenericType(ASPStringConverter.toConstant(gtv.getName()))); - } - ASPParameterList params = new ASPParameterList(paramList, writer); - return new ASPRefType(ASPStringConverter.toConstant(cl.getClassName()), params); - } - - private class TypeConverter implements TypeVisitor{ - - @Override - public ASPType visit(RefType type) { - List paramList = new ArrayList<>(); - for(RefTypeOrTPHOrWildcardOrGeneric gtv : type.getParaList()){ - paramList.add(gtv.acceptTV(this)); - } - ASPParameterList params = new ASPParameterList(paramList, writer); - return new ASPRefType(ASPStringConverter.toConstant(type.getName()), params); - } - - @Override - public ASPType visit(SuperWildcardType superWildcardType) { - throw new NotImplementedException(); - } - - @Override - public ASPType visit(TypePlaceholder typePlaceholder) { - return new ASPTypeVar(ASPStringConverter.toConstant(typePlaceholder.getName()),writer); - } - - @Override - public ASPType visit(ExtendsWildcardType extendsWildcardType) { - throw new NotImplementedException(); - } - - @Override - public ASPType visit(GenericRefType genericRefType) { - return new ASPRefType(ASPStringConverter.toConstant(genericRefType.getParsedName()), - new ASPParameterList(new ArrayList<>(), writer)); - } - } -} diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPStatement.java b/src/de/dhbwstuttgart/sat/asp/writer/ASPStatement.java similarity index 91% rename from src/de/dhbwstuttgart/sat/asp/writer/model/ASPStatement.java rename to src/de/dhbwstuttgart/sat/asp/writer/ASPStatement.java index 76bb63e8..8d342464 100644 --- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPStatement.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/ASPStatement.java @@ -1,4 +1,4 @@ -package de.dhbwstuttgart.sat.asp.writer.model; +package de.dhbwstuttgart.sat.asp.writer; public class ASPStatement { private final String stmt; diff --git a/src/de/dhbwstuttgart/sat/asp/writer/ASPWriter.java b/src/de/dhbwstuttgart/sat/asp/writer/ASPWriter.java index 450950d9..e5e60882 100644 --- a/src/de/dhbwstuttgart/sat/asp/writer/ASPWriter.java +++ b/src/de/dhbwstuttgart/sat/asp/writer/ASPWriter.java @@ -1,7 +1,5 @@ package de.dhbwstuttgart.sat.asp.writer; -import de.dhbwstuttgart.sat.asp.writer.model.ASPStatement; - import java.util.HashSet; public class ASPWriter { diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPFCType.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPFCType.java deleted file mode 100644 index 790fd5af..00000000 --- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPFCType.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.dhbwstuttgart.sat.asp.writer.model; - -import de.dhbwstuttgart.sat.asp.model.ASPRule; -import de.dhbwstuttgart.sat.asp.writer.ASPWriter; - -public class ASPFCType extends ASPRefType { - public ASPFCType(ASPRefType refType){ - super(refType.name, refType.params); - } - - public String toString(){ - return ASPRule.ASP_FCTYPE + "(" + name +"," + params.name + ")"; - } -} diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPGenericType.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPGenericType.java deleted file mode 100644 index 327ce04a..00000000 --- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPGenericType.java +++ /dev/null @@ -1,25 +0,0 @@ -package de.dhbwstuttgart.sat.asp.writer.model; - -import de.dhbwstuttgart.sat.asp.model.ASPRule; -import de.dhbwstuttgart.sat.asp.writer.ASPWriter; - -public class ASPGenericType implements ASPType{ - private final String name; - - public ASPGenericType(String name){ - this.name = name; - } - - public String toString(){ - return ASPRule.ASP_GENERIC_TYPE_NAME + "(" + name + ")"; - } - - private String toASP() { - return ASPRule.ASP_GENERIC_TYPE_NAME + "(" + name + ")"; - } - - @Override - public String getPointer() { - return name; - } -} diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPair.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPair.java deleted file mode 100644 index e881f346..00000000 --- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPair.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.dhbwstuttgart.sat.asp.writer.model; - -import de.dhbwstuttgart.sat.asp.writer.ASPWriter; - -public abstract class ASPPair { - public final ASPType leftSide; - public final ASPType rightSide; - - public ASPPair(ASPType ls, ASPType rs, ASPWriter writer){ - this.leftSide = ls; - this.rightSide = rs; - writer.add(new ASPStatement(toASP())); - } - - private String toASP(){ - return this.getRuleName() + "(" + leftSide.getPointer() + ","+ rightSide.getPointer() + ")"; - } - - public String toString(){ - return toASP(); - } - - protected abstract String getRuleName(); -} diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairEquals.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairEquals.java deleted file mode 100644 index bf6e2485..00000000 --- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairEquals.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.dhbwstuttgart.sat.asp.writer.model; - -import de.dhbwstuttgart.sat.asp.model.ASPRule; -import de.dhbwstuttgart.sat.asp.writer.ASPWriter; - -public class ASPPairEquals extends ASPPair{ - public ASPPairEquals(ASPType ls, ASPType rs, ASPWriter writer){ - super(ls, rs, writer); - } - - @Override - protected String getRuleName() { - return ASPRule.ASP_PAIR_EQUALS_NAME.toString(); - } -} diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmaller.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmaller.java deleted file mode 100644 index 610e5c56..00000000 --- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmaller.java +++ /dev/null @@ -1,17 +0,0 @@ -package de.dhbwstuttgart.sat.asp.writer.model; - -import de.dhbwstuttgart.sat.asp.model.ASPRule; -import de.dhbwstuttgart.sat.asp.writer.ASPWriter; - -import java.util.Map; - -public class ASPPairSmaller extends ASPPair{ - public ASPPairSmaller(ASPFCType ls, ASPFCType rs, ASPWriter writer){ - super(ls, rs, writer); - } - - @Override - protected String getRuleName() { - return ASPRule.ASP_PAIR_SMALLER_NAME.toString(); - } -} \ No newline at end of file diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmallerDot.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmallerDot.java deleted file mode 100644 index b572ed99..00000000 --- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPPairSmallerDot.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.dhbwstuttgart.sat.asp.writer.model; - -import de.dhbwstuttgart.sat.asp.model.ASPRule; -import de.dhbwstuttgart.sat.asp.writer.ASPWriter; - -public class ASPPairSmallerDot extends ASPPair{ - public ASPPairSmallerDot(ASPType ls, ASPType rs, ASPWriter writer){ - super(ls, rs, writer); - } - - @Override - protected String getRuleName() { - return ASPRule.ASP_PAIR_SMALLER_DOT_NAME.toString(); - } -} diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPParameterList.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPParameterList.java deleted file mode 100644 index fafa50f5..00000000 --- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPParameterList.java +++ /dev/null @@ -1,45 +0,0 @@ -package de.dhbwstuttgart.sat.asp.writer.model; - -import de.dhbwstuttgart.sat.asp.ASPStringConverter; -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.Iterator; -import java.util.List; - -public class ASPParameterList { - public final String name; - private final List types; - - public ASPParameterList(List types, ASPWriter writer){ - int paramNum = 0; - this.types = types; - if(types.size() == 0){ - name = ASPRule.ASP_PARAMLIST_END_POINTER.toString(); - }else{ - name = newName(); - String nextPointer = name; - Iterator it = types.iterator(); - while(it.hasNext()){ - ASPType t = it.next(); - String param = nextPointer + "," + t.toString() + ","; - nextPointer = newName(); - if(! it.hasNext())nextPointer = ASPRule.ASP_PARAMLIST_END_POINTER.toString(); - param += nextPointer; - writer.add(new ASPStatement(ASPRule.ASP_PARAMLIST_NAME + "(" + param + ")")); - writer.add(new ASPStatement(ASPRule.ASP_PARAMLISTNUMERATION_NAME + "(" + name + "," + t.getPointer() + "," + paramNum + ")")); - paramNum++; - } - } - } - - private String newName() { - return ASPStringConverter.toConstant(NameGenerator.makeNewName()); - } - - public String toString(){ - return name; - } -} diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPRefType.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPRefType.java deleted file mode 100644 index 46a4d1c7..00000000 --- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPRefType.java +++ /dev/null @@ -1,26 +0,0 @@ -package de.dhbwstuttgart.sat.asp.writer.model; - -import de.dhbwstuttgart.sat.asp.model.ASPRule; - -public class ASPRefType implements ASPType { - protected final ASPParameterList params; - protected final String name; - - public ASPRefType(String name, ASPParameterList params){ - this.name = name; - this.params = params; - } - - public ASPParameterList getParams() { - return params; - } - - public String toString(){ - return ASPRule.ASP_TYPE + "(" + name +"," + params.name + ")"; - } - - @Override - public String getPointer() { - return name; - } -} diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPType.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPType.java deleted file mode 100644 index 201e36ad..00000000 --- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPType.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.dhbwstuttgart.sat.asp.writer.model; - -public interface ASPType { - String getPointer(); -} diff --git a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPTypeVar.java b/src/de/dhbwstuttgart/sat/asp/writer/model/ASPTypeVar.java deleted file mode 100644 index e10a88bf..00000000 --- a/src/de/dhbwstuttgart/sat/asp/writer/model/ASPTypeVar.java +++ /dev/null @@ -1,27 +0,0 @@ -package de.dhbwstuttgart.sat.asp.writer.model; - -import de.dhbwstuttgart.sat.asp.model.ASPRule; -import de.dhbwstuttgart.sat.asp.writer.ASPWriter; - -public class ASPTypeVar implements ASPType{ - private final String name; - - public ASPTypeVar(String name, ASPWriter writer){ - this.name = name; - writer.add(new ASPStatement(this.toASP())); - } - - @Override - public String toString() { - return toASP(); - } - - private String toASP() { - return ASPRule.ASP_TYPE_VAR+"("+ name +")"; - } - - @Override - public String getPointer() { - return name; - } -}