forked from JavaTX/JavaCompilerCore
1. BUG 15: TPH1 <. ? super TPH2 führt zu TPH1 <. TPH2 und zu Eq1 einzugefuegt 1. BUG 16: Unify in Zusammenhangskomponenten aufgeteit, muss wieder zurueckgenommen werden
This commit is contained in:
parent
67b6d29ce8
commit
47b5b2a288
@ -801,7 +801,7 @@ public class SourceFile
|
||||
.map(i -> constraintsClone.elementAt(i))
|
||||
.collect(Vector::new, Vector::add, Vector::addAll));
|
||||
//Vector<Vector<Pair>> vecconstraintsclone = streamconstraintsclone.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
|
||||
System.out.println();
|
||||
//Schritt 4: Unifikation
|
||||
Vector<Vector<Vector<Pair>>> vecunifyResult =
|
||||
//streamconstraintsclone.map(x -> Unify.unify(x, finiteClosure)).collect(Vector::new, Vector::add, Vector::addAll);
|
||||
|
@ -7,7 +7,9 @@ import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
import java.util.TreeSet;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import de.dhbwstuttgart.logger.Logger;
|
||||
import de.dhbwstuttgart.logger.Section;
|
||||
@ -150,8 +152,19 @@ public class Unify
|
||||
if(p.TA1 instanceof TypePlaceholder)
|
||||
{
|
||||
//TPH <. ? super Ty entspricht TPH <. Ty
|
||||
if (p.TA2 instanceof SuperWildcardType) p.TA2 = ((SuperWildcardType)p.TA2).get_SuperType();
|
||||
if (p.TA2 instanceof SuperWildcardType) {
|
||||
p.TA2 = ((SuperWildcardType)p.TA2).get_SuperType();
|
||||
|
||||
|
||||
//HIER GIBT ES EIN PROBLEM, WENN get_SuperType ein TPH LIEFERT PL 15-03-12
|
||||
//Dann ist THP <. TPH in Eq2 anstatt in Eq1
|
||||
//Muesste mit folgendem if gelöst sein. PL 15-03-17
|
||||
if (p.TA2 instanceof TypePlaceholder) {
|
||||
Eq1.addElement(p);
|
||||
// Eq2.remove(p);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(p.OperatorEqual())
|
||||
{
|
||||
//Alle Paare die bereits durch sub_unify die richtige Struktur haben einfach durchleiten.
|
||||
@ -608,10 +621,87 @@ public class Unify
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//EINSCHUB AUFTEILEN ZUSAMMENHANGSKOMPONENTEN PL 15-03-19 IN SCHRITTEN A. - C.
|
||||
//BRINGT nichts OverloadingInMethod2
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//A. Zusammenhangskomponenten bilden
|
||||
|
||||
BiFunction<Vector<TypePlaceholder>,Vector<TypePlaceholder>,Vector<TypePlaceholder>> addAllSet =
|
||||
(v1, v2) -> { for (TypePlaceholder v2elem : v2) { if (!v1.contains(v2elem)) v1.addElement(v2elem); }
|
||||
return v1;
|
||||
|
||||
};
|
||||
//A.1 Eq1 als Vec<Vec<Eq1>> zu cartProduktSets hinzufuegen
|
||||
Vector<Vector<Vector<Pair>>> VecVecEq1 = Eq1.stream().map(x -> { Vector<Pair> PVec = new Vector<>();
|
||||
PVec.addElement(x);
|
||||
Vector<Vector<Pair>> PVecVec = new Vector<>();
|
||||
PVecVec.add(PVec);
|
||||
return PVecVec;})
|
||||
.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
|
||||
cartProduktSets.addAll(VecVecEq1);
|
||||
|
||||
//A.2 Schritt 1: Alle Variablen in den Paaren von Elementen einsammeln
|
||||
|
||||
//A.2 Schritt 1: Alle Variablen in den Paaren von Elementen einsammeln
|
||||
Stream<Vector<Vector<TypePlaceholder>>> constraintsclonevars2 =
|
||||
cartProduktSets.stream()
|
||||
.map(vecvec_p -> vecvec_p.stream().map(vec_p -> vec_p.stream()
|
||||
.reduce(new Vector<TypePlaceholder>(), (vTPH, p) -> { addAllSet.apply(vTPH,p.TA1.getInvolvedTypePlaceholder());
|
||||
addAllSet.apply(vTPH, p.TA2.getInvolvedTypePlaceholder());
|
||||
return vTPH;},
|
||||
(x,y) -> {x.addAll(y); return x;})
|
||||
|
||||
).collect(Vector::new, Vector::add, Vector::addAll)
|
||||
);//.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
|
||||
Vector<Vector<Vector<TypePlaceholder>>> constraintsclonevars3 = constraintsclonevars2.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
|
||||
Vector<Vector<TypePlaceholder>> constraintsclonevars4 =
|
||||
constraintsclonevars3.stream().map(vars -> vars.stream().reduce(new Vector<TypePlaceholder>(),(vTPH1, vTPH2) -> { addAllSet.apply(vTPH1,vTPH2); return vTPH1;}))
|
||||
.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
|
||||
|
||||
Vector<Vector<TypePlaceholder>> constraintsclonevars =
|
||||
cartProduktSets.stream()
|
||||
.map(vecvec_p -> vecvec_p.stream().map(vec_p -> vec_p.stream()
|
||||
.reduce(new Vector<TypePlaceholder>(), (vTPH, p) -> { vTPH.addAll(p.TA1.getInvolvedTypePlaceholder());
|
||||
vTPH.addAll(p.TA2.getInvolvedTypePlaceholder());
|
||||
return vTPH;},
|
||||
(x,y) -> {x.addAll(y); return x;})
|
||||
|
||||
).reduce(new Vector<TypePlaceholder>(), (vTPH1, vTPH2) -> { vTPH1.addAll(vTPH2); return vTPH1;})
|
||||
//HIER STIMMT ES NICHT
|
||||
).collect(Vector::new, Vector::add, Vector::addAll);
|
||||
|
||||
//A.3 Schritt 2: Schnittmengen jedes Elements mit jedem Elememt von vars bilden und dann index zusammenfassen
|
||||
//in indexset sind dann die Mengen von Indizes enthalten, die gemeisam unifiziert wreden müssen
|
||||
Vector<Vector<Integer>> indexeset = new Vector<>();
|
||||
if (constraintsclonevars4 != null && constraintsclonevars4.size()>0) {
|
||||
indexeset = Unify.schnitt(constraintsclonevars4);
|
||||
}
|
||||
|
||||
//A.4 Schritt 3: Umwandlung der Indizes in die zugehoerigen Elemente
|
||||
// In streamconstraintsclone sind die Mengen von Paar enthalten die unifiziert werden muessen
|
||||
Stream<Vector<Vector<Vector<Pair>>>> streamconstraintsclone = indexeset.stream().map(x -> x.stream()
|
||||
.map(i -> cartProduktSets.elementAt(i))//);
|
||||
.collect(Vector::new, Vector::add, Vector::addAll));
|
||||
Vector<Vector<Vector<Vector<Pair>>>> vecconstraintsclone = streamconstraintsclone.collect(Vector::new, Vector::add, Vector::addAll);
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//B. Schitte 4. bis 7 der Unifikation auf den Zusammenhangskomponenten getrennt ausfuehren
|
||||
//Schritt 4, Teil 2: Kartesisches Produkt bilden.
|
||||
//Hier wird aus den in Schritt 4, Teil 1 erzeugten Vektoren das Kartesische Produkt gebilden.
|
||||
Vector<Pair> helpvp;
|
||||
Vector<Vector<Pair>> bigCartProductErg = new Vector<Vector<Pair>>();
|
||||
|
||||
//auskommentiert, da bereits in Schritt A vor der Zusammenhangskomponenetenbildung hinzugefuegt PL 15-03-19
|
||||
bigCartProductErg.addElement(copyVectorPair(Eq1));
|
||||
|
||||
for (Vector<Vector<Pair>> vecvecpair : cartProduktSets)
|
||||
@ -774,7 +864,6 @@ public class Unify
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Diese Methode wird verwendet, um Zuordnungen z.B. TPH a = Integer
|
||||
|
Loading…
Reference in New Issue
Block a user