implemented scalark3 test
This commit is contained in:
parent
7d3ef78ccd
commit
4dec73cada
@ -676,6 +676,563 @@ public class UnifyTest {
|
||||
System.out.println(solution.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scalark3(){
|
||||
UnifyType type1;
|
||||
UnifyType type2;
|
||||
|
||||
//und-constraints
|
||||
Set<UnifyPair> undConstraints = new HashSet<>();
|
||||
//X <. E
|
||||
type1 = new PlaceholderType("X");
|
||||
type2 = new PlaceholderType("E");
|
||||
undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//L =. Scalar
|
||||
type1 = new PlaceholderType("L");
|
||||
type2 = new ReferenceType("Scalar");
|
||||
undConstraints.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//F <. E
|
||||
type1 = new PlaceholderType("F");
|
||||
type2 = new PlaceholderType("E");
|
||||
undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//H =. Scalar
|
||||
type1 = new PlaceholderType("H");
|
||||
type2 = new ReferenceType("Scalar");
|
||||
undConstraints.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//E <!=. java.lang.Number
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Number");
|
||||
undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERNEQDOT));
|
||||
//G =. java.lang.Boolean
|
||||
type1 = new PlaceholderType("G");
|
||||
type2 = new ReferenceType("java.lang.Boolean");
|
||||
undConstraints.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//java.lang.Boolean =. G
|
||||
type1 = new ReferenceType("java.lang.Boolean");
|
||||
type2 = new PlaceholderType("G");
|
||||
undConstraints.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//J <!=. java.lang.Number
|
||||
type1 = new PlaceholderType("J");
|
||||
type2 = new ReferenceType("java.lang.Number");
|
||||
undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERNEQDOT));
|
||||
//V <. C
|
||||
type1 = new PlaceholderType("V");
|
||||
type2 = new PlaceholderType("C");
|
||||
undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//C =. A
|
||||
type1 = new PlaceholderType("C");
|
||||
type2 = new PlaceholderType("A");
|
||||
undConstraints.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//D <. C
|
||||
type1 = new PlaceholderType("D");
|
||||
type2 = new PlaceholderType("C");
|
||||
undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
|
||||
//oder-constraints
|
||||
List<Set<Constraint<UnifyPair>>> oderConstraints = new ArrayList<>();
|
||||
Set<Constraint<UnifyPair>> constraints = new HashSet<>();
|
||||
Constraint<UnifyPair> constraint = new Constraint<>();
|
||||
|
||||
//set #1
|
||||
constraints = new HashSet<>();
|
||||
//D =. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("D");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraints.add(constraint);
|
||||
//D =. java.lang.Float
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("D");
|
||||
type2 = new ReferenceType("java.lang.Float");
|
||||
constraints.add(constraint);
|
||||
oderConstraints.add(constraints);
|
||||
|
||||
//set #2
|
||||
constraints = new HashSet<>();
|
||||
//F =. java.lang.Float
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("F");
|
||||
type2 = new ReferenceType("java.lang.Float");
|
||||
constraints.add(constraint);
|
||||
//F =. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("F");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraints.add(constraint);
|
||||
oderConstraints.add(constraints);
|
||||
|
||||
//set #3
|
||||
constraints = new HashSet<>();
|
||||
//H =. ? extends Scalar
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("H");
|
||||
type2 = new ExtendsType(new ReferenceType("Scalar"));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//java.lang.Integer =. J
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new PlaceholderType("J");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//java.lang.Integer =. J
|
||||
constraint = new Constraint<>();
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new PlaceholderType("J");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//H =. ? extends Vector<AJU>
|
||||
type1 = new PlaceholderType("H");
|
||||
type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJU"))));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//java.lang.Integer =. J
|
||||
constraint = new Constraint<>();
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new PlaceholderType("J");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//H =. Vector<AJU>
|
||||
type1 = new PlaceholderType("H");
|
||||
type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJU")));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//java.lang.Integer =. J
|
||||
constraint = new Constraint<>();
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new PlaceholderType("J");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//H =. ? extends AbstractList<AJT>
|
||||
type1 = new PlaceholderType("H");
|
||||
type2 = new ExtendsType(new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("AJT"))));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//java.lang.Integer =. J
|
||||
constraint = new Constraint<>();
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new PlaceholderType("J");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//H =. Scalar
|
||||
type1 = new PlaceholderType("H");
|
||||
type2 = new ReferenceType("Scalar");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//java.lang.Integer =. J
|
||||
constraint = new Constraint<>();
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new PlaceholderType("J");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//H =. AbstractList<AJT>
|
||||
type1 = new PlaceholderType("H");
|
||||
type2 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("AJT")));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
oderConstraints.add(constraints);
|
||||
|
||||
//set #4
|
||||
constraints = new HashSet<>();
|
||||
//E <. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//L =. Scalar
|
||||
type1 = new PlaceholderType("L");
|
||||
type2 = new ReferenceType("Scalar");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//java.lang.Integer =. O
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new PlaceholderType("O");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//E <. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//AJV =. O
|
||||
type1 = new PlaceholderType("AJV");
|
||||
type2 = new PlaceholderType("O");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//L =. AbstractList<AJV>
|
||||
type1 = new PlaceholderType("L");
|
||||
type2 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("AJV")));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//E <. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//java.lang.Integer =. O
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new PlaceholderType("O");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//L =. ? extends Scalar
|
||||
type1 = new PlaceholderType("L");
|
||||
type2 = new ExtendsType(new ReferenceType("Scalar"));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//E <. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//L =. ? extends AbstractList<AJV>
|
||||
type1 = new PlaceholderType("L");
|
||||
type2 = new ExtendsType(new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("AJV"))));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//AJV =. O
|
||||
type1 = new PlaceholderType("AJV");
|
||||
type2 = new PlaceholderType("O");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//L =. Vector<AJW>
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("L");
|
||||
type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJW")));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//E <. java.lang.Integer
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//AJW =. O
|
||||
type1 = new PlaceholderType("AJW");
|
||||
type2 = new PlaceholderType("O");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//E <. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//AJW =. O
|
||||
type1 = new PlaceholderType("AJW");
|
||||
type2 = new PlaceholderType("O");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//L =. ? extends Vector<AJW>
|
||||
type1 = new PlaceholderType("L");
|
||||
type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJW"))));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
oderConstraints.add(constraints);
|
||||
|
||||
//set #5
|
||||
constraints = new HashSet<>();
|
||||
//E <. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//B =. ? extends Scalar
|
||||
type1 = new PlaceholderType("B");
|
||||
type2 = new ExtendsType(new ReferenceType("Scalar"));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//java.lang.Integer =. S
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new ReferenceType("S");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//AJX =. S
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("AJX");
|
||||
type2 = new PlaceholderType("S");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//E <. java.lang.Integer
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//B =. AbstractList<AJX>
|
||||
type1 = new PlaceholderType("B");
|
||||
type2 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("AJX")));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//AJX =. S
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("AJX");
|
||||
type2 = new PlaceholderType("S");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//E <. java.lang.Integer
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//B =. ? extends AbstractList<AJX>
|
||||
type1 = new PlaceholderType("B");
|
||||
type2 = new ExtendsType(new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("AJX"))));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//E <. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//B =. Vector<AJY>
|
||||
type1 = new PlaceholderType("B");
|
||||
type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJY")));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//AJY =. S
|
||||
type1 = new PlaceholderType("AJY");
|
||||
type2 = new PlaceholderType("S");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//E <. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//AJY =. S
|
||||
type1 = new PlaceholderType("AJY");
|
||||
type2 = new PlaceholderType("S");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//B =. ? extends Vector<AJY>
|
||||
type1 = new PlaceholderType("B");
|
||||
type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJY"))));
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//E <. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//java.lang.Integer =. S
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new PlaceholderType("S");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
//B =. Scalar
|
||||
type1 = new PlaceholderType("B");
|
||||
type2 = new ReferenceType("Scalar");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
oderConstraints.add(constraints);
|
||||
|
||||
//set #6
|
||||
constraints = new HashSet<>();
|
||||
//S <. java.lang.Float
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("S");
|
||||
type2 = new ReferenceType("java.lang.Float");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//O <. java.lang.Float
|
||||
type1 = new PlaceholderType("O");
|
||||
type2 = new ReferenceType("java.lang.Float");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//java.lang.Float =. U
|
||||
type1 = new ReferenceType("java.lang.Float");
|
||||
type2 = new PlaceholderType("U");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//S <. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("S");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//O <. java.lang.Integer
|
||||
type1 = new PlaceholderType("O");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//java.lang.Integer =. U
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new PlaceholderType("U");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
oderConstraints.add(constraints);
|
||||
|
||||
//set #7
|
||||
constraints = new HashSet<>();
|
||||
//U <. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("U");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//C <. java.lang.Integer
|
||||
type1 = new PlaceholderType("C");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//java.lang.Integer =. V
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new PlaceholderType("V");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//C <. java.lang.Float
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("C");
|
||||
type2 = new ReferenceType("java.lang.Float");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//U <. java.lang.Float#
|
||||
type1 = new PlaceholderType("U");
|
||||
type2 = new ReferenceType("java.lang.Float");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//java.lang.Float =. V
|
||||
type1 = new ReferenceType("java.lang.Float");
|
||||
type2 = new PlaceholderType("V");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
oderConstraints.add(constraints);
|
||||
|
||||
//set #8
|
||||
constraints = new HashSet<>();
|
||||
//W =. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("W");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//W =. java.lang.Float
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("W");
|
||||
type2 = new ReferenceType("java.lang.Float");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
oderConstraints.add(constraints);
|
||||
|
||||
//set #9
|
||||
constraints = new HashSet<>();
|
||||
//W <. java.lang.Integer
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("W");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//E <. java.lang.Integer
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Integer");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//java.lang.Integer =. X
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new PlaceholderType("X");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
//W <. java.lang.Float
|
||||
constraint = new Constraint<>();
|
||||
type1 = new PlaceholderType("W");
|
||||
type2 = new ReferenceType("java.lang.Float");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//E <. java.lang.Float
|
||||
type1 = new PlaceholderType("E");
|
||||
type2 = new ReferenceType("java.lang.Float");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT));
|
||||
//java.lang.Float =. X
|
||||
type1 = new ReferenceType("java.lang.Float");
|
||||
type2 = new PlaceholderType("X");
|
||||
constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT));
|
||||
constraints.add(constraint);
|
||||
oderConstraints.add(constraints);
|
||||
|
||||
//FiniteClosure
|
||||
Set<UnifyPair> fcConstraints = new HashSet<>();
|
||||
//java.lang.Number < java.lang.Object
|
||||
type1 = new ReferenceType("java.lang.Number");
|
||||
type2 = new ReferenceType("java.lang.Object");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Number < java.io.Serializable
|
||||
type1 = new ReferenceType("java.lang.Number");
|
||||
type2 = new ReferenceType("java.io.Serializable");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Integer < java.lang.Number
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new ReferenceType("java.lang.Number");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Float < java.lang.Number
|
||||
type1 = new ReferenceType("java.lang.Float");
|
||||
type2 = new ReferenceType("java.lang.Number");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Float < java.lang.Object
|
||||
type1 = new ReferenceType("java.lang.Float");
|
||||
type2 = new ReferenceType("java.lang.Object");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Float < java.lang.constant.Constable
|
||||
type1 = new ReferenceType("java.lang.Float");
|
||||
type2 = new ReferenceType("java.lang.constant.Constable");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Float < java.io.Serializable
|
||||
type1 = new ReferenceType("java.lang.Float");
|
||||
type2 = new ReferenceType("java.io.Serializable");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Float < java.lang.Comparable<java.lang.Float>
|
||||
type1 = new ReferenceType("java.lang.Float");
|
||||
type2 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Float")));
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Float < java.lang.constant.ConstantDesc
|
||||
type1 = new ReferenceType("java.lang.Float");
|
||||
type2 = new ReferenceType("java.lang.constant.ConstantDesc");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Integer < java.lang.Object
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new ReferenceType("java.lang.Object");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Integer < java.lang.constant.Constable
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new ReferenceType("java.lang.constant.Constable");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Integer < java.io.Serializable
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new ReferenceType("java.io.Serializable");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Integer < java.lang.Comparable<java.lang.Integer>
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Integer")));
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Integer < java.lang.constant.ConstantDesc
|
||||
type1 = new ReferenceType("java.lang.Integer");
|
||||
type2 = new ReferenceType("java.lang.constant.ConstantDesc");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Comparable<java.lang.Float> < java.lang.Object
|
||||
type1 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Float")));
|
||||
type2 = new ReferenceType("java.lang.Object");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//Vector<java.lang.Integer> < java.lang.Object
|
||||
type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer")));
|
||||
type2 = new ReferenceType("java.lang.Object");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//Vector<java.lang.Integer> < AbstractList<java.lang.Integer>
|
||||
type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer")));
|
||||
type2 = new ReferenceType("AbstractList", new TypeParams(new ReferenceType("java.lang.Integer")));
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//Scalar < Vector<java.lang.Integer>
|
||||
type1 = new ReferenceType("Scalar");
|
||||
type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer")));
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.constant.ConstantDesc < java.lang.Object
|
||||
type1 = new ReferenceType("java.lang.constant.ConstantDesc");
|
||||
type2 = new ReferenceType("java.lang.Object");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//Scalar < java.lang.Object
|
||||
type1 = new ReferenceType("Scalar");
|
||||
type2 = new ReferenceType("java.lang.Object");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//Scalar < AbstractList<java.lang.Integer>
|
||||
type1 = new ReferenceType("Scalar");
|
||||
type2 = new ReferenceType("AbstractList", new TypeParams(new ReferenceType("java.lang.Integer")));
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//Vector<EXP> < AbstractList<EXP>
|
||||
type1 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("EXP")));
|
||||
type2 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("EXP")));
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//Vector<EXP> < java.lang.Object
|
||||
type1 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("EXP")));
|
||||
type2 = new ReferenceType("java.lang.Object");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.constant.Constable < java.lang.Object
|
||||
type1 = new ReferenceType("java.lang.constant.Constable");
|
||||
type2 = new ReferenceType("java.lang.Object");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.io.Serializable < java.lang.Object
|
||||
type1 = new ReferenceType("java.io.Serializable");
|
||||
type2 = new ReferenceType("java.lang.Object");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//AbstractList<java.lang.Integer> < java.lang.Object
|
||||
type1 = new ReferenceType("AbstractList", new TypeParams(new ReferenceType("java.lang.Integer")));
|
||||
type2 = new ReferenceType("java.lang.Object");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
//java.lang.Comparable<java.lang.Integer> < java.lang.Object
|
||||
type1 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Integer")));
|
||||
type2 = new ReferenceType("java.lang.Object");
|
||||
fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||
|
||||
FiniteClosure finiteClosure = new FiniteClosure(fcConstraints, new NullWriter());
|
||||
TypeUnify unifyAlgo = new TypeUnify();
|
||||
ConstraintSet< Pair> cons = new ConstraintSet<>();
|
||||
UnifyResultModelParallel urm = new UnifyResultModelParallel(cons, finiteClosure);
|
||||
UnifyTaskModelParallel tasks = new UnifyTaskModelParallel();
|
||||
Set<Set<UnifyPair>> solution = unifyAlgo.unify(undConstraints, oderConstraints, finiteClosure, new NullWriter(), false, urm, tasks);
|
||||
System.out.println(solution.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matrixk2(){
|
||||
UnifyType type1;
|
||||
|
Loading…
Reference in New Issue
Block a user