forked from JavaTX/JavaCompilerCore
implemented unify test
This commit is contained in:
parent
4dbae46765
commit
bb4eaaccc5
@ -1,17 +1,27 @@
|
|||||||
package typeinference;
|
package typeinference;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile;
|
||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.Constructor;
|
||||||
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||||
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory;
|
||||||
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
|
||||||
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
|
||||||
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
import de.dhbwstuttgart.typedeployment.TypeInsert;
|
||||||
import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
|
import de.dhbwstuttgart.typedeployment.TypeInsertFactory;
|
||||||
|
import de.dhbwstuttgart.typeinference.constraints.Constraint;
|
||||||
|
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
||||||
|
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
import de.dhbwstuttgart.typeinference.unify.TypeUnify;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.UnifyResultModel;
|
||||||
|
import de.dhbwstuttgart.typeinference.unify.UnifyTaskModel;
|
||||||
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.*;
|
import de.dhbwstuttgart.typeinference.unify.model.*;
|
||||||
|
import org.apache.commons.io.output.NullWriter;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -40,11 +50,11 @@ public class UnifyTest {
|
|||||||
UnifyPair pair2 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
|
UnifyPair pair2 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
|
||||||
|
|
||||||
type1 = new ReferenceType("String");
|
type1 = new ReferenceType("String");
|
||||||
type2 = new ReferenceType("b");
|
type2 = new PlaceholderType("b");
|
||||||
UnifyPair pair3 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
|
UnifyPair pair3 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
|
||||||
|
|
||||||
type1 = new ReferenceType("Integer");
|
type1 = new ReferenceType("Integer");
|
||||||
type2 = new ReferenceType("c");
|
type2 = new PlaceholderType("c");
|
||||||
UnifyPair pair4 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
|
UnifyPair pair4 = new UnifyPair(type1, type2, PairOperator.SMALLERDOT);
|
||||||
|
|
||||||
Set<UnifyPair> undConstraints = new HashSet<>();
|
Set<UnifyPair> undConstraints = new HashSet<>();
|
||||||
@ -53,10 +63,32 @@ public class UnifyTest {
|
|||||||
undConstraints.add(pair3);
|
undConstraints.add(pair3);
|
||||||
undConstraints.add(pair4);
|
undConstraints.add(pair4);
|
||||||
|
|
||||||
/*IFiniteClosure finiteClosure = UnifyTypeFactory.
|
List<Set<Constraint<UnifyPair>>> oderConstraints = new ArrayList<>();
|
||||||
|
|
||||||
|
Set<UnifyPair> constraints = new HashSet<>();
|
||||||
|
type1 = new ReferenceType("Object");
|
||||||
|
type2 = new ReferenceType("String");
|
||||||
|
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||||
|
type1 = new ReferenceType("Number");
|
||||||
|
type2 = new ReferenceType("Integer");
|
||||||
|
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||||
|
type1 = new ReferenceType("Object");
|
||||||
|
type2 = new ReferenceType("Number");
|
||||||
|
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||||
|
type1 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("X")));
|
||||||
|
type2 = new ReferenceType("List", new TypeParams(new PlaceholderType("X")));
|
||||||
|
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||||
|
type1 = new ReferenceType("Object");
|
||||||
|
type2 = new ReferenceType("AbstractList", new TypeParams(new PlaceholderType("X")));
|
||||||
|
constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER));
|
||||||
|
|
||||||
|
IFiniteClosure finiteClosure = new FiniteClosure(constraints, new NullWriter());
|
||||||
|
|
||||||
TypeUnify unifyAlgo = new TypeUnify();
|
TypeUnify unifyAlgo = new TypeUnify();
|
||||||
unifyAlgo.unifyParallel()*/
|
ConstraintSet< Pair> cons = new ConstraintSet<>();
|
||||||
|
UnifyResultModel urm = new UnifyResultModel(cons, finiteClosure);
|
||||||
|
UnifyTaskModel tasks = new UnifyTaskModel();
|
||||||
|
urm = unifyAlgo.unifyParallel(undConstraints, oderConstraints, finiteClosure, new NullWriter(), false, urm, tasks);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user