Merge remote-tracking branch 'origin/targetBytecode' into unif23

This commit is contained in:
pl@gohorb.ba-horb.de 2023-04-11 15:52:26 +02:00
commit be6f4bd578
5 changed files with 49 additions and 3 deletions

View File

@ -121,6 +121,7 @@ public class UnifyTypeFactory {
} }
PlaceholderType ntph = new PlaceholderType(tph.getName()); PlaceholderType ntph = new PlaceholderType(tph.getName());
ntph.setVariance(tph.getVariance()); ntph.setVariance(tph.getVariance());
ntph.setOrCons(tph.getOrCons());
int in = PLACEHOLDERS.indexOf(ntph); int in = PLACEHOLDERS.indexOf(ntph);
if (in == -1) { if (in == -1) {
PLACEHOLDERS.add(ntph); PLACEHOLDERS.add(ntph);

View File

@ -25,6 +25,14 @@ public class TypePlaceholder extends RefTypeOrTPHOrWildcardOrGeneric
*/ */
private int variance = 0; private int variance = 0;
/*
* Fuer Oder-Constraints:
* orCons = 1: Receiver
* orCons = 0: Argument oder kein Oder-Constraint
* orCons = -1: RetType
*/
private byte orCons = 0;
/** /**
* Privater Konstruktor - Eine TypePlaceholder-Variable wird �ber die * Privater Konstruktor - Eine TypePlaceholder-Variable wird �ber die
@ -104,4 +112,12 @@ public class TypePlaceholder extends RefTypeOrTPHOrWildcardOrGeneric
public void accept(ResultSetVisitor visitor) { public void accept(ResultSetVisitor visitor) {
visitor.visit(this); visitor.visit(this);
} }
public void setOrCons(byte i) {
orCons = i;
}
public byte getOrCons() {
return orCons;
}
} }

View File

@ -613,6 +613,11 @@ public class TYPEStmt implements StatementVisitor{
methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(), PairOperator.EQUALSDOT)); methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(), PairOperator.EQUALSDOT));
extendsMethodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(), PairOperator.EQUALSDOT)); extendsMethodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(), PairOperator.EQUALSDOT));
//methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(), PairOperator.EQUALSDOT));
//extendsMethodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(), PairOperator.EQUALSDOT));
((TypePlaceholder)forMethod.getType()).setOrCons((byte)-1);//fuer Maximums-Bestimmung
Set<Pair> parameterContraints = generateParameterConstraints(forMethod, assumption, info, resolver); Set<Pair> parameterContraints = generateParameterConstraints(forMethod, assumption, info, resolver);
methodConstraint.addAll(parameterContraints); methodConstraint.addAll(parameterContraints);

View File

@ -131,7 +131,11 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
* fuehrt zu Fehlern bei Arrays.sort (contract nicht erfuellt) * fuehrt zu Fehlern bei Arrays.sort (contract nicht erfuellt)
* @see com.google.common.collect.Ordering#compare(java.lang.Object, java.lang.Object) * @see com.google.common.collect.Ordering#compare(java.lang.Object, java.lang.Object)
*/ */
public int compare (Set<UnifyPair> left, Set<UnifyPair> right) { public int compare (Set<UnifyPair> leftpara, Set<UnifyPair> rightpara) {
Set<UnifyPair> left = new HashSet<>(leftpara);
Set<UnifyPair> right = new HashSet<>(rightpara);
/* /*
//pairop = PairOperator.SMALLERDOTWC; //pairop = PairOperator.SMALLERDOTWC;
List<UnifyType> al = new ArrayList<>(); List<UnifyType> al = new ArrayList<>();
@ -220,22 +224,26 @@ public class OrderingUnifyPair extends OrderingExtend<Set<UnifyPair>> {
!(y.getRhsType() instanceof PlaceholderType) && !(y.getRhsType() instanceof PlaceholderType) &&
x.getPairOp() == PairOperator.EQUALSDOT);}) x.getPairOp() == PairOperator.EQUALSDOT);})
.collect(Collectors.toCollection(HashSet::new)); .collect(Collectors.toCollection(HashSet::new));
left.removeAll(lefteqOder);
Set<UnifyPair> righteqOder = right.stream() Set<UnifyPair> righteqOder = right.stream()
.filter(x -> { UnifyPair y = x.getGroundBasePair(); .filter(x -> { UnifyPair y = x.getGroundBasePair();
return (y.getLhsType() instanceof PlaceholderType && return (y.getLhsType() instanceof PlaceholderType &&
!(y.getRhsType() instanceof PlaceholderType) && !(y.getRhsType() instanceof PlaceholderType) &&
x.getPairOp() == PairOperator.EQUALSDOT);}) x.getPairOp() == PairOperator.EQUALSDOT);})
.collect(Collectors.toCollection(HashSet::new)); .collect(Collectors.toCollection(HashSet::new));
right.removeAll(righteqOder);
Set<UnifyPair> lefteqRet = left.stream() Set<UnifyPair> lefteqRet = left.stream()
.filter(x -> { UnifyPair y = x.getGroundBasePair(); .filter(x -> { UnifyPair y = x.getGroundBasePair();
return (y.getRhsType() instanceof PlaceholderType && return (y.getRhsType() instanceof PlaceholderType &&
x.getPairOp() == PairOperator.EQUALSDOT);}) ((PlaceholderType)y.getRhsType()).getOrCons() == (byte)-1);})
.collect(Collectors.toCollection(HashSet::new)); .collect(Collectors.toCollection(HashSet::new));
left.removeAll(lefteqRet);
Set<UnifyPair> righteqRet = right.stream() Set<UnifyPair> righteqRet = right.stream()
.filter(x -> { UnifyPair y = x.getGroundBasePair(); .filter(x -> { UnifyPair y = x.getGroundBasePair();
return (y.getRhsType() instanceof PlaceholderType && return (y.getRhsType() instanceof PlaceholderType &&
x.getPairOp() == PairOperator.EQUALSDOT);}) ((PlaceholderType)y.getRhsType()).getOrCons() == (byte)-1);})
.collect(Collectors.toCollection(HashSet::new)); .collect(Collectors.toCollection(HashSet::new));
right.removeAll(righteqRet);
Set<UnifyPair> leftleOder = left.stream() Set<UnifyPair> leftleOder = left.stream()
.filter(x -> (x.getPairOp() == PairOperator.SMALLERDOT)) .filter(x -> (x.getPairOp() == PairOperator.SMALLERDOT))
.collect(Collectors.toCollection(HashSet::new)); .collect(Collectors.toCollection(HashSet::new));

View File

@ -60,6 +60,14 @@ public final class PlaceholderType extends UnifyType{
*/ */
private int variance = 0; private int variance = 0;
/*
* Fuer Oder-Constraints:
* orCons = 1: Receiver
* orCons = 0: Argument oder kein Oder-Constraint
* orCons = -1: RetType
*/
private byte orCons = 0;
/** /**
* Creates a new placeholder type with the specified name. * Creates a new placeholder type with the specified name.
*/ */
@ -122,6 +130,14 @@ public final class PlaceholderType extends UnifyType{
}} }}
} }
public void setOrCons(byte i) {
orCons = i;
}
public byte getOrCons() {
return orCons;
}
public Boolean isWildcardable() { public Boolean isWildcardable() {
return wildcardable; return wildcardable;
} }