From 2151c4550b6ed314e022e84800ab530ae82d9621 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Tue, 10 Jun 2014 20:23:01 +0200 Subject: [PATCH] Backup --- src/mycompiler/SourceFile.java | 9 +++-- src/mycompiler/mystatement/DoubleLiteral.java | 9 +++-- test/plugindevelopment/MartinTestCases/Id.jav | 3 ++ .../MartinTestCases/MatrixVectorMul.jav | 14 +++++++ .../MartinTestCases/Matrix_lambda.jav | 5 +++ .../MartinTestCases/MethodId.jav | 6 +++ .../MartinTestCases/MethodIntegerUse.jav | 8 ++++ .../MartinTestCases/MethodUse.jav | 8 ++++ .../plugindevelopment/MartinTestCases/OL3.jav | 9 +++++ .../MartinTestCases/Plus1.jav | 3 ++ .../MartinTestCases/Plus1_Float_Double.jav | 3 ++ .../MartinTestCases/Tester.java | 4 ++ .../jav/Lambda_usecases/Fehler Report | 37 +++++++++++++++++++ .../jav/Lambda_usecases/Id.jav | 3 ++ .../jav/Lambda_usecases/MatrixVectorMul.jav | 14 +++++++ .../jav/Lambda_usecases/Matrix_lambda.jav | 5 +++ .../jav/Lambda_usecases/MethodId.jav | 6 +++ .../jav/Lambda_usecases/MethodIntegerUse.jav | 8 ++++ .../jav/Lambda_usecases/MethodUse.jav | 8 ++++ .../jav/Lambda_usecases/OL.jav | 19 ++++++++++ .../jav/Lambda_usecases/Plus1.jav | 3 ++ .../Lambda_usecases/Plus1_Float_Double.jav | 3 ++ 22 files changed, 179 insertions(+), 8 deletions(-) create mode 100644 test/plugindevelopment/MartinTestCases/Id.jav create mode 100644 test/plugindevelopment/MartinTestCases/MatrixVectorMul.jav create mode 100644 test/plugindevelopment/MartinTestCases/Matrix_lambda.jav create mode 100644 test/plugindevelopment/MartinTestCases/MethodId.jav create mode 100644 test/plugindevelopment/MartinTestCases/MethodIntegerUse.jav create mode 100644 test/plugindevelopment/MartinTestCases/MethodUse.jav create mode 100644 test/plugindevelopment/MartinTestCases/OL3.jav create mode 100644 test/plugindevelopment/MartinTestCases/Plus1.jav create mode 100644 test/plugindevelopment/MartinTestCases/Plus1_Float_Double.jav create mode 100644 test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Fehler Report create mode 100644 test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Id.jav create mode 100644 test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MatrixVectorMul.jav create mode 100644 test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Matrix_lambda.jav create mode 100644 test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MethodId.jav create mode 100644 test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MethodIntegerUse.jav create mode 100644 test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MethodUse.jav create mode 100644 test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/OL.jav create mode 100644 test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Plus1.jav create mode 100644 test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Plus1_Float_Double.jav diff --git a/src/mycompiler/SourceFile.java b/src/mycompiler/SourceFile.java index e77d56a55..56cf5fabc 100755 --- a/src/mycompiler/SourceFile.java +++ b/src/mycompiler/SourceFile.java @@ -690,6 +690,7 @@ public class SourceFile ////////////////////////////// // Unifizierung der Constraints: ////////////////////////////// + boolean unifyFail = true; for(Vector constraints : xConstraints){ //Alle durch das Karthesische Produkt entstandenen Möglichkeiten durchgehen: Vector> result = new Vector>(); @@ -785,6 +786,7 @@ public class SourceFile for(Class klasse : this.KlassenVektor){ //Der Unifikationsalgorithmus kann wiederum auch mehrere Lösungen errechnen, diese werden im folgenden durchlaufen: for(Vector resultSet : result){ + unifyFail = false; //Ein Unifiziertes Ergebnis ist entstanden (es kann auch leer sein, das bedeutet nur, dass die Constraints mindestens in einem Fall Sinn ergaben) //Add Result set as a new ReconstructionResult to ret: TypeinferenceResultSet reconstructionResult = new TypeinferenceResultSet(klasse, constraints, new ResultSet(resultSet)); ret.add(reconstructionResult); @@ -795,11 +797,10 @@ public class SourceFile } } - - } - - + if(unifyFail){ + if(!this.KlassenVektor.isEmpty())throw new TypeinferenceException("Fehler in Typinferierung", this.KlassenVektor.firstElement()); + } return ret; /* // HOTI: Nur zur Info.Ich habe den Loglevel auf Info geschaltet, damit diff --git a/src/mycompiler/mystatement/DoubleLiteral.java b/src/mycompiler/mystatement/DoubleLiteral.java index 766234dea..7a80f1c13 100755 --- a/src/mycompiler/mystatement/DoubleLiteral.java +++ b/src/mycompiler/mystatement/DoubleLiteral.java @@ -205,14 +205,15 @@ public class DoubleLiteral extends Literal @Override public ConstraintsSet TYPEExpr(TypeAssumptions assumptions) { - // TODO Auto-generated method stub - return null; + this.setType(assumptions.getTypeFor(new RefType("Double",this.getOffset()))); + return new ConstraintsSet(); } @Override public JavaCodeResult printJavaCode(ResultSet resultSet) { - // TODO Auto-generated method stub - return null; + JavaCodeResult ret = new JavaCodeResult(); + ret.attach(""+this.Double); + return ret; } @Override public Vector getChildren() { diff --git a/test/plugindevelopment/MartinTestCases/Id.jav b/test/plugindevelopment/MartinTestCases/Id.jav new file mode 100644 index 000000000..d2293b4b8 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/Id.jav @@ -0,0 +1,3 @@ +class Id { + Fun1 op = (x) -> x; + } \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/MatrixVectorMul.jav b/test/plugindevelopment/MartinTestCases/MatrixVectorMul.jav new file mode 100644 index 000000000..5aa6ee451 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/MatrixVectorMul.jav @@ -0,0 +1,14 @@ +import java.util.Vector; + +class Matrix extends Vector> { + + mvmul(Vector v) { + i; + ele; + v.add(1); + while (i < v.size()) { + + ele = 5 + v.elementAt(i); + } + } +} diff --git a/test/plugindevelopment/MartinTestCases/Matrix_lambda.jav b/test/plugindevelopment/MartinTestCases/Matrix_lambda.jav new file mode 100644 index 000000000..293f776e4 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/Matrix_lambda.jav @@ -0,0 +1,5 @@ +import java.util.Vector; + +class Matrix extends Vector> { + op = (Matrix m) -> (f) -> f.apply(this, m); +} \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/MethodId.jav b/test/plugindevelopment/MartinTestCases/MethodId.jav new file mode 100644 index 000000000..f8f44dec3 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/MethodId.jav @@ -0,0 +1,6 @@ +class MethodId { + + US m (UR x) { + return x; + } + } \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/MethodIntegerUse.jav b/test/plugindevelopment/MartinTestCases/MethodIntegerUse.jav new file mode 100644 index 000000000..11f2c06bc --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/MethodIntegerUse.jav @@ -0,0 +1,8 @@ +class MethodIntegerUse { + Fun1 op = (x) -> m(x); + + + Integer m (Integer x) { + return x; + } + } \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/MethodUse.jav b/test/plugindevelopment/MartinTestCases/MethodUse.jav new file mode 100644 index 000000000..1349b7ff7 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/MethodUse.jav @@ -0,0 +1,8 @@ +class MethodUse { + Fun1 op = (x) -> m(x); + + + AP m (AO x) { + return x; + } + } \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/OL3.jav b/test/plugindevelopment/MartinTestCases/OL3.jav new file mode 100644 index 000000000..0ccd6da1b --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/OL3.jav @@ -0,0 +1,9 @@ +class Test{ + String main(){ + return m(()->{return "Test";}); + } + String m(p){ + return p.apply(); + } + void m(p){} +} diff --git a/test/plugindevelopment/MartinTestCases/Plus1.jav b/test/plugindevelopment/MartinTestCases/Plus1.jav new file mode 100644 index 000000000..6b0ca749a --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/Plus1.jav @@ -0,0 +1,3 @@ +class Plus1 { + Fun1 op = (x) -> x+1; + } \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/Plus1_Float_Double.jav b/test/plugindevelopment/MartinTestCases/Plus1_Float_Double.jav new file mode 100644 index 000000000..75c3baad7 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/Plus1_Float_Double.jav @@ -0,0 +1,3 @@ +class Plus1_Float_Double { + op = (x) -> x+1.0; + } \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/Tester.java b/test/plugindevelopment/MartinTestCases/Tester.java index 92aea9e30..98769837c 100644 --- a/test/plugindevelopment/MartinTestCases/Tester.java +++ b/test/plugindevelopment/MartinTestCases/Tester.java @@ -52,11 +52,15 @@ public class Tester extends TypeInsertTester{ @Test public void runTests(){ Vector testFiles = new Vector(); + //testFiles.add("OL3.jav"); + testFiles.add("Plus1_Float_Double.jav"); + /* testFiles.add("AchimTest1.jav"); testFiles.add("MatrixWhile.jav"); //testFiles.add("BoundedType1.jav"); testFiles.add("BoundedType2.jav"); testFiles.add("BoundedType.jav"); + testFiles.add("OL2.jav"); testFiles.add("OL.jav"); testFiles.add("Simple.jav"); diff --git a/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Fehler Report b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Fehler Report new file mode 100644 index 000000000..246508723 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Fehler Report @@ -0,0 +1,37 @@ +Allgemeine Probleme: + +- Argument von lambda-Aussdrücken hat falsche Typvar: Könnte das darin liegen, + dass die Typvar auch in der abstrakten Syntax gelöscht wird? + +- unnötige constraints entfernen + +- Textmarker werden, beim speichern nicht gelöscht, es wird einfach der neue + Text hinzugefügt + +Dateien: + +- Id.jav: funktioniert + +- Matrix_lambda.jav: es bleiben TPH im Typ stehen. + TPH IM müsste irgend Supertyp von Matrix (this) sein. + +- MethodId.jav: funktioniert; + +- MethodIntegerUse.jav: funktioniert; + +- MethodUse.jav: funktioniert; + +- OL.jav: + * java.lang.Float funktioniert als Return-Typ nicht: Parseerror + * wenn man beim ersten m einen Typ auswählt wird der vom zweiten m eingetragen + warum? + In der zweiten Klasse kann man nach dem eintragen nichts mehr auswählen + * Wenn man in der zweiten Klassen einen Typ auswählt kann man in der ersten + nichts mehr auswählen. Was wird eigetragen? + +- Plus1_Float_Double.jav: Syntax-Error und Nullpointer-Exception + +- Plus1.jav: funktioniert; Frage: gibt es keinen anderen Typ mit +1? + + + diff --git a/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Id.jav b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Id.jav new file mode 100644 index 000000000..d2293b4b8 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Id.jav @@ -0,0 +1,3 @@ +class Id { + Fun1 op = (x) -> x; + } \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MatrixVectorMul.jav b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MatrixVectorMul.jav new file mode 100644 index 000000000..5aa6ee451 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MatrixVectorMul.jav @@ -0,0 +1,14 @@ +import java.util.Vector; + +class Matrix extends Vector> { + + mvmul(Vector v) { + i; + ele; + v.add(1); + while (i < v.size()) { + + ele = 5 + v.elementAt(i); + } + } +} diff --git a/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Matrix_lambda.jav b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Matrix_lambda.jav new file mode 100644 index 000000000..f9d2f4e06 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Matrix_lambda.jav @@ -0,0 +1,5 @@ +import java.util.Vector; + +class Matrix extends Vector> { + Fun1>, Matrix> op = (Matrix m) -> (f) -> f.apply(this, m); +} \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MethodId.jav b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MethodId.jav new file mode 100644 index 000000000..f8f44dec3 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MethodId.jav @@ -0,0 +1,6 @@ +class MethodId { + + US m (UR x) { + return x; + } + } \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MethodIntegerUse.jav b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MethodIntegerUse.jav new file mode 100644 index 000000000..11f2c06bc --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MethodIntegerUse.jav @@ -0,0 +1,8 @@ +class MethodIntegerUse { + Fun1 op = (x) -> m(x); + + + Integer m (Integer x) { + return x; + } + } \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MethodUse.jav b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MethodUse.jav new file mode 100644 index 000000000..1349b7ff7 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/MethodUse.jav @@ -0,0 +1,8 @@ +class MethodUse { + Fun1 op = (x) -> m(x); + + + AP m (AO x) { + return x; + } + } \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/OL.jav b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/OL.jav new file mode 100644 index 000000000..65b5f88f3 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/OL.jav @@ -0,0 +1,19 @@ + +class OL { + + java.lang.Float m(java.lang.Float x) { return x + x; } + + java.lang.Boolean m(java.lang.Boolean x) {return x || x; } +} + + + +class Main { + + main(x) { + ol; + ol = new OL(); + return ol.m(x); + } + +} diff --git a/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Plus1.jav b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Plus1.jav new file mode 100644 index 000000000..6b0ca749a --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Plus1.jav @@ -0,0 +1,3 @@ +class Plus1 { + Fun1 op = (x) -> x+1; + } \ No newline at end of file diff --git a/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Plus1_Float_Double.jav b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Plus1_Float_Double.jav new file mode 100644 index 000000000..75c3baad7 --- /dev/null +++ b/test/plugindevelopment/MartinTestCases/jav/Lambda_usecases/Plus1_Float_Double.jav @@ -0,0 +1,3 @@ +class Plus1_Float_Double { + op = (x) -> x+1.0; + } \ No newline at end of file