Fehler beheben

This commit is contained in:
JanUlrich 2018-07-17 19:56:01 +02:00
parent d0e7ea86ed
commit dad9e58763
8 changed files with 34 additions and 17 deletions

View File

@ -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;

View File

@ -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<B,C> < Y<B,C>
* X<D,E> < Y<D,E>
Will man dies aber rausnehmen, muss man die andere Kette umbenennen.
Schwierig/Unmöglich, dank mehrfachvererbung
* Z<B,C,D,E> < X<B,C> < Y<B,C>
* Z<B,C,D,E> < X<D,E> < Y<D,E>
*/
public static Collection<Pair> toFC(Collection<ClassOrInterface> availableClasses) throws ClassNotFoundException {
HashMap<String, Pair> pairs = new HashMap<>();
TypePrinter printer = new TypePrinter();
@ -135,13 +147,14 @@ public class FCGenerator {
* X<D,E> < Y<D,E>
* so bekommen sie hier den gleichen Namen zugewiesen und werden in der HashMap aussortiert
* X<TPH,TPH> < Y<TPH,TPH>
*/
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.

View File

@ -14,15 +14,17 @@ import java.util.stream.Collectors;
public class ASPUnify {
private final List<File> input;
private static final List<File> 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<File> 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;
}
}

View File

@ -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)));

View File

@ -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));

View File

@ -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<Pair> testSet = new ConstraintSet<>();

View File

@ -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{
}

View File

@ -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;