forked from JavaTX/JavaCompilerCore
Fehler beseitigt
This commit is contained in:
parent
d39aecff4d
commit
bd74b24500
8
bin/.gitignore
vendored
8
bin/.gitignore
vendored
@ -1,8 +1,8 @@
|
|||||||
/mycompiler
|
|
||||||
/typinferenz
|
|
||||||
/userinterface
|
|
||||||
/bytecode
|
|
||||||
/myJvmDisassembler
|
/myJvmDisassembler
|
||||||
|
/mycompiler
|
||||||
/parser
|
/parser
|
||||||
/plugindevelopment
|
/plugindevelopment
|
||||||
/syntaxTree
|
/syntaxTree
|
||||||
|
/typinferenz
|
||||||
|
/userinterface
|
||||||
|
/bytecode
|
||||||
|
@ -16,6 +16,7 @@ import mycompiler.myclass.Class;
|
|||||||
import mycompiler.myclass.Constructor;
|
import mycompiler.myclass.Constructor;
|
||||||
import mycompiler.myclass.Field;
|
import mycompiler.myclass.Field;
|
||||||
import mycompiler.myclass.FieldDeclaration;
|
import mycompiler.myclass.FieldDeclaration;
|
||||||
|
import mycompiler.myclass.FormalParameter;
|
||||||
import mycompiler.myclass.ImportDeclarations;
|
import mycompiler.myclass.ImportDeclarations;
|
||||||
import mycompiler.myclass.UsedId;
|
import mycompiler.myclass.UsedId;
|
||||||
import mycompiler.myexception.CTypeReconstructionException;
|
import mycompiler.myexception.CTypeReconstructionException;
|
||||||
@ -1216,16 +1217,21 @@ public class SourceFile
|
|||||||
|
|
||||||
for(int j=0;j<constructors.length;j++){
|
for(int j=0;j<constructors.length;j++){
|
||||||
if(java.lang.reflect.Modifier.isPublic(constructors[j].getModifiers())){
|
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);
|
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++){
|
for(int k=0;k<constructors[j].getParameterTypes().length;k++){
|
||||||
String paraType=constructors[j].getParameterTypes()[k].getName();
|
String paraType=constructors[j].getParameterTypes()[k].getName();
|
||||||
//String paraType=constructors[j].getParameterTypes()[k].getSimpleName();
|
//String paraType=constructors[j].getParameterTypes()[k].getSimpleName();
|
||||||
// Fixme HOTI beachte overloaded id
|
// 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>()));
|
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));
|
//basicAssumptions.addMethodIntersectionType(new CIntersectionType(constructor));
|
||||||
Method constructorMethod = mycompiler.myclass.Method.createEmptyMethod(methodName, parentClass);
|
Method constructorMethod = mycompiler.myclass.Method.createEmptyMethod(methodName, parentClass);
|
||||||
|
constructorMethod.parameterlist = paraList;
|
||||||
parentClass.addField(new Constructor(constructorMethod));
|
parentClass.addField(new Constructor(constructorMethod));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1234,7 +1240,6 @@ public class SourceFile
|
|||||||
basicAssumptions.addClassAssumption(new ClassAssumption(parentClass));
|
basicAssumptions.addClassAssumption(new ClassAssumption(parentClass));
|
||||||
imports.removeElement(importDecl);
|
imports.removeElement(importDecl);
|
||||||
doneImports.addElement(importDecl);
|
doneImports.addElement(importDecl);
|
||||||
|
|
||||||
}
|
}
|
||||||
imports.addAll(doneImports);
|
imports.addAll(doneImports);
|
||||||
return basicAssumptions;
|
return basicAssumptions;
|
||||||
|
@ -128,7 +128,8 @@ public class FieldDeclaration extends Field{
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ConstraintsSet TYPE(TypeAssumptions publicAssumptions) {
|
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();
|
ConstraintsSet ret = new ConstraintsSet();
|
||||||
TypeAssumptions localAssumptions = publicAssumptions.clone();
|
TypeAssumptions localAssumptions = publicAssumptions.clone();
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import mycompiler.mytype.GenericTypeVar;
|
|||||||
import mycompiler.mytype.Pair;
|
import mycompiler.mytype.Pair;
|
||||||
import mycompiler.mytype.RefType;
|
import mycompiler.mytype.RefType;
|
||||||
import mycompiler.mytype.Type;
|
import mycompiler.mytype.Type;
|
||||||
|
import mycompiler.mytype.TypePlaceholder;
|
||||||
import mycompiler.mytype.Void;
|
import mycompiler.mytype.Void;
|
||||||
import mycompiler.mytypereconstruction.CSupportData;
|
import mycompiler.mytypereconstruction.CSupportData;
|
||||||
import mycompiler.mytypereconstruction.CTriple;
|
import mycompiler.mytypereconstruction.CTriple;
|
||||||
@ -33,9 +34,14 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import typinferenz.ConstraintsSet;
|
import typinferenz.ConstraintsSet;
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
|
import typinferenz.OderConstraint;
|
||||||
import typinferenz.ResultSet;
|
import typinferenz.ResultSet;
|
||||||
|
import typinferenz.UndConstraint;
|
||||||
import typinferenz.assumptions.TypeAssumptions;
|
import typinferenz.assumptions.TypeAssumptions;
|
||||||
|
|
||||||
|
|
||||||
@ -172,10 +178,34 @@ public class PostIncExpr extends UnaryExpr
|
|||||||
expr.addOffsetsToExpression(localAssumption,NameVariable,isMemberVariable);
|
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
|
@Override
|
||||||
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
|
||||||
// TODO Auto-generated method stub
|
if(this.getType() == null)this.setType(TypePlaceholder.fresh(this));
|
||||||
return null;
|
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
|
@Override
|
||||||
|
@ -2,6 +2,7 @@ package typinferenz.assumptions;
|
|||||||
|
|
||||||
import typinferenz.TypeInsertable;
|
import typinferenz.TypeInsertable;
|
||||||
import typinferenz.Typeable;
|
import typinferenz.Typeable;
|
||||||
|
import mycompiler.myparser.JavaClassName;
|
||||||
import mycompiler.mytype.*;
|
import mycompiler.mytype.*;
|
||||||
import mycompiler.myclass.Class;
|
import mycompiler.myclass.Class;
|
||||||
|
|
||||||
@ -23,8 +24,8 @@ public class Assumption {
|
|||||||
return this.typable.getType();
|
return this.typable.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentifier(){
|
public JavaClassName getIdentifier(){
|
||||||
return typable.getIdentifier();
|
return new JavaClassName(typable.getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package typinferenz.assumptions;
|
|||||||
|
|
||||||
import mycompiler.myclass.Field;
|
import mycompiler.myclass.Field;
|
||||||
import mycompiler.myclass.Class;
|
import mycompiler.myclass.Class;
|
||||||
|
import mycompiler.myparser.JavaClassName;
|
||||||
import mycompiler.mytype.RefType;
|
import mycompiler.mytype.RefType;
|
||||||
|
|
||||||
public class FieldAssumption extends Assumption {
|
public class FieldAssumption extends Assumption {
|
||||||
@ -19,8 +20,8 @@ public class FieldAssumption extends Assumption {
|
|||||||
return this.parentClass;
|
return this.parentClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentifier(){
|
public JavaClassName getIdentifier(){
|
||||||
return this.field.getIdentifier();
|
return new JavaClassName(this.field.getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package typinferenz.assumptions;
|
package typinferenz.assumptions;
|
||||||
|
|
||||||
|
import mycompiler.myparser.JavaClassName;
|
||||||
import mycompiler.mystatement.LocalVarDecl;
|
import mycompiler.mystatement.LocalVarDecl;
|
||||||
import mycompiler.mytype.GenericTypeVar;
|
import mycompiler.mytype.GenericTypeVar;
|
||||||
import mycompiler.mytype.RefType;
|
import mycompiler.mytype.RefType;
|
||||||
@ -18,8 +19,8 @@ public class GenericVarAssumption extends Assumption{
|
|||||||
return genericVar;//new RefType(this.getIdentifier(), -1);
|
return genericVar;//new RefType(this.getIdentifier(), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentifier(){
|
public JavaClassName getIdentifier(){
|
||||||
return genericVar.getName();
|
return new JavaClassName(genericVar.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(){
|
public String toString(){
|
||||||
|
@ -350,6 +350,7 @@ public class TypeAssumptions {
|
|||||||
*/
|
*/
|
||||||
public ConstructorAssumption getConstructorAssumption(String name, int size) {
|
public ConstructorAssumption getConstructorAssumption(String name, int size) {
|
||||||
for(ConstructorAssumption ca : this.constructorAssumptions){
|
for(ConstructorAssumption ca : this.constructorAssumptions){
|
||||||
|
System.out.println(ca.getIdentifier().toString() + ca.getParaCount());
|
||||||
if(ca.getParaCount()==size && ca.getIdentifier().equals(name))return ca;
|
if(ca.getParaCount()==size && ca.getIdentifier().equals(name))return ca;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -9,7 +9,7 @@ interface RR extends BB<String> {
|
|||||||
class BoundedType1 {
|
class BoundedType1 {
|
||||||
|
|
||||||
|
|
||||||
<T1 extends Boolean & Number & AA & RR> m1(AA a) {
|
<T1 extends Boolean & Integer & AA & RR> m1(AA a) {
|
||||||
T1 b;
|
T1 b;
|
||||||
a.AAm(b);
|
a.AAm(b);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
class BoundedType {
|
class BoundedType {
|
||||||
<T extends Boolean & Number> m(T x) {
|
<T extends Boolean & Integer> m(T x) {
|
||||||
r;
|
r;
|
||||||
r=x;
|
r=x;
|
||||||
return r;
|
return r;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
class Plus1_Float_Double {
|
class Plus1_Float_Double {
|
||||||
op = (x) -> x+1.0;
|
op = (x) -> x + 1.0;
|
||||||
}
|
}
|
@ -54,9 +54,9 @@ public class Tester extends TypeInsertTester{
|
|||||||
Vector<String> testFiles = new Vector<String>();
|
Vector<String> testFiles = new Vector<String>();
|
||||||
//testFiles.add("OL3.jav");
|
//testFiles.add("OL3.jav");
|
||||||
testFiles.add("Plus1_Float_Double.jav");
|
testFiles.add("Plus1_Float_Double.jav");
|
||||||
/*
|
///*
|
||||||
testFiles.add("AchimTest1.jav");
|
testFiles.add("AchimTest1.jav");
|
||||||
testFiles.add("MatrixWhile.jav");
|
//testFiles.add("MatrixWhile.jav");
|
||||||
//testFiles.add("BoundedType1.jav");
|
//testFiles.add("BoundedType1.jav");
|
||||||
testFiles.add("BoundedType2.jav");
|
testFiles.add("BoundedType2.jav");
|
||||||
testFiles.add("BoundedType.jav");
|
testFiles.add("BoundedType.jav");
|
||||||
|
Loading…
Reference in New Issue
Block a user