Void Reference-Typen wieder zu Void RefTypes konvertieren

This commit is contained in:
JanUlrich 2016-05-03 12:46:32 +02:00
parent 4a6a8d62e3
commit ca8952a43c
3 changed files with 35 additions and 0 deletions

View File

@ -94,6 +94,7 @@ public class Logger {
public static String getWholeLog(){
String ret = "";
LOG_HISTORY.removeIf((logLine)->logLine==null);
Logger.LOG_HISTORY.sort((log1, log2)->log1.timestamp.compareTo(log2.timestamp));
ret += Logger.LOG_HISTORY.toString();
return ret;

View File

@ -15,6 +15,7 @@ import de.dhbwstuttgart.syntaxtree.type.RefType;
import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType;
import de.dhbwstuttgart.syntaxtree.type.Type;
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
import de.dhbwstuttgart.syntaxtree.type.Void;
import de.dhbwstuttgart.syntaxtree.type.WildcardType;
import de.dhbwstuttgart.typeinference.ConstraintsSet;
import de.dhbwstuttgart.typeinference.EinzelElement;
@ -171,6 +172,7 @@ public class UnifyTypeFactory {
public static Type convert(ReferenceType t) {
//TODO: Hier kann man die GTVs extrahieren
if(t.getName() == "void")return new Void(NULL_NODE, 0);
RefType ret = new RefType(t.getName(),null,0);
ret.set_ParaList(convert(t.getTypeParams()));
return ret;

View File

@ -850,6 +850,38 @@ public class UnifyTest {
//Assert.assertEquals(expected, actual);
}
@Test
public void unifyTestVector(){
/*
* Vector<T2> < T1
* T1 < Vector<String>
*/
TypeFactory tf = new TypeFactory();
FiniteClosureBuilder fcb = new FiniteClosureBuilder();
UnifyType tphT1 = tf.getPlaceholderType("T1");
UnifyType tphT2 = tf.getPlaceholderType("T2");
UnifyType gtv = tf.getSimpleType("gtv");
UnifyType vector = tf.getSimpleType("Vector", gtv);
UnifyType vectorE = tf.getSimpleType("Vector", tphT2);
UnifyType string = tf.getSimpleType("String");
UnifyType vectorString = tf.getSimpleType("Vector", string);
fcb.add(vector, vector);
IFiniteClosure fc = fcb.getFiniteClosure();
Set<UnifyPair> eq = new HashSet<UnifyPair>();
eq.add(new UnifyPair(tphT1, vectorString, PairOperator.SMALLERDOT));
eq.add(new UnifyPair(vectorE, tphT1, PairOperator.SMALLERDOT));
Set<Set<UnifyPair>> actual = new TypeUnify().unifySequential(eq, fc);
System.out.println("Test OverloadingVector:");
System.out.println(actual);
}
@Test
public void unifyTestOverloading(){
/*