Fehlerhaftes RefType erstellen von Klassen gefixt

This commit is contained in:
JanUlrich 2014-03-20 11:35:57 +01:00
parent 947be154ea
commit ddb9ef6d7d
9 changed files with 17 additions and 122 deletions

View File

@ -58,11 +58,13 @@ import org.apache.log4j.Logger;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet; import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.OderConstraint; import typinferenz.OderConstraint;
import typinferenz.ResultSet; import typinferenz.ResultSet;
import typinferenz.Typeable;
import typinferenz.UndConstraint; import typinferenz.UndConstraint;
import typinferenz.FunN; import typinferenz.FunN;
import typinferenz.assumptions.TypeAssumptions; import typinferenz.assumptions.TypeAssumptions;

View File

@ -31,7 +31,7 @@ public class Constructor extends Method {
super(methode.getOffset()); super(methode.getOffset());
this.methode = methode; this.methode = methode;
this.setDeclIdVector(methode.getDeclIdVector()); this.setDeclIdVector(methode.getDeclIdVector());
this.methode.setType(new RefType(this.methode.getParentClass().getName(),0)); this.methode.setType(this.methode.getParentClass().getType());
} }

View File

@ -171,7 +171,7 @@ public class This extends Expr
ConstraintsSet ret = new ConstraintsSet(); ConstraintsSet ret = new ConstraintsSet();
//this.set_Type(new); //this.set_Type(new);
//this.setType(assumptions.getThisValue());//Die Assumption für this als TypeVariable setzen. //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; return ret;
} }

View File

@ -21,6 +21,9 @@ import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption;
* "interface FunN<R,T1, T2, ... ,TN> { R apply(T1 arg1, T2 arg2, ... , TN argN); }" * "interface FunN<R,T1, T2, ... ,TN> { R apply(T1 arg1, T2 arg2, ... , TN argN); }"
* @author A10023 - Andreas Stadelmeier * @author A10023 - Andreas Stadelmeier
* *
* Bemerkung:
* FunN ist ein RefType. Der RefType ist nicht mit einem FunNInterface verbunden.
*
*/ */
public class FunN extends RefType implements ITypeReplacementListener{ public class FunN extends RefType implements ITypeReplacementListener{

View File

@ -2,10 +2,12 @@ package typinferenz;
import mycompiler.myclass.Class; import mycompiler.myclass.Class;
public class FunNInterface extends Class{ public class FunNInterface extends Class{
//TODO: Diese Klasse sollte eigentlich von Interface erben
public FunNInterface() {
super("FunN"); public FunNInterface(int parameterCount) {
super("Fun"+parameterCount);
} }
} }

View File

@ -76,6 +76,7 @@ public class Overloading{
//Ein Constraint für den Receiver der Methode (falls vorhanden)... //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))); //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) 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()); 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))); //ret.add(new Constraint(methodCall.get_Receiver().get_Expr().getTypeVariable(), new RefType(assumption.getClassName(), parameterAssumptions, 0)));

View File

@ -35,7 +35,7 @@ public class MethodAssumption extends FieldAssumption {
} }
public Type getParentClassType() { public Type getParentClassType() {
return new RefType(this.parentClass.getName(),0); return this.parentClass.getType();
} }

View File

@ -148,7 +148,7 @@ public class TypeAssumptions {
//Falls es sich um die apply-Methode eines FunN-Interface handelt: //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. if(methodName.equals("apply")){ //Ein Workaround für den Typinferenzalgorithmus TODO: Das hier rausnehmen.
//CMethodTypeAssumption funNAssumption = new FunN(parameterCount).toCMethodTypeAssumption(); //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); ret.add(funNAssumption);
} }
if(ret.size()==0)throw new TypinferenzException("Eine Methode "+methodName+" ist in den Assumptions nicht vorhanden"); if(ret.size()==0)throw new TypinferenzException("Eine Methode "+methodName+" ist in den Assumptions nicht vorhanden");

View File

@ -1,7 +1,7 @@
Class DEBUG [Typeinference] Erstellte Assumptions: this: MatrixMethod Assumptions: Class DEBUG [Typeinference] Erstellte Assumptions: this: MatrixMethod Assumptions:
[] []
FieldVar 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: LocalVar Assumptions:
[] []
Parameter 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, ]) -> 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: 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 <K, C>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<K, FunN>, 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 <K, C>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<K, FunN>, 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 <K, C>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<K, FunN>, 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 <K, C>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<K, FunN>, 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 <K, C>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<K, FunN>, 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 <K, C>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<K, FunN>, 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 <K, C>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<K, FunN>, C> op = (C m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}