From ca8952a43c0e335be33906b396034709ac93f092 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Tue, 3 May 2016 12:46:32 +0200 Subject: [PATCH] Void Reference-Typen wieder zu Void RefTypes konvertieren --- src/de/dhbwstuttgart/logger/Logger.java | 1 + .../syntaxtree/factory/UnifyTypeFactory.java | 2 ++ test/unify/UnifyTest.java | 32 +++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/src/de/dhbwstuttgart/logger/Logger.java b/src/de/dhbwstuttgart/logger/Logger.java index c1bbd93e..725c6fd5 100755 --- a/src/de/dhbwstuttgart/logger/Logger.java +++ b/src/de/dhbwstuttgart/logger/Logger.java @@ -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; diff --git a/src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java b/src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java index 66553dc9..06069bc6 100644 --- a/src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java +++ b/src/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java @@ -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; diff --git a/test/unify/UnifyTest.java b/test/unify/UnifyTest.java index d4f36b39..825fd40d 100644 --- a/test/unify/UnifyTest.java +++ b/test/unify/UnifyTest.java @@ -850,6 +850,38 @@ public class UnifyTest { //Assert.assertEquals(expected, actual); } + @Test + public void unifyTestVector(){ + /* + * Vector < T1 + * T1 < Vector + */ + 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 eq = new HashSet(); + eq.add(new UnifyPair(tphT1, vectorString, PairOperator.SMALLERDOT)); + eq.add(new UnifyPair(vectorE, tphT1, PairOperator.SMALLERDOT)); + + Set> actual = new TypeUnify().unifySequential(eq, fc); + + System.out.println("Test OverloadingVector:"); + System.out.println(actual); + } + @Test public void unifyTestOverloading(){ /*