Fehler in Testcases behoben. RefTyp.hashCode() angefügt

This commit is contained in:
JanUlrich 2014-04-24 13:01:24 +02:00
parent e7db1e7494
commit fab7522def
8 changed files with 21 additions and 11 deletions

View File

@ -65,10 +65,11 @@ public abstract class AddOp extends Operator
@Override
@Override
public Type getReturnType(RefType inputType, TypeAssumptions ass) {
Type ret = ass.getTypeFor(new RefType("java.lang.Integer",-1));
if(ret == null)throw new DebugException("java.lang.Integer kann nicht aufgelöst werden");
Type iT = ass.getTypeFor(inputType);
Hashtable<RefType, RefType> types = getOperatorTypes();
Type ret = types.get(iT);
return ret;
}

View File

@ -21,6 +21,7 @@ import mycompiler.myoperator.MulOp;
import mycompiler.myoperator.Operator;
import mycompiler.myoperator.RelOp;
import mycompiler.mytype.GenericTypeVar;
import mycompiler.mytype.RefType;
import mycompiler.mytype.Type;
import mycompiler.mytypereconstruction.CSupportData;
import mycompiler.mytypereconstruction.set.CSubstitutionSet;
@ -34,6 +35,7 @@ import org.apache.log4j.Logger;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import typinferenz.ConstraintsSet;
import typinferenz.JavaCodeResult;
@ -261,7 +263,8 @@ public class Binary extends BinaryExpr
ret.add(this.expr2.TYPEExpr(assumptions));
//Der Operator generiert die fehlenden Constraints:
ret.add(this.op.TYPEExpr(expr1, expr2, assumptions));
this.set_Type(this.op.getReturnType(assumptions));
//Kleiner Hack, wenn die op.TYPEExpr ohne Fehler durchlaufen wurde, dann kann expr1.getType() zu RefType gecastet werden
this.set_Type(this.op.getReturnType((RefType) expr1.getType(),assumptions));
return ret;
}

View File

@ -180,7 +180,7 @@ public class BoolLiteral extends Literal
@Override
public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) {
this.type = new BooleanType();
this.type = assumptions.getTypeFor(new RefType("java.lang.Boolean",-1));
return new ConstraintsSet();
}

View File

@ -83,7 +83,14 @@ public class RefType extends Type implements IMatchable
}
// ino.end
// ino.method.RefType.26640.definition
@Override
public int hashCode() {
int hash = 0;
hash += this.name.hashCode();//Nur den Name hashen. Sorgt für langsame, aber funktionierende HashMaps
return hash;
}
// ino.method.RefType.26640.definition
public RefType(String fullyQualifiedName, Vector parameter, int offset)
// ino.end
// ino.method.RefType.26640.body

View File

@ -13,8 +13,7 @@ class Main {
ol;
ol = new OL2();
y;
/* y = new Vector<Integer>(); */
y.addElement(ol.m(x));
y.add(ol.m(x));
}
}

View File

@ -59,10 +59,8 @@ public class Tester extends TypeInsertTester{
testFiles.add("BoundedType.jav");
testFiles.add("OL2.jav");
testFiles.add("OL.jav");
testFiles.add("Probleme");
testFiles.add("Simple.jav");
testFiles.add("SMatrix.jav");
testFiles.add("Tester.java");
testFiles.add("UnifyTest1.jav");
testFiles.add("UsecaseEight_pl.jav");
testFiles.add("UsecaseFive_pl.jav");

View File

@ -5,7 +5,7 @@ import java.util.Stack;
class Test {
public getValue(a){
String x;
a.addElement(x);
a.add(x);
}
}

View File

@ -1,3 +1,5 @@
import java.util.Vector;
class UsecaseFive_pl<A> {
foo() {