forked from JavaTX/JavaCompilerCore
first call to unify
This commit is contained in:
parent
bd8a62cda7
commit
7484ace724
@ -1,23 +1,58 @@
|
||||
package unify;
|
||||
|
||||
import org.apache.commons.bcel6.generic.ReferenceType;
|
||||
import org.junit.Test;
|
||||
|
||||
import de.dhbwstuttgart.bytecode.TypePlaceholderType;
|
||||
import de.dhbwstuttgart.syntaxtree.Class;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.Menge;
|
||||
import de.dhbwstuttgart.typeinference.Pair;
|
||||
import de.dhbwstuttgart.typeinference.unify.FC_TTO;
|
||||
import de.dhbwstuttgart.typeinference.unify.Unify;
|
||||
|
||||
public class UnifyTest {
|
||||
|
||||
@Test
|
||||
public void unifyTestSimpleTypes() {
|
||||
|
||||
/*
|
||||
* Input
|
||||
*/
|
||||
Type tph1 = TypePlaceholder.backdoorCreate("b");
|
||||
Type tph2 = TypePlaceholder.backdoorCreate("a");
|
||||
//Type refT = new RefType()
|
||||
|
||||
//Pair x = new Pair();
|
||||
RefType rt1 = new RefType("java.lang.Boolean", null, 0);
|
||||
RefType rt2 = new RefType("java.lang.Integer", null, 0);
|
||||
|
||||
Menge<Pair> assumptions = new Menge<Pair>();
|
||||
|
||||
// b <. Boolean <. a <. Integer
|
||||
assumptions.add(new Pair(tph1, rt1));
|
||||
assumptions.add(new Pair(rt1, tph2));
|
||||
assumptions.add(new Pair(tph2, rt2));
|
||||
|
||||
/*
|
||||
* FC TTO
|
||||
*/
|
||||
Menge<Pair> fc = new Menge<Pair>();
|
||||
|
||||
// String <. Boolean <. Integer
|
||||
fc.add(new Pair(new RefType("java.lang.String", null, 0), new RefType("java.lang.Boolean", null, 0)));
|
||||
fc.add(new Pair(new RefType("java.lang.Boolean", null, 0), new RefType("java.lang.Integer", null, 0)));
|
||||
|
||||
Menge tto = (Menge) fc.clone();
|
||||
|
||||
Menge<Class> classes = new Menge<Class>();
|
||||
|
||||
classes.add(new Class("java.lang.Boolean", 0));
|
||||
classes.add(new Class("java.lang.String", 0));
|
||||
classes.add(new Class("java.lang.Integer", 0));
|
||||
|
||||
// Was ist tto und classes?
|
||||
FC_TTO fctto = new FC_TTO(fc, tto, null);
|
||||
|
||||
System.out.println(Unify.unify(assumptions, fctto));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user