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