forked from JavaTX/JavaCompilerCore
Added missing rules
This commit is contained in:
parent
21c6aef7fd
commit
0e524caae7
@ -16,6 +16,14 @@ public interface IRuleSet {
|
|||||||
public Optional<Set<MPair>> reduce1(MPair pair);
|
public Optional<Set<MPair>> reduce1(MPair pair);
|
||||||
public Optional<Set<MPair>> reduce2(MPair pair);
|
public Optional<Set<MPair>> reduce2(MPair pair);
|
||||||
|
|
||||||
|
public Optional<MPair> reduceWildcardLow(MPair pair);
|
||||||
|
public Optional<MPair> reduceWildcardLowRight(MPair pair);
|
||||||
|
public Optional<MPair> reduceWildcardUp(MPair pair);
|
||||||
|
public Optional<MPair> reduceWildcardUpRight(MPair pair);
|
||||||
|
public Optional<MPair> reduceWildCardLowUp(MPair pair);
|
||||||
|
public Optional<MPair> reduceWildcardUpLow(MPair pair);
|
||||||
|
public Optional<MPair> reduceWildcardLeft(MPair pair);
|
||||||
|
|
||||||
public boolean erase1(MPair pair);
|
public boolean erase1(MPair pair);
|
||||||
public boolean erase2(MPair pair);
|
public boolean erase2(MPair pair);
|
||||||
public boolean erase3(MPair pair);
|
public boolean erase3(MPair pair);
|
||||||
|
@ -559,4 +559,102 @@ public class RuleSet implements IRuleSet{
|
|||||||
|
|
||||||
return applied ? Optional.of(new HashSet<>(result)) : Optional.empty();
|
return applied ? Optional.of(new HashSet<>(result)) : Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<MPair> reduceWildcardLow(MPair pair) {
|
||||||
|
if(pair.getPairOp() != PairOperator.SMALLERDOTWC)
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
Type lhsType = pair.getLhsType();
|
||||||
|
Type rhsType = pair.getRhsType();
|
||||||
|
if(!(lhsType instanceof ExtendsType) || !(rhsType instanceof ExtendsType))
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
return Optional.of(new MPair(((ExtendsType) lhsType).getExtendedType(), ((ExtendsType) rhsType).getExtendedType(), PairOperator.SMALLERDOT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<MPair> reduceWildcardLowRight(MPair pair) {
|
||||||
|
if(pair.getPairOp() != PairOperator.SMALLERDOTWC)
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
Type lhsType = pair.getLhsType();
|
||||||
|
Type rhsType = pair.getRhsType();
|
||||||
|
if((lhsType instanceof ExtendsType) || !(rhsType instanceof ExtendsType))
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
return Optional.of(new MPair(lhsType, ((ExtendsType) rhsType).getExtendedType(), PairOperator.SMALLERDOT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<MPair> reduceWildcardUp(MPair pair) {
|
||||||
|
if(pair.getPairOp() != PairOperator.SMALLERDOTWC)
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
Type lhsType = pair.getLhsType();
|
||||||
|
Type rhsType = pair.getRhsType();
|
||||||
|
if(!(lhsType instanceof SuperType) || !(rhsType instanceof SuperType))
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
return Optional.of(new MPair(((SuperType) rhsType).getSuperedType(), ((SuperType) lhsType).getSuperedType(), PairOperator.SMALLERDOT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<MPair> reduceWildcardUpRight(MPair pair) {
|
||||||
|
if(pair.getPairOp() != PairOperator.SMALLERDOTWC)
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
Type lhsType = pair.getLhsType();
|
||||||
|
Type rhsType = pair.getRhsType();
|
||||||
|
if((lhsType instanceof SuperType) || !(rhsType instanceof SuperType))
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
return Optional.of(new MPair(((SuperType) rhsType).getSuperedType(), lhsType, PairOperator.SMALLERDOT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<MPair> reduceWildCardLowUp(MPair pair) {
|
||||||
|
if(pair.getPairOp() != PairOperator.SMALLERDOTWC)
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
Type lhsType = pair.getLhsType();
|
||||||
|
Type rhsType = pair.getRhsType();
|
||||||
|
if(!(lhsType instanceof ExtendsType) || !(rhsType instanceof SuperType))
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
return Optional.of(new MPair(((ExtendsType) lhsType).getExtendedType(), ((SuperType) rhsType).getSuperedType(), PairOperator.EQUALSDOT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<MPair> reduceWildcardUpLow(MPair pair) {
|
||||||
|
if(pair.getPairOp() != PairOperator.SMALLERDOTWC)
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
Type lhsType = pair.getLhsType();
|
||||||
|
Type rhsType = pair.getRhsType();
|
||||||
|
if(!(lhsType instanceof SuperType) || !(rhsType instanceof ExtendsType))
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
return Optional.of(new MPair(((SuperType) lhsType).getSuperedType(), ((ExtendsType) rhsType).getExtendedType(), PairOperator.EQUALSDOT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<MPair> reduceWildcardLeft(MPair pair) {
|
||||||
|
if(pair.getPairOp() != PairOperator.SMALLERDOTWC)
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
Type rhsType = pair.getRhsType();
|
||||||
|
if((rhsType instanceof SuperType) || (rhsType instanceof ExtendsType))
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
Type lhsType = pair.getLhsType();
|
||||||
|
|
||||||
|
if(lhsType instanceof SuperType)
|
||||||
|
return Optional.of(new MPair(((SuperType) lhsType).getSuperedType(), rhsType, PairOperator.EQUALSDOT));
|
||||||
|
|
||||||
|
if(lhsType instanceof ExtendsType)
|
||||||
|
return Optional.of(new MPair(((ExtendsType) lhsType).getExtendedType(), rhsType, PairOperator.EQUALSDOT));
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user