forked from JavaTX/JavaCompilerCore
ConstuctorAssumption angefügt
This commit is contained in:
parent
9d361072e3
commit
d4b9ea9a73
@ -42,9 +42,10 @@ import org.apache.log4j.xml.DOMConfigurator;
|
||||
import com.sun.corba.se.spi.orbutil.fsm.Guard.Result;
|
||||
import com.sun.org.apache.xerces.internal.impl.xs.identity.Field;
|
||||
|
||||
import typinferenz.TypinferenzException;
|
||||
// ino.end
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.ParserException;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
|
||||
|
||||
|
||||
@ -752,8 +753,8 @@ public class MyCompiler implements MyCompilerAPI
|
||||
try {
|
||||
srcFile = (SourceFile) parser.yyparse( scanner );
|
||||
} catch (IOException | yyException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
if(e instanceof yyException)throw new ParserException((yyException)e);
|
||||
}
|
||||
//////////////////////////////////////
|
||||
// Postprocessing:
|
||||
@ -786,7 +787,6 @@ public class MyCompiler implements MyCompilerAPI
|
||||
}
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -812,7 +812,6 @@ public class MyCompiler implements MyCompilerAPI
|
||||
reader.close();
|
||||
gesamterSrc += fileData.toString() + "\n"; // Alle Dateien nacheinander hintereinander anhängen...
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
throw new TypinferenzException("Die übergebenen Dateien konnten nicht zum Parsen eingelesen werden.");
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ import sun.reflect.generics.reflectiveObjects.TypeVariableImpl;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.FunN;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.UndConstraint;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
|
||||
|
||||
|
||||
@ -741,7 +741,7 @@ public class SourceFile
|
||||
|
||||
TypeAssumptions basics;
|
||||
|
||||
basics = this.makeBasicAssumptions(); //TODO: Diese Funktion ändern, dass nur noch TypeAssumptions zurückgegeben werden. Diese sind wichtig, da hier die Standard-Library von Java als Assumptions generiert wird.
|
||||
basics = this.makeBasicAssumptions();
|
||||
|
||||
//A.addElement(basics); //auskommentiert von Andreas Stadelmeier
|
||||
|
||||
@ -1376,7 +1376,9 @@ public class SourceFile
|
||||
|
||||
return foo;
|
||||
*/
|
||||
return new TypeAssumptions(null); //TODO: Diese TypeAssumptions mit basic-Assumptions füllen
|
||||
TypeAssumptions ret = new TypeAssumptions();
|
||||
|
||||
return ret; //TODO: Diese TypeAssumptions mit basic-Assumptions füllen
|
||||
}
|
||||
// ino.end
|
||||
|
||||
@ -1515,7 +1517,6 @@ public class SourceFile
|
||||
|
||||
@Override
|
||||
public SyntaxTreeNode getParent() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package mycompiler;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
import mycompiler.myclass.Class;
|
||||
|
||||
public abstract class SyntaxTreeNode {
|
||||
|
@ -57,15 +57,16 @@ 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.TypinferenzException;
|
||||
import typinferenz.UndConstraint;
|
||||
import typinferenz.FunN;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
|
||||
|
||||
|
||||
@ -1156,11 +1157,6 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
|
||||
JavaCodeResult classBodyCode = new JavaCodeResult();
|
||||
if(this.modifiers!=null)classBodyCode.attach(this.modifiers.printJavaCode(reconstructionResult.getUnifiedConstraints())).attach(" ");
|
||||
|
||||
if(superclassid == null || superclassid.get_Name().size()<1){
|
||||
int superclassidOffset = superclassid == null ? 0 : superclassid.getOffset();
|
||||
superclassid = new UsedId("Object", superclassidOffset);
|
||||
}
|
||||
|
||||
classBodyCode.attach(this.name + " extends ").attach(superclassid.printJavaCode(reconstructionResult.getUnifiedConstraints())).attach("\n");
|
||||
|
||||
@ -1262,6 +1258,12 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
super.parserPostProcessing(parent);
|
||||
|
||||
//Wenn keine Superklasse, dann erbt die Klasse zwangsweise von Object:
|
||||
if(superclassid == null || superclassid.get_Name().size()<1){
|
||||
int superclassidOffset = superclassid == null ? 0 : superclassid.getOffset();
|
||||
superclassid = new UsedId("Object", superclassidOffset);
|
||||
}
|
||||
|
||||
//Alle Methoden auf Konstruktoren durchsuchen und diese umwandeln:
|
||||
Vector<Field> tempFields = new Vector<Field>();
|
||||
for(Field f : this.getFields()){
|
||||
|
@ -15,8 +15,10 @@ import typinferenz.ConstraintsSet;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.assumptions.ConstructorAssumption;
|
||||
import typinferenz.assumptions.MethodAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
|
||||
public class Constructor extends Method {
|
||||
private Method methode;
|
||||
@ -238,10 +240,17 @@ public class Constructor extends Method {
|
||||
|
||||
@Override
|
||||
public TypeAssumptions createTypeAssumptions(Class classmember) {
|
||||
|
||||
return this.methode.createTypeAssumptions(classmember);
|
||||
Class parentClass = this.getParentClass();
|
||||
TypeAssumptions ret = new TypeAssumptions();
|
||||
ret.addConstructorAssumption(new ConstructorAssumption(this, parentClass));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SyntaxTreeNode getParent(){
|
||||
return this.methode.getParent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parserPostProcessing(SyntaxTreeNode parent) {
|
||||
|
||||
|
@ -7,9 +7,9 @@ import typinferenz.JavaCodeResult;
|
||||
import typinferenz.OderConstraint;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.assumptions.FieldAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.myexception.JVMCodeException;
|
||||
@ -75,7 +75,7 @@ public class FieldDeclaration extends Field{
|
||||
//////////////////////////////
|
||||
TypeAssumptions assumptions = new TypeAssumptions();
|
||||
/*
|
||||
* TODO: Der Feld-Assumption muss ein TPH als Typ hinzugefügt werden, falls er Typlos initialisiert wurde. Dies kann auch der Type-Algorithmus der Inst/FieldVar - Klasse machen.
|
||||
* Der Feld-Assumption muss ein TPH als Typ hinzugefügt werden, falls er Typlos initialisiert wurde. Dies kann auch der Type-Algorithmus der Inst/FieldVar - Klasse machen.
|
||||
* Wird das Feld mit einem Typ initialisiert so muss dieser auch in die Assumptions.
|
||||
*/
|
||||
if(this.getType() == null)throw new TypinferenzException("Der Typ eines Feldes darf nicht null sein");
|
||||
|
@ -22,12 +22,13 @@ import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.Typeable;
|
||||
import typinferenz.TypeInsertable;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
|
||||
// ino.class.FormalParameter.23391.declaration
|
||||
public class FormalParameter extends SyntaxTreeNode implements ITypeReplacementListener, Typeable, TypeInsertable
|
||||
|
@ -563,7 +563,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
||||
@Override
|
||||
public JavaCodeResult printJavaCode(ResultSet resultSet) {
|
||||
JavaCodeResult ret = new JavaCodeResult();
|
||||
ret.attach(this.getType().printJavaCode(resultSet)).attach(" ").attach(this.get_Method_Name()).attach("()\n"); //TODO: hier müssen auch noch die Parameter ausgegeben werden!
|
||||
ret.attach(this.getType().printJavaCode(resultSet)).attach(" ").attach(this.get_Method_Name()).attach("(").attach(this.getParameterList().printJavaCode(resultSet)).attach(")\n");
|
||||
ret.attach(this.block.printJavaCode(resultSet));
|
||||
|
||||
return ret;
|
||||
|
@ -7,7 +7,7 @@ import java.util.Vector;
|
||||
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
import mycompiler.IItemWithOffset;
|
||||
import mycompiler.mybytecode.JVMCode;
|
||||
import mycompiler.mytype.Type;
|
||||
|
@ -32,14 +32,15 @@ import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.FreshTypeVariable;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
|
||||
|
||||
|
||||
|
@ -10,9 +10,9 @@ import typinferenz.FreshTypeVariable;
|
||||
import typinferenz.FunN;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.Typeable;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.assumptions.ParameterAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
import mycompiler.SyntaxTreeNode;
|
||||
import mycompiler.mybytecode.ClassFile;
|
||||
import mycompiler.mybytecode.CodeAttribute;
|
||||
@ -124,7 +124,7 @@ public class LambdaExpression extends Expr{
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
//Die Assumptions für die Parameter der LambdaExpression
|
||||
TypeAssumptions ArgumentAssumptions = new TypeAssumptions(assumptions.getThisValue().getName());
|
||||
TypeAssumptions ArgumentAssumptions = new TypeAssumptions(this.getParentClass().getName());
|
||||
Vector<Type> paramTypes = new Vector<Type>();
|
||||
|
||||
for(FormalParameter param : params.formalparameter){
|
||||
|
@ -664,7 +664,6 @@ public class MethodCall extends Expr
|
||||
*/
|
||||
@Override
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
//TODO hier muss unterschieden werden zwischen einem Konstruktor und einer Methode.
|
||||
//Hier der Ablauf für einen Methodenaufruf:
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
//Der Return-Type des MEthodenaufrufs ist zunächst unbekannt:
|
||||
|
@ -170,7 +170,8 @@ public class This extends Expr
|
||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
//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));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,8 @@ import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PatternLayout;
|
||||
import org.apache.log4j.SimpleLayout;
|
||||
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
import mycompiler.MyCompiler;
|
||||
import mycompiler.MyCompilerAPI;
|
||||
import mycompiler.mytype.Type;
|
||||
|
@ -11,8 +11,8 @@ import typinferenz.ConstraintsSet;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.TypeInsertPoint;
|
||||
import typinferenz.TypeInsertSet;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
import mycompiler.mytype.GenericTypeVar;
|
||||
import mycompiler.mytype.Pair;
|
||||
import mycompiler.mytype.RefType;
|
||||
|
@ -59,8 +59,8 @@ public class OderConstraint{
|
||||
@Override
|
||||
public String toString(){
|
||||
String ret = "[";
|
||||
for(Pair p : this.getConstraintPairs()){
|
||||
ret += p.toString()+ ", ";
|
||||
for(UndConstraint p : this.getUndConstraints()){
|
||||
ret += p.toString()+ "| ";
|
||||
}
|
||||
return ret+"]";
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package typinferenz;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
import mycompiler.mytype.Pair;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
|
@ -27,9 +27,15 @@ public class UndConstraint extends OderConstraint {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
String ret = super.toString();
|
||||
return ret.replace(',', '|');
|
||||
//String ret = super.toString();
|
||||
//return ret.replace('|', ',');
|
||||
String ret = "[";
|
||||
for(Pair p : this.getConstraintPairs()){
|
||||
ret += p.toString()+ ", ";
|
||||
}
|
||||
return ret+"]";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import java.util.Vector;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.FunN;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
import mycompiler.mytype.GenericTypeVar;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
@ -155,6 +155,7 @@ public class CopyOfTypeAssumptions implements Iterable<CTypeAssumption> {
|
||||
}
|
||||
//TODO: Dann die lokalen Variablen
|
||||
// ... (noch nicht implementiert)
|
||||
|
||||
//und zuletzt die Felder der Klasse in dessen Namensraum sich dieses AssumptionSet befindet.
|
||||
for(CTypeAssumption ass : this.getInstVarAssumptions()){
|
||||
if(ass.getIdentifier().equals(variableName))return ass.getAssumedType();
|
||||
|
@ -1,14 +1,16 @@
|
||||
package typinferenz.assumptions;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import mycompiler.myclass.Class;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||
import typinferenz.FunN;
|
||||
import typinferenz.FunNInterface;
|
||||
import typinferenz.FunNMethod;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
import mycompiler.mytype.GenericTypeVar;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
@ -46,6 +48,7 @@ public class TypeAssumptions {
|
||||
|
||||
|
||||
private Vector<MethodAssumption> methodAssumptions = new Vector<MethodAssumption>();
|
||||
private Vector<ConstructorAssumption> constructorAssumptions = new Vector<ConstructorAssumption>();
|
||||
private Vector<FieldAssumption> fieldAssumptions = new Vector<FieldAssumption>();
|
||||
private Vector<LocalVarAssumption> localVarAssumptions = new Vector<LocalVarAssumption>();
|
||||
private Vector<ParameterAssumption> parameterAssumptions = new Vector<ParameterAssumption>();
|
||||
@ -67,7 +70,12 @@ public class TypeAssumptions {
|
||||
public void addMethodAssumption(MethodAssumption mAss){
|
||||
this.methodAssumptions.add(mAss);
|
||||
}
|
||||
|
||||
|
||||
public void addConstructorAssumption(
|
||||
ConstructorAssumption constructorAssumption) {
|
||||
this.constructorAssumptions.add(constructorAssumption);
|
||||
}
|
||||
|
||||
public void addFieldAssumption(FieldAssumption ass){
|
||||
this.fieldAssumptions.add(ass);
|
||||
}
|
||||
@ -87,10 +95,11 @@ public class TypeAssumptions {
|
||||
*/
|
||||
public Vector<FieldAssumption> getFieldVars(String withName){
|
||||
//TODO: Implementieren
|
||||
return null;
|
||||
return new Vector<FieldAssumption>();
|
||||
}
|
||||
|
||||
public Type getTypeOfFieldVar(String withName, Class inClass){
|
||||
//TODO: Implementieren
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -100,7 +109,8 @@ public class TypeAssumptions {
|
||||
* @return
|
||||
*/
|
||||
public Vector<MethodAssumption> getMethods(String withName){
|
||||
return null;
|
||||
//TODO: Implementieren
|
||||
return new Vector<MethodAssumption>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,6 +119,7 @@ public class TypeAssumptions {
|
||||
* @return
|
||||
*/
|
||||
public Type getTypeOfLocalVar(String withName){
|
||||
//TODO: Implementieren
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -243,9 +254,13 @@ public class TypeAssumptions {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Type getThisValue() {
|
||||
@Deprecated
|
||||
public Type getThisValue2() {
|
||||
if(thisClassName == null)throw new TypinferenzException("Kein Wert für this vorhanden, in diesem Kontext");
|
||||
return new RefType(thisClassName, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package typinferenz;
|
||||
package typinferenz.exceptions;
|
||||
|
||||
/**
|
||||
* Eine RuntimeException, welche bei einem Fehler während des Typinferenzalgorithmus ausgelöst wird.
|
@ -8,7 +8,8 @@ import java.util.Vector;
|
||||
import mycompiler.MyCompiler;
|
||||
import mycompiler.MyCompilerAPI;
|
||||
import mycompiler.mytypereconstruction.TypeinferenceResultSet;
|
||||
import typinferenz.TypinferenzException;
|
||||
import typinferenz.exceptions.TypinferenzException;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
@ -2,7 +2,7 @@ class OverloadingTest{
|
||||
|
||||
var;
|
||||
|
||||
public Object clone(){
|
||||
public clone(){
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ class OverloadingTest{
|
||||
|
||||
class OverloadingTest2{
|
||||
|
||||
public Object clone(){
|
||||
public clone(){
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -1,123 +1,36 @@
|
||||
Class DEBUG [Typeinference] Erstellte Assumptions: this: MatrixMethod Assumptions:
|
||||
[MethodAssumption: Matrix null { []]
|
||||
Class DEBUG [Typeinference] Erstellte Assumptions: this: ThisTestMethod Assumptions:
|
||||
[]
|
||||
FieldVar Assumptions:
|
||||
[typinferenz.assumptions.FieldAssumption@15502c5e]
|
||||
[typinferenz.assumptions.FieldAssumption@6d657803]
|
||||
LocalVar Assumptions:
|
||||
[]
|
||||
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
|
||||
ThisTest < 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] Karthesisches Produkt der Constraints: [[(TPH A <. TPH A), (ThisTest <. TPH A)]]
|
||||
SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH A = ThisTest)], [(TPH A = Object)]]
|
||||
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] JavaFile für ResultSet Unified Constraints: [(TPH A = ThisTest)]
|
||||
|
||||
SourceFile DEBUG [Typeinference] class <K, C>Matrix extends Vector<Vector<Integer>>
|
||||
SourceFile DEBUG [Typeinference] class ThisTest extends Object
|
||||
{
|
||||
Fun1<Fun1<K, FunN>, C> op = (C m) -> {
|
||||
return (FunN f) -> {
|
||||
return f.apply(this, m);;
|
||||
};
|
||||
};
|
||||
Matrix Matrix()
|
||||
ThisTest thisVar = this;
|
||||
ThisTest ThisTest()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
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] JavaFile für ResultSet Unified Constraints: [(TPH A = Object)]
|
||||
|
||||
SourceFile DEBUG [Typeinference] class <K, C>Matrix extends Vector<Vector<Integer>>
|
||||
SourceFile DEBUG [Typeinference] class ThisTest extends Object
|
||||
{
|
||||
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()
|
||||
Object thisVar = this;
|
||||
ThisTest ThisTest()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,6 @@ import mycompiler.mytypereconstruction.typeassumption.CLocalVarTypeAssumption;
|
||||
import mycompiler.mytypereconstruction.typeassumption.CMethodTypeAssumption;
|
||||
|
||||
|
||||
/*TODO:
|
||||
*/
|
||||
|
||||
public class TestAbstractInferenceTest extends AbstractInferenceTestOLD_2 {
|
||||
|
||||
private final static String TESTEDCLASSNAME="TestAbstractInferenceTest";
|
||||
|
@ -1,5 +1,50 @@
|
||||
package plugindevelopment;
|
||||
|
||||
public class OverloadingInsertTest {
|
||||
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 org.junit.Test;
|
||||
|
||||
import typinferenz.TypeInsertSet;
|
||||
|
||||
public class OverloadingInsertTest {
|
||||
private static final String TEST_FILE = "OverloadingInsertTest.jav";
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
this.test(this.TEST_FILE);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class TypeInsertTester{
|
||||
inferencelog.addAppender(logAppender); //Bei den Tests wird der Log auch in System.out geschrieben.
|
||||
}
|
||||
}
|
||||
private static final String rootDirectory = System.getProperty("user.dir")+"/test/plugindevelopment/";
|
||||
static final String rootDirectory = System.getProperty("user.dir")+"/test/plugindevelopment/";
|
||||
|
||||
public static void test(String sourceFileToInfere, String solutionFile){
|
||||
String inferedSource = "";
|
||||
@ -47,7 +47,7 @@ public class TypeInsertTester{
|
||||
try {
|
||||
compiler.parse(new File(rootDirectory + sourceFileToInfere));
|
||||
Vector<TypeinferenceResultSet> results = compiler.typeReconstruction();
|
||||
TestCase.assertTrue("Es darf nicht mehr als eine Lösungsmöglichkeit geben", results.size()==1);
|
||||
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);
|
||||
@ -68,7 +68,7 @@ public class TypeInsertTester{
|
||||
}
|
||||
|
||||
//Source: https://stackoverflow.com/questions/326390/how-to-create-a-java-string-from-the-contents-of-a-file
|
||||
private static String getFileContent(String path)throws IOException
|
||||
static String getFileContent(String path)throws IOException
|
||||
{
|
||||
byte[] encoded = Files.readAllBytes(Paths.get(path));
|
||||
return StandardCharsets.UTF_8.decode(ByteBuffer.wrap(encoded)).toString();
|
||||
|
Loading…
Reference in New Issue
Block a user