Trennung von KomplexeMenge und COnstraintsSet. Experimenteller Zustand

This commit is contained in:
JanUlrich 2015-05-26 21:43:05 +02:00
parent 2b6ffdef11
commit 15e9fb44b8
7 changed files with 105 additions and 210 deletions

View File

@ -1,123 +1,57 @@
package de.dhbwstuttgart.typeinference; package de.dhbwstuttgart.typeinference;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector;
import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.logger.*; import de.dhbwstuttgart.logger.*;
import de.dhbwstuttgart.typeinference.unify.Unifier; import de.dhbwstuttgart.typeinference.unify.Unifier;
interface Constraint{ public class ConstraintsSet implements Iterable<OderConstraint>{
}
public class ConstraintsSet{
private UndMenge<Pair> set = new UndMenge<>();
private static final Logger log = Logger.getLogger(ConstraintsSet.class.getName()); private static final Logger log = Logger.getLogger(ConstraintsSet.class.getName());
private Menge<OderConstraint> constraintsSet;
public void add(ConstraintsSet CSet){
for(KomplexeMenge<Pair> i : CSet.set.set){
this.set.addItems(i);
}
}
public void add(KomplexeMenge<Pair> constraint){
this.set.addItems(constraint);
}
/*
private UndConstraint constraintsSet;
public ConstraintsSet(){ public ConstraintsSet(){
constraintsSet = new UndConstraint(); constraintsSet = new Menge<OderConstraint>();
} }
public void add(ConstraintsSet CSet){ public void add(ConstraintsSet CSet){
constraintsSet.addItems(CSet.getConstraints()); for(OderConstraint element : CSet)
add(element);
} }
public void add(OderConstraint constraint){ public void add(OderConstraint constraint){
constraintsSet.addItems(constraint); constraintsSet.add(constraint);
} }
public UndConstraint getConstraints(){
return constraintsSet;
}
*/
/** /**
* Liefert alle Constraint-Variationen * Liefert alle Constraint-Variationen
* @return * @return
*/ */
/* public Vector<Vector<UndConstraint>> getConstraints(){
public Menge<Menge<UndConstraint>> getConstraints(){ Vector<Vector<UndConstraint>> ret = new Vector<Vector<UndConstraint>>();
Menge<Menge<UndConstraint>> ret = new Menge<Menge<UndConstraint>>();
for(OderConstraint con : constraintsSet){ for(OderConstraint con : constraintsSet){
ret.add(con.getUndConstraints()); ret.add(con.getUndConstraints());
} }
ret = new KarthesischesProdukt<UndConstraint>().berechneKarthesischesProdukt(ret); ret = new KarthesischesProdukt<UndConstraint>().berechneKarthesischesProdukt(ret);
return ret; return ret;
} }
@Override @Override
public String toString(){ public String toString(){
return constraintsSet.toString(); String ret ="";
} for(OderConstraint constraint : this){
ret += constraint.toString()+"\n";
*/
/**
*
* @param unify
*/
public void filterWrongConstraints(Unifier unify) {
/*
Menge<KomplexeMenge<Pair>> newSet = new Menge<KomplexeMenge<Pair>>();
for(OderMenge<Pair> orSet : this.getOrSets()){
OderMenge<Pair> filtered = this.filterOrSet(unify, orSet);
newSet.add(filtered);
}
for(KomplexeMenge<Pair> i : this.set.set){
newSet.addAll(i.getAndSets());
}
this.set.set = newSet;
Menge<KomplexeMenge<Pair>> newSet = new Menge<KomplexeMenge<Pair>>();
for(OderMenge<Pair> orSet : this.getOrSets()){
Menge<Menge<Pair>> res = unify.apply(orSet.getItems());
if(res.size()>0){
newSet.add(orSet);
}else{
Logger.getLogger(this.getClass().getName())
.debug("Ausgesondertes Constraint: "+orSet, Section.TYPEINFERENCE);
}
}
for(KomplexeMenge<Pair> i : set){
newSet.addAll(i.getAndSets());
}
this.set = newSet;
*/
}
private OderMenge<Pair> filterOrSet(Unifier unify, OderMenge<Pair> orMenge){
/*
OderMenge<Pair> ret = new OderMenge<Pair>();
for(OderMenge<Pair> m : orMenge.getOrSets()){
ret.addItems(this.filterOrSet(unify, m));
}
for(UndMenge<Pair> m : orMenge.getAndSets()){
Menge<Menge<Pair>> res = unify.apply(m.getItems());
if(res.size()>0){
ret.addItems(m);
}else{
Logger.getLogger(this.getClass().getName())
.debug("Ausgesondertes Constraint: "+m, Section.TYPEINFERENCE);
}
} }
return ret; return ret;
*/ }
return orMenge;
public Iterator<OderConstraint> iterator() {
return constraintsSet.iterator();
}
public void filterWrongConstraints(Unifier unify) {
for(OderConstraint constraint : this){
constraint.filterWrongConstraints(unify);
}
} }
/** /**
@ -125,23 +59,21 @@ public class ConstraintsSet{
* @param unifier * @param unifier
*/ */
public void unifyUndConstraints(Unifier unifier) { public void unifyUndConstraints(Unifier unifier) {
/* Vector<UndConstraint> uCons = this.filterUndConstraints();
Menge<UndConstraint> uCons = this.filterUndConstraints(); Vector<Pair> alleUndConstraints = new Vector<>();
Menge<Pair> alleUndConstraints = new Menge<>();
for(UndConstraint undConstraint : uCons){ for(UndConstraint undConstraint : uCons){
alleUndConstraints.addAll(undConstraint.getConstraintPairs()); alleUndConstraints.addAll(undConstraint.getConstraintPairs());
} }
this.filterWrongConstraints( this.filterWrongConstraints(
(pairs)->{ (pairs)->{
Menge<Pair> undConstraintsUndPairs = new Menge<>(); Vector<Pair> undConstraintsUndPairs = new Vector<>();
undConstraintsUndPairs.addAll(pairs); undConstraintsUndPairs.addAll(pairs);
undConstraintsUndPairs.addAll(alleUndConstraints); undConstraintsUndPairs.addAll(alleUndConstraints);
log.debug("Versuche Pairs auszusondern:\n"+pairs, Section.TYPEINFERENCE); log.debug("Versuche Pairs auszusondern:\n"+pairs, Section.TYPEINFERENCE);
log.debug("Unifiziere:\n"+undConstraintsUndPairs, Section.TYPEINFERENCE); log.debug("Unifiziere:\n"+undConstraintsUndPairs, Section.TYPEINFERENCE);
Menge<Menge<Pair>> unifyResult = unifier.apply(undConstraintsUndPairs); Vector<Vector<Pair>> unifyResult = unifier.apply(undConstraintsUndPairs);
return unifyResult; return unifyResult;
}); });
*/
} }
/** /**
@ -149,15 +81,12 @@ public class ConstraintsSet{
* UndConstraints, welche sich nicht innerhalb eines OderConstraints befinden, herausgefiltert * UndConstraints, welche sich nicht innerhalb eines OderConstraints befinden, herausgefiltert
* @return [u1, ... , uN] * @return [u1, ... , uN]
*/ */
private Menge<UndConstraint> filterUndConstraints() { private Vector<UndConstraint> filterUndConstraints() {
/* Vector<UndConstraint> ret = new Vector<>();
Menge<UndConstraint> ret = new Menge<>();
for(OderConstraint con : constraintsSet){ for(OderConstraint con : constraintsSet){
UndConstraint filtered = con.filterUndConstraints(); UndConstraint filtered = con.filterUndConstraints();
if(filtered != null)ret.add(filtered); if(filtered != null)ret.add(filtered);
} }
return ret; return ret;
*/
return null;
} }
} }

View File

@ -1,6 +1,6 @@
package de.dhbwstuttgart.typeinference; package de.dhbwstuttgart.typeinference;
import de.dhbwstuttgart.typeinference.Menge; import java.util.Vector;
import de.dhbwstuttgart.logger.Logger; import de.dhbwstuttgart.logger.Logger;
import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.logger.Section;
@ -10,42 +10,41 @@ import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.typeinference.unify.Unifier; import de.dhbwstuttgart.typeinference.unify.Unifier;
public class OderConstraint{ public class OderConstraint{
private OderMenge<Pair> oSet = new OderMenge<Pair>(); private Menge<UndConstraint> oderConstraintPairs;
//private Menge<UndConstraint> oderConstraintPairs;
private final static Logger logger = Logger.getLogger(OderConstraint.class.getName()); private final static Logger logger = Logger.getLogger(OderConstraint.class.getName());
/** /**
* Erstellt ein neues Oder Constraint und fügt bereits ein Constraint hinzu. * Erstellt ein neues Oder Constraint und f<EFBFBD>gt bereits ein Constraint hinzu.
* @param p1 * @param p1
* @param p2 * @param p2
*/ */
public OderConstraint(ConstraintType p1, ConstraintType p2){ public OderConstraint(ConstraintType p1, ConstraintType p2){
if(p1 == null || p2 == null)throw new NullPointerException(); if(p1 == null || p2 == null)throw new NullPointerException();
ConstraintPair constraintPair = new ConstraintPair(p1,p2); ConstraintPair constraintPair = new ConstraintPair(p1,p2);
oderConstraintPairs = new Menge<UndConstraint>();
this.addConstraint(constraintPair); this.addConstraint(constraintPair);
} }
public OderConstraint(){ public OderConstraint(){
oderConstraintPairs = new Menge<UndConstraint>();
} }
/** /**
* Liefert alle in diesem OderConstraint enthaltene Constraints. Dabei gehen die Verknüpfungen (Oder/Und) verloren. * Liefert alle in diesem OderConstraint enthaltene Constraints. Dabei gehen die Verkn<EFBFBD>pfungen (Oder/Und) verloren.
* @return * @return
*/
public Menge<Pair> getConstraintPairs(){ public Vector<Pair> getConstraintPairs(){
Menge<Pair> ret = new Menge<Pair>(); Vector<Pair> ret = new Vector<Pair>();
for(UndConstraint oC : this.oderConstraintPairs){ for(UndConstraint oC : this.oderConstraintPairs){
ret.addAll(oC.getConstraintPairs()); ret.addAll(oC.getConstraintPairs());
} }
return ret; return ret;
return this.g
} }
*/
/** /**
* Fügt ein Pair(p1, p2) dem Constraint hinzu * F<EFBFBD>gt ein Pair(p1, p2) dem Constraint hinzu
* @param p1 * @param p1
* @param p2 * @param p2
*/ */
@ -58,19 +57,37 @@ public class OderConstraint{
* @param toAdd * @param toAdd
*/ */
public void addConstraint(ConstraintPair toAdd){ public void addConstraint(ConstraintPair toAdd){
//oderConstraintPairs.add(new SingleConstraint(toAdd)); oderConstraintPairs.add(new SingleConstraint(toAdd));
this.oSet.addItem(toAdd.getPair());
}
public void addConstraint(UndConstraint methodConstraint) {
this.oSet.addItems(methodConstraint.getConstraints());//oderConstraintPairs.add(methodConstraint);
} }
//TODO: Funktionalität ¼r filter implementieren @Override
void filterWrongConstraints(Unifier unifier) { public String toString(){
String ret = "[";
for(UndConstraint p : this.getUndConstraints()){
ret += p.toString()+ "| ";
}
return ret+"]";
}
public Vector<UndConstraint> getUndConstraints() {
return this.oderConstraintPairs;
/* /*
Menge<UndConstraint> filteredConstraints = new Menge<>(); Vector<UndConstraint> ret = new Vector<UndConstraint>();
for(Pair p : this.getConstraintPairs()){
ret.add(new UndConstraint(p.TA1,p.TA2));
}
return ret;
*/
}
public void addConstraint(UndConstraint methodConstraint) {
oderConstraintPairs.add(methodConstraint);
}
void filterWrongConstraints(Unifier unifier) {
Vector<UndConstraint> filteredConstraints = new Vector<>();
for(UndConstraint cons : this.getUndConstraints()){ for(UndConstraint cons : this.getUndConstraints()){
Menge<Menge<Pair>> unifierResult = unifier.apply(cons.getItems()); Vector<Vector<Pair>> unifierResult = unifier.apply(cons.getConstraintPairs());
if(!unifierResult.isEmpty()){ if(!unifierResult.isEmpty()){
filteredConstraints.add(cons); filteredConstraints.add(cons);
}else{ }else{
@ -78,42 +95,13 @@ public class OderConstraint{
} }
} }
this.oderConstraintPairs = filteredConstraints; this.oderConstraintPairs = filteredConstraints;
*/
} }
UndConstraint filterUndConstraints() { UndConstraint filterUndConstraints() {
return null;
/*
if(this.oderConstraintPairs.size()==1){ if(this.oderConstraintPairs.size()==1){
return this.oderConstraintPairs.firstElement(); return this.oderConstraintPairs.firstElement();
} }
return null; return null;
*/
} }
public void addItems(UndConstraint uCons) {
}
/*
@Override
public String toString(){
String ret = "[";
for(UndConstraint p : this.getUndConstraints()){
ret += p.toString()+ " | ";
}
return ret+"]";
}
public Menge<UndConstraint> getUndConstraints() {
return this.set;
Menge<UndConstraint> ret = new Menge<UndConstraint>();
for(Pair p : this.getConstraintPairs()){
ret.add(new UndConstraint(p.TA1,p.TA2));
}
return ret;
}
*/
} }

View File

@ -18,10 +18,17 @@ import de.dhbwstuttgart.typeinference.unify.Unifier;
* Item * Item
*/ */
interface Mapper<A,B>{
B applyOrSet(OderMenge<A> i);
B applyAndSet(UndMenge<A> i);
B applySingle(EinzelElement<A> i);
}
interface KomplexeMenge<A>{ interface KomplexeMenge<A>{
void addItems(KomplexeMenge<A> item); void addItems(KomplexeMenge<A> item);
void addItem(A item); void addItem(A item);
Menge<Menge<A>> cartesianProduct(); Menge<Menge<A>> cartesianProduct();
<B> KomplexeMenge<B> map(Mapper<A,B> m);
} }
public class OderMenge<A> implements KomplexeMenge<A>{ public class OderMenge<A> implements KomplexeMenge<A>{
@ -85,4 +92,9 @@ public class OderMenge<A> implements KomplexeMenge<A>{
} }
return ret + "]"; return ret + "]";
} }
@Override
public <B> KomplexeMenge<B> map(Mapper<A, B> m) {
return m.applyOrSet(this);
}
} }

View File

@ -1,6 +1,6 @@
package de.dhbwstuttgart.typeinference; package de.dhbwstuttgart.typeinference;
import de.dhbwstuttgart.typeinference.Menge; import java.util.Vector;
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefType;
@ -11,51 +11,47 @@ import de.dhbwstuttgart.typeinference.exceptions.TypeinferenceException;
/** /**
* Beschreibung von Herrn Plümicke: * Beschreibung von Herrn Plümicke:
* "The set of constraints consists of constraints of the form θ R θ' , where θ and * "The set of constraints consists of constraints of the form θ R θ' , where θ and
* θ' are Java types and R (R ∈ { < , <? , = }) is a subtyping condition." * θ' are Java types and R (R { < , <? , = }) is a subtyping condition."
* *
* @author AI10023 - Andreas Stadelmeier * @author AI10023 - Andreas Stadelmeier
* *
* Die Klasse stellt ein OderConstraint-Set dar, welches nur aus einem Constraint besteht. * Die Klasse stellt ein OderConstraint-Set dar, welches nur aus einem Constraint besteht.
* *
*/ */
public class SingleConstraint extends EinzelElement<Pair>{ public class SingleConstraint extends UndConstraint{
//private Pair constraintPair; //entspricht θ condition θ' private Pair constraintPair; //entspricht θ condition θ'
//private R condition; //entspricht der condition (R) //private R condition; //entspricht der condition (R)
public SingleConstraint(ConstraintType p1, ConstraintType p2){ public SingleConstraint(ConstraintType p1, ConstraintType p2){
super(new ConstraintPair(p1,p2).getPair());
//super(p1,p2); //super(p1,p2);
//ConstraintPair constraintPair = new ConstraintPair(p1,p2);//super.getConstraintPairs().firstElement(); ConstraintPair constraintPair = new ConstraintPair(p1,p2);//super.getConstraintPairs().firstElement();
//this.addConstraint(constraintPair); this.addConstraint(constraintPair);
} }
public SingleConstraint(ConstraintPair toAdd) { public SingleConstraint(ConstraintPair toAdd) {
super(toAdd.getPair()); this.addConstraint(toAdd);
//this.addConstraint(toAdd);
} }
public Pair getPair(){ public Pair getPair(){
return this.cartesianProduct().firstElement().firstElement(); return constraintPair;
} }
/* @Override //Methode überschreiben, damit immer nur ein Vector mit nur einem Element zurückgeliefert wird.
@Override //Methode überschreiben, damit immer nur ein Menge mit nur einem Element zurückgeliefert wird. public Vector<Pair> getConstraintPairs(){
public Menge<Pair> getConstraintPairs(){ Vector<Pair> ret = new Vector<Pair>();
Menge<Pair> ret = new Menge<Pair>();
ret.add(constraintPair); ret.add(constraintPair);
return ret; return ret;
} }
*/
public void addConstraint(ConstraintPair toAdd){ public void addConstraint(ConstraintPair toAdd){
//if(constraintPair != null)throw new DebugException("Ein Constraint darf nur aus einem ConstraintPair bestehen. Das hinzufügen von "+ toAdd + " ist nicht möglich."); if(constraintPair != null)throw new DebugException("Ein Constraint darf nur aus einem ConstraintPair bestehen. Das hinzufügen von "+ toAdd + " ist nicht möglich.");
Type p1 = toAdd.getPair().TA1; Type p1 = toAdd.getPair().TA1;
Type p2 = toAdd.getPair().TA2; Type p2 = toAdd.getPair().TA2;
if(p1==null || p2 == null)throw new NullPointerException(); if(p1==null || p2 == null)throw new NullPointerException();
this.addItem(toAdd.getPair());
//Hier werden die GTVs zu TPH gewandelt. //Hier werden die GTVs zu TPH gewandelt.
//if(p1 instanceof RefType)((RefType)p1).GTV2TPH(); //if(p1 instanceof RefType)((RefType)p1).GTV2TPH();
@ -64,24 +60,22 @@ public class SingleConstraint extends EinzelElement<Pair>{
//if((p1 instanceof GenericTypeVar))p1 = ((GenericTypeVar)p1).getTypePlaceHolder();//throw new DebugException("GenericTypeVar sind in den Constraints nicht erlaubt");// //if((p1 instanceof GenericTypeVar))p1 = ((GenericTypeVar)p1).getTypePlaceHolder();//throw new DebugException("GenericTypeVar sind in den Constraints nicht erlaubt");//
//if((p2 instanceof GenericTypeVar))p2 = ((GenericTypeVar)p2).getTypePlaceHolder();//throw new DebugException("GenericTypeVar sind in den Constraints nicht erlaubt");// //if((p2 instanceof GenericTypeVar))p2 = ((GenericTypeVar)p2).getTypePlaceHolder();//throw new DebugException("GenericTypeVar sind in den Constraints nicht erlaubt");//
// BaseTypes werden in RefTypes umgewandelt. Constraints dürfen nur RefTypes oder TypePlaceholder enthalten, da sonst der Unify-Algorithmus nicht funktioniert. // BaseTypes werden in RefTypes umgewandelt. Constraints dürfen nur RefTypes oder TypePlaceholder enthalten, da sonst der Unify-Algorithmus nicht funktioniert.
//if(!(p1 instanceof RefType) && !(p1 instanceof TypePlaceholder) && !(p1 instanceof GenericTypeVar))p1 = new RefType(p1); //if(!(p1 instanceof RefType) && !(p1 instanceof TypePlaceholder) && !(p1 instanceof GenericTypeVar))p1 = new RefType(p1);
//if(!(p2 instanceof RefType) && !(p2 instanceof TypePlaceholder) && !(p2 instanceof GenericTypeVar))p2 = new RefType(p2); //if(!(p2 instanceof RefType) && !(p2 instanceof TypePlaceholder) && !(p2 instanceof GenericTypeVar))p2 = new RefType(p2);
//if(!(TypePlaceholder.class.isInstance(p1)) || !(RefType.class.isInstance(p1)) || !(TypePlaceholder.class.isInstance(p2)) || !(RefType.class.isInstance(p2))) //if(!(TypePlaceholder.class.isInstance(p1)) || !(RefType.class.isInstance(p1)) || !(TypePlaceholder.class.isInstance(p2)) || !(RefType.class.isInstance(p2)))
//{//Wenn die beiden übergebenen Typen weder RefTypes noch TypePlaceholder sind: //{//Wenn die beiden übergebenen Typen weder RefTypes noch TypePlaceholder sind:
// throw new TypinferenzException("Ein Constraint darf nur aus TypePlaceholdern und Reftypes bestehen"); // throw new TypinferenzException("Ein Constraint darf nur aus TypePlaceholdern und Reftypes bestehen");
//} //}
//if(!(p1 instanceof RefType) && !(p1 instanceof TypePlaceholder))throw new DebugException("Fehler: "+p2+" kann nicht in TPH oder RefType umgewandelt werden"); //if(!(p1 instanceof RefType) && !(p1 instanceof TypePlaceholder))throw new DebugException("Fehler: "+p2+" kann nicht in TPH oder RefType umgewandelt werden");
//if(!(p2 instanceof RefType) && !(p2 instanceof TypePlaceholder))throw new DebugException("Fehler: "+p2+" kann nicht in TPH oder RefType umgewandelt werden"); //if(!(p2 instanceof RefType) && !(p2 instanceof TypePlaceholder))throw new DebugException("Fehler: "+p2+" kann nicht in TPH oder RefType umgewandelt werden");
//constraintPair = new Pair(p1,p2); constraintPair = new Pair(p1,p2);
} }
/*
@Override @Override
public String toString(){ public String toString(){
return ""+constraintPair.TA1.toString()+" < "+constraintPair.TA2.toString(); return ""+constraintPair.TA1.toString()+" < "+constraintPair.TA2.toString();
} }
*/
} }

View File

@ -1,57 +1,43 @@
package de.dhbwstuttgart.typeinference; package de.dhbwstuttgart.typeinference;
import java.util.Iterator; import java.util.Vector;
import de.dhbwstuttgart.typeinference.Menge;
import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.typeinference.unify.Unifier; import de.dhbwstuttgart.typeinference.unify.Unifier;
/** /**
* Stellt ein Constraint dar, welches aus mehreren Constraint-Paaren besteht. Diese gelten alle stets gleichzeitig / sind per "Und" miteinander verknüpft. * Stellt ein Constraint dar, welches aus mehreren Constraint-Paaren besteht. Diese gelten alle stets gleichzeitig / sind per "Und" miteinander verknüpft.
* @author janulrich * @author janulrich
* *
*/ */
public class UndConstraint{ public class UndConstraint extends OderConstraint {
private UndMenge<Pair> uSet = new UndMenge<Pair>();
public UndConstraint(ConstraintType p1, ConstraintType p2) { public UndConstraint(ConstraintType p1, ConstraintType p2) {
//super(p1, p2); super(p1, p2);
this.uSet.addItem(new SingleConstraint(p1,p2).getPair());
} }
public UndConstraint() { public UndConstraint() {
super(); super();
} }
UndMenge<Pair> getConstraints(){
return uSet;
}
/*
@Override @Override
public Menge<UndConstraint> getUndConstraints() { public Vector<UndConstraint> getUndConstraints() {
Menge<UndConstraint> ret = new Menge<UndConstraint>(); Vector<UndConstraint> ret = new Vector<UndConstraint>();
ret.add(this); ret.add(this);
return ret; return ret;
} }
*/
@Override @Override
public String toString(){ public String toString(){
//String ret = super.toString(); //String ret = super.toString();
//return ret.replace('|', ','); //return ret.replace('|', ',');
/*
String ret = "["; String ret = "[";
for(Pair p : this.uSet.getItems()){ for(Pair p : this.getConstraintPairs()){
ret += p.toString()+ ", "; ret += p.toString()+ ", ";
} }
return ret+"]"; return ret+"]";
*/
return uSet.toString();
} }
/*
@Override @Override
void filterWrongConstraints(Unifier unifier) { void filterWrongConstraints(Unifier unifier) {
//In einem UndConstraint gibt es keine falschen Constraints //In einem UndConstraint gibt es keine falschen Constraints
@ -61,18 +47,4 @@ public class UndConstraint{
UndConstraint filterUndConstraints(){ UndConstraint filterUndConstraints(){
return this; return this;
} }
@Override
public Iterator<Pair> iterator() {
return this.uSet.getItems().iterator();
}
*/
public void addConstraint(ConstraintType type, ConstraintType type2) {
this.uSet.addItem(new ConstraintPair(type,type2).getPair());
}
public void addConstraint(ConstraintPair constraintPair) {
this.uSet.addItem(constraintPair.getPair());
}
} }

View File

@ -638,9 +638,9 @@ public class Unify
for(Menge<Pair> pairs : vecvecpair){ for(Menge<Pair> pairs : vecvecpair){
UndConstraint uCons = new UndConstraint(); UndConstraint uCons = new UndConstraint();
for(Pair p : pairs){ for(Pair p : pairs){
uCons.addItem(p); uCons.addConstraint(new ConstraintPair(p));
} }
orConstraints.addItems(uCons); orConstraints.addConstraint(uCons);
} }
cSet.addItems(orConstraints); cSet.addItems(orConstraints);
} }