forked from JavaTX/JavaCompilerCore
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:
parent
be9ee49878
commit
b40cb49b9f
@ -18,6 +18,7 @@ import de.dhbwstuttgart.syntaxtree.type.WildcardType;
|
|||||||
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||||
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||||
|
import de.dhbwstuttgart.typeinference.result.PairNoResult;
|
||||||
import de.dhbwstuttgart.typeinference.result.PairTPHEqualTPH;
|
import de.dhbwstuttgart.typeinference.result.PairTPHEqualTPH;
|
||||||
import de.dhbwstuttgart.typeinference.result.PairTPHequalRefTypeOrWildcardType;
|
import de.dhbwstuttgart.typeinference.result.PairTPHequalRefTypeOrWildcardType;
|
||||||
import de.dhbwstuttgart.typeinference.result.PairTPHsmallerTPH;
|
import de.dhbwstuttgart.typeinference.result.PairTPHsmallerTPH;
|
||||||
@ -208,6 +209,7 @@ public class UnifyTypeFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ResultPair convert(UnifyPair mp, Map<String,TypePlaceholder> tphs) {
|
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 tl = UnifyTypeFactory.convert(mp.getLhsType(), tphs);
|
||||||
RefTypeOrTPHOrWildcardOrGeneric tr = UnifyTypeFactory.convert(mp.getRhsType(), tphs);
|
RefTypeOrTPHOrWildcardOrGeneric tr = UnifyTypeFactory.convert(mp.getRhsType(), tphs);
|
||||||
if(tl instanceof TypePlaceholder){
|
if(tl instanceof TypePlaceholder){
|
||||||
@ -218,7 +220,7 @@ public class UnifyTypeFactory {
|
|||||||
//Einfach ignorieren TODO: Das hier muss ausgebessert werden:
|
//Einfach ignorieren TODO: Das hier muss ausgebessert werden:
|
||||||
//return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, ASTFactory.createObjectType());
|
//return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, ASTFactory.createObjectType());
|
||||||
}else{
|
}else{
|
||||||
return new PairTPHsmallerTPH((TypePlaceholder)tl, (TypePlaceholder)tr);
|
return new PairTPHsmallerTPH((TypePlaceholder)tl, (TypePlaceholder)tr, convert(mp.getBasePair(), tphs));
|
||||||
}
|
}
|
||||||
}else if(tr instanceof RefType){
|
}else if(tr instanceof RefType){
|
||||||
return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (RefType) tr);
|
return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (RefType) tr);
|
||||||
@ -227,7 +229,7 @@ public class UnifyTypeFactory {
|
|||||||
}else if(tr instanceof GenericRefType){
|
}else if(tr instanceof GenericRefType){
|
||||||
return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (GenericRefType) tr);
|
return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (GenericRefType) tr);
|
||||||
}else throw new NotImplementedException();
|
}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) {
|
public static RefTypeOrTPHOrWildcardOrGeneric convert(ReferenceType t, Map<String,TypePlaceholder> tphs) {
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -10,12 +10,23 @@ public class PairTPHsmallerTPH extends ResultPair{
|
|||||||
public final TypePlaceholder left;
|
public final TypePlaceholder left;
|
||||||
public final TypePlaceholder right;
|
public final TypePlaceholder right;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* urspruengliches Paar aus diesem dieses Resultpair erzeugt wurde
|
||||||
|
* wichtig fuer generated Generics
|
||||||
|
*/
|
||||||
|
ResultPair origPair;
|
||||||
|
|
||||||
public PairTPHsmallerTPH(TypePlaceholder left, TypePlaceholder right){
|
public PairTPHsmallerTPH(TypePlaceholder left, TypePlaceholder right){
|
||||||
super(left, right);
|
super(left, right);
|
||||||
this.left = left;
|
this.left = left;
|
||||||
this.right = right;
|
this.right = right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PairTPHsmallerTPH(TypePlaceholder left, TypePlaceholder right, ResultPair origPair){
|
||||||
|
this(left, right);
|
||||||
|
this.origPair = origPair;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(ResultPairVisitor visitor) {
|
public void accept(ResultPairVisitor visitor) {
|
||||||
visitor.visit(this);
|
visitor.visit(this);
|
||||||
|
@ -4,4 +4,7 @@ public interface ResultPairVisitor {
|
|||||||
void visit(PairTPHsmallerTPH p);
|
void visit(PairTPHsmallerTPH p);
|
||||||
void visit(PairTPHequalRefTypeOrWildcardType p);
|
void visit(PairTPHequalRefTypeOrWildcardType p);
|
||||||
void visit(PairTPHEqualTPH p);
|
void visit(PairTPHEqualTPH p);
|
||||||
|
|
||||||
|
//bisher nicht umgesetzt
|
||||||
|
//void visit(PairNoResult p);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user