diff --git a/src/mycompiler/myclass/Class.java b/src/mycompiler/myclass/Class.java index 2ac0d866..fdb1940d 100755 --- a/src/mycompiler/myclass/Class.java +++ b/src/mycompiler/myclass/Class.java @@ -58,11 +58,13 @@ import org.apache.log4j.Logger; + import sun.reflect.generics.reflectiveObjects.NotImplementedException; import typinferenz.ConstraintsSet; import typinferenz.JavaCodeResult; import typinferenz.OderConstraint; import typinferenz.ResultSet; +import typinferenz.Typeable; import typinferenz.UndConstraint; import typinferenz.FunN; import typinferenz.assumptions.TypeAssumptions; diff --git a/src/mycompiler/myclass/Constructor.java b/src/mycompiler/myclass/Constructor.java index b7c3d789..80e0ff48 100644 --- a/src/mycompiler/myclass/Constructor.java +++ b/src/mycompiler/myclass/Constructor.java @@ -31,7 +31,7 @@ public class Constructor extends Method { super(methode.getOffset()); this.methode = methode; this.setDeclIdVector(methode.getDeclIdVector()); - this.methode.setType(new RefType(this.methode.getParentClass().getName(),0)); + this.methode.setType(this.methode.getParentClass().getType()); } diff --git a/src/mycompiler/mystatement/This.java b/src/mycompiler/mystatement/This.java index 39aa5f07..d83e85d3 100755 --- a/src/mycompiler/mystatement/This.java +++ b/src/mycompiler/mystatement/This.java @@ -171,7 +171,7 @@ public class This extends Expr ConstraintsSet ret = new ConstraintsSet(); //this.set_Type(new); //this.setType(assumptions.getThisValue());//Die Assumption für this als TypeVariable setzen. - this.setType(new RefType(this.getParentClass().getName(),0)); + this.setType(this.getParentClass().getType()); return ret; } diff --git a/src/typinferenz/FunN.java b/src/typinferenz/FunN.java index 890a16f5..5b636c30 100755 --- a/src/typinferenz/FunN.java +++ b/src/typinferenz/FunN.java @@ -21,6 +21,9 @@ import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption; * "interface FunN { R apply(T1 arg1, T2 arg2, ... , TN argN); }" * @author A10023 - Andreas Stadelmeier * + * Bemerkung: + * FunN ist ein RefType. Der RefType ist nicht mit einem FunNInterface verbunden. + * */ public class FunN extends RefType implements ITypeReplacementListener{ diff --git a/src/typinferenz/FunNInterface.java b/src/typinferenz/FunNInterface.java index 2141951c..269f9aa1 100644 --- a/src/typinferenz/FunNInterface.java +++ b/src/typinferenz/FunNInterface.java @@ -2,10 +2,12 @@ package typinferenz; import mycompiler.myclass.Class; + public class FunNInterface extends Class{ - - public FunNInterface() { - super("FunN"); +//TODO: Diese Klasse sollte eigentlich von Interface erben + + public FunNInterface(int parameterCount) { + super("Fun"+parameterCount); } - + } diff --git a/src/typinferenz/Overloading.java b/src/typinferenz/Overloading.java index c961ec46..3eceb2df 100755 --- a/src/typinferenz/Overloading.java +++ b/src/typinferenz/Overloading.java @@ -76,6 +76,7 @@ public class Overloading{ //Ein Constraint für den Receiver der Methode (falls vorhanden)... //ret.add(new Constraint(methodCall.get_Receiver().get_Expr().getTypeVariable(), new RefType(assumption.getClassName(), null, 0))); if(methodCall.get_Receiver() != null && methodCall.get_Receiver().get_Expr() != null) + //TODO: FunN-MethodAssumption darf keine Klasse (Class) als ParentClass besitzen. Denn der Typ der Klasse steht noch nicht fest (bisher ist es immer "FunN"). methodConstraint.addConstraint(methodCall.get_Receiver().get_Expr().getType(), methodAssumption.getParentClassType()); //ret.add(new Constraint(methodCall.get_Receiver().get_Expr().getTypeVariable(), new RefType(assumption.getClassName(), parameterAssumptions, 0))); diff --git a/src/typinferenz/assumptions/MethodAssumption.java b/src/typinferenz/assumptions/MethodAssumption.java index e767b803..2097b538 100644 --- a/src/typinferenz/assumptions/MethodAssumption.java +++ b/src/typinferenz/assumptions/MethodAssumption.java @@ -35,7 +35,7 @@ public class MethodAssumption extends FieldAssumption { } public Type getParentClassType() { - return new RefType(this.parentClass.getName(),0); + return this.parentClass.getType(); } diff --git a/src/typinferenz/assumptions/TypeAssumptions.java b/src/typinferenz/assumptions/TypeAssumptions.java index 5ff0bf1b..34c36673 100755 --- a/src/typinferenz/assumptions/TypeAssumptions.java +++ b/src/typinferenz/assumptions/TypeAssumptions.java @@ -148,7 +148,7 @@ public class TypeAssumptions { //Falls es sich um die apply-Methode eines FunN-Interface handelt: if(methodName.equals("apply")){ //Ein Workaround für den Typinferenzalgorithmus TODO: Das hier rausnehmen. //CMethodTypeAssumption funNAssumption = new FunN(parameterCount).toCMethodTypeAssumption(); - MethodAssumption funNAssumption = new MethodAssumption(new FunNMethod(parameterCount), new FunNInterface()); + MethodAssumption funNAssumption = new MethodAssumption(new FunNMethod(parameterCount), new FunNInterface(parameterCount)); ret.add(funNAssumption); } if(ret.size()==0)throw new TypinferenzException("Eine Methode "+methodName+" ist in den Assumptions nicht vorhanden"); diff --git a/test/mycompiler/test/lambda/testResults/LambdaTest.log b/test/mycompiler/test/lambda/testResults/LambdaTest.log index fe82ed39..f0067523 100644 --- a/test/mycompiler/test/lambda/testResults/LambdaTest.log +++ b/test/mycompiler/test/lambda/testResults/LambdaTest.log @@ -1,7 +1,7 @@ Class DEBUG [Typeinference] Erstellte Assumptions: this: MatrixMethod Assumptions: [] FieldVar Assumptions: -[typinferenz.assumptions.FieldAssumption@4dd290b5, typinferenz.assumptions.FieldAssumption@3b1a82fd, typinferenz.assumptions.FieldAssumption@4dd290b5, typinferenz.assumptions.FieldAssumption@3b1a82fd] +[typinferenz.assumptions.FieldAssumption@45eb96fc, typinferenz.assumptions.FieldAssumption@6e059e40, typinferenz.assumptions.FieldAssumption@45eb96fc, typinferenz.assumptions.FieldAssumption@6e059e40] LocalVar Assumptions: [] Parameter Assumptions: @@ -9,116 +9,3 @@ Parameter Assumptions: Block DEBUG [Typeinference] Prozessing statement: null Return null (( [ f, ]) -> null { [null Return null (f.apply( [ null (this(null)), m, ]))]) Block DEBUG [Typeinference] Prozessing statement: null Return null (f.apply( [ null (this(null)), m, ])) -Block DEBUG [Typeinference] Prozessing statement: TPH K Return TPH G (f: TPH E.apply( [ Matrix (this(null)), m: TPH C, ])) -Block DEBUG [Typeinference] Prozessing statement: TPH L Return TPH F (( [ TPH E f, ]) -> TPH K { [TPH K Return TPH G (f: TPH E.apply( [ Matrix (this(null)), m: TPH C, ]))]) -Class DEBUG [Typeinference] Erstellte Constraints: TPH A < TPH A -[[(TPH H <. TPH G), (Matrix <. TPH I), (TPH C <. TPH J), (TPH E <. FunN), ]| ] -TPH G < TPH K -Fun1< TPH K, TPH E > < TPH F -TPH F < TPH L -Fun1< TPH L, TPH C > < TPH D -TPH D < TPH A - -SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(TPH A <. TPH A), (TPH H <. TPH G), (Matrix <. TPH I), (TPH C <. TPH J), (TPH E <. FunN), (TPH G <. TPH K), (Fun1< TPH K, TPH E > <. TPH F), (TPH F <. TPH L), (Fun1< TPH L, TPH C > <. TPH D), (TPH D <. TPH A)]] -SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Matrix), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)], [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< Vector< GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)], [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? extends Vector< GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)], [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? extends Vector< ? extends GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)], [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? extends Vector< ? super GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)], [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? super Vector< GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)], [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? super Matrix >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)]] -SourceFile DEBUG [Typeinference] -JavaFiles: - -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Matrix), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)] - -SourceFile DEBUG [Typeinference] class Matrix extends Vector> -{ -Fun1, C> op = (C m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() -{ -} -} - -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< Vector< GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)] - -SourceFile DEBUG [Typeinference] class Matrix extends Vector> -{ -Fun1, C> op = (C m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() -{ -} -} - -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? extends Vector< GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)] - -SourceFile DEBUG [Typeinference] class Matrix extends Vector> -{ -Fun1, C> op = (C m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() -{ -} -} - -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? extends Vector< ? extends GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)] - -SourceFile DEBUG [Typeinference] class Matrix extends Vector> -{ -Fun1, C> op = (C m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() -{ -} -} - -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? extends Vector< ? super GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)] - -SourceFile DEBUG [Typeinference] class Matrix extends Vector> -{ -Fun1, C> op = (C m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() -{ -} -} - -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? super Vector< GTV Integer > >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)] - -SourceFile DEBUG [Typeinference] class Matrix extends Vector> -{ -Fun1, C> op = (C m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() -{ -} -} - -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH H <. TPH G), (TPH C <. TPH J), (TPH G <. TPH K), (TPH L = Fun1< TPH K, FunN >), (TPH A = Fun1< Fun1< TPH K, FunN >, TPH C >), (TPH I = Vector< ? super Matrix >), (TPH E = FunN), (TPH F = Fun1< TPH K, FunN >), (TPH D = Fun1< Fun1< TPH K, FunN >, TPH C >)] - -SourceFile DEBUG [Typeinference] class Matrix extends Vector> -{ -Fun1, C> op = (C m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() -{ -} -} -