Fehler beseitigt

This commit is contained in:
JanUlrich 2014-08-28 18:42:40 +02:00
parent d39aecff4d
commit bd74b24500
12 changed files with 61 additions and 21 deletions

8
bin/.gitignore vendored
View File

@ -1,8 +1,8 @@
/mycompiler
/typinferenz
/userinterface
/bytecode
/myJvmDisassembler
/mycompiler
/parser
/plugindevelopment
/syntaxTree
/typinferenz
/userinterface
/bytecode

View File

@ -16,6 +16,7 @@ import mycompiler.myclass.Class;
import mycompiler.myclass.Constructor;
import mycompiler.myclass.Field;
import mycompiler.myclass.FieldDeclaration;
import mycompiler.myclass.FormalParameter;
import mycompiler.myclass.ImportDeclarations;
import mycompiler.myclass.UsedId;
import mycompiler.myexception.CTypeReconstructionException;
@ -1216,16 +1217,21 @@ public class SourceFile
for(int j=0;j<constructors.length;j++){
if(java.lang.reflect.Modifier.isPublic(constructors[j].getModifiers())){
String methodName="<init>";
String methodName=className;
CMethodTypeAssumption constructor = new CMethodTypeAssumption(new RefType(className, 0), methodName, new RefType(className,-1), constructors[j].getParameterTypes().length,MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Vector<Integer>(),null);
ParameterList paraList = new ParameterList();
for(int k=0;k<constructors[j].getParameterTypes().length;k++){
String paraType=constructors[j].getParameterTypes()[k].getName();
//String paraType=constructors[j].getParameterTypes()[k].getSimpleName();
// Fixme HOTI beachte overloaded id
FormalParameter fpara = new FormalParameter(new DeclId("p"+k));
fpara.setType(new RefType(paraType,-1));
paraList.formalparameter.add(fpara);
constructor.addParaAssumption(new CParaTypeAssumption(className, methodName, constructors[j].getParameterTypes().length,0,paraType, new RefType(paraType,-1), MyCompiler.NO_LINENUMBER,MyCompiler.NO_LINENUMBER,new Vector<Integer>()));
}
//basicAssumptions.addMethodIntersectionType(new CIntersectionType(constructor));
Method constructorMethod = mycompiler.myclass.Method.createEmptyMethod(methodName, parentClass);
constructorMethod.parameterlist = paraList;
parentClass.addField(new Constructor(constructorMethod));
}
}
@ -1234,7 +1240,6 @@ public class SourceFile
basicAssumptions.addClassAssumption(new ClassAssumption(parentClass));
imports.removeElement(importDecl);
doneImports.addElement(importDecl);
}
imports.addAll(doneImports);
return basicAssumptions;

View File

@ -128,7 +128,8 @@ public class FieldDeclaration extends Field{
}
@Override
public ConstraintsSet TYPE(TypeAssumptions publicAssumptions) {
if(this.wert == null)throw new TypeinferenceException("Typlose Felder müssen mit Wert initialisiert werden", this);
if(this.wert == null && (this.getType() == null || this.getType() instanceof TypePlaceholder))
throw new TypeinferenceException("Typlose Felder müssen mit Wert initialisiert werden", this);
ConstraintsSet ret = new ConstraintsSet();
TypeAssumptions localAssumptions = publicAssumptions.clone();

View File

@ -19,6 +19,7 @@ import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.Pair;
import mycompiler.mytype.RefType;
import mycompiler.mytype.Type;
import mycompiler.mytype.TypePlaceholder;
import mycompiler.mytype.Void;
import mycompiler.mytypereconstruction.CSupportData;
import mycompiler.mytypereconstruction.CTriple;
@ -33,9 +34,14 @@ import org.apache.log4j.Logger;
import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult;
import typinferenz.OderConstraint;
import typinferenz.ResultSet;
import typinferenz.UndConstraint;
import typinferenz.assumptions.TypeAssumptions;
@ -172,10 +178,34 @@ public class PostIncExpr extends UnaryExpr
expr.addOffsetsToExpression(localAssumption,NameVariable,isMemberVariable);
}
private Vector<RefType> getNumericTypes(){
Vector<RefType> ret = new Vector<>();
ret.add(new RefType("Integer",-1));
ret.add(new RefType("Long",-1));
ret.add(new RefType("Double",-1));
return ret ;
}
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
// TODO Auto-generated method stub
return null;
if(this.getType() == null)this.setType(TypePlaceholder.fresh(this));
ConstraintsSet ret = new ConstraintsSet();
OderConstraint oderConstraint = new OderConstraint();
ret.add(this.expr.TYPEExpr(assumptions));
for(RefType t : getNumericTypes()){
UndConstraint undConstraint = new UndConstraint();
undConstraint.addConstraint(this.getType(), t);
undConstraint.addConstraint(this.expr.getType(), t);
oderConstraint.addConstraint(undConstraint);
}
ret.add(oderConstraint);
return ret;
}
@Override
public ConstraintsSet TYPEStmt(TypeAssumptions assumptions) {
return this.TYPEExpr(assumptions);
}
@Override

View File

@ -2,6 +2,7 @@ package typinferenz.assumptions;
import typinferenz.TypeInsertable;
import typinferenz.Typeable;
import mycompiler.myparser.JavaClassName;
import mycompiler.mytype.*;
import mycompiler.myclass.Class;
@ -23,8 +24,8 @@ public class Assumption {
return this.typable.getType();
}
public String getIdentifier(){
return typable.getIdentifier();
public JavaClassName getIdentifier(){
return new JavaClassName(typable.getIdentifier());
}
}

View File

@ -2,6 +2,7 @@ package typinferenz.assumptions;
import mycompiler.myclass.Field;
import mycompiler.myclass.Class;
import mycompiler.myparser.JavaClassName;
import mycompiler.mytype.RefType;
public class FieldAssumption extends Assumption {
@ -19,8 +20,8 @@ public class FieldAssumption extends Assumption {
return this.parentClass;
}
public String getIdentifier(){
return this.field.getIdentifier();
public JavaClassName getIdentifier(){
return new JavaClassName(this.field.getIdentifier());
}
@Override

View File

@ -1,5 +1,6 @@
package typinferenz.assumptions;
import mycompiler.myparser.JavaClassName;
import mycompiler.mystatement.LocalVarDecl;
import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.RefType;
@ -18,8 +19,8 @@ public class GenericVarAssumption extends Assumption{
return genericVar;//new RefType(this.getIdentifier(), -1);
}
public String getIdentifier(){
return genericVar.getName();
public JavaClassName getIdentifier(){
return new JavaClassName(genericVar.getName());
}
public String toString(){

View File

@ -350,6 +350,7 @@ public class TypeAssumptions {
*/
public ConstructorAssumption getConstructorAssumption(String name, int size) {
for(ConstructorAssumption ca : this.constructorAssumptions){
System.out.println(ca.getIdentifier().toString() + ca.getParaCount());
if(ca.getParaCount()==size && ca.getIdentifier().equals(name))return ca;
}
return null;

View File

@ -9,7 +9,7 @@ interface RR extends BB<String> {
class BoundedType1 {
<T1 extends Boolean & Number & AA & RR> m1(AA a) {
<T1 extends Boolean & Integer & AA & RR> m1(AA a) {
T1 b;
a.AAm(b);
}

View File

@ -1,5 +1,5 @@
class BoundedType {
<T extends Boolean & Number> m(T x) {
<T extends Boolean & Integer> m(T x) {
r;
r=x;
return r;

View File

@ -1,3 +1,3 @@
class Plus1_Float_Double {
op = (x) -> x+1.0;
op = (x) -> x + 1.0;
}

View File

@ -54,9 +54,9 @@ public class Tester extends TypeInsertTester{
Vector<String> testFiles = new Vector<String>();
//testFiles.add("OL3.jav");
testFiles.add("Plus1_Float_Double.jav");
/*
///*
testFiles.add("AchimTest1.jav");
testFiles.add("MatrixWhile.jav");
//testFiles.add("MatrixWhile.jav");
//testFiles.add("BoundedType1.jav");
testFiles.add("BoundedType2.jav");
testFiles.add("BoundedType.jav");