diff --git a/src/mycompiler/myoperator/AddOp.java b/src/mycompiler/myoperator/AddOp.java index 38c96b10..bd43703f 100755 --- a/src/mycompiler/myoperator/AddOp.java +++ b/src/mycompiler/myoperator/AddOp.java @@ -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 types = getOperatorTypes(); + Type ret = types.get(iT); return ret; } diff --git a/src/mycompiler/mystatement/Binary.java b/src/mycompiler/mystatement/Binary.java index eaffa3f3..65186b40 100755 --- a/src/mycompiler/mystatement/Binary.java +++ b/src/mycompiler/mystatement/Binary.java @@ -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; } diff --git a/src/mycompiler/mystatement/BoolLiteral.java b/src/mycompiler/mystatement/BoolLiteral.java index 128d7683..7c4c9a37 100755 --- a/src/mycompiler/mystatement/BoolLiteral.java +++ b/src/mycompiler/mystatement/BoolLiteral.java @@ -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(); } diff --git a/src/mycompiler/mytype/RefType.java b/src/mycompiler/mytype/RefType.java index c8ba376f..0cbe76aa 100755 --- a/src/mycompiler/mytype/RefType.java +++ b/src/mycompiler/mytype/RefType.java @@ -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 diff --git a/test/plugindevelopment/MartinTestCases/OL2.jav b/test/plugindevelopment/MartinTestCases/OL2.jav index 8a2c485b..799d586d 100755 --- a/test/plugindevelopment/MartinTestCases/OL2.jav +++ b/test/plugindevelopment/MartinTestCases/OL2.jav @@ -13,8 +13,7 @@ class Main { ol; ol = new OL2(); y; - /* y = new Vector(); */ - y.addElement(ol.m(x)); + y.add(ol.m(x)); } } diff --git a/test/plugindevelopment/MartinTestCases/Tester.java b/test/plugindevelopment/MartinTestCases/Tester.java index a73f0a42..d056fc59 100644 --- a/test/plugindevelopment/MartinTestCases/Tester.java +++ b/test/plugindevelopment/MartinTestCases/Tester.java @@ -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"); diff --git a/test/plugindevelopment/MartinTestCases/UnifyTest1.jav b/test/plugindevelopment/MartinTestCases/UnifyTest1.jav index abb8580b..88d59e58 100755 --- a/test/plugindevelopment/MartinTestCases/UnifyTest1.jav +++ b/test/plugindevelopment/MartinTestCases/UnifyTest1.jav @@ -5,7 +5,7 @@ import java.util.Stack; class Test { public getValue(a){ String x; - a.addElement(x); + a.add(x); } } diff --git a/test/plugindevelopment/MartinTestCases/UsecaseFive_pl.jav b/test/plugindevelopment/MartinTestCases/UsecaseFive_pl.jav index 1ccfddbd..5e25f6d8 100755 --- a/test/plugindevelopment/MartinTestCases/UsecaseFive_pl.jav +++ b/test/plugindevelopment/MartinTestCases/UsecaseFive_pl.jav @@ -1,3 +1,5 @@ +import java.util.Vector; + class UsecaseFive_pl { foo() {