modified: src/de/dhbwstuttgart/core/JavaTXCompiler.java
modified: src/de/dhbwstuttgart/typeinference/result/ResultSet.java modified: src/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java modified: src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java modified: src/de/dhbwstuttgart/typeinference/unify/model/Pair.java
This commit is contained in:
parent
99bf02606b
commit
693b47b619
@ -29,6 +29,7 @@ import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||
import de.dhbwstuttgart.typeinference.unify.TypeUnifyTask;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@ -200,7 +201,9 @@ public class JavaTXCompiler {
|
||||
if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT);
|
||||
return y; //alle Paare a <.? b erden durch a =. b ersetzt
|
||||
}).collect(Collectors.toCollection(HashSet::new)));
|
||||
if (res.isPresent()) return res.get(); //wenn subst ein Erg liefert wurde was veraendert
|
||||
if (res.isPresent()) {//wenn subst ein Erg liefert wurde was veraendert
|
||||
return new TypeUnifyTask().applyTypeUnificationRules(res.get(), finiteClosure);
|
||||
}
|
||||
else return x; //wenn nichts veraendert wurde wird x zurueckgegeben
|
||||
}).collect(Collectors.toCollection(HashSet::new));
|
||||
System.out.println("RESULT Final: " + results);
|
||||
|
@ -48,6 +48,7 @@ class Resolver implements ResultSetVisitor {
|
||||
public ResolvedType resolve(TypePlaceholder tph){
|
||||
toResolve = tph;
|
||||
resolved = null;
|
||||
System.out.println(tph.toString());
|
||||
for(ResultPair resultPair : result.results){
|
||||
if(resultPair instanceof PairTPHEqualTPH && ((PairTPHEqualTPH) resultPair).getLeft().equals(toResolve)){
|
||||
return resolve(((PairTPHEqualTPH) resultPair).getRight());
|
||||
@ -113,6 +114,8 @@ class Resolver implements ResultSetVisitor {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -379,6 +379,8 @@ public class TYPEStmt implements StatementVisitor{
|
||||
return;
|
||||
}
|
||||
if (literal.value instanceof Integer) {
|
||||
//constraintsSet.addUndConstraint(new Pair(literal.getType(),integer, PairOperator.EQUALSDOT));
|
||||
// /*
|
||||
Set<Constraint> oderConstraints = new HashSet<>();
|
||||
Constraint constraint = new Constraint();
|
||||
constraint.add(new Pair(literal.getType(), integer, PairOperator.EQUALSDOT));
|
||||
@ -387,6 +389,7 @@ public class TYPEStmt implements StatementVisitor{
|
||||
constraint.add(new Pair(literal.getType(), doublee, PairOperator.EQUALSDOT));
|
||||
oderConstraints.add(constraint);
|
||||
constraintsSet.addOderConstraint(oderConstraints);
|
||||
// */
|
||||
return;
|
||||
}
|
||||
if (literal.value instanceof Short) {
|
||||
|
@ -25,6 +25,7 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IUnify;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.ExtendsType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.ReferenceType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.SuperType;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.TypeParams;
|
||||
import de.dhbwstuttgart.typeinference.unify.model.Unifier;
|
||||
@ -589,8 +590,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
})//.filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y)) fuer testzwecke auskommentiert um nofstred zu bestimmen PL 2018-10-10
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
nofstred = nextSetasList.size();
|
||||
nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y))
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
//NOCH NICHT korrekt PL 2018-10-12
|
||||
//nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y))
|
||||
// .collect(Collectors.toCollection(ArrayList::new));
|
||||
writeLog("res (undef): " + res.toString());
|
||||
writeLog("abhSubst: " + abhSubst.toString());
|
||||
writeLog("a: " + a.toString());
|
||||
writeLog("Durchschnitt: " + durchschnitt.toString());
|
||||
@ -625,10 +628,15 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
if (!substRes.isPresent()) {
|
||||
return true;
|
||||
}
|
||||
//PL 2018-10-12
|
||||
//Evtl. zurest applyTypeUnification aufrufen
|
||||
//evtl auch unify aufrufen
|
||||
else {
|
||||
UnifyPair checkPair = substRes.get().stream()
|
||||
.filter(x -> x.getGroundBasePair().equals(pair.getValue().get())).findFirst().get();
|
||||
if ((checkPair.getLhsType() instanceof PlaceholderType) || (checkPair.getRhsType() instanceof PlaceholderType)) {
|
||||
if (((checkPair.getLhsType() instanceof PlaceholderType) || (checkPair.getRhsType() instanceof PlaceholderType))
|
||||
&& (checkPair.getPairOp() == PairOperator.SMALLERDOT || checkPair.getPairOp() == PairOperator.SMALLERDOTWC))
|
||||
{
|
||||
Set<UnifyPair> up = new HashSet<>();
|
||||
up.add(checkPair);
|
||||
Set<UnifyPair> undef = new HashSet<>();
|
||||
@ -637,11 +645,19 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
writeLog("Second erase:" +checkPair.toString());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if ((checkPair.getLhsType() instanceof ReferenceType) && (checkPair.getRhsType() instanceof ReferenceType))
|
||||
// && (checkPair.getPairOp() == PairOperator.SMALLERDOT || checkPair.getPairOp() == PairOperator.SMALLERDOTWC)
|
||||
{
|
||||
Set<UnifyPair> setCheckPair = new HashSet<>();
|
||||
setCheckPair.add(checkPair);
|
||||
return isUndefinedPairSet(applyTypeUnificationRules(setCheckPair, fc));
|
||||
} else {
|
||||
//Pair type <. ? extends ? extends type betrachten TODO PL 2018-10-09
|
||||
}
|
||||
else {
|
||||
//Pair type <. type' betrachten TODO PL 2018-10-09
|
||||
}
|
||||
}
|
||||
return true;}).reduce((xx, yy) -> xx || yy).get();
|
||||
|
@ -18,4 +18,8 @@ public class Pair<T, T1> {
|
||||
public T getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "(" + key.toString() + "," + "," + value.toString() + ")\n";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user