Änderungen an typeReconstruction in SourceFile. Die Constraints aller Klassen einer SourceFile werden nun gemeinsam Unifiziert und jede Klasse aus dem SourceFile erhält das selbe ResultSet. Tests angefügt.

This commit is contained in:
JanUlrich 2014-03-19 15:14:50 +01:00
parent 38698d04fd
commit 7defd01db8
13 changed files with 369 additions and 135 deletions

View File

@ -646,89 +646,96 @@ public class SourceFile
globalAssumptions.add(klasse.getPublicFieldAssumptions()); globalAssumptions.add(klasse.getPublicFieldAssumptions());
} }
ConstraintsSet oderConstraints = new ConstraintsSet();
//Alle Constraints der in dieser SourceFile enthaltenen Klassen sammeln: //Alle Constraints der in dieser SourceFile enthaltenen Klassen sammeln:
for(Class klasse : KlassenVektor){ for(Class klasse : KlassenVektor){
ConstraintsSet oderConstraints = klasse.typeReconstruction(finiteClosure, globalAssumptions); oderConstraints.add(klasse.typeReconstruction(finiteClosure, globalAssumptions));
//Die Constraints in Pair's umwandeln (Karthesisches Produkt bilden):
Vector<Vector<Pair>> xConstraints = new Vector<Vector<Pair>>();// = oderConstraints.getConstraints();
for(Vector<UndConstraint> uC:oderConstraints.getConstraints()){ //mit dem getConstraints-Aufruf wird das Karthesische Produkt erzeugt.
Vector<Pair> cons = new Vector<Pair>();
for(UndConstraint undCons:uC){
cons.addAll(undCons.getConstraintPairs());
}
xConstraints.add(cons);
}
typinferenzLog.debug("Karthesisches Produkt der Constraints: "+xConstraints);
//////////////////////////////
// Unifizierung der Constraints:
//////////////////////////////
for(Vector<Pair> constraints : xConstraints){
//Alle durch das Karthesische Produkt entstandenen Möglichkeiten durchgehen:
Vector<Vector<Pair>> result = new Vector<Vector<Pair>>();
//Alle FunN-Typen werden per clone-methode in RefTypes verwandelt. (Die clone Methode in FunN darf nicht überschrieben werden.
for(Pair p : constraints){
if(p.TA1 instanceof FunN){
p.TA1 = p.TA1.clone();
}
if(p.TA2 instanceof FunN){
p.TA2 = p.TA2.clone();
}
}
//Erst die Unifizierung erstellen:
Vector<Pair> constraintsClone = (Vector<Pair>)constraints.clone();
Vector<Vector<Pair>> unifyResult = Unify.unify(constraintsClone, finiteClosure);
//Dann den Ergebnissen anfügen
result.addAll(unifyResult);
// Debugoutput:Vector<Vector<Pair>>
typinferenzLog.debug("Unifiziertes Ergebnis: "+result);
/*
// Prüfe ob eindeutige Lösung:
if(result.size()>1 && !Unify.hasSolvedForm(result.elementAt(0))){
typinferenzLog.debug("Keine eindeutige Lösung!");
}else if(result.size()>1){
//Replace TPH:
for(Pair res : result.elementAt(0)){
if(res.OperatorEqual()){
if(res.TA1 instanceof TypePlaceholder)((TypePlaceholder)res.TA1).fireReplaceTypeEvent(new CReplaceTypeEvent(res.TA1, res.TA2));
}
}
}
*/
//typinferenzLog.debug();
//typinferenzLog.debug(supportData.getFiniteClosure());
//typinferenzLog.debug("Typinformationen: \n"+this.getTypeInformation(this.getMethodList(), fieldInitializers));
typinferenzLog.debug("\nJavaFiles:\n");
//typinferenzLog.debug(this.printJavaCode(new ResultSet(new Vector<Pair>())));
//Der Unifikationsalgorithmus kann wiederum auch mehrere Lösungen errechnen, diese werden im folgenden durchlaufen:
for(Vector<Pair> resultSet : result){
//Add Result set as a new ReconstructionResult to ret:
TypeinferenceResultSet reconstructionResult = new TypeinferenceResultSet(klasse, constraints, new ResultSet(resultSet));
ret.add(reconstructionResult);
//ResultSet res = new ResultSet(resultSet);
typinferenzLog.debug("JavaFile für ResultSet "+reconstructionResult+"\n");
typinferenzLog.debug(klasse.printJavaCode(reconstructionResult));
}
}
} }
////////////////
//Karthesisches Produkt bilden:
////////////////
//Die Constraints in Pair's umwandeln (Karthesisches Produkt bilden):
Vector<Vector<Pair>> xConstraints = new Vector<Vector<Pair>>();// = oderConstraints.getConstraints();
for(Vector<UndConstraint> uC:oderConstraints.getConstraints()){ //mit dem getConstraints-Aufruf wird das Karthesische Produkt erzeugt.
Vector<Pair> cons = new Vector<Pair>();
for(UndConstraint undCons:uC){
cons.addAll(undCons.getConstraintPairs());
}
xConstraints.add(cons);
}
typinferenzLog.debug("Karthesisches Produkt der Constraints: "+xConstraints);
//////////////////////////////
// Unifizierung der Constraints:
//////////////////////////////
for(Vector<Pair> constraints : xConstraints){
//Alle durch das Karthesische Produkt entstandenen Möglichkeiten durchgehen:
Vector<Vector<Pair>> result = new Vector<Vector<Pair>>();
//Alle FunN-Typen werden per clone-methode in RefTypes verwandelt. (Die clone Methode in FunN darf nicht überschrieben werden.
for(Pair p : constraints){
if(p.TA1 instanceof FunN){
p.TA1 = p.TA1.clone();
}
if(p.TA2 instanceof FunN){
p.TA2 = p.TA2.clone();
}
}
//Erst die Unifizierung erstellen:
Vector<Pair> constraintsClone = (Vector<Pair>)constraints.clone();
Vector<Vector<Pair>> unifyResult = Unify.unify(constraintsClone, finiteClosure);
//Dann den Ergebnissen anfügen
result.addAll(unifyResult);
// Debugoutput:Vector<Vector<Pair>>
typinferenzLog.debug("Unifiziertes Ergebnis: "+result);
/*
// Prüfe ob eindeutige Lösung:
if(result.size()>1 && !Unify.hasSolvedForm(result.elementAt(0))){
typinferenzLog.debug("Keine eindeutige Lösung!");
}else if(result.size()>1){
//Replace TPH:
for(Pair res : result.elementAt(0)){
if(res.OperatorEqual()){
if(res.TA1 instanceof TypePlaceholder)((TypePlaceholder)res.TA1).fireReplaceTypeEvent(new CReplaceTypeEvent(res.TA1, res.TA2));
}
}
}
*/
//typinferenzLog.debug();
//typinferenzLog.debug(supportData.getFiniteClosure());
//typinferenzLog.debug("Typinformationen: \n"+this.getTypeInformation(this.getMethodList(), fieldInitializers));
typinferenzLog.debug("\nJavaFiles:\n");
//typinferenzLog.debug(this.printJavaCode(new ResultSet(new Vector<Pair>())));
//Für jede Klasse in diesem SourceFile gilt das selbe ResultSet:
for(Class klasse : this.KlassenVektor){
//Der Unifikationsalgorithmus kann wiederum auch mehrere Lösungen errechnen, diese werden im folgenden durchlaufen:
for(Vector<Pair> resultSet : result){
//Add Result set as a new ReconstructionResult to ret:
TypeinferenceResultSet reconstructionResult = new TypeinferenceResultSet(klasse, constraints, new ResultSet(resultSet));
ret.add(reconstructionResult);
//ResultSet res = new ResultSet(resultSet);
typinferenzLog.debug("JavaFile für ResultSet "+reconstructionResult+"\n");
typinferenzLog.debug(klasse.printJavaCode(reconstructionResult));
}
}
}
return ret; return ret;
/* /*
// HOTI: Nur zur Info.Ich habe den Loglevel auf Info geschaltet, damit // HOTI: Nur zur Info.Ich habe den Loglevel auf Info geschaltet, damit

View File

@ -630,10 +630,11 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
// @author A10023 - Andreas Stadelmeier: // @author A10023 - Andreas Stadelmeier:
////////////////////////////// //////////////////////////////
//Erzeuge Assumptions: //Erzeuge Assumptions:
TypeAssumptions assumptions = this.getTypeAssumptions(); TypeAssumptions assumptions = this.getPrivateFieldAssumptions();
//-- //Globale Assumptions anfügen:
assumptions.add(globalAssumptions); assumptions.add(globalAssumptions);
typinferenzLog.debug("Erstellte Assumptions: "+assumptions);
/* /*
//Generiere Liste mit Expressions, welche zur Initialisierung von Feldern verwendet werden. //Generiere Liste mit Expressions, welche zur Initialisierung von Feldern verwendet werden.
Vector<Expr> fieldInitializers = new Vector<Expr>(); Vector<Expr> fieldInitializers = new Vector<Expr>();
@ -816,11 +817,11 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
*/ */
/** /**
* Die Funktion ist erst nach dem Aufruf von getMethodList() nutzbar. * Ermittelt alle privaten Felder und Methoden der Klasse und Erstellt eine Assumption für diese.
* Ermittelt alle Felder und Methoden der Klasse und Erstellt eine Assumption für diese. * Bemerkung: Momentan werden noch alle Felder dieser Klasse zurückgegeben.
* @return Die erstellten TypeAssumptions * @return Die erstellten TypeAssumptions
*/ */
private TypeAssumptions getTypeAssumptions() { private TypeAssumptions getPrivateFieldAssumptions() {
if(this.typeAssumptions != null)return this.typeAssumptions; //Das sorgt dafür, dass die Assumptions nur einmalig generiert werden. if(this.typeAssumptions != null)return this.typeAssumptions; //Das sorgt dafür, dass die Assumptions nur einmalig generiert werden.
TypeAssumptions assumptions = new TypeAssumptions(this.getName()); TypeAssumptions assumptions = new TypeAssumptions(this.getName());
//this.getMethodList(); //Diese Funktion muss zuerst ausgeführt werden. //this.getMethodList(); //Diese Funktion muss zuerst ausgeführt werden.
@ -839,9 +840,6 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
// assumptions.addMethodAssumption(new RefType(this.getName(),0), "<init>", new RefType(this.getName(),0), new Vector<CParaTypeAssumption>()); // assumptions.addMethodAssumption(new RefType(this.getName(),0), "<init>", new RefType(this.getName(),0), new Vector<CParaTypeAssumption>());
//} //}
typinferenzLog.debug("Erstellte Assumptions: "+assumptions);
this.typeAssumptions = assumptions; //Diese müssen anschließend nicht wieder generiert werden. this.typeAssumptions = assumptions; //Diese müssen anschließend nicht wieder generiert werden.
return assumptions; return assumptions;
} }
@ -1247,7 +1245,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
* @return * @return
*/ */
public TypeAssumptions getPublicFieldAssumptions() { public TypeAssumptions getPublicFieldAssumptions() {
TypeAssumptions ret = this.getTypeAssumptions(); TypeAssumptions ret = this.getPrivateFieldAssumptions();
for(Field f : this.getFields()){ for(Field f : this.getFields()){
ret.add(f.createTypeAssumptions(this)); ret.add(f.createTypeAssumptions(this));
} }

View File

@ -273,6 +273,54 @@ public class Constructor extends Method {
public Type getType() { public Type getType() {
return this.methode.getType(); return this.methode.getType();
} }
@Override
public boolean equals(Object obj) {
return this.methode.equals(obj);
}
@Override
public void set_DeclId(DeclId did) {
this.methode.set_DeclId(did);
}
@Override
public Vector<DeclId> get_Name() {
return this.methode.get_Name();
}
@Override
public Vector<DeclId> getDeclIdVector() {
return this.methode.getDeclIdVector();
}
@Override
public void setDeclIdVector(Vector<DeclId> vDeclId) {
this.methode.setDeclIdVector(vDeclId);
}
@Override
public String getIdentifier() {
return this.methode.getIdentifier();
}
@Override
public String getDescription() {
return this.methode.getDescription();
}
@Override
public Class getParentClass() {
return this.methode.getParentClass();
}
} }

View File

@ -702,5 +702,14 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
return ret; return ret;
} }
@Override
public boolean equals(Object obj){
if(!(obj instanceof Method))return false;
Method equals = (Method) obj;
if(!this.returntype.equals(equals.returntype))return false;
if(!this.parameterlist.equals(equals.parameterlist))return false;
return super.equals(obj);
}
} }
// ino.end // ino.end

View File

@ -6,6 +6,7 @@ package mycompiler.mytype;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
import java.util.logging.Logger;
import typinferenz.JavaCodeResult; import typinferenz.JavaCodeResult;
import typinferenz.ResultSet; import typinferenz.ResultSet;
@ -512,6 +513,16 @@ public class TypePlaceholder extends Type implements IReplaceTypeEventProvider
return equalType.printJavaCode(resultSet); return equalType.printJavaCode(resultSet);
} }
/**
* Berechnet die InsertPoints dieses TypePlaceholders.
* Alle an diesem TypePlaceholder registrierten ITypeReplacementListener werden darauf kontrolliert,
* ob sie von TypeInsertable erben.
* Diese ergeben zusammen mit den Informationen aus dem übergebenen ResultSet einen TypeInsertPoint.
* Mehrere TypeInsertPoint's ergeben ein TypeInsertSet.
* @param result Das ResultSet das den einzusetzenden Typ für diesen TPH enthält.
* @return
* @see TypeInsertPoint
*/
public TypeInsertSet getTypeInsertPoints(ResultSet result) { public TypeInsertSet getTypeInsertPoints(ResultSet result) {
TypeInsertSet ret = new TypeInsertSet(); TypeInsertSet ret = new TypeInsertSet();
for(ITypeReplacementListener ti : this.m_ReplacementListeners){ for(ITypeReplacementListener ti : this.m_ReplacementListeners){

View File

@ -29,7 +29,7 @@ import mycompiler.mytypereconstruction.typeassumptionkey.CTypeAssumptionKey;
// ino.class.CTypeReconstructionResult.27238.description type=javadoc // ino.class.CTypeReconstructionResult.27238.description type=javadoc
/** /**
* Diese Container-Klasse kapselt alle Ergebniswerte f<EFBFBD>r eine m<EFBFBD>gliche * Diese Container-Klasse kapselt alle Ergebniswerte f<EFBFBD>r eine m<EFBFBD>gliche
* Typkombination aller Klassen und deren Methoden sowie lokalen Variablen. Eine * Typkombination einer Klasse und deren Methoden sowie lokalen Variablen. Eine
* Instanz dieser Klasse steht f<EFBFBD>r genau eine m<EFBFBD>gliche Typkombination.<br/> * Instanz dieser Klasse steht f<EFBFBD>r genau eine m<EFBFBD>gliche Typkombination.<br/>
* Objekte dieser Klasse werden vom Typrekonstruktionsalgorithmus <EFBFBD>ber die * Objekte dieser Klasse werden vom Typrekonstruktionsalgorithmus <EFBFBD>ber die
* Compiler-API zur<EFBFBD>ckgegeben. * Compiler-API zur<EFBFBD>ckgegeben.

View File

@ -43,4 +43,16 @@ public class MethodAssumption extends FieldAssumption {
return "MethodAssumption: "+this.method.toString(); return "MethodAssumption: "+this.method.toString();
} }
@Override
public boolean equals(Object obj){
if(!(obj instanceof MethodAssumption))return false;
MethodAssumption equals = (MethodAssumption)obj;
if(equals.method==null)return false;
if(equals.parentClass==null)return false;
if(!(equals.method.equals(this.method)))return false;
if(!(equals.parentClass.equals(this.parentClass)))return false;
return true;
}
} }

View File

@ -68,7 +68,7 @@ public class TypeAssumptions {
} }
public void addMethodAssumption(MethodAssumption mAss){ public void addMethodAssumption(MethodAssumption mAss){
this.methodAssumptions.add(mAss); if(!this.methodAssumptions.contains(mAss))this.methodAssumptions.add(mAss);
} }
public void addConstructorAssumption( public void addConstructorAssumption(
@ -93,12 +93,13 @@ public class TypeAssumptions {
* @param withName * @param withName
* @return * @return
*/ */
public Vector<FieldAssumption> getFieldVars(String withName){ @Deprecated
public Vector<FieldAssumption> getFieldVars2(String withName){
//TODO: Implementieren //TODO: Implementieren
return new Vector<FieldAssumption>(); return new Vector<FieldAssumption>();
} }
@Deprecated
public Type getTypeOfFieldVar(String withName, Class inClass){ public Type getTypeOfFieldVar2(String withName, Class inClass){
//TODO: Implementieren //TODO: Implementieren
return null; return null;
} }
@ -108,7 +109,8 @@ public class TypeAssumptions {
* @param withName * @param withName
* @return * @return
*/ */
public Vector<MethodAssumption> getMethods(String withName){ @Deprecated
public Vector<MethodAssumption> getMethods2(String withName){
//TODO: Implementieren //TODO: Implementieren
return new Vector<MethodAssumption>(); return new Vector<MethodAssumption>();
} }
@ -118,7 +120,8 @@ public class TypeAssumptions {
* @param withName * @param withName
* @return * @return
*/ */
public Type getTypeOfLocalVar(String withName){ @Deprecated
public Type getTypeOfLocalVar2(String withName){
//TODO: Implementieren //TODO: Implementieren
return null; return null;
} }

View File

@ -1,36 +1,123 @@
Class DEBUG [Typeinference] Erstellte Assumptions: this: ThisTestMethod Assumptions: Class DEBUG [Typeinference] Erstellte Assumptions: this: MatrixMethod Assumptions:
[] []
FieldVar Assumptions: FieldVar Assumptions:
[typinferenz.assumptions.FieldAssumption@6d657803] [typinferenz.assumptions.FieldAssumption@193d22b1, typinferenz.assumptions.FieldAssumption@7cb09f68, typinferenz.assumptions.FieldAssumption@193d22b1, typinferenz.assumptions.FieldAssumption@7cb09f68]
LocalVar Assumptions: LocalVar Assumptions:
[] []
Parameter Assumptions: Parameter Assumptions:
[] []
Class DEBUG [Typeinference] Erstellte Constraints: TPH A < TPH A Block DEBUG [Typeinference] Prozessing statement: null Return null (( [ f, ]) -> null { [null Return null (f.apply( [ null (this(null)), m, ]))])
ThisTest < TPH A Block DEBUG [Typeinference] Prozessing statement: null Return null (f.apply( [ null (this(null)), m, ]))
Block DEBUG [Typeinference] Prozessing statement: TPH BW Return TPH BS (f: TPH BQ.apply( [ Matrix (this(null)), m: TPH BO, ]))
Block DEBUG [Typeinference] Prozessing statement: TPH BX Return TPH BR (( [ TPH BQ f, ]) -> TPH BW { [TPH BW Return TPH BS (f: TPH BQ.apply( [ Matrix (this(null)), m: TPH BO, ]))])
Class DEBUG [Typeinference] Erstellte Constraints: TPH BM < TPH BM
[[(TPH BT <. TPH BS), (Matrix <. TPH BU), (TPH BO <. TPH BV), (TPH BQ <. FunN), ]| ]
TPH BS < TPH BW
Fun1< TPH BW, TPH BQ > < TPH BR
TPH BR < TPH BX
Fun1< TPH BX, TPH BO > < TPH BP
TPH BP < TPH BM
SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(TPH A <. TPH A), (ThisTest <. TPH A)]] SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(TPH BM <. TPH BM), (TPH BT <. TPH BS), (Matrix <. TPH BU), (TPH BO <. TPH BV), (TPH BQ <. FunN), (TPH BS <. TPH BW), (Fun1< TPH BW, TPH BQ > <. TPH BR), (TPH BR <. TPH BX), (Fun1< TPH BX, TPH BO > <. TPH BP), (TPH BP <. TPH BM)]]
SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH A = ThisTest)], [(TPH A = Object)]] SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Matrix), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)], [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Vector< Vector< GTV Integer > >), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)], [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Vector< ? extends Vector< GTV Integer > >), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)], [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Vector< ? extends Vector< ? extends GTV Integer > >), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)], [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Vector< ? extends Vector< ? super GTV Integer > >), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)], [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Vector< ? super Vector< GTV Integer > >), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)], [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Vector< ? super Matrix >), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)]]
SourceFile DEBUG [Typeinference] SourceFile DEBUG [Typeinference]
JavaFiles: JavaFiles:
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH A = ThisTest)] SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Matrix), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)]
SourceFile DEBUG [Typeinference] class ThisTest extends Object SourceFile DEBUG [Typeinference] class <BW, BO>Matrix extends Vector<Vector<Integer>>
{ {
ThisTest thisVar = this; Fun1<Fun1<BW, FunN>, BO> op = (BO m) -> {
ThisTest ThisTest() return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{ {
} }
} }
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH A = Object)] SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Vector< Vector< GTV Integer > >), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)]
SourceFile DEBUG [Typeinference] class ThisTest extends Object SourceFile DEBUG [Typeinference] class <BW, BO>Matrix extends Vector<Vector<Integer>>
{ {
Object thisVar = this; Fun1<Fun1<BW, FunN>, BO> op = (BO m) -> {
ThisTest ThisTest() return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Vector< ? extends Vector< GTV Integer > >), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)]
SourceFile DEBUG [Typeinference] class <BW, BO>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<BW, FunN>, BO> op = (BO m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Vector< ? extends Vector< ? extends GTV Integer > >), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)]
SourceFile DEBUG [Typeinference] class <BW, BO>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<BW, FunN>, BO> op = (BO m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Vector< ? extends Vector< ? super GTV Integer > >), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)]
SourceFile DEBUG [Typeinference] class <BW, BO>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<BW, FunN>, BO> op = (BO m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Vector< ? super Vector< GTV Integer > >), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)]
SourceFile DEBUG [Typeinference] class <BW, BO>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<BW, FunN>, BO> op = (BO m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{
}
}
SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH BT <. TPH BS), (TPH BO <. TPH BV), (TPH BS <. TPH BW), (TPH BX = Fun1< TPH BW, FunN >), (TPH BM = Fun1< Fun1< TPH BW, FunN >, TPH BO >), (TPH BU = Vector< ? super Matrix >), (TPH BQ = FunN), (TPH BR = Fun1< TPH BW, FunN >), (TPH BP = Fun1< Fun1< TPH BW, FunN >, TPH BO >)]
SourceFile DEBUG [Typeinference] class <BW, BO>Matrix extends Vector<Vector<Integer>>
{
Fun1<Fun1<BW, FunN>, BO> op = (BO m) -> {
return (FunN f) -> {
return f.apply(this, m);;
};
};
Matrix Matrix()
{ {
} }
} }

View File

@ -0,0 +1,12 @@
class FunNInsertTest{
Object1 var1;
Object2 var2;
Object3 var3;
op = (a) -> (b) -> (c) -> {
var1 = a;
var2 = b;
var3 = c;
};
}

View File

@ -0,0 +1,18 @@
package plugindevelopment;
import java.util.Vector;
import org.junit.Test;
public class FunNInsertTest {
private static final String TEST_FILE = "FunNInsertTest.jav";
@Test
public void run(){
Vector<String> mustContain = new Vector<String>();
mustContain.add("Fun1<Fun1<Fun1<void, Object3>, Object2>, Object1> op");
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
}
}

View File

@ -0,0 +1,46 @@
package plugindevelopment;
import java.io.File;
import java.io.IOException;
import java.util.Vector;
import junit.framework.TestCase;
import mycompiler.MyCompiler;
import mycompiler.MyCompilerAPI;
import mycompiler.myparser.JavaParser.yyException;
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
import typinferenz.TypeInsertSet;
public class MultipleTypesInsertTester {
public static void test(String sourceFileToInfere, Vector<String> mustContain){
String gesamterSrc = "";
String inferedSource = "";
MyCompilerAPI compiler = MyCompiler.getAPI();
try {
compiler.parse(new File(TypeInsertTester.rootDirectory + sourceFileToInfere));
Vector<TypeinferenceResultSet> results = compiler.typeReconstruction();
//TestCase.assertTrue("Es darf nicht mehr als eine Lösungsmöglichkeit geben und nicht "+results.size(), results.size()==1);
for(TypeinferenceResultSet result : results){
Vector<TypeInsertSet> points = result.getTypeInsertionPoints();
//TestCase.assertTrue("Es muss mindestens ein TypeInsertSet vorhanden sein", points.size()>0);
for(TypeInsertSet point : points){
//TestCase.assertTrue("Es muss mindestens ein TypeInsertPoint vorhanden sein", point.points.size()>0);
if(point.points.size()>0){
inferedSource = point.insertAllTypes(TypeInsertTester.getFileContent(TypeInsertTester.rootDirectory + sourceFileToInfere));
System.out.println(inferedSource);
gesamterSrc += inferedSource;
}
}
}
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
for(String containString : mustContain){
TestCase.assertTrue("\""+containString+"\" muss in den inferierten Lösungen vorkommen",gesamterSrc.contains(containString));
}
}
}

View File

@ -19,32 +19,15 @@ public class OverloadingInsertTest {
@Test @Test
public void run(){ public void run(){
this.test(this.TEST_FILE); Vector<String> mustContain = new Vector<String>();
mustContain.add("Overloading2 methode");
mustContain.add("Overloading2 overload");
mustContain.add("Overloading2 var2");
mustContain.add("OverloadingInsertTest methode");
mustContain.add("OverloadingInsertTest overload");
mustContain.add("OverloadingInsertTest var2");
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
} }
public static void test(String sourceFileToInfere){
String inferedSource = "";
MyCompilerAPI compiler = MyCompiler.getAPI();
try {
compiler.parse(new File(TypeInsertTester.rootDirectory + sourceFileToInfere));
Vector<TypeinferenceResultSet> results = compiler.typeReconstruction();
//TestCase.assertTrue("Es darf nicht mehr als eine Lösungsmöglichkeit geben und nicht "+results.size(), results.size()==1);
for(TypeinferenceResultSet result : results){
Vector<TypeInsertSet> points = result.getTypeInsertionPoints();
TestCase.assertTrue("Es muss mindestens ein TypeInsertSet vorhanden sein", points.size()>0);
for(TypeInsertSet point : points){
TestCase.assertTrue("Es muss mindestens ein TypeInsertPoint vorhanden sein", point.points.size()>0);
if(point.points.size()>0){
inferedSource = point.insertAllTypes(TypeInsertTester.getFileContent(TypeInsertTester.rootDirectory + sourceFileToInfere));
System.out.println(inferedSource);
}
}
}
} catch (IOException | yyException e) {
e.printStackTrace();
TestCase.fail();
}
}
} }