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
This commit is contained in:
pl@gohorb.ba-horb.de 2021-04-19 14:22:40 +02:00
parent be9ee49878
commit b40cb49b9f
4 changed files with 50 additions and 2 deletions

View File

@ -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<String,TypePlaceholder> 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<String,TypePlaceholder> tphs) {

View File

@ -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<RefTypeOrTPHOrWildcardOrGeneric, RefTypeOrTPHOrWildcardOrGeneric>{
//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);
}
}

View File

@ -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);

View File

@ -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);
}