diff --git a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java index 7dbc0864..40e96d38 100755 --- a/src/de/dhbwstuttgart/syntaxtree/SourceFile.java +++ b/src/de/dhbwstuttgart/syntaxtree/SourceFile.java @@ -810,7 +810,7 @@ public class SourceFile // In streamconstraintsclone sind die Mengen von Paar enthalten die unifiziert werden muessen Stream> streamconstraintsclone = indexeset.stream().map(x -> x.stream() .map(i -> constraintsClone.elementAt(i)) - .collect(Menge::new, Menge::add, Menge::addAll)); + .>collect(Menge::new, Menge::add, Menge::addAll)); //Menge> vecconstraintsclone = streamconstraintsclone.collect(Menge::new, Menge::add, Menge::addAll); System.out.println(); //Schritt 4: Unifikation diff --git a/src/de/dhbwstuttgart/typeinference/DeepCloneable.java b/src/de/dhbwstuttgart/typeinference/DeepCloneable.java new file mode 100644 index 00000000..c20b6493 --- /dev/null +++ b/src/de/dhbwstuttgart/typeinference/DeepCloneable.java @@ -0,0 +1,18 @@ +package de.dhbwstuttgart.typeinference; + +public interface DeepCloneable{ + public A deepClone(); +} + +/* +public class CloneableMenge extends Menge{ + + public CloneableMenge deepClone(){ + CloneableMenge ret = new CloneableMenge<>(); + for(A i : this){ + ret.add(i.deepClone()); + } + return ret; + } +} +*/ \ No newline at end of file diff --git a/src/de/dhbwstuttgart/typeinference/Menge.java b/src/de/dhbwstuttgart/typeinference/Menge.java index 10df5235..aa2b2f43 100644 --- a/src/de/dhbwstuttgart/typeinference/Menge.java +++ b/src/de/dhbwstuttgart/typeinference/Menge.java @@ -3,6 +3,7 @@ package de.dhbwstuttgart.typeinference; import java.util.Set; import java.util.Vector; + public class Menge extends Vector implements Set{ - + } diff --git a/src/de/dhbwstuttgart/typeinference/Pair.java b/src/de/dhbwstuttgart/typeinference/Pair.java index 21f0e989..dcb13958 100755 --- a/src/de/dhbwstuttgart/typeinference/Pair.java +++ b/src/de/dhbwstuttgart/typeinference/Pair.java @@ -31,7 +31,7 @@ import de.dhbwstuttgart.syntaxtree.type.WildcardType; // Klasse, die ein Paar in der Menge Eq speichern kann // ino.end // ino.class.Pair.26540.declaration -public class Pair implements Serializable +public class Pair implements Serializable, DeepCloneable // ino.end // ino.class.Pair.26540.body { @@ -414,6 +414,7 @@ public class Pair implements Serializable } public Pair deepClone() { + /* try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); @@ -427,6 +428,8 @@ public class Pair implements Serializable } catch (ClassNotFoundException e) { return null; } + */ + return clone(); } } // ino.end diff --git a/src/de/dhbwstuttgart/typeinference/unify/Unify.java b/src/de/dhbwstuttgart/typeinference/unify/Unify.java index b7e54a07..bb561cbf 100755 --- a/src/de/dhbwstuttgart/typeinference/unify/Unify.java +++ b/src/de/dhbwstuttgart/typeinference/unify/Unify.java @@ -11,6 +11,9 @@ import java.util.Set; import de.dhbwstuttgart.typeinference.Menge; +import java.util.function.BiConsumer; +import java.util.function.Function; +import java.util.function.Supplier; import java.util.stream.Stream; import com.google.common.collect.Sets; @@ -41,6 +44,7 @@ import de.dhbwstuttgart.syntaxtree.type.ObjectType; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.type.WildcardType; import de.dhbwstuttgart.typeinference.ConstraintsSet; +import de.dhbwstuttgart.typeinference.DeepCloneable; import de.dhbwstuttgart.typeinference.OderConstraint; import de.dhbwstuttgart.typeinference.Pair; import de.dhbwstuttgart.typeinference.Pair.PairOperator; @@ -674,7 +678,7 @@ public class Unify for (Menge> vecvecpair : cartProduktSets){ if(vecvecpair.size() == 1){//gibt es nur eine UndMenge in diesem Set, dann kommt diese in jedem Karthesischen Produkt vor: //undMenge.addAll(cloner.deepClone(vecvecpair.firstElement())); - undMenge.addAll(vecvecpair.firstElement()); + undMenge.addAll(Unify.deepClone(vecvecpair.firstElement())); temp.add(vecvecpair); }else{//gibt es mehrere Mengen, kann gefiltert werden: oderConstraints.add(vecvecpair); //die Menge zu den zu filternden OderConstraints anfügen @@ -2469,7 +2473,19 @@ throws MatchException inferencelog.debug("Nummer: " + nTypnrInPair); inferencelog.debug("TV: " + a.getName()); inferencelog.debug("Bedingung: " + bMitVorbedingung); - + /* + Cloner cloner = new Cloner(); + cloner.setDumpClonedClasses(true); + SectionLogger log = Logger.getSectionLogger("Subst-Methode", Section.UNIFY); + Timewatch timer = Timewatch.getTimewatch(); + de.dhbwstuttgart.logger.Timestamp timestamp = timer.start("Unify-Subst"); + P = cloner.deepClone(P); + a = cloner.deepClone(a); + o = cloner.deepClone(o); + long time = timestamp.stop(); + log.debug("Benötigte Zeit für DeepClone: "+time); + */ + // richtiger Typ aus Pair raussuchen Type T = null; if( nTypnrInPair == 1 ) @@ -3632,5 +3648,11 @@ tempKlasse.get_Superclass_Name() ); System.out.println( "P. S.: return T instanceof FreshWildcardType; } + private static Menge deepClone(Menge m){ + + Menge ret = m.stream().map((Function)(x -> x.deepClone())).>collect(Menge::new, Menge::add, Menge::addAll); + + return ret; + } } -// ino.end +// ino.end \ No newline at end of file