forked from JavaTX/JavaCompilerCore
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:
parent
013539e7e8
commit
72a84323de
@ -22,6 +22,8 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyType;
|
|||||||
public class Match implements IMatch {
|
public class Match implements IMatch {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
//A<X> =. A<Integer> ==> True
|
||||||
|
//A<Integer> =. A<X> ==> False
|
||||||
public Optional<Unifier> match(ArrayList<UnifyPair> termsList) {
|
public Optional<Unifier> match(ArrayList<UnifyPair> termsList) {
|
||||||
|
|
||||||
// Start with the identity unifier. Substitutions will be added later.
|
// Start with the identity unifier. Substitutions will be added later.
|
||||||
|
@ -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 (eq2sAsList.isEmpty() && first) {//Alle eq2s sind empty und alle oderConstraints mit Variance != 0 sind bearbeitet
|
||||||
if (!oderConstraintsOutput.isEmpty()) {
|
if (!oderConstraintsOutput.isEmpty()) {
|
||||||
Set<Set<UnifyPair>> ret = oderConstraintsOutput.remove(0);
|
Set<Set<UnifyPair>> ret = oderConstraintsOutput.remove(0);
|
||||||
if (ret.iterator().next().iterator().next().getLhsType().getName().equals("M"))
|
//if (ret.iterator().next().iterator().next().getLhsType().getName().equals("M"))
|
||||||
System.out.println("M");
|
// System.out.println("M");
|
||||||
//Set<UnifyPair> retFlat = new HashSet<>();
|
//Set<UnifyPair> retFlat = new HashSet<>();
|
||||||
//ret.stream().forEach(x -> retFlat.addAll(x));
|
//ret.stream().forEach(x -> retFlat.addAll(x));
|
||||||
ret.stream().forEach(x -> x.stream().forEach(y -> y.addSubstitutions(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;
|
allGen = false;
|
||||||
break;
|
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.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
|
//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) {
|
for(UnifyType tqp : thetaQPrimes) {
|
||||||
|
Collection<PlaceholderType> tphs = tqp.getInvolvedPlaceholderTypes();
|
||||||
Optional<Unifier> opt = stdUnify.unify(tqp, thetaPrime);
|
Optional<Unifier> opt = stdUnify.unify(tqp, thetaPrime);
|
||||||
if (!opt.isPresent()) {
|
if (!opt.isPresent()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Unifier unifier = opt.get();
|
Unifier unifier = opt.get();
|
||||||
unifier.swapPlaceholderSubstitutions(thetaPrime.getTypeParams());
|
unifier.swapPlaceholderSubstitutions(thetaPrime.getTypeParams());
|
||||||
Set<UnifyPair> substitutionSet = new HashSet<>();
|
Set<UnifyPair> substitutionSet = new HashSet<>();
|
||||||
for (Entry<PlaceholderType, UnifyType> sigma : unifier) {
|
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
|
//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
|
//alle folgenden New UnifyPair ebenfalls ueberpruefen PL 2018-04-19
|
||||||
pair.getSubstitution(), pair));
|
pair.getSubstitution(), pair));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//List<UnifyType> freshTphs = new ArrayList<>(); PL 18-02-06 in die For-Schleife verschoben
|
//List<UnifyType> freshTphs = new ArrayList<>(); PL 18-02-06 in die For-Schleife verschoben
|
||||||
for (UnifyType tq : thetaQs) {
|
for (UnifyType tq : thetaQs) {
|
||||||
|
@ -487,7 +487,7 @@ implements IFiniteClosure {
|
|||||||
result.add(type);
|
result.add(type);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UnifyType> getAllTypesByName(String typeName) {
|
public Set<UnifyType> getAllTypesByName(String typeName) {
|
||||||
if(!strInheritanceGraph.containsKey(typeName))
|
if(!strInheritanceGraph.containsKey(typeName))
|
||||||
|
@ -157,7 +157,7 @@ public final class PlaceholderType extends UnifyType{
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<? extends PlaceholderType> getInvolvedPlaceholderTypes() {
|
public Collection<PlaceholderType> getInvolvedPlaceholderTypes() {
|
||||||
ArrayList<PlaceholderType> ret = new ArrayList<>();
|
ArrayList<PlaceholderType> ret = new ArrayList<>();
|
||||||
ret.add(this);
|
ret.add(this);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -97,7 +97,7 @@ public abstract class UnifyType {
|
|||||||
return typeName + params;
|
return typeName + params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<? extends PlaceholderType> getInvolvedPlaceholderTypes() {
|
public Collection<PlaceholderType> getInvolvedPlaceholderTypes() {
|
||||||
ArrayList<PlaceholderType> ret = new ArrayList<>();
|
ArrayList<PlaceholderType> ret = new ArrayList<>();
|
||||||
ret.addAll(typeParams.getInvolvedPlaceholderTypes());
|
ret.addAll(typeParams.getInvolvedPlaceholderTypes());
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -64,7 +64,7 @@ public abstract class WildcardType extends UnifyType {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<? extends PlaceholderType> getInvolvedPlaceholderTypes() {
|
public Collection<PlaceholderType> getInvolvedPlaceholderTypes() {
|
||||||
ArrayList<PlaceholderType> ret = new ArrayList<>();
|
ArrayList<PlaceholderType> ret = new ArrayList<>();
|
||||||
ret.addAll(wildcardedType.getInvolvedPlaceholderTypes());
|
ret.addAll(wildcardedType.getInvolvedPlaceholderTypes());
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.lang.Integer;
|
import java.lang.Integer;
|
||||||
//import java.lang.Byte;
|
import java.lang.Byte;
|
||||||
import java.lang.Boolean;
|
import java.lang.Boolean;
|
||||||
|
|
||||||
public class MatrixOP extends Vector<Vector<Integer>> {
|
public class MatrixOP extends Vector<Vector<Integer>> {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.lang.Integer;
|
import java.lang.Integer;
|
||||||
import java.util.Collection;
|
//import java.util.Collection;
|
||||||
|
|
||||||
class Merge {
|
class Merge {
|
||||||
|
|
||||||
merge(a, b) {
|
merge(a, b) {
|
||||||
a.addAll(b);
|
a.addAll(b);
|
||||||
|
Loading…
Reference in New Issue
Block a user