Filter in Unify zw. Schritt 4 und 5 einfügen
This commit is contained in:
parent
442da87f48
commit
c3a8567e3f
@ -7,6 +7,6 @@
|
||||
<classpathentry kind="lib" path="lib/junit-4.0.jar" sourcepath="/home/janulrich/.m2/repository/junit/junit/4.0/junit-4.0-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/cloning.jar"/>
|
||||
<classpathentry kind="lib" path="lib/bcel-5.2.jar"/>
|
||||
<classpathentry kind="lib" path="lib/guava-10.0.1.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
|
@ -1,35 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
|
||||
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
|
||||
|
||||
<appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender">
|
||||
<param name="Target" value="System.out"/>
|
||||
|
||||
<layout class="de.dhbwstuttgart.logger.PatternLayout">
|
||||
<param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<logger name="codegen">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
<logger name="parser">
|
||||
<level value="OFF"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
<logger name="inference">
|
||||
<level value="WARN"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
|
||||
<logger name="bytecode">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
</log4j:configuration>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
|
||||
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
|
||||
|
||||
<appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender">
|
||||
<param name="Target" value="System.out"/>
|
||||
|
||||
<layout class="de.dhbwstuttgart.logger.PatternLayout">
|
||||
<param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<logger name="codegen">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
<logger name="parser">
|
||||
<level value="OFF"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
<logger name="inference">
|
||||
<level value="WARN"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
|
||||
<logger name="bytecode">
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
</log4j:configuration>
|
||||
|
@ -1,24 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
|
||||
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
|
||||
|
||||
<appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender">
|
||||
<param name="Target" value="System.out"/>
|
||||
|
||||
<layout class="de.dhbwstuttgart.logger.PatternLayout">
|
||||
<param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<logger name="trtest">
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
<logger name="funcTest">
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
</log4j:configuration>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
|
||||
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
|
||||
|
||||
<appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender">
|
||||
<param name="Target" value="System.out"/>
|
||||
|
||||
<layout class="de.dhbwstuttgart.logger.PatternLayout">
|
||||
<param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<logger name="trtest">
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
<logger name="funcTest">
|
||||
<level value="DEBUG"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
|
||||
</log4j:configuration>
|
||||
|
BIN
lib/guava-10.0.1.jar
Normal file
BIN
lib/guava-10.0.1.jar
Normal file
Binary file not shown.
@ -1,7 +1,8 @@
|
||||
package de.dhbwstuttgart.typeinference;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
public class Menge<A> extends Vector<A>{
|
||||
public class Menge<A> extends Vector<A> implements Set<A>{
|
||||
|
||||
}
|
||||
|
@ -224,3 +224,41 @@ class TypePatchJob{
|
||||
return fileContent;
|
||||
}
|
||||
}
|
||||
|
||||
class TypedJavaSource{
|
||||
public TypedJavaSource(String source, int offset){
|
||||
|
||||
}
|
||||
|
||||
public void addInsert(GenericVarInsert genericVar, int offset){
|
||||
|
||||
}
|
||||
|
||||
public void addInsert(VarInsert var, int offset){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class VarInsert{
|
||||
public VarInsert(String var){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class GenericVarInsert{
|
||||
public GenericVarInsert(String varName){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class GenericVarExtendsInsert extends GenericVarInsert{
|
||||
public GenericVarExtendsInsert(String varName, String extendsVarName){
|
||||
super(varName);
|
||||
}
|
||||
}
|
||||
|
||||
class GenericVarSuperInsert extends GenericVarInsert{
|
||||
public GenericVarSuperInsert(String varName, String superVarName){
|
||||
super(varName);
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,17 @@ package de.dhbwstuttgart.typeinference.unify;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.Sets.SetView;
|
||||
import com.rits.cloning.Cloner;
|
||||
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
import de.dhbwstuttgart.logger.SectionLogger;
|
||||
@ -630,7 +636,7 @@ public class Unify
|
||||
}
|
||||
//Schritt 4, Teil 2: Kartesisches Produkt bilden.
|
||||
|
||||
///*
|
||||
/*
|
||||
//TODO: Vor der Bildung des Karthesischen Produkts unmögliche Kombinationen ausfiltern
|
||||
//cartProduktSets kontrollieren:
|
||||
ConstraintsSet cSet = new ConstraintsSet();
|
||||
@ -651,10 +657,43 @@ public class Unify
|
||||
cSet.add(orConstraints);
|
||||
}
|
||||
|
||||
Menge<Menge<Pair>> bigCartProductErg3 = cSet.cartesianProduct();
|
||||
if(filter)log.debug("Karthesisches Produkt nach Filterung: "+bigCartProductErg3);
|
||||
Sets.cartesianProduct(bigCartProductErg3);
|
||||
*/
|
||||
SectionLogger log = Logger.getSectionLogger(Unify.class.getName(), Section.UNIFY);
|
||||
|
||||
if(filter && false){
|
||||
Unifier filterUnify = (pairs)->{
|
||||
if(filter){
|
||||
Cloner cloner = new Cloner();
|
||||
Menge<Menge<Menge<Pair>>> temp = new Menge<>();
|
||||
Menge<Pair> undMenge = new Menge<Pair>(); //Die Menge von Pairs, welche in jedem Kartesischen Produkt enthalten sind.
|
||||
undMenge.addAll(cloner.deepClone(Eq1));
|
||||
for (Menge<Menge<Pair>> vecvecpair : cartProduktSets){
|
||||
Menge<Menge<Pair>> temp2 = new Menge<>();
|
||||
if(vecvecpair.size() == 1){//gibt es nur eine UndMenge in diesem Set, dann kommt diese in jedem Karthesischen Produkt vor:
|
||||
undMenge.addAll(cloner.deepClone(vecvecpair.firstElement()));
|
||||
temp2 = vecvecpair;
|
||||
}else{//gibt es mehrere Mengen, kann gefiltert werden:
|
||||
for(Menge<Pair> pairs : vecvecpair){
|
||||
Menge<Pair> testMenge = new Menge<Pair>();
|
||||
testMenge.addAll(cloner.deepClone(undMenge));
|
||||
testMenge.addAll(cloner.deepClone(pairs));
|
||||
Menge<Menge<Pair>> test = Unify.unifyFiltered(testMenge, fc_tto, false);
|
||||
if(test.size()>0){
|
||||
temp2.add(pairs);
|
||||
}
|
||||
else{
|
||||
log.debug("Ausgesondertes Constraint: "+pairs);
|
||||
}
|
||||
}
|
||||
}
|
||||
temp.add(temp2);
|
||||
}
|
||||
SetView<Menge<Menge<Pair>>> difference = Sets.difference(cartProduktSets, temp);
|
||||
log.debug("Ausgelöschte Constraints: "+difference.toString());
|
||||
//cartProduktSets = temp;
|
||||
/*
|
||||
Unifier filterUnify = (pairs)->{
|
||||
String pairsString = pairs.toString();
|
||||
Menge<Menge<Pair>> retValue = new Menge<>();
|
||||
retValue = Unify.unifyFiltered(pairs,fc_tto,false);
|
||||
@ -666,11 +705,9 @@ public class Unify
|
||||
|
||||
log.debug("Filtere mithilfe von 'filterWrongConstraints': "+cSet);
|
||||
cSet.filterWrongConstraints(filterUnify);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
Menge<Menge<Pair>> bigCartProductErg3 = cSet.cartesianProduct();
|
||||
if(filter)log.debug("Karthesisches Produkt nach Filterung: "+bigCartProductErg3);
|
||||
//*/
|
||||
|
||||
///* Altes Karthesisches Produkt: Auskommentiert durch Andreas Stadelmeier
|
||||
@ -693,22 +730,30 @@ public class Unify
|
||||
}
|
||||
}
|
||||
}
|
||||
//*/
|
||||
|
||||
|
||||
/*
|
||||
if(! bigCartProductErg.equals(bigCartProductErg3)){
|
||||
for(int i = 0; i<bigCartProductErg3.size();i++){
|
||||
if(! (bigCartProductErg.get(i).equals(bigCartProductErg3.get(i)))){
|
||||
System.out.println(); //TODO: Hier testen, wo der Unterschied zwischen den beiden Karthesischen Produkten ist
|
||||
System.out.println();
|
||||
//TODO: Hier testen, wo der Unterschied zwischen den beiden Karthesischen Produkten ist
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
//*/
|
||||
|
||||
//Schritt 5: Einsetzen der Subst Regel
|
||||
//Hier werden die TPHs substituiert, und dann nach geänderten und nicht geänderten Sets sortiert.
|
||||
Menge<Menge<Pair>> changedSets = new Menge<Menge<Pair>>();
|
||||
Menge<Menge<Pair>> notChangedSets = new Menge<Menge<Pair>>();
|
||||
int counter = 0;
|
||||
for(Menge<Pair> vecpair : bigCartProductErg)
|
||||
{
|
||||
counter++;
|
||||
if(counter > 1000){
|
||||
System.out.println(counter + " von "+bigCartProductErg.size());
|
||||
}
|
||||
boolean change = false; //eingefuegt PL 13-05-22
|
||||
Pair substPair = null;
|
||||
do
|
||||
|
@ -1,5 +1,11 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import de.dhbwstuttgart.logger.LoggerConfiguration;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
|
||||
import org.junit.Test;
|
||||
@ -7,11 +13,17 @@ import org.junit.Test;
|
||||
public class GenericTypeVarTest2 {
|
||||
|
||||
private static final String TEST_FILE2 = "GenericTypeVarTest2.jav";
|
||||
private static final String LOGFILE = "GenericTypeVarTest2.log";
|
||||
|
||||
|
||||
@Test
|
||||
public void run2(){
|
||||
public void run2() throws FileNotFoundException{
|
||||
Menge<String> mustContain = new Menge<String>();
|
||||
mustContain.add("String var2");
|
||||
MultipleTypesInsertTester.test(TEST_FILE2, mustContain);
|
||||
File logFile = new File(MultipleTypesInsertTester.rootDirectory+this.LOGFILE);
|
||||
LoggerConfiguration lConf = new LoggerConfiguration();
|
||||
|
||||
lConf.setOutput(Section.TYPEINFERENCE, new PrintStream(logFile));
|
||||
MultipleTypesInsertTester.test(TEST_FILE2, mustContain, lConf);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,20 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
|
||||
public class LambdaTest26 {
|
||||
|
||||
private static final String TEST_FILE = "LambdaTest26.jav";
|
||||
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
Menge<String> mustContain = new Menge<String>();
|
||||
|
@ -2,13 +2,16 @@ package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.core.MyCompiler;
|
||||
import de.dhbwstuttgart.core.MyCompilerAPI;
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.logger.LoggerConfiguration;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
import de.dhbwstuttgart.logger.SectionLogger;
|
||||
import de.dhbwstuttgart.parser.JavaParser.yyException;
|
||||
import de.dhbwstuttgart.typeinference.TypeinferenceResultSet;
|
||||
import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint;
|
||||
@ -38,6 +41,8 @@ public class MultipleTypesInsertTester extends TypeInsertTester{
|
||||
public static void test(String sourceFileToInfere, Menge<String> mustContain){
|
||||
String gesamterSrc = "";
|
||||
String inferedSource = "";
|
||||
SectionLogger log = Logger.getSectionLogger(MultipleTypesInsertTester.class.getName(), Section.TYPEINFERENCE);
|
||||
|
||||
MyCompilerAPI compiler = MyCompiler.getAPI(logConfig);
|
||||
try {
|
||||
compiler.parse(new File(rootDirectory + sourceFileToInfere));
|
||||
@ -51,7 +56,7 @@ public class MultipleTypesInsertTester extends TypeInsertTester{
|
||||
//TestCase.assertTrue("Es muss mindestens ein TypeInsertPoint vorhanden sein", point.points.size()>0);
|
||||
if(point.points.size()>0){
|
||||
inferedSource = point.insertAllTypes(TypeInsertTester.getFileContent(rootDirectory + sourceFileToInfere));
|
||||
System.out.println(inferedSource);
|
||||
log.debug(inferedSource);
|
||||
gesamterSrc += inferedSource;
|
||||
}
|
||||
|
||||
@ -64,6 +69,12 @@ public class MultipleTypesInsertTester extends TypeInsertTester{
|
||||
for(String containString : mustContain){
|
||||
TestCase.assertTrue("\""+containString+"\" muss in den inferierten Lösungen vorkommen",gesamterSrc.contains(containString));
|
||||
}
|
||||
try {
|
||||
Files.write(Logger.getWholeLog().getBytes(),new File(rootDirectory+sourceFileToInfere+".log"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
TestCase.fail();
|
||||
}
|
||||
}
|
||||
|
||||
public static void testSingleInsert(String sourceFileToInfere, Menge<String> mustContain){
|
||||
|
@ -1,5 +1,7 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import de.dhbwstuttgart.logger.LoggerConfiguration;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
|
||||
import org.junit.Test;
|
||||
@ -13,7 +15,7 @@ public class OverloadingInMethod2 {
|
||||
Menge<String> mustContain = new Menge<String>();
|
||||
|
||||
//mustContain.add("Fun0<Fun1<java.lang.String, Fun2<AH, LambdaTest, java.lang.String>>> op");
|
||||
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
|
||||
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain, new LoggerConfiguration().setOutput(Section.UNIFY, System.out));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import de.dhbwstuttgart.logger.LoggerConfiguration;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
|
||||
import org.junit.Test;
|
||||
@ -12,7 +14,7 @@ public class ThisTest {
|
||||
public void run(){
|
||||
Menge<String> mustContain = new Menge<String>();
|
||||
|
||||
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
|
||||
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain, new LoggerConfiguration().setOutput(Section.UNIFY, System.out));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user