From b40cb49b9f61c1ef6d9c6011c5b832eaedad3191 Mon Sep 17 00:00:00 2001 From: "pl@gohorb.ba-horb.de" Date: Mon, 19 Apr 2021 14:22:40 +0200 Subject: [PATCH] In PairTPHsmallerTPH origPair eingefuegt, was das OriginalPair darstellt, entweder vor oder waehrend der Unikation modified: src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java new file: src/main/java/de/dhbwstuttgart/typeinference/result/PairNoResult.java noetig da als oriPairs auch Paare nicht solved form vorkommen koennen modified: src/main/java/de/dhbwstuttgart/typeinference/result/PairTPHsmallerTPH.java modified: src/main/java/de/dhbwstuttgart/typeinference/result/ResultPairVisitor.java --- .../syntaxtree/factory/UnifyTypeFactory.java | 6 ++-- .../typeinference/result/PairNoResult.java | 32 +++++++++++++++++++ .../result/PairTPHsmallerTPH.java | 11 +++++++ .../result/ResultPairVisitor.java | 3 ++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/dhbwstuttgart/typeinference/result/PairNoResult.java diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java index a698ce3bf..468f9647f 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java @@ -18,6 +18,7 @@ import de.dhbwstuttgart.syntaxtree.type.WildcardType; import de.dhbwstuttgart.typeinference.constraints.Constraint; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.Pair; +import de.dhbwstuttgart.typeinference.result.PairNoResult; import de.dhbwstuttgart.typeinference.result.PairTPHEqualTPH; import de.dhbwstuttgart.typeinference.result.PairTPHequalRefTypeOrWildcardType; import de.dhbwstuttgart.typeinference.result.PairTPHsmallerTPH; @@ -208,6 +209,7 @@ public class UnifyTypeFactory { } public static ResultPair convert(UnifyPair mp, Map tphs) { + if (mp == null) { return null;} //kann bei basePairs passieren RefTypeOrTPHOrWildcardOrGeneric tl = UnifyTypeFactory.convert(mp.getLhsType(), tphs); RefTypeOrTPHOrWildcardOrGeneric tr = UnifyTypeFactory.convert(mp.getRhsType(), tphs); if(tl instanceof TypePlaceholder){ @@ -218,7 +220,7 @@ public class UnifyTypeFactory { //Einfach ignorieren TODO: Das hier muss ausgebessert werden: //return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, ASTFactory.createObjectType()); }else{ - return new PairTPHsmallerTPH((TypePlaceholder)tl, (TypePlaceholder)tr); + return new PairTPHsmallerTPH((TypePlaceholder)tl, (TypePlaceholder)tr, convert(mp.getBasePair(), tphs)); } }else if(tr instanceof RefType){ return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (RefType) tr); @@ -227,7 +229,7 @@ public class UnifyTypeFactory { }else if(tr instanceof GenericRefType){ return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (GenericRefType) tr); }else throw new NotImplementedException(); - }else throw new NotImplementedException(); + }else return new PairNoResult(tl, tr);//throw new NotImplementedException(); } public static RefTypeOrTPHOrWildcardOrGeneric convert(ReferenceType t, Map tphs) { diff --git a/src/main/java/de/dhbwstuttgart/typeinference/result/PairNoResult.java b/src/main/java/de/dhbwstuttgart/typeinference/result/PairNoResult.java new file mode 100644 index 000000000..63b3137cc --- /dev/null +++ b/src/main/java/de/dhbwstuttgart/typeinference/result/PairNoResult.java @@ -0,0 +1,32 @@ +package de.dhbwstuttgart.typeinference.result; + +import de.dhbwstuttgart.exceptions.NotImplementedException; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; +import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; + +/** + * enthaelt alle Paare, die in einem Ergebnis nicht vorkommen koennen + * sie sind noetig fuer origPairs in PairTPHsmallerTPH, da hier auch + * Paare vorkommen koennen die keine Result sind (z.B. bei FunN$$) + */ +public class PairNoResult extends ResultPair{ + //public final TypePlaceholder left; + //public final TypePlaceholder right; + + /* + * urspruengliches Paar aus diesem dieses Resultpair erzeugt wurde + * wichtig fuer generated Generics + */ + ResultPair origPair; + + public PairNoResult(RefTypeOrTPHOrWildcardOrGeneric left, RefTypeOrTPHOrWildcardOrGeneric right){ + super(left, right); + } + + /* noch nicht implementiert. */ + @Override + public void accept(ResultPairVisitor visitor) { + throw new NotImplementedException(); + //visitor.visit(this); + } +} diff --git a/src/main/java/de/dhbwstuttgart/typeinference/result/PairTPHsmallerTPH.java b/src/main/java/de/dhbwstuttgart/typeinference/result/PairTPHsmallerTPH.java index 8d586f4b5..1df94e6b1 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/result/PairTPHsmallerTPH.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/result/PairTPHsmallerTPH.java @@ -9,6 +9,12 @@ import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; public class PairTPHsmallerTPH extends ResultPair{ public final TypePlaceholder left; public final TypePlaceholder right; + + /* + * urspruengliches Paar aus diesem dieses Resultpair erzeugt wurde + * wichtig fuer generated Generics + */ + ResultPair origPair; public PairTPHsmallerTPH(TypePlaceholder left, TypePlaceholder right){ super(left, right); @@ -16,6 +22,11 @@ public class PairTPHsmallerTPH extends ResultPair{ this.right = right; } + public PairTPHsmallerTPH(TypePlaceholder left, TypePlaceholder right, ResultPair origPair){ + this(left, right); + this.origPair = origPair; + } + @Override public void accept(ResultPairVisitor visitor) { visitor.visit(this); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/result/ResultPairVisitor.java b/src/main/java/de/dhbwstuttgart/typeinference/result/ResultPairVisitor.java index 18427731b..e1372336f 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/result/ResultPairVisitor.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/result/ResultPairVisitor.java @@ -4,4 +4,7 @@ public interface ResultPairVisitor { void visit(PairTPHsmallerTPH p); void visit(PairTPHequalRefTypeOrWildcardType p); void visit(PairTPHEqualTPH p); + + //bisher nicht umgesetzt + //void visit(PairNoResult p); }