modified: ../../../../main/java/de/dhbwstuttgart/typeinference/unify/Match.java

modified:   ../../../../main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
im Fall 1 die Substitutionen der Typeplaceholders der Muster entfernt

	modified:   ../../../../main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java
	modified:   ../../../../main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java
	modified:   ../../../../main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java
	modified:   ../../../../main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java
	modified:   ../../bytecode/javFiles/MatrixOP.jav
	modified:   ../../bytecode/javFiles/Merge.jav
This commit is contained in:
Martin Plümicke 2019-01-04 01:19:31 +01:00
parent 013539e7e8
commit 72a84323de
8 changed files with 22 additions and 13 deletions

View File

@ -22,6 +22,8 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
public class Match implements IMatch {
@Override
//A<X> =. A<Integer> ==> True
//A<Integer> =. A<X> ==> False
public Optional<Unifier> match(ArrayList<UnifyPair> termsList) {
// Start with the identity unifier. Substitutions will be added later.

View File

@ -1309,8 +1309,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
if (eq2sAsList.isEmpty() && first) {//Alle eq2s sind empty und alle oderConstraints mit Variance != 0 sind bearbeitet
if (!oderConstraintsOutput.isEmpty()) {
Set<Set<UnifyPair>> ret = oderConstraintsOutput.remove(0);
if (ret.iterator().next().iterator().next().getLhsType().getName().equals("M"))
System.out.println("M");
//if (ret.iterator().next().iterator().next().getLhsType().getName().equals("M"))
// System.out.println("M");
//Set<UnifyPair> retFlat = new HashSet<>();
//ret.stream().forEach(x -> retFlat.addAll(x));
ret.stream().forEach(x -> x.stream().forEach(y -> y.addSubstitutions(x)));
@ -1476,9 +1476,14 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
allGen = false;
break;
}
//if (thetaPrime.getName().equals("java.util.Vector") //Fuer Bug 127
// && thetaPrime instanceof ReferenceType
// && ((ReferenceType)thetaPrime).getTypeParams().iterator().next().getName().equals("java.util.Vector")
// && ((ReferenceType)((ReferenceType)thetaPrime).getTypeParams().iterator().next()).getTypeParams().iterator().next().getName().equals("java.lang.Integer")) {
// System.out.println("");
//}
Set<UnifyType> cs = fc.getAllTypesByName(thetaPrime.getName());//cs= [java.util.Vector<NP>, java.util.Vector<java.util.Vector<java.lang.Integer>>, ????java.util.Vector<gen_hv>???]
//Set<UnifyType> cs = fc.getAllTypesByMatch(thetaPrime); //PL 2019-01-02 geaendet wegen Bug 127//SO GEHT ES NICHT
//PL 18-02-06 entfernt, kommt durch unify wieder rein
@ -1522,19 +1527,21 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
}
for(UnifyType tqp : thetaQPrimes) {
Collection<PlaceholderType> tphs = tqp.getInvolvedPlaceholderTypes();
Optional<Unifier> opt = stdUnify.unify(tqp, thetaPrime);
if (!opt.isPresent()) {
continue;
}
Unifier unifier = opt.get();
unifier.swapPlaceholderSubstitutions(thetaPrime.getTypeParams());
Set<UnifyPair> substitutionSet = new HashSet<>();
for (Entry<PlaceholderType, UnifyType> sigma : unifier) {
substitutionSet.add(new UnifyPair(sigma.getKey(), sigma.getValue(), PairOperator.EQUALSDOT,
if (!tphs.contains(sigma.getKey())) {//eingefuegt PL 2019-02-02 Bug 127
substitutionSet.add(new UnifyPair(sigma.getKey(), sigma.getValue(), PairOperator.EQUALSDOT,
//TODO: nochmals ueberlegen ob hier pair.getSubstitution() korrekt ist, oder ob leere Menge hin müsste
//alle folgenden New UnifyPair ebenfalls ueberpruefen PL 2018-04-19
pair.getSubstitution(), pair));
}
}
//List<UnifyType> freshTphs = new ArrayList<>(); PL 18-02-06 in die For-Schleife verschoben
for (UnifyType tq : thetaQs) {

View File

@ -487,7 +487,7 @@ implements IFiniteClosure {
result.add(type);
return result;
}
@Override
public Set<UnifyType> getAllTypesByName(String typeName) {
if(!strInheritanceGraph.containsKey(typeName))

View File

@ -157,7 +157,7 @@ public final class PlaceholderType extends UnifyType{
@Override
public Collection<? extends PlaceholderType> getInvolvedPlaceholderTypes() {
public Collection<PlaceholderType> getInvolvedPlaceholderTypes() {
ArrayList<PlaceholderType> ret = new ArrayList<>();
ret.add(this);
return ret;

View File

@ -97,7 +97,7 @@ public abstract class UnifyType {
return typeName + params;
}
public Collection<? extends PlaceholderType> getInvolvedPlaceholderTypes() {
public Collection<PlaceholderType> getInvolvedPlaceholderTypes() {
ArrayList<PlaceholderType> ret = new ArrayList<>();
ret.addAll(typeParams.getInvolvedPlaceholderTypes());
return ret;

View File

@ -64,7 +64,7 @@ public abstract class WildcardType extends UnifyType {
@Override
public Collection<? extends PlaceholderType> getInvolvedPlaceholderTypes() {
public Collection<PlaceholderType> getInvolvedPlaceholderTypes() {
ArrayList<PlaceholderType> ret = new ArrayList<>();
ret.addAll(wildcardedType.getInvolvedPlaceholderTypes());
return ret;

View File

@ -1,6 +1,6 @@
import java.util.Vector;
import java.lang.Integer;
//import java.lang.Byte;
import java.lang.Byte;
import java.lang.Boolean;
public class MatrixOP extends Vector<Vector<Integer>> {

View File

@ -1,8 +1,8 @@
import java.util.List;
import java.lang.Integer;
import java.util.Collection;
//import java.util.Collection;
class Merge {
class Merge {
merge(a, b) {
a.addAll(b);