diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java index 743fbb74..326f5a77 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java @@ -120,7 +120,7 @@ public class UnifyTypeFactory { } public static UnifyType convert(TypePlaceholder tph){ - PlaceholderType ntph = new PlaceholderType(tph.getName()); + PlaceholderType ntph = PlaceholderType.convertTypePlaceholder(tph.getName());//eingefuegt PL 2019-01-11 //new PlaceholderType(tph.getName()); int in = PLACEHOLDERS.indexOf(ntph); if (in == -1) { PLACEHOLDERS.add(ntph); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java index 09402c2f..23848ae6 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java @@ -23,7 +23,7 @@ public final class PlaceholderType extends UnifyType{ * Static list containing the names of all existing placeholders. * Used for generating fresh placeholders. */ - public static final ArrayList EXISTING_PLACEHOLDERS = new ArrayList(); + public static final ArrayList EXISTING_PLACEHOLDERS = new ArrayList(); /** * Prefix of auto-generated placeholder names. @@ -60,17 +60,28 @@ public final class PlaceholderType extends UnifyType{ */ public PlaceholderType(String name) { super(name, new TypeParams()); - EXISTING_PLACEHOLDERS.add(name); // Add to list of existing placeholder names IsGenerated = false; // This type is user generated } + public static PlaceholderType convertTypePlaceholder(String name) {//eingefuegt PL 2019-01-11 + PlaceholderType newTph = new PlaceholderType(name); + int i = EXISTING_PLACEHOLDERS.indexOf(newTph);//equals vergleicht den Namen + if (i == -1) { + EXISTING_PLACEHOLDERS.add(newTph); // Add to list of existing placeholder names + return newTph; + } + else { + return EXISTING_PLACEHOLDERS.get(i); + } + } + /** * Creates a new placeholdertype * @param isGenerated true if this placeholder is auto-generated, false if it is user-generated. */ protected PlaceholderType(String name, boolean isGenerated) { super(name, new TypeParams()); - EXISTING_PLACEHOLDERS.add(name); // Add to list of existing placeholder names + EXISTING_PLACEHOLDERS.add(this); // Add to list of existing placeholder names IsGenerated = isGenerated; } diff --git a/src/test/java/javFiles/AddLong.jav b/src/test/java/javFiles/AddLong.jav deleted file mode 100644 index d6d47e9f..00000000 --- a/src/test/java/javFiles/AddLong.jav +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.Integer; -import java.lang.Long; - -public class AddLong{ - Long add(Integer a, Long b) { - Long c = a+b; - return c; - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/EmptyClass.jav b/src/test/java/javFiles/EmptyClass.jav deleted file mode 100644 index 8160d7da..00000000 --- a/src/test/java/javFiles/EmptyClass.jav +++ /dev/null @@ -1,3 +0,0 @@ -public class EmptyClass{ - -} \ No newline at end of file diff --git a/src/test/java/javFiles/EmptyMethod.jav b/src/test/java/javFiles/EmptyMethod.jav deleted file mode 100644 index dd28fc69..00000000 --- a/src/test/java/javFiles/EmptyMethod.jav +++ /dev/null @@ -1,37 +0,0 @@ -public class EmptyMethod{ - static String s1 =""; - String s2; - public void m1(){ - //String s = ""; - System.out.println("test"); - //Integer ab = Math.abs(1); - //Math.abs(1); - //String lV = "local"; - //s1 = "1"; - //s1.concat("2"); - s2 = s1; - //m2(); - Clazz i = new Clazz(); - Integer i = new Integer(1); - } - - public void m2(){} -} - -class Clazz{} -/* -public class EmptyMethod2{ - public static test = "5"; - public void m1(Integer i, String j, Boolean b){ - //String s = ""; - EmptyMethod em = new EmptyMethod(); - em.m1(); - em.s1 = ""; - //Integer ab = Math.abs(1); - //Math.abs(1); - //String lV = "local"; - //s1 = "1"; - //s1.concat("2"); - //s2 = s1; - } -}*/ \ No newline at end of file diff --git a/src/test/java/javFiles/Expressions.jav b/src/test/java/javFiles/Expressions.jav deleted file mode 100644 index e2e992a1..00000000 --- a/src/test/java/javFiles/Expressions.jav +++ /dev/null @@ -1,8 +0,0 @@ -class Expressions{ - -void test(){ - var x = 2; - x = x + 2; -} - -} \ No newline at end of file diff --git a/src/test/java/javFiles/FC_Matrix.jav b/src/test/java/javFiles/FC_Matrix.jav deleted file mode 100644 index 75ead472..00000000 --- a/src/test/java/javFiles/FC_Matrix.jav +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.Vector; - -class Matrix extends Vector> { - - methode(m) { - m.add(1); - Matrix i; - methode(i); - } - } diff --git a/src/test/java/javFiles/Faculty.jav b/src/test/java/javFiles/Faculty.jav deleted file mode 100644 index ca539add..00000000 --- a/src/test/java/javFiles/Faculty.jav +++ /dev/null @@ -1,15 +0,0 @@ -import java.lang.Integer; - -class Faculty { - - Integer mul(Integer x, Integer y) { - return x; - } - - m () { - var fact = (Integer x) -> { - return mul(x, fact.apply(x)); - }; - return fact; - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/FacultyIf.jav b/src/test/java/javFiles/FacultyIf.jav deleted file mode 100644 index 3c368923..00000000 --- a/src/test/java/javFiles/FacultyIf.jav +++ /dev/null @@ -1,17 +0,0 @@ -import java.lang.Integer; - -class Faculty { - - m () { - - var fact = (Integer x) -> { - if (x == 1) { - return x; - } - else { - return x * (fact.apply(x-1)); - } - }; - return fact; - } -} diff --git a/src/test/java/javFiles/FacultyTyped.jav b/src/test/java/javFiles/FacultyTyped.jav deleted file mode 100644 index 089d2f33..00000000 --- a/src/test/java/javFiles/FacultyTyped.jav +++ /dev/null @@ -1,19 +0,0 @@ -import java.lang.Integer; - -class Faculty { - - Integer mul(Integer x, Integer y) { - return x; - } - - Fun1 m () { - var fact = (Integer x) -> { - return mul(x, fact.apply(x)); - }; - return fact; - } -} - -interface Fun1{ - B apply(A a); -} \ No newline at end of file diff --git a/src/test/java/javFiles/Fields.jav b/src/test/java/javFiles/Fields.jav deleted file mode 100644 index cd2add71..00000000 --- a/src/test/java/javFiles/Fields.jav +++ /dev/null @@ -1,11 +0,0 @@ -import java.lang.String; - -class Fields{ -test2 = "test"; -test; -m(){ - var test3; - return test; -} - -} \ No newline at end of file diff --git a/src/test/java/javFiles/Generics.jav b/src/test/java/javFiles/Generics.jav deleted file mode 100644 index dd7b4eba..00000000 --- a/src/test/java/javFiles/Generics.jav +++ /dev/null @@ -1,22 +0,0 @@ -import java.lang.String; - -class Generics { - // A mt1(A a, B b){ - B mt1(B a, B b){ - return mt1(a, a); - } -} - -class Test { - methode(String s){ - return new Generics().mt1(s,s); - } -} - -/* -Problem: -auto test = new List(); -auto test2 = new List(); -... //code, welcher möglicherweise test und test2 vertauscht -test.add("hallo"); -*/ \ No newline at end of file diff --git a/src/test/java/javFiles/IfTest.jav b/src/test/java/javFiles/IfTest.jav deleted file mode 100644 index 1e1141df..00000000 --- a/src/test/java/javFiles/IfTest.jav +++ /dev/null @@ -1,14 +0,0 @@ -import java.lang.Integer; -import java.lang.Boolean; -import java.lang.Object; - -public class IfTest{ - Object m1(b) { - Integer i; - if(b) { - return i; - }else{ - return b; - } - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Import.jav b/src/test/java/javFiles/Import.jav deleted file mode 100644 index c48082ba..00000000 --- a/src/test/java/javFiles/Import.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.Vector; - -class Import { - void methode(){ - Vector v; - v.add(v); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Lambda.jav b/src/test/java/javFiles/Lambda.jav deleted file mode 100644 index 5bd67a0b..00000000 --- a/src/test/java/javFiles/Lambda.jav +++ /dev/null @@ -1,13 +0,0 @@ - -class Apply { } - -public class Lambda { - - m () { - var lam1 = (x) -> { - return x; - }; - return lam1.apply(new Apply()); - } -} - diff --git a/src/test/java/javFiles/Lambda2.jav b/src/test/java/javFiles/Lambda2.jav deleted file mode 100644 index cf1e910b..00000000 --- a/src/test/java/javFiles/Lambda2.jav +++ /dev/null @@ -1,33 +0,0 @@ -import java.lang.String; - -public class Lambda2 -{ - public static void main(List args){ - var listOfStrings = new List(); - var listOfObjects; - listOfObjects = map(listOfStrings, (a) -> a); -} - -public map(a , b){ - b.apply(a); - return a; -} - -/* -public static List map(List input, Function func) { - List output; - output = new List(); - output.add(func.apply(input.get())); - return output; -} -*/ -} - -class List{ - A get(); - void add(A); -} - -class Function{ - B apply(A a); -} \ No newline at end of file diff --git a/src/test/java/javFiles/Lambda3.jav b/src/test/java/javFiles/Lambda3.jav deleted file mode 100644 index 9e22f302..00000000 --- a/src/test/java/javFiles/Lambda3.jav +++ /dev/null @@ -1,24 +0,0 @@ -import java.lang.String; - -public class Lambda2 -{ - /* - public static List map(List input, - Function func){ - input.add(func.apply(input.get())); - } - */ - public map(input,func){ - input.add(func.apply(input.get())); - return map(new List(), func); - } -} - -class List{ - A get(); - void add(A); -} - -class Function{ - B apply(A a); -} \ No newline at end of file diff --git a/src/test/java/javFiles/LambdaField.jav b/src/test/java/javFiles/LambdaField.jav deleted file mode 100644 index 4eb53738..00000000 --- a/src/test/java/javFiles/LambdaField.jav +++ /dev/null @@ -1,6 +0,0 @@ -public class LambdaField { - - f = x -> x; - -} - diff --git a/src/test/java/javFiles/LambdaRunnable.jav b/src/test/java/javFiles/LambdaRunnable.jav deleted file mode 100644 index 37924ea2..00000000 --- a/src/test/java/javFiles/LambdaRunnable.jav +++ /dev/null @@ -1,14 +0,0 @@ -import java.lang.Runnable; -import java.lang.String; -import java.lang.System; - -public class LamRunnable{ - - public LamRunnable(){ - - - Runnable lam = () -> {System.out.println("lambda");}; - lam.run(); - } -} - diff --git a/src/test/java/javFiles/ListenerOverload.jav b/src/test/java/javFiles/ListenerOverload.jav deleted file mode 100644 index e1a8d65d..00000000 --- a/src/test/java/javFiles/ListenerOverload.jav +++ /dev/null @@ -1,20 +0,0 @@ -import java.lang.Integer; -import java.lang.String; - -class ListenerOverload{ - -call(p){ - call(p.left); - call(p.right); -} - -call(Integer i){} - -call(String s){} - -} - -class Pair{ - A left; - B right; -} \ No newline at end of file diff --git a/src/test/java/javFiles/Matrix.jav b/src/test/java/javFiles/Matrix.jav deleted file mode 100644 index 5e1eac08..00000000 --- a/src/test/java/javFiles/Matrix.jav +++ /dev/null @@ -1,28 +0,0 @@ -import java.util.Vector; -import java.lang.Integer; - -class Matrix extends Vector> { - Integer mul1(Integer x, Integer y) { return x;} - Integer add1(Integer x, Integer y) { return x;} - mul(m) { - var ret = new Matrix(); - var i = 0; - while(i < size()) { - var v1 = this.elementAt(i); - var v2 = new Vector(); - var j = 0; - while(j < v1.size()) { - var erg = 0; - var k = 0; - while(k < v1.size()) { - erg = erg + v1.elementAt(k) * m.elementAt(k).elementAt(j); - //erg = add1(erg, mul1(v1.elementAt(k), - // m.elementAt(k).elementAt(j))); - k++; } - v2.addElement(new Integer(erg)); - j++; } - ret.addElement(v2); - i++; } - return ret; - } -} diff --git a/src/test/java/javFiles/Meth_Gen.jav b/src/test/java/javFiles/Meth_Gen.jav deleted file mode 100644 index 056dd82f..00000000 --- a/src/test/java/javFiles/Meth_Gen.jav +++ /dev/null @@ -1,11 +0,0 @@ -class Meth_Gen { - - m1(x, y) { - m2(x); - x = y; - } - - m2(y) { - m1(y, y); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/MethodCallGenerics.jav b/src/test/java/javFiles/MethodCallGenerics.jav deleted file mode 100644 index 0d02509b..00000000 --- a/src/test/java/javFiles/MethodCallGenerics.jav +++ /dev/null @@ -1,14 +0,0 @@ -import java.lang.String; - -class Generics { - // A mt1(A a, B b){ - B mt1(B a, B b){ - return mt1(a, a); - } -} - -class Test { - methode(String s){ - return new Generics().mt1(s,s); - } -} diff --git a/src/test/java/javFiles/Methods.jav b/src/test/java/javFiles/Methods.jav deleted file mode 100644 index e45d9830..00000000 --- a/src/test/java/javFiles/Methods.jav +++ /dev/null @@ -1,17 +0,0 @@ - -class Methods { - mt4(a,b,c) { return a.add(b).sub(c) ; } - - mt1(a) {return a;} - - mt2(a) {return a.f; } - - mt3(a) {return a.add(); } -} - -class Test { - java.lang.Object f; - add(){} - add(b){return b;} - sub(b){} -} \ No newline at end of file diff --git a/src/test/java/javFiles/MethodsEasy.jav b/src/test/java/javFiles/MethodsEasy.jav deleted file mode 100644 index ee6f9daf..00000000 --- a/src/test/java/javFiles/MethodsEasy.jav +++ /dev/null @@ -1,7 +0,0 @@ - -class Methods { - mt4(a,b,c) { return a.mt3(b).mt3(c) ; } - - mt3(a) {return a.mt3(a); } -} - diff --git a/src/test/java/javFiles/Op1.jav b/src/test/java/javFiles/Op1.jav deleted file mode 100644 index 800f58b8..00000000 --- a/src/test/java/javFiles/Op1.jav +++ /dev/null @@ -1,11 +0,0 @@ -public class Op1{ - public Op1() { - - Runnable lam = () -> { - String test = ""; - String b = "b"; - test = b; - System.out.println(test);}; - //lam.run(); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Package.jav b/src/test/java/javFiles/Package.jav deleted file mode 100644 index bbc1e51d..00000000 --- a/src/test/java/javFiles/Package.jav +++ /dev/null @@ -1,5 +0,0 @@ -package strucType.input; - -class Neu -{ -} \ No newline at end of file diff --git a/src/test/java/javFiles/Sorting.jav b/src/test/java/javFiles/Sorting.jav deleted file mode 100644 index 04ef23e5..00000000 --- a/src/test/java/javFiles/Sorting.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.List; -import java.util.Collection; - -class Sorting{ - void merge(a, b){ - a.addAll(b); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Subclass.jav b/src/test/java/javFiles/Subclass.jav deleted file mode 100644 index fe6e9208..00000000 --- a/src/test/java/javFiles/Subclass.jav +++ /dev/null @@ -1,6 +0,0 @@ -public class Subclass extends Superclass { - - public void printMethod() { - super.printMethod(); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Superclass.jav b/src/test/java/javFiles/Superclass.jav deleted file mode 100644 index d58089de..00000000 --- a/src/test/java/javFiles/Superclass.jav +++ /dev/null @@ -1,6 +0,0 @@ -public class Superclass { - - public void printMethod() { - System.out.println("Printed in Superclass."); - } -} diff --git a/src/test/java/javFiles/Vector.jav b/src/test/java/javFiles/Vector.jav deleted file mode 100644 index 5c21cfff..00000000 --- a/src/test/java/javFiles/Vector.jav +++ /dev/null @@ -1,23 +0,0 @@ -import java.util.ArrayList; -import java.util.Vector; -import java.lang.Object; - -class MyVector{ - -id(x){ - Object i; - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - return x; -} -} \ No newline at end of file diff --git a/src/test/java/javFiles/fc.jav b/src/test/java/javFiles/fc.jav deleted file mode 100644 index a3278cbc..00000000 --- a/src/test/java/javFiles/fc.jav +++ /dev/null @@ -1,18 +0,0 @@ -import java.util.List; - -class Test{ - methode(param1, param2, param3) { - param2.add(param3); - return param1.meth(param2); - } -} - -interface Klasse1{ - Klasse1 meth(List p); - Klasse1 meth(Klasse2 p); -} - -interface Klasse2{ - Klasse1 meth(Klasse1 p); - Klasse2 meth(Klasse2 p); -} \ No newline at end of file diff --git a/src/test/java/javFiles/mathStruc.jav b/src/test/java/javFiles/mathStruc.jav deleted file mode 100644 index 93f901ce..00000000 --- a/src/test/java/javFiles/mathStruc.jav +++ /dev/null @@ -1,13 +0,0 @@ - -class mathStruc { - -mathStruc(A a) { } - -A model(){ A a; return a; } - -methode(){ -var innerOp = o -> ms -> - new mathStruc(o.apply(this.model(),ms.model())); - return innerOp; - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/test.jav b/src/test/java/javFiles/test.jav deleted file mode 100644 index 303d167a..00000000 --- a/src/test/java/javFiles/test.jav +++ /dev/null @@ -1,15 +0,0 @@ -class Test{ - methode(param1, param2, param3) { - return param1.meth(param2.meth(param3)); - } -} - -interface Klasse1{ - Klasse1 meth(Klasse1 p); - Klasse1 meth(Klasse2 p); -} - -interface Klasse2{ - Klasse1 meth(Klasse1 p); - Klasse2 meth(Klasse2 p); -} \ No newline at end of file diff --git a/src/test/java/javFiles/test1.jav b/src/test/java/javFiles/test1.jav deleted file mode 100644 index 4b34948e..00000000 --- a/src/test/java/javFiles/test1.jav +++ /dev/null @@ -1,7 +0,0 @@ -class Faculty { - - int a; - m (int x) { - return a+x; - } -}