merge mit sat

This commit is contained in:
JanUlrich 2018-02-19 04:22:08 +01:00
commit 166aa5e506
14 changed files with 101 additions and 25 deletions

View File

@ -73,6 +73,14 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>

View File

@ -40,17 +40,29 @@ public class CompilationEnvironment {
* @param sourceFiles die zu kompilierenden Dateien
*/
public CompilationEnvironment(List<File> sourceFiles) {
String bootClassPath = System.getProperty("sun.boot.class.path");
/**
* Java 9 bringt einige Änderungen am Classloader
* So funktioniert der BootClassLoader nicht mehr.
* hier gibts ein paar Quellen zum nachlesen:
* http://java9.wtf/class-loading/
* https://stackoverflow.com/questions/46494112/classloaders-hierarchy-in-java-9
*
*/
//String bootClassPath = System.getProperty("sun.boot.class.path");
// ClassLoader cl = ClassLoader.getPlatformClassLoader();
ClassLoader cl = ClassLoader.getSystemClassLoader();
String bootClassPath = System.getProperty("java.class.path");
librarys = new ArrayList<>();
if(bootClassPath != null){
for(String path : bootClassPath.split(File.pathSeparator)) {
try {
librarys.add(new URL("file:"+path));
} catch (MalformedURLException e) {
new DebugException("Fehler im Classpath auf diesem System");
}
for(String path : bootClassPath.split(File.pathSeparator)) {
try {
librarys.add(new URL("file:"+path));
} catch (MalformedURLException e) {
new DebugException("Fehler im Classpath auf diesem System");
}
}
}
//URLClassLoader loader = new URLClassLoader(new URL[0], cl);
//librarys = Arrays.asList(loader.getURLs());
this.sourceFiles = sourceFiles;
this.packageCrawler = new PackageCrawler(librarys);
}

View File

@ -8,7 +8,8 @@ public enum ASPRule {
ASP_PARAMLIST_NAME("param"),
ASP_PARAMLISTNUMERATION_NAME("paramNum"),
ASP_PARAMLIST_END_POINTER("null"),
ASP_TYPE("type")
ASP_TYPE("type"),
ASP_FCTYPE("type")
;
private final String text;

View File

@ -36,8 +36,8 @@ public class ASPGenerator {
private String toASP(List<Pair> constraintSet, Collection<ClassOrInterface> fcClasses){
TypeConverter converter = new TypeConverter();
for(ClassOrInterface cl : fcClasses){
ASPType superClass = cl.getSuperClass().acceptTV(converter);
ASPPairSmaller fcEntry = new ASPPairSmaller(convert(cl), superClass);
ASPRefType superClass = (ASPRefType) cl.getSuperClass().acceptTV(converter);
ASPPairSmaller fcEntry = new ASPPairSmaller(new ASPFCType(convert(cl)), new ASPFCType(superClass), writer);
writer.add(new ASPStatement(fcEntry.toASP()));
}
for(Pair cons : constraintSet){
@ -52,13 +52,13 @@ public class ASPGenerator {
ASPType ls = pair.TA1.acceptTV(converter);
ASPType rs = pair.TA2.acceptTV(converter);
if(pair.OperatorEqual()){
return new ASPPairEquals(ls, rs);
return new ASPPairEquals(ls, rs,writer);
}else if(pair.OperatorSmallerDot()){
return new ASPPairSmallerDot(ls, rs);
return new ASPPairSmallerDot(ls, rs, writer);
}else throw new NotImplementedException();
}
private ASPType convert(ClassOrInterface cl){
private ASPRefType convert(ClassOrInterface cl){
List<ASPType> paramList = new ArrayList<>();
for(GenericTypeVar gtv : cl.getGenerics()){
paramList.add(new ASPGenericType(toConstant(gtv.getName())));

View File

@ -0,0 +1,14 @@
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 + ")";
}
}

View File

@ -12,4 +12,14 @@ public class ASPGenericType implements ASPType{
public String toString(){
return ASPRule.ASP_GENERIC_TYPE_NAME + "(" + name + ")";
}
@Override
public String toASP() {
return toString();
}
@Override
public String getPointer() {
return name;
}
}

View File

@ -1,16 +1,20 @@
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){
public ASPPair(ASPType ls, ASPType rs, ASPWriter writer){
this.leftSide = ls;
this.rightSide = rs;
writer.add(new ASPStatement(ls.toASP()));
writer.add(new ASPStatement(rs.toASP()));
}
public String toASP(){
return this.getRuleName() + "(" + leftSide + ","+ rightSide + ")";
return this.getRuleName() + "(" + leftSide.getPointer() + ","+ rightSide.getPointer() + ")";
}
public String toString(){

View File

@ -1,10 +1,11 @@
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){
super(ls, rs);
public ASPPairEquals(ASPType ls, ASPType rs, ASPWriter writer){
super(ls, rs, writer);
}
@Override

View File

@ -1,12 +1,13 @@
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(ASPType ls, ASPType rs){
super(ls, rs);
public ASPPairSmaller(ASPFCType ls, ASPFCType rs, ASPWriter writer){
super(ls, rs, writer);
}
@Override

View File

@ -1,10 +1,11 @@
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){
super(ls, rs);
public ASPPairSmallerDot(ASPType ls, ASPType rs, ASPWriter writer){
super(ls, rs, writer);
}
@Override

View File

@ -3,8 +3,8 @@ package de.dhbwstuttgart.sat.asp.writer.model;
import de.dhbwstuttgart.sat.asp.model.ASPRule;
public class ASPRefType implements ASPType {
private final ASPParameterList params;
private final String name;
protected final ASPParameterList params;
protected final String name;
public ASPRefType(String name, ASPParameterList params){
this.name = name;
@ -18,4 +18,14 @@ public class ASPRefType implements ASPType {
public String toString(){
return ASPRule.ASP_TYPE + "(" + name +"," + params.name + ")";
}
@Override
public String toASP() {
return toString();
}
@Override
public String getPointer() {
return name;
}
}

View File

@ -1,4 +1,7 @@
package de.dhbwstuttgart.sat.asp.writer.model;
public interface ASPType {
String toASP();
String getPointer();
}

View File

@ -11,4 +11,14 @@ public class ASPTypeVar implements ASPType{
public String toString() {
return "typeVar("+ name +")";
}
@Override
public String toASP() {
return toString();
}
@Override
public String getPointer() {
return name;
}
}

View File

@ -1,3 +1,4 @@
import java.util.Vector;
class Vector{