ASP Generator auf neues Format anpassen

This commit is contained in:
JanUlrich 2018-02-13 05:25:18 +01:00
parent 6e770b5ec5
commit 191a1166b9
13 changed files with 67 additions and 19 deletions

View File

@ -82,7 +82,7 @@ public class JavaTXCompiler {
List<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses(); List<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses();
//Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC //Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
for(SourceFile sf : this.sourceFiles.values()) { for(SourceFile sf : this.sourceFiles.values()) {
//allClasses.addAll(getAvailableClasses(sf)); allClasses.addAll(getAvailableClasses(sf));
allClasses.addAll(sf.getClasses()); allClasses.addAll(sf.getClasses());
} }

View File

@ -49,9 +49,19 @@ public class CompilationEnvironment {
* *
*/ */
//String bootClassPath = System.getProperty("sun.boot.class.path"); //String bootClassPath = System.getProperty("sun.boot.class.path");
ClassLoader cl = ClassLoader.getPlatformClassLoader(); // ClassLoader cl = ClassLoader.getPlatformClassLoader();
URLClassLoader loader = new URLClassLoader(new URL[0], cl); ClassLoader cl = ClassLoader.getSystemClassLoader();
librarys = Arrays.asList(loader.getURLs()); String bootClassPath = System.getProperty("java.class.path");
librarys = new ArrayList<>();
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.sourceFiles = sourceFiles;
this.packageCrawler = new PackageCrawler(librarys); this.packageCrawler = new PackageCrawler(librarys);
} }

View File

@ -37,7 +37,7 @@ public class ASPGenerator {
TypeConverter converter = new TypeConverter(); TypeConverter converter = new TypeConverter();
for(ClassOrInterface cl : fcClasses){ for(ClassOrInterface cl : fcClasses){
ASPRefType superClass = (ASPRefType) cl.getSuperClass().acceptTV(converter); ASPRefType superClass = (ASPRefType) cl.getSuperClass().acceptTV(converter);
ASPPairSmaller fcEntry = new ASPPairSmaller(new ASPFCType(convert(cl)), new ASPFCType(superClass)); ASPPairSmaller fcEntry = new ASPPairSmaller(new ASPFCType(convert(cl)), new ASPFCType(superClass), writer);
writer.add(new ASPStatement(fcEntry.toASP())); writer.add(new ASPStatement(fcEntry.toASP()));
} }
for(Pair cons : constraintSet){ for(Pair cons : constraintSet){
@ -52,9 +52,9 @@ public class ASPGenerator {
ASPType ls = pair.TA1.acceptTV(converter); ASPType ls = pair.TA1.acceptTV(converter);
ASPType rs = pair.TA2.acceptTV(converter); ASPType rs = pair.TA2.acceptTV(converter);
if(pair.OperatorEqual()){ if(pair.OperatorEqual()){
return new ASPPairEquals(ls, rs); return new ASPPairEquals(ls, rs,writer);
}else if(pair.OperatorSmallerDot()){ }else if(pair.OperatorSmallerDot()){
return new ASPPairSmallerDot(ls, rs); return new ASPPairSmallerDot(ls, rs, writer);
}else throw new NotImplementedException(); }else throw new NotImplementedException();
} }

View File

@ -1,12 +1,9 @@
package de.dhbwstuttgart.sat.asp.writer.model; package de.dhbwstuttgart.sat.asp.writer.model;
import de.dhbwstuttgart.sat.asp.model.ASPRule; import de.dhbwstuttgart.sat.asp.model.ASPRule;
import de.dhbwstuttgart.sat.asp.writer.ASPWriter;
public class ASPFCType extends ASPRefType { public class ASPFCType extends ASPRefType {
public ASPFCType(String name, ASPParameterList params){
super(name, params);
}
public ASPFCType(ASPRefType refType){ public ASPFCType(ASPRefType refType){
super(refType.name, refType.params); super(refType.name, refType.params);
} }

View File

@ -12,4 +12,14 @@ public class ASPGenericType implements ASPType{
public String toString(){ public String toString(){
return ASPRule.ASP_GENERIC_TYPE_NAME + "(" + name + ")"; 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; package de.dhbwstuttgart.sat.asp.writer.model;
import de.dhbwstuttgart.sat.asp.writer.ASPWriter;
public abstract class ASPPair { public abstract class ASPPair {
public final ASPType leftSide; public final ASPType leftSide;
public final ASPType rightSide; public final ASPType rightSide;
public ASPPair(ASPType ls, ASPType rs){ public ASPPair(ASPType ls, ASPType rs, ASPWriter writer){
this.leftSide = ls; this.leftSide = ls;
this.rightSide = rs; this.rightSide = rs;
writer.add(new ASPStatement(ls.toASP()));
writer.add(new ASPStatement(rs.toASP()));
} }
public String toASP(){ public String toASP(){
return this.getRuleName() + "(" + leftSide + ","+ rightSide + ")"; return this.getRuleName() + "(" + leftSide.getPointer() + ","+ rightSide.getPointer() + ")";
} }
public String toString(){ public String toString(){

View File

@ -1,10 +1,11 @@
package de.dhbwstuttgart.sat.asp.writer.model; package de.dhbwstuttgart.sat.asp.writer.model;
import de.dhbwstuttgart.sat.asp.model.ASPRule; import de.dhbwstuttgart.sat.asp.model.ASPRule;
import de.dhbwstuttgart.sat.asp.writer.ASPWriter;
public class ASPPairEquals extends ASPPair{ public class ASPPairEquals extends ASPPair{
public ASPPairEquals(ASPType ls, ASPType rs){ public ASPPairEquals(ASPType ls, ASPType rs, ASPWriter writer){
super(ls, rs); super(ls, rs, writer);
} }
@Override @Override

View File

@ -1,12 +1,13 @@
package de.dhbwstuttgart.sat.asp.writer.model; package de.dhbwstuttgart.sat.asp.writer.model;
import de.dhbwstuttgart.sat.asp.model.ASPRule; import de.dhbwstuttgart.sat.asp.model.ASPRule;
import de.dhbwstuttgart.sat.asp.writer.ASPWriter;
import java.util.Map; import java.util.Map;
public class ASPPairSmaller extends ASPPair{ public class ASPPairSmaller extends ASPPair{
public ASPPairSmaller(ASPFCType ls, ASPFCType rs){ public ASPPairSmaller(ASPFCType ls, ASPFCType rs, ASPWriter writer){
super(ls, rs); super(ls, rs, writer);
} }
@Override @Override

View File

@ -1,10 +1,11 @@
package de.dhbwstuttgart.sat.asp.writer.model; package de.dhbwstuttgart.sat.asp.writer.model;
import de.dhbwstuttgart.sat.asp.model.ASPRule; import de.dhbwstuttgart.sat.asp.model.ASPRule;
import de.dhbwstuttgart.sat.asp.writer.ASPWriter;
public class ASPPairSmallerDot extends ASPPair{ public class ASPPairSmallerDot extends ASPPair{
public ASPPairSmallerDot(ASPType ls, ASPType rs){ public ASPPairSmallerDot(ASPType ls, ASPType rs, ASPWriter writer){
super(ls, rs); super(ls, rs, writer);
} }
@Override @Override

View File

@ -18,4 +18,14 @@ public class ASPRefType implements ASPType {
public String toString(){ public String toString(){
return ASPRule.ASP_TYPE + "(" + name +"," + params.name + ")"; 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; package de.dhbwstuttgart.sat.asp.writer.model;
public interface ASPType { public interface ASPType {
String toASP();
String getPointer();
} }

View File

@ -11,4 +11,14 @@ public class ASPTypeVar implements ASPType{
public String toString() { public String toString() {
return "typeVar("+ name +")"; 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{ class Vector{