modified: ../src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java

modified:   ../src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java
	modified:   ../src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
	modified:   ../src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java
noch Fehler bei mathStruc<Integer> und Matrix laeuft sehr lange vll. terminiert es nicht.
This commit is contained in:
pl@gohorb.ba-horb.de 2020-03-26 17:23:56 +01:00
parent eca187da79
commit 8bdb7e7b13
4 changed files with 16 additions and 54 deletions

View File

@ -73,7 +73,7 @@ public class JavaTXCompiler {
public static JavaTXCompiler INSTANCE;
final CompilationEnvironment environment;
Boolean resultmodel = true;
Boolean resultmodel = false;
public final Map<File, SourceFile> sourceFiles = new HashMap<>();
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll?
public volatile UnifyTaskModel usedTasks = new UnifyTaskModel();

View File

@ -31,6 +31,9 @@ import de.dhbwstuttgart.typeinference.unify.distributeVariance;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import org.apache.commons.io.output.NullOutputStream;
/**
* Implementation of the type inference rules.
@ -43,6 +46,7 @@ public class RuleSet implements IRuleSet{
public RuleSet() {
super();
logFile = new OutputStreamWriter(new NullOutputStream());
}
RuleSet(Writer logFile) {

View File

@ -637,62 +637,17 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
.next()
.stream()
.filter(x -> x.getGroundBasePair().getLhsType() instanceof PlaceholderType &&
x.getRhsType() instanceof ReferenceType &&
! (x.getRhsType() instanceof PlaceholderType) &&
x.getPairOp() == PairOperator.EQUALSDOT)
.map(x ->
((PlaceholderType)x.getGroundBasePair().getLhsType()).getVariance())
.findAny();
//Fuer Operatorenaufrufe wird variance auf 2 gesetzt
//Fuer Operatorenaufrufe wird variance auf 2 gesetzt.
//da kein Receiver existiert also keon x.getGroundBasePair().getLhsType() instanceof PlaceholderType
//Es werden alle Elemente des Kartesischen Produkts abgearbeitet
variance = optVariance.isPresent() ? optVariance.get() : 2;
}
//if (variance == 1 && nextSetasList.size() > 1) {
// List<Set<UnifyPair>> al = new ArrayList<>(nextSetasList.size());
// for (int ii = 0; ii < nextSetasList.size();ii++) {
// al.add(0,nextSetasList.get(ii));
// }
// nextSetasList = al;
//}
//Set<UnifyPair> a = nextSetasListIt.next();
/*if (nextSetasList.size()>1) {zu loeschen
if (nextSetasList.iterator().next().iterator().next().getLhsType().getName().equals("D"))
System.out.print("");
if (variance == 1) {
a_next = oup.max(nextSetasList.iterator());
}
else if (variance == -1) {
a_next = oup.min(nextSetasList.iterator());
}
else if (variance == 0) {
a_next = nextSetasList.iterator().next();
}
}
else {
a_next = nextSetasList.iterator().next();
}
*/
if (variance == 2) {
writeLog("VARIANCE2 " + nextSetasList.toString());
Set<UnifyPair> XX = nextSetasList.iterator()
.next()
.stream()
.filter(x ->
x.getGroundBasePair().getLhsType() instanceof PlaceholderType &&
! (x.getRhsType() instanceof PlaceholderType) &&
x.getPairOp() == PairOperator.EQUALSDOT)
.collect(Collectors.toCollection(HashSet::new));
Set<Integer> sI = XX.stream()
.map(x ->
((PlaceholderType)x.getGroundBasePair().getLhsType()).getVariance())
.collect(Collectors.toCollection(HashSet::new));;
Optional<Integer> oI = sI.stream()
.findAny();
variance = oI.isPresent() ? oI.get() : 2;
System.out.println("");
}
if (!nextSetasList.iterator().hasNext())
System.out.print("");
if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1)
@ -741,6 +696,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
List<Set<UnifyPair>> nextSetasListRest = new ArrayList<>();
//List<Set<UnifyPair>> nextSetasListRestMin = new ArrayList<>();
//List<Set<UnifyPair>> nextSetasListRestOder = new ArrayList<>();
writeLog("WhileAnfangNextSet: " + nextSet.toString());
writeLog("WhileAnfangNextSetasList: " + nextSetasList.toString());
if (variance == 1) {
a = oup.max(nextSetasList.iterator());
nextSetasList.remove(a);

View File

@ -203,7 +203,7 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
Set<UnifyPair> lefteqOder = left.stream()
.filter(x -> { UnifyPair y = x.getGroundBasePair();
try {
/*try {
((FiniteClosure)fc).logFile.write("leftBase: " + leftBase.toString() +"\n");
((FiniteClosure)fc).logFile.write("rightBase: " + rightBase.toString() +"\n\n");
((FiniteClosure)fc).logFile.write("left: " + left.toString() +"\n");
@ -214,15 +214,15 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
((FiniteClosure)fc).logFile.write("x.getPairOp(): " + x.getPairOp().toString() +"\n\n");
}
catch (IOException ie) {
}
} */
return (y.getLhsType() instanceof PlaceholderType &&
y.getRhsType() instanceof ReferenceType &&
!(y.getRhsType() instanceof PlaceholderType) &&
x.getPairOp() == PairOperator.EQUALSDOT);})
.collect(Collectors.toCollection(HashSet::new));
Set<UnifyPair> righteqOder = right.stream()
.filter(x -> { UnifyPair y = x.getGroundBasePair();
return (y.getLhsType() instanceof PlaceholderType &&
y.getRhsType() instanceof ReferenceType &&
!(y.getRhsType() instanceof PlaceholderType) &&
x.getPairOp() == PairOperator.EQUALSDOT);})
.collect(Collectors.toCollection(HashSet::new));
Set<UnifyPair> lefteqRet = left.stream()
@ -243,7 +243,7 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
.collect(Collectors.toCollection(HashSet::new));
synchronized(this) {
/* synchronized(this) {
try {
((FiniteClosure)fc).logFile.write("leftBase: " + leftBase.toString() +"\n");
((FiniteClosure)fc).logFile.write("rightBase: " + rightBase.toString() +"\n\n");
@ -260,6 +260,7 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
catch (IOException ie) {
}
}
*/
if (lefteqOder.size() == 1 && righteqOder.size() == 1 && lefteqRet.size() == 1 && righteqRet.size() == 1) {