From 82d8ecba74c00dd90584c7b674c2013fb744b35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Wed, 20 Feb 2019 17:50:06 +0100 Subject: [PATCH] BigRefacoring branch hard rueberkopiert --- src/main/java/de/dhbwstuttgart/.DS_Store | Bin 6148 -> 0 bytes .../bytecode/BytecodeGenMethod.java | 4 +- .../de/dhbwstuttgart/core/JavaTXCompiler.java | 49 +- .../syntaxtree/factory/UnifyTypeFactory.java | 90 ++- .../constraints/ConstraintSet.java | 26 + .../typeinference/typeAlgo/TYPEStmt.java | 8 + .../typeinference/unify/Match.java | 2 + .../typeinference/unify/RuleSet.java | 22 +- .../typeinference/unify/TypeUnify.java | 24 +- .../typeinference/unify/TypeUnify2Task.java | 3 +- .../typeinference/unify/TypeUnifyTask.java | 631 ++++++++++++++---- .../unify/interfaces/IFiniteClosure.java | 1 + .../unify/model/FiniteClosure.java | 94 ++- .../unify/model/OrderingUnifyPair.java | 49 +- .../unify/model/PlaceholderType.java | 32 +- .../typeinference/unify/model/UnifyPair.java | 19 +- .../typeinference/unify/model/UnifyType.java | 2 +- .../unify/model/WildcardType.java | 2 +- src/test/java/asp/gencay/GeneratorTest.java | 2 - src/test/java/bytecode/MatrixTest.java | 0 src/test/java/bytecode/YTest.java | 4 +- src/test/java/javFiles/AddLong.jav | 9 - src/test/java/javFiles/EmptyClass.jav | 3 - src/test/java/javFiles/EmptyMethod.jav | 37 - src/test/java/javFiles/Expressions.jav | 8 - src/test/java/javFiles/FC_Matrix.jav | 10 - src/test/java/javFiles/Faculty.jav | 15 - src/test/java/javFiles/FacultyIf.jav | 17 - src/test/java/javFiles/FacultyTyped.jav | 19 - src/test/java/javFiles/Fields.jav | 11 - src/test/java/javFiles/Generics.jav | 22 - src/test/java/javFiles/IfTest.jav | 14 - src/test/java/javFiles/Import.jav | 8 - src/test/java/javFiles/Lambda.jav | 13 - src/test/java/javFiles/Lambda2.jav | 33 - src/test/java/javFiles/Lambda3.jav | 24 - src/test/java/javFiles/LambdaField.jav | 6 - src/test/java/javFiles/LambdaRunnable.jav | 14 - src/test/java/javFiles/ListenerOverload.jav | 20 - src/test/java/javFiles/Matrix.jav | 28 - src/test/java/javFiles/Meth_Gen.jav | 11 - src/test/java/javFiles/MethodCallGenerics.jav | 14 - src/test/java/javFiles/Methods.jav | 17 - src/test/java/javFiles/MethodsEasy.jav | 7 - src/test/java/javFiles/Op1.jav | 11 - src/test/java/javFiles/Package.jav | 5 - src/test/java/javFiles/Sorting.jav | 8 - src/test/java/javFiles/Subclass.jav | 6 - src/test/java/javFiles/Superclass.jav | 6 - src/test/java/javFiles/Vector.jav | 23 - src/test/java/javFiles/fc.jav | 18 - src/test/java/javFiles/mathStruc.jav | 13 - src/test/java/javFiles/test.jav | 15 - src/test/java/javFiles/test1.jav | 7 - .../resources/bytecode/LambdaCapturetest.java | 43 -- src/test/resources/bytecode/javFiles/Id.jav | 4 +- .../resources/bytecode/javFiles/Matrix.jav | 8 +- .../resources/bytecode/javFiles/Merge.jav | 4 +- src/test/resources/bytecode/javFiles/OL.jav | 4 +- .../bytecode/simplifyalgo/CycleTest.java | 76 --- .../bytecode/simplifyalgo/SameLeftSide.java | 97 --- .../bytecode/simplifyalgo/SimpleCycle.java | 79 --- src/test/resources/javFiles/Faculty.jav | 2 +- .../javFiles/bytecode/AssignToLit.jav | 30 - .../javFiles/bytecode/BinaryInMeth.jav | 17 - .../resources/javFiles/bytecode/DuMethod.jav | 11 - .../javFiles/bytecode/EmptyMethod.jav | 8 - .../resources/javFiles/bytecode/Example.jav | 9 - .../javFiles/bytecode/Exceptions.jav | 3 - src/test/resources/javFiles/bytecode/Fac.jav | 15 - .../resources/javFiles/bytecode/Faculty.jav | 48 -- .../resources/javFiles/bytecode/Faculty2.jav | 10 - .../resources/javFiles/bytecode/Field.jav | 9 - src/test/resources/javFiles/bytecode/For.jav | 30 - .../resources/javFiles/bytecode/FunOL.jav | 12 - src/test/resources/javFiles/bytecode/Gen.jav | 8 - .../resources/javFiles/bytecode/Generics.jav | 17 - .../resources/javFiles/bytecode/Generics2.jav | 6 - .../javFiles/bytecode/GreaterEqual.jav | 57 -- .../javFiles/bytecode/GreaterThan.jav | 56 -- .../resources/javFiles/bytecode/IfTest.jav | 15 - .../resources/javFiles/bytecode/Import.jav | 8 - .../javFiles/bytecode/Interface1.jav | 3 - .../javFiles/bytecode/LamRunnable.jav | 9 - .../resources/javFiles/bytecode/Lambda.jav | 10 - .../resources/javFiles/bytecode/Lambda2.jav | 35 - .../resources/javFiles/bytecode/Lambda3.jav | 23 - .../resources/javFiles/bytecode/Lambda4.jav | 18 - .../javFiles/bytecode/LambdaCapture.jav | 12 - .../javFiles/bytecode/LambdaVoid.jav | 9 - .../resources/javFiles/bytecode/LessEqual.jav | 56 -- .../resources/javFiles/bytecode/LessThan.jav | 57 -- .../resources/javFiles/bytecode/Matrix.jav | 44 -- .../resources/javFiles/bytecode/MatrixOP.jav | 43 -- .../resources/javFiles/bytecode/Merge.jav | 20 - .../resources/javFiles/bytecode/Methods.jav | 14 - src/test/resources/javFiles/bytecode/OL.jav | 22 - src/test/resources/javFiles/bytecode/Op.jav | 16 - src/test/resources/javFiles/bytecode/Op2.jav | 11 - .../javFiles/bytecode/OverlaodGen.jav | 11 - .../javFiles/bytecode/Overloading.jav | 18 - src/test/resources/javFiles/bytecode/Plus.jav | 9 - .../javFiles/bytecode/PostIncDec.jav | 27 - .../resources/javFiles/bytecode/PreInc.jav | 28 - .../javFiles/bytecode/RecursiveMeth.jav | 5 - .../resources/javFiles/bytecode/RelOps.jav | 8 - .../javFiles/bytecode/ReturnMethod.jav | 6 - .../resources/javFiles/bytecode/Sorting.jav | 23 - .../resources/javFiles/bytecode/StaticM.jav | 10 - .../resources/javFiles/bytecode/SubMatrix.jav | 13 - src/test/resources/javFiles/bytecode/Tph.jav | 12 - src/test/resources/javFiles/bytecode/Tph2.jav | 10 - src/test/resources/javFiles/bytecode/Tph3.jav | 13 - src/test/resources/javFiles/bytecode/Tph4.jav | 12 - src/test/resources/javFiles/bytecode/Tph5.jav | 13 - .../resources/javFiles/bytecode/VectorAdd.jav | 19 - .../resources/javFiles/bytecode/VoidMeth.jav | 4 - src/test/resources/javFiles/bytecode/WC.jav | 8 - .../resources/javFiles/bytecode/While.jav | 12 - src/test/resources/javFiles/bytecode/Y.jav | 28 - .../javFiles/bytecode/applyLambda.jav | 16 - .../resources/javFiles/parser/AntlrTest.jav | 6 - .../javFiles/parser/BoundedParameter.jav | 3 - .../resources/javFiles/parser/CastTest.jav | 8 - .../resources/javFiles/parser/ExtendsTest.jav | 4 - .../javFiles/parser/FeatherWeightJava.jav | 11 - .../parser/FieldInitializationTest.jav | 3 - .../javFiles/parser/FieldVarTest.jav | 5 - .../javFiles/parser/GenericFieldVarTest.jav | 3 - .../resources/javFiles/parser/ImportTest.jav | 4 - .../resources/javFiles/parser/ImportTest2.jav | 4 - .../javFiles/parser/ImportTestGeneric.jav | 5 - .../resources/javFiles/parser/NewTest.jav | 5 - .../resources/javFiles/parser/OpratorTest.jav | 12 - .../javFiles/parser/PackageNameTest.jav | 9 - .../javFiles/parser/StatementsTest.jav | 8 - .../javFiles/parser/StructuralTypes.jav | 5 - .../resources/javFiles/parser/WhileTest.jav | 14 - src/test/resources/testBytecode/Field.java | 6 - src/test/resources/testBytecode/Import.java | 8 - src/test/resources/testBytecode/Lam1.java | 10 - src/test/resources/testBytecode/LamRun.java | 8 - .../resources/testBytecode/MethFieldVar.java | 38 -- src/test/resources/testBytecode/Subclass.java | 6 - .../resources/testBytecode/SuperTest.java | 14 - .../resources/testBytecode/Superclass.java | 6 - .../resources/testBytecode/TestMyTest.java | 11 - src/test/resources/testBytecode/testF.java | 5 - src/test/resources/testBytecode/testTets.java | 5 - .../resources/testBytecode/testTetsF.java | 5 - 150 files changed, 845 insertions(+), 2315 deletions(-) delete mode 100644 src/main/java/de/dhbwstuttgart/.DS_Store mode change 100644 => 100755 src/test/java/bytecode/MatrixTest.java delete mode 100644 src/test/java/javFiles/AddLong.jav delete mode 100644 src/test/java/javFiles/EmptyClass.jav delete mode 100644 src/test/java/javFiles/EmptyMethod.jav delete mode 100644 src/test/java/javFiles/Expressions.jav delete mode 100644 src/test/java/javFiles/FC_Matrix.jav delete mode 100644 src/test/java/javFiles/Faculty.jav delete mode 100644 src/test/java/javFiles/FacultyIf.jav delete mode 100644 src/test/java/javFiles/FacultyTyped.jav delete mode 100644 src/test/java/javFiles/Fields.jav delete mode 100644 src/test/java/javFiles/Generics.jav delete mode 100644 src/test/java/javFiles/IfTest.jav delete mode 100644 src/test/java/javFiles/Import.jav delete mode 100644 src/test/java/javFiles/Lambda.jav delete mode 100644 src/test/java/javFiles/Lambda2.jav delete mode 100644 src/test/java/javFiles/Lambda3.jav delete mode 100644 src/test/java/javFiles/LambdaField.jav delete mode 100644 src/test/java/javFiles/LambdaRunnable.jav delete mode 100644 src/test/java/javFiles/ListenerOverload.jav delete mode 100644 src/test/java/javFiles/Matrix.jav delete mode 100644 src/test/java/javFiles/Meth_Gen.jav delete mode 100644 src/test/java/javFiles/MethodCallGenerics.jav delete mode 100644 src/test/java/javFiles/Methods.jav delete mode 100644 src/test/java/javFiles/MethodsEasy.jav delete mode 100644 src/test/java/javFiles/Op1.jav delete mode 100644 src/test/java/javFiles/Package.jav delete mode 100644 src/test/java/javFiles/Sorting.jav delete mode 100644 src/test/java/javFiles/Subclass.jav delete mode 100644 src/test/java/javFiles/Superclass.jav delete mode 100644 src/test/java/javFiles/Vector.jav delete mode 100644 src/test/java/javFiles/fc.jav delete mode 100644 src/test/java/javFiles/mathStruc.jav delete mode 100644 src/test/java/javFiles/test.jav delete mode 100644 src/test/java/javFiles/test1.jav delete mode 100644 src/test/resources/bytecode/LambdaCapturetest.java delete mode 100644 src/test/resources/bytecode/simplifyalgo/CycleTest.java delete mode 100644 src/test/resources/bytecode/simplifyalgo/SameLeftSide.java delete mode 100644 src/test/resources/bytecode/simplifyalgo/SimpleCycle.java delete mode 100644 src/test/resources/javFiles/bytecode/AssignToLit.jav delete mode 100644 src/test/resources/javFiles/bytecode/BinaryInMeth.jav delete mode 100644 src/test/resources/javFiles/bytecode/DuMethod.jav delete mode 100644 src/test/resources/javFiles/bytecode/EmptyMethod.jav delete mode 100644 src/test/resources/javFiles/bytecode/Example.jav delete mode 100644 src/test/resources/javFiles/bytecode/Exceptions.jav delete mode 100644 src/test/resources/javFiles/bytecode/Fac.jav delete mode 100644 src/test/resources/javFiles/bytecode/Faculty.jav delete mode 100644 src/test/resources/javFiles/bytecode/Faculty2.jav delete mode 100644 src/test/resources/javFiles/bytecode/Field.jav delete mode 100644 src/test/resources/javFiles/bytecode/For.jav delete mode 100644 src/test/resources/javFiles/bytecode/FunOL.jav delete mode 100644 src/test/resources/javFiles/bytecode/Gen.jav delete mode 100644 src/test/resources/javFiles/bytecode/Generics.jav delete mode 100644 src/test/resources/javFiles/bytecode/Generics2.jav delete mode 100644 src/test/resources/javFiles/bytecode/GreaterEqual.jav delete mode 100644 src/test/resources/javFiles/bytecode/GreaterThan.jav delete mode 100644 src/test/resources/javFiles/bytecode/IfTest.jav delete mode 100644 src/test/resources/javFiles/bytecode/Import.jav delete mode 100644 src/test/resources/javFiles/bytecode/Interface1.jav delete mode 100644 src/test/resources/javFiles/bytecode/LamRunnable.jav delete mode 100644 src/test/resources/javFiles/bytecode/Lambda.jav delete mode 100644 src/test/resources/javFiles/bytecode/Lambda2.jav delete mode 100644 src/test/resources/javFiles/bytecode/Lambda3.jav delete mode 100644 src/test/resources/javFiles/bytecode/Lambda4.jav delete mode 100644 src/test/resources/javFiles/bytecode/LambdaCapture.jav delete mode 100644 src/test/resources/javFiles/bytecode/LambdaVoid.jav delete mode 100644 src/test/resources/javFiles/bytecode/LessEqual.jav delete mode 100644 src/test/resources/javFiles/bytecode/LessThan.jav delete mode 100644 src/test/resources/javFiles/bytecode/Matrix.jav delete mode 100644 src/test/resources/javFiles/bytecode/MatrixOP.jav delete mode 100644 src/test/resources/javFiles/bytecode/Merge.jav delete mode 100644 src/test/resources/javFiles/bytecode/Methods.jav delete mode 100644 src/test/resources/javFiles/bytecode/OL.jav delete mode 100644 src/test/resources/javFiles/bytecode/Op.jav delete mode 100644 src/test/resources/javFiles/bytecode/Op2.jav delete mode 100644 src/test/resources/javFiles/bytecode/OverlaodGen.jav delete mode 100644 src/test/resources/javFiles/bytecode/Overloading.jav delete mode 100644 src/test/resources/javFiles/bytecode/Plus.jav delete mode 100644 src/test/resources/javFiles/bytecode/PostIncDec.jav delete mode 100644 src/test/resources/javFiles/bytecode/PreInc.jav delete mode 100644 src/test/resources/javFiles/bytecode/RecursiveMeth.jav delete mode 100644 src/test/resources/javFiles/bytecode/RelOps.jav delete mode 100644 src/test/resources/javFiles/bytecode/ReturnMethod.jav delete mode 100644 src/test/resources/javFiles/bytecode/Sorting.jav delete mode 100644 src/test/resources/javFiles/bytecode/StaticM.jav delete mode 100644 src/test/resources/javFiles/bytecode/SubMatrix.jav delete mode 100644 src/test/resources/javFiles/bytecode/Tph.jav delete mode 100644 src/test/resources/javFiles/bytecode/Tph2.jav delete mode 100644 src/test/resources/javFiles/bytecode/Tph3.jav delete mode 100644 src/test/resources/javFiles/bytecode/Tph4.jav delete mode 100644 src/test/resources/javFiles/bytecode/Tph5.jav delete mode 100644 src/test/resources/javFiles/bytecode/VectorAdd.jav delete mode 100644 src/test/resources/javFiles/bytecode/VoidMeth.jav delete mode 100644 src/test/resources/javFiles/bytecode/WC.jav delete mode 100644 src/test/resources/javFiles/bytecode/While.jav delete mode 100644 src/test/resources/javFiles/bytecode/Y.jav delete mode 100644 src/test/resources/javFiles/bytecode/applyLambda.jav delete mode 100644 src/test/resources/javFiles/parser/AntlrTest.jav delete mode 100644 src/test/resources/javFiles/parser/BoundedParameter.jav delete mode 100644 src/test/resources/javFiles/parser/CastTest.jav delete mode 100644 src/test/resources/javFiles/parser/ExtendsTest.jav delete mode 100644 src/test/resources/javFiles/parser/FeatherWeightJava.jav delete mode 100644 src/test/resources/javFiles/parser/FieldInitializationTest.jav delete mode 100644 src/test/resources/javFiles/parser/FieldVarTest.jav delete mode 100644 src/test/resources/javFiles/parser/GenericFieldVarTest.jav delete mode 100644 src/test/resources/javFiles/parser/ImportTest.jav delete mode 100644 src/test/resources/javFiles/parser/ImportTest2.jav delete mode 100644 src/test/resources/javFiles/parser/ImportTestGeneric.jav delete mode 100644 src/test/resources/javFiles/parser/NewTest.jav delete mode 100644 src/test/resources/javFiles/parser/OpratorTest.jav delete mode 100644 src/test/resources/javFiles/parser/PackageNameTest.jav delete mode 100644 src/test/resources/javFiles/parser/StatementsTest.jav delete mode 100644 src/test/resources/javFiles/parser/StructuralTypes.jav delete mode 100644 src/test/resources/javFiles/parser/WhileTest.jav delete mode 100644 src/test/resources/testBytecode/Field.java delete mode 100644 src/test/resources/testBytecode/Import.java delete mode 100644 src/test/resources/testBytecode/Lam1.java delete mode 100644 src/test/resources/testBytecode/LamRun.java delete mode 100644 src/test/resources/testBytecode/MethFieldVar.java delete mode 100644 src/test/resources/testBytecode/Subclass.java delete mode 100644 src/test/resources/testBytecode/SuperTest.java delete mode 100644 src/test/resources/testBytecode/Superclass.java delete mode 100644 src/test/resources/testBytecode/TestMyTest.java delete mode 100644 src/test/resources/testBytecode/testF.java delete mode 100644 src/test/resources/testBytecode/testTets.java delete mode 100644 src/test/resources/testBytecode/testTetsF.java diff --git a/src/main/java/de/dhbwstuttgart/.DS_Store b/src/main/java/de/dhbwstuttgart/.DS_Store deleted file mode 100644 index aa8a1074b6c8b435c3b9b58fbf5afc60d45b908c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}T>S5T317w-vDmL65n3>!GEhCm~clcoQOeP_ao9G!V1Wq!z7}JchoJZ{X`V zv%3`~dK0lS1GC>`em2=JVK)N+qB{)R01W_;sDzao4qphxNlQ|(o;gIJ=jeli5Tam| z-ITJ~@fR7OcPAl$JIEn|5AQEXRDiLU;3kQ)yw!RYmAUHt!lIOQSzoT7dsk}Y<$gZQ zy8hslt`7bDDzNsEQpvmR2gh+Vx@fHKsx?BS@HR`Hi8fJPP&jh5b z$=XF@Z9ML@noei4J!v}Q?QOI-J6n@UO|EUUcMf{jclYCm$>WnDSKxQ3WyRtYp3x|+ zGtBx)fKN(ArQoeMNE4M_Vr)9;bTUR}fEi#0W}E@Lt;wYsUk5)vGr$b|JOi{pIH-iK z#loQ8I&jb}0Ady0TF|Cmf@&O#uEoM2Mo@$)MKqcqu;T4uEoNjDF sourceFiles = new HashMap<>(); - Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"/test/logFiles/log" geschrieben werden soll? + Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll? public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException { this(Arrays.asList(sourceFile)); @@ -109,7 +113,8 @@ public class JavaTXCompiler { return new ArrayList<>(allClasses); } - public List typeInference() throws ClassNotFoundException { +/* + public List typeInferenceOld() throws ClassNotFoundException { List allClasses = new ArrayList<>();//environment.getAllAvailableClasses(); //Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC for(SourceFile sf : this.sourceFiles.values()) { @@ -193,10 +198,7 @@ public class JavaTXCompiler { } } return x;//HIER DIE JEWEILS RECHT BZW. LINKE SEITE AUF GLEICHE VARIANZ SETZEN WIE DIE JEWEILS ANDERE SEITE - }) - /* PL 2018-11-07 wird in varianceInheritance erledigt - .map( y -> { - + }).map( y -> { if ((y.getLhsType() instanceof PlaceholderType) && (y.getRhsType() instanceof PlaceholderType)) { if (((PlaceholderType)y.getLhsType()).getVariance() != 0 && ((PlaceholderType)y.getRhsType()).getVariance() == 0) { ((PlaceholderType)y.getRhsType()).setVariance(((PlaceholderType)y.getLhsType()).getVariance()); @@ -206,20 +208,16 @@ public class JavaTXCompiler { } } return y; } ) - */ .collect(Collectors.toCollection(HashSet::new)); - varianceInheritance(xConsSet); - - - - Set> result = unify.unifySequential(xConsSet, finiteClosure, logFile, log); - //Set> result = unify.unify(xConsSet, finiteClosure); - System.out.println("RESULT: " + result); - logFile.write("RES: " + result.toString()+"\n"); - logFile.flush(); - results.addAll(result); + varianceInheritance(xConsSet); + Set> result = unify.unifySequential(xConsSet, finiteClosure, logFile, log); + //Set> result = unify.unify(xConsSet, finiteClosure); + System.out.println("RESULT: " + result); + logFile.write("RES: " + result.toString()+"\n"); + logFile.flush(); + results.addAll(result); } - + results = results.stream().map(x -> { Optional> res = new RuleSet().subst(x.stream().map(y -> { if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT); @@ -242,12 +240,14 @@ public class JavaTXCompiler { return results.stream().map((unifyPairs -> new ResultSet(UnifyTypeFactory.convert(unifyPairs, generateTPHMap(cons))))).collect(Collectors.toList()); } - + */ /** - * Vererbt alle Variancen + * Vererbt alle Variancen bei Paaren (a <. theta) oder (Theta <. a) + * wenn a eine Variance !=0 hat auf alle Typvariablen in Theta. * @param eq The set of constraints */ - private void varianceInheritance(Set eq) { + /* + private void varianceInheritance(Set eq) { Set usedTPH = new HashSet<>(); Set phSet = eq.stream().map(x -> { Set pair = new HashSet<>(); @@ -273,8 +273,6 @@ public class JavaTXCompiler { phSetVariance.removeIf(x -> (x.getVariance() == 0 || usedTPH.contains(x))); } } -<<<<<<< HEAD -======= */ public UnifyResultModel typeInferenceAsync() throws ClassNotFoundException { @@ -289,7 +287,7 @@ public class JavaTXCompiler { Set> results = new HashSet<>(); UnifyResultModel urm = null; try { - FileWriter logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName())); + Writer logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName())); IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses,logFile); System.out.println(finiteClosure); @@ -425,7 +423,7 @@ public class JavaTXCompiler { final ConstraintSet cons = getConstraints(); Set> results = new HashSet<>(); try { - FileWriter logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName())); + Writer logFile = new FileWriter(new File(System.getProperty("user.dir")+"/src/test/java/logFiles/"+"log_"+sourceFiles.keySet().iterator().next().getName())); IFiniteClosure finiteClosure = UnifyTypeFactory.generateFC(allClasses,logFile); System.out.println(finiteClosure); @@ -630,7 +628,6 @@ public class JavaTXCompiler { return usedTPH; } ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java index 71985334..a764db6e 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java @@ -1,5 +1,7 @@ package de.dhbwstuttgart.syntaxtree.factory; +import java.io.FileWriter; +import java.io.Writer; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -29,7 +31,7 @@ public class UnifyTypeFactory { private static ArrayList PLACEHOLDERS = new ArrayList<>(); - public static FiniteClosure generateFC(List fromClasses) throws ClassNotFoundException { + public static FiniteClosure generateFC(List fromClasses, Writer logFile) throws ClassNotFoundException { /* Die transitive Hülle muss funktionieren. Man darf schreiben List extends AL @@ -40,7 +42,7 @@ public class UnifyTypeFactory { Generell dürfen sie immer die gleichen Namen haben. TODO: die transitive Hülle bilden */ - return new FiniteClosure(FCGenerator.toUnifyFC(fromClasses)); + return new FiniteClosure(FCGenerator.toUnifyFC(fromClasses), logFile); } public static UnifyPair generateSmallerPair(UnifyType tl, UnifyType tr){ @@ -63,26 +65,26 @@ public class UnifyTypeFactory { * Convert from * ASTType -> UnifyType */ - public static UnifyType convert(RefTypeOrTPHOrWildcardOrGeneric t){ + public static UnifyType convert(RefTypeOrTPHOrWildcardOrGeneric t, Boolean innerType){ if(t instanceof GenericRefType){ - return UnifyTypeFactory.convert((GenericRefType)t); + return UnifyTypeFactory.convert((GenericRefType)t, innerType); }else if(t instanceof FunN){ - return UnifyTypeFactory.convert((FunN)t); + return UnifyTypeFactory.convert((FunN)t, innerType); }else if(t instanceof TypePlaceholder){ - return UnifyTypeFactory.convert((TypePlaceholder)t); + return UnifyTypeFactory.convert((TypePlaceholder)t, innerType); }else if(t instanceof ExtendsWildcardType){ - return UnifyTypeFactory.convert((ExtendsWildcardType)t); + return UnifyTypeFactory.convert((ExtendsWildcardType)t, innerType); }else if(t instanceof SuperWildcardType){ - return UnifyTypeFactory.convert((SuperWildcardType)t); + return UnifyTypeFactory.convert((SuperWildcardType)t, innerType); }else if(t instanceof RefType){ - return UnifyTypeFactory.convert((RefType)t); + return UnifyTypeFactory.convert((RefType)t, innerType); } //Es wurde versucht ein Typ umzuwandeln, welcher noch nicht von der Factory abgedeckt ist throw new NotImplementedException("Der Typ "+t+" kann nicht umgewandelt werden"); } - public static UnifyType convert(RefType t){ + public static UnifyType convert(RefType t, Boolean innerType){ //Check if it is a FunN Type: Pattern p = Pattern.compile("Fun(\\d+)"); Matcher m = p.matcher(t.getName().toString()); @@ -90,14 +92,14 @@ public class UnifyTypeFactory { if(b){ Integer N = Integer.valueOf(m.group(1)); if((N + 1) == t.getParaList().size()){ - return convert(new FunN(t.getParaList())); + return convert(new FunN(t.getParaList()), false); } } UnifyType ret; if(t.getParaList() != null && t.getParaList().size() > 0){ List params = new ArrayList<>(); for(RefTypeOrTPHOrWildcardOrGeneric pT : t.getParaList()){ - params.add(UnifyTypeFactory.convert(pT)); + params.add(UnifyTypeFactory.convert(pT, true)); } ret = new ReferenceType(t.getName().toString(),new TypeParams(params)); }else{ @@ -106,39 +108,45 @@ public class UnifyTypeFactory { return ret; } - public static UnifyType convert(FunN t){ + public static UnifyType convert(FunN t, Boolean innerType){ UnifyType ret; List params = new ArrayList<>(); if(t.getParaList() != null && t.getParaList().size() > 0){ for(RefTypeOrTPHOrWildcardOrGeneric pT : t.getParaList()){ - params.add(UnifyTypeFactory.convert(pT)); + params.add(UnifyTypeFactory.convert(pT, false)); } } ret = FunNType.getFunNType(new TypeParams(params)); return ret; } - public static UnifyType convert(TypePlaceholder tph){ + public static UnifyType convert(TypePlaceholder tph, Boolean innerType){ + if (tph.getName().equals("AFR")) { + System.out.println("XXX"+innerType); + } PlaceholderType ntph = new PlaceholderType(tph.getName()); int in = PLACEHOLDERS.indexOf(ntph); if (in == -1) { PLACEHOLDERS.add(ntph); + ntph.setInnerType(innerType); return ntph; } else { - return PLACEHOLDERS.get(in); + PlaceholderType oldpht = PLACEHOLDERS.get(in); + oldpht.setInnerType(oldpht.isInnerType() || innerType); + return oldpht; } } - public static UnifyType convert(GenericRefType t){ + public static UnifyType convert(GenericRefType t, Boolean innerType){ return new ReferenceType(t.getParsedName()); } - public static UnifyType convert(WildcardType t){ + public static UnifyType convert(WildcardType t, Boolean innerType){ if(t.isExtends()) - return new ExtendsType(UnifyTypeFactory.convert(t.getInnerType())); + return new ExtendsType(UnifyTypeFactory.convert(t.getInnerType(), false)); else if(t.isSuper()) - return new SuperType(UnifyTypeFactory.convert(t.getInnerType())); + return new SuperType(UnifyTypeFactory.convert(t.getInnerType(), false)); else throw new NotImplementedException(); } @@ -152,22 +160,42 @@ public class UnifyTypeFactory { } public static UnifyPair convert(Pair p) { + UnifyPair ret = null; if(p.GetOperator().equals(PairOperator.SMALLERDOT)) { - UnifyPair ret = generateSmallerDotPair(UnifyTypeFactory.convert(p.TA1) - , UnifyTypeFactory.convert(p.TA2)); - return ret; + ret = generateSmallerDotPair(UnifyTypeFactory.convert(p.TA1, false) + , UnifyTypeFactory.convert(p.TA2, false)); + //return ret; }else if(p.GetOperator().equals(PairOperator.SMALLERNEQDOT)) { - UnifyPair ret = generateSmallNotEqualDotPair(UnifyTypeFactory.convert(p.TA1) - , UnifyTypeFactory.convert(p.TA2)); - return ret; + ret = generateSmallNotEqualDotPair(UnifyTypeFactory.convert(p.TA1, false) + , UnifyTypeFactory.convert(p.TA2, false)); + //return ret; }else if(p.GetOperator().equals(PairOperator.EQUALSDOT)) { - UnifyPair ret = generateEqualDotPair(UnifyTypeFactory.convert(p.TA1) - , UnifyTypeFactory.convert(p.TA2)); - return ret; + ret = generateEqualDotPair(UnifyTypeFactory.convert(p.TA1, false) + , UnifyTypeFactory.convert(p.TA2, false)); + //return ret; }else if(p.GetOperator().equals(PairOperator.SMALLER)){ - return generateSmallerPair(UnifyTypeFactory.convert(p.TA1), - UnifyTypeFactory.convert(p.TA2)); + ret = generateSmallerPair(UnifyTypeFactory.convert(p.TA1, false), + UnifyTypeFactory.convert(p.TA2, false)); }else throw new NotImplementedException(); + UnifyType lhs, rhs; + if (((lhs = ret.getLhsType()) instanceof PlaceholderType) + && ((PlaceholderType)lhs).isWildcardable() + && (rhs = ret.getLhsType()) instanceof PlaceholderType) { + if (lhs.getName().equals("AQ")) { + System.out.println(""); + } + ((PlaceholderType)rhs).enableWildcardtable(); + } + + if (((rhs = ret.getLhsType()) instanceof PlaceholderType) + && ((PlaceholderType)rhs).isWildcardable() + && (lhs = ret.getLhsType()) instanceof PlaceholderType) { + if (rhs.getName().equals("AQ")) { + System.out.println(""); + } + ((PlaceholderType)lhs).enableWildcardtable(); + } + return ret; } /** diff --git a/src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java b/src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java index 581f9fbd..1dda8dc5 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java @@ -6,6 +6,7 @@ import de.dhbwstuttgart.typeinference.unify.GuavaSetOperations; import de.dhbwstuttgart.typeinference.unify.model.UnifyPair; import java.util.*; +import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; @@ -53,4 +54,29 @@ public class ConstraintSet { ret.oderConstraints = newOder; return ret; } + + public void forEach (Consumer c) { + undConstraints.stream().forEach(c); + for(Set> oderConstraint : oderConstraints){ + oderConstraint.parallelStream().forEach((Constraint as) -> + as.stream().forEach(c)); + } + } + + public Set getAll () { + Set ret = new HashSet<>(); + ret.addAll(undConstraints); + for(Set> oderConstraint : oderConstraints){ + oderConstraint.parallelStream().forEach((Constraint as) -> ret.addAll(as)); + } + return ret; + } + + public List>> getOderConstraints() { + return oderConstraints; + } + + public Set getUndConstraints() { + return undConstraints; + } } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java index 2f705c67..4fd14fbc 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java @@ -1,3 +1,4 @@ +//PL 2018-12-19: Merge chekcen package de.dhbwstuttgart.typeinference.typeAlgo; import de.dhbwstuttgart.exceptions.NotImplementedException; @@ -228,6 +229,13 @@ public class TYPEStmt implements StatementVisitor{ binary.operation.equals(BinaryExpr.Operator.ADD)|| binary.operation.equals(BinaryExpr.Operator.SUB)){ Set> numericAdditionOrStringConcatenation = new HashSet<>(); + +// TODO PL 2018-11-06 + + // Auf importierte Typen einschraenken + // pruefen, ob Typen richtig bestimmt werden. + + //Zuerst der Fall für Numerische AusdrücPairOpnumericeratorke, das sind Mul, Mod und Div immer: //see: https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.17 diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/Match.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/Match.java index 78f7360f..3e995607 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/Match.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/Match.java @@ -22,6 +22,8 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyType; public class Match implements IMatch { @Override + //A =. A ==> True + //A =. A ==> False public Optional match(ArrayList termsList) { // Start with the identity unifier. Substitutions will be added later. diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java index acb6afbb..da8998d2 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java @@ -30,6 +30,7 @@ import de.dhbwstuttgart.typeinference.unify.distributeVariance; import java.io.FileWriter; import java.io.IOException; +import java.io.Writer; /** * Implementation of the type inference rules. @@ -38,13 +39,13 @@ import java.io.IOException; */ public class RuleSet implements IRuleSet{ - FileWriter logFile; + Writer logFile; public RuleSet() { super(); } - RuleSet(FileWriter logFile) { + RuleSet(Writer logFile) { this.logFile = logFile; } @@ -321,20 +322,21 @@ public class RuleSet implements IRuleSet{ UnifyType lhsType = pair.getLhsType(); ReferenceType lhsSType; + UnifyType rhsType = pair.getRhsType(); + ReferenceType rhsSType; - if(lhsType instanceof ReferenceType) + if ((lhsType instanceof ReferenceType) && (rhsType instanceof ReferenceType)) { lhsSType = (ReferenceType) lhsType; -<<<<<<< HEAD - else if(lhsType instanceof WildcardType) { -======= rhsSType = (ReferenceType) rhsType; } else if (((lhsType instanceof ExtendsType) && (rhsType instanceof ExtendsType)) || ((lhsType instanceof SuperType) && (rhsType instanceof SuperType))) { ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 UnifyType lhsSTypeRaw = ((WildcardType) lhsType).getWildcardedType(); - if(lhsSTypeRaw instanceof ReferenceType) + UnifyType rhsSTypeRaw = ((WildcardType) rhsType).getWildcardedType(); + if ((lhsSTypeRaw instanceof ReferenceType) && (rhsSTypeRaw instanceof ReferenceType)) { lhsSType = (ReferenceType) lhsSTypeRaw; + rhsSType = (ReferenceType) rhsSTypeRaw; + } else return Optional.empty(); } @@ -343,7 +345,8 @@ public class RuleSet implements IRuleSet{ if(lhsSType.getTypeParams().empty()) return Optional.empty(); - + + /* PL 2018-01-22 in obere Teil integriert UnifyType rhsType = pair.getRhsType(); ReferenceType rhsSType; @@ -358,6 +361,7 @@ public class RuleSet implements IRuleSet{ } else return Optional.empty(); + */ if(!rhsSType.getName().equals(lhsSType.getName())) return Optional.empty(); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java index c89803fd..2cea2184 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java @@ -1,24 +1,19 @@ package de.dhbwstuttgart.typeinference.unify; import java.io.FileWriter; +import java.io.Writer; +import java.util.List; import java.util.Set; import java.util.concurrent.ForkJoinPool; -<<<<<<< HEAD -======= import de.dhbwstuttgart.typeinference.constraints.Constraint; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.Pair; ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure; import de.dhbwstuttgart.typeinference.unify.model.FiniteClosure; import de.dhbwstuttgart.typeinference.unify.model.UnifyPair; public class TypeUnify { -<<<<<<< HEAD - public Set> unify(Set eq, IFiniteClosure fc, FileWriter logFile, Boolean log) { - TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, true, logFile, log); -======= /** * unify parallel ohne result modell @@ -30,17 +25,14 @@ public class TypeUnify { * @param cons * @return */ - public Set> unify(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, FileWriter logFile, Boolean log, UnifyResultModel ret) { + public Set> unify(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) { TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret); ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 ForkJoinPool pool = new ForkJoinPool(); pool.invoke(unifyTask); Set> res = unifyTask.join(); return res; } -<<<<<<< HEAD -======= /** * unify asynchron mit Rückgabe UnifyResultModel ohne dass alle results gesammelt sind * @param undConstrains @@ -52,7 +44,7 @@ public class TypeUnify { * @param ret * @return */ - public UnifyResultModel unifyAsync(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, FileWriter logFile, Boolean log, UnifyResultModel ret) { + public UnifyResultModel unifyAsync(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) { TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret); ForkJoinPool pool = new ForkJoinPool(); pool.invoke(unifyTask); @@ -70,7 +62,7 @@ public class TypeUnify { * @param ret * @return */ - public UnifyResultModel unifyParallel(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, FileWriter logFile, Boolean log, UnifyResultModel ret) { + public UnifyResultModel unifyParallel(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) { TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, true, logFile, log, 0, ret); ForkJoinPool pool = new ForkJoinPool(); pool.invoke(unifyTask); @@ -79,14 +71,11 @@ public class TypeUnify { } /* ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 public Set> unifySequential(Set eq, IFiniteClosure fc, FileWriter logFile, Boolean log) { TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, false, logFile, log); Set> res = unifyTask.compute(); return res; } -<<<<<<< HEAD -======= */ /** @@ -99,11 +88,10 @@ public class TypeUnify { * @param cons * @return */ - public Set> unifyOderConstraints(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, FileWriter logFile, Boolean log, UnifyResultModel ret) { + public Set> unifyOderConstraints(Set undConstrains, List>> oderConstraints, IFiniteClosure fc, Writer logFile, Boolean log, UnifyResultModel ret) { TypeUnifyTask unifyTask = new TypeUnifyTask(undConstrains, oderConstraints, fc, false, logFile, log, 0, ret); Set> res = unifyTask.compute(); return res; } ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java index 43b294ad..31247aef 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java @@ -2,6 +2,7 @@ package de.dhbwstuttgart.typeinference.unify; import java.io.FileWriter; import java.io.IOException; +import java.io.Writer; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -16,7 +17,7 @@ public class TypeUnify2Task extends TypeUnifyTask { Set> setToFlatten; - public TypeUnify2Task(Set> setToFlatten, Set eq, List>> oderConstraints, Set nextSetElement, IFiniteClosure fc, boolean parallel, FileWriter logFile, Boolean log, int rekTiefe, UnifyResultModel urm) { + public TypeUnify2Task(Set> setToFlatten, Set eq, List>> oderConstraints, Set nextSetElement, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm) { super(eq, oderConstraints, fc, parallel, logFile, log, rekTiefe, urm); this.setToFlatten = setToFlatten; this.nextSetElement = nextSetElement; diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index b4b671fa..1d383c66 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -1,3 +1,4 @@ +//PL 2018-12-19: Merge checken package de.dhbwstuttgart.typeinference.unify; import java.util.ArrayList; @@ -18,13 +19,10 @@ import java.util.function.BinaryOperator; import java.util.stream.Collectors; import java.util.stream.Stream; -<<<<<<< HEAD -======= import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory; import de.dhbwstuttgart.typeinference.constraints.Constraint; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.result.ResultSet; ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure; import de.dhbwstuttgart.typeinference.unify.interfaces.IRuleSet; import de.dhbwstuttgart.typeinference.unify.interfaces.ISetOperations; @@ -39,12 +37,14 @@ import de.dhbwstuttgart.typeinference.unify.model.TypeParams; import de.dhbwstuttgart.typeinference.unify.model.Unifier; import de.dhbwstuttgart.typeinference.unify.model.UnifyPair; import de.dhbwstuttgart.typeinference.unify.model.UnifyType; +import de.dhbwstuttgart.typeinference.unify.model.WildcardType; import de.dhbwstuttgart.typeinference.unify.model.OrderingUnifyPair; import de.dhbwstuttgart.typeinference.unify.model.Pair; import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.io.Writer; import com.google.common.collect.Ordering; @@ -60,8 +60,6 @@ public class TypeUnifyTask extends RecursiveTask>> { private boolean printtag = false; Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"/test/logFiles/log" geschrieben werden soll? -<<<<<<< HEAD -======= /** * Element, das aus dem nextSet den Gleichunen dieses Threads hinzugefuegt wurde */ @@ -77,9 +75,8 @@ public class TypeUnifyTask extends RecursiveTask>> { protected boolean one = false; Integer MaxNoOfThreads = 8; ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/"; - FileWriter logFile; + Writer logFile; /** * The implementation of setOps that will be used during the unification @@ -96,7 +93,9 @@ public class TypeUnifyTask extends RecursiveTask>> { */ protected IRuleSet rules; - protected Set eq; + protected Set eq; //und-constraints + + protected List>> oderConstraintsField; protected IFiniteClosure fc; @@ -104,18 +103,23 @@ public class TypeUnifyTask extends RecursiveTask>> { protected boolean parallel; + int rekTiefeField; + Integer nOfUnify = 0; Integer noUndefPair = 0; Integer noAllErasedElements = 0; + static Integer noou = 0; + static int noBacktracking; public TypeUnifyTask() { rules = new RuleSet(); } + /* public TypeUnifyTask(Set eq, IFiniteClosure fc, boolean parallel, FileWriter logFile, Boolean log) { this.eq = eq; this.fc = fc; @@ -124,11 +128,12 @@ public class TypeUnifyTask extends RecursiveTask>> { this.logFile = logFile; this.log = log; rules = new RuleSet(logFile); + noOfThread++; + thNo = noOfThread; } + */ -<<<<<<< HEAD -======= - public TypeUnifyTask(Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, FileWriter logFile, Boolean log, int rekTiefe, UnifyResultModel urm) { + public TypeUnifyTask(Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, Writer logFile, Boolean log, int rekTiefe, UnifyResultModel urm) { synchronized (this) { this.eq = eq; //this.oderConstraints = oderConstraints.stream().map(x -> x.stream().map(y -> new HashSet<>(y)).collect(Collectors.toSet(HashSet::new))).collect(Collectors.toList(ArrayList::new)); @@ -165,7 +170,6 @@ public class TypeUnifyTask extends RecursiveTask>> { this.urm = urm; } } ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 /** * Vererbt alle Variancen @@ -199,8 +203,6 @@ public class TypeUnifyTask extends RecursiveTask>> { } } */ -<<<<<<< HEAD -======= protected Set> compute() { if (one) { @@ -227,13 +229,264 @@ public class TypeUnifyTask extends RecursiveTask>> { else return res; } /* ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 @Override protected Set> compute() { - Set> res = unify(eq, fc, parallel); + Set> fstElems = new HashSet<>(); + fstElems.add(eq); + Set> res = computeCartesianRecursiveOderConstraints(fstElems, oderConstraints, fc, parallel); if (isUndefinedPairSetSet(res)) { return new HashSet<>(); } else return res; } +*/ + + + public Set> computeCartesianRecursiveOderConstraints(Set> fstElems, List>> topLevelSets, IFiniteClosure fc, boolean parallel, int rekTiefe) { + //ArrayList>> remainingSets = new ArrayList<>(topLevelSets); + fstElems.addAll(topLevelSets.stream() + .filter(x -> x.size()==1) + .map(y -> y.stream().findFirst().get()) + .collect(Collectors.toCollection(HashSet::new))); + ArrayList>> remainingSets = topLevelSets.stream() + .filter(x -> x.size()>1) + .collect(Collectors.toCollection(ArrayList::new)); + if (remainingSets.isEmpty()) {//Alle Elemente sind 1-elementig + Set eq = new HashSet<>(); + fstElems.stream().forEach(x -> eq.addAll(x)); + Set> result = unify(eq, new ArrayList<>(), fc, parallel, rekTiefe); + return result; + } + Set> nextSet = remainingSets.remove(0); + writeLog("nextSet: " + nextSet.toString()); + List> nextSetasList =new ArrayList<>(nextSet); + try { + //List> + //nextSetasList = oup.sortedCopy(nextSet);//new ArrayList<>(nextSet); + } + catch (java.lang.IllegalArgumentException e) { + System.out.print(""); + } + Set> result = new HashSet<>(); + int variance = 0; + Optional xi = nextSetasList.stream().map(x -> x.stream().filter(y -> y.getLhsType() instanceof PlaceholderType) + .filter(z -> ((PlaceholderType)z.getLhsType()).getVariance() != 0) + .map(c -> ((PlaceholderType)c.getLhsType()).getVariance()) + .reduce((a,b)-> {if (a==b) return a; else return 0; })) + .filter(d -> d.isPresent()) + .map(e -> e.get()) + .findAny(); + if (xi.isPresent()) { + variance = xi.get(); + } + //if (variance == 1 && nextSetasList.size() > 1) { + // List> al = new ArrayList<>(nextSetasList.size()); + // for (int ii = 0; ii < nextSetasList.size();ii++) { + // al.add(0,nextSetasList.get(ii)); + // } + // nextSetasList = al; + //} + //Set a = nextSetasListIt.next(); + /*if (nextSetasList.size()>1) {zu loeschen + if (nextSetasList.iterator().next().iterator().next().getLhsType().getName().equals("D")) + System.out.print(""); + if (variance == 1) { + a_next = oup.max(nextSetasList.iterator()); + } + else if (variance == -1) { + a_next = oup.min(nextSetasList.iterator()); + } + else if (variance == 0) { + a_next = nextSetasList.iterator().next(); + } + } + else { + a_next = nextSetasList.iterator().next(); + } + */ + if (!nextSetasList.iterator().hasNext()) + System.out.print(""); + if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1) + System.out.print(""); + writeLog("nextSetasList: " + nextSetasList.toString()); + while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) { + Set a = null; + if (variance == 1) { + a = oup.max(nextSetasList.iterator()); + nextSetasList.remove(a); + } + else if (variance == -1) { + a = oup.min(nextSetasList.iterator()); + nextSetasList.remove(a); + } + else if (variance == 0) { + a = nextSetasList.remove(0); + } + //writeLog("nextSet: " + nextSetasList.toString()+ "\n"); + //nextSetasList.remove(a); + /* zu loeschen + if (nextSetasList.size() > 0) { + if (nextSetasList.size()>1) { + if (variance == 1) { + a_next = oup.max(nextSetasList.iterator()); + } + else if (variance == -1) { + a_next = oup.min(nextSetasList.iterator()); + } + else { + a_next = nextSetasList.iterator().next(); + } + } + else { + a_next = nextSetasList.iterator().next(); + } + } + */ + //PL 2018-03-01 + //TODO: 1. Maximum und Minimum unterscheiden + //TODO: 2. compare noch für alle Elmemente die nicht X =. ty sind erweitern + //for(Set a : newSet) { + i++; + Set> elems = new HashSet>(fstElems); + elems.add(a); + Set> res = new HashSet<>(); + if (remainingSets.isEmpty()) { + noou++; + writeLog("Vor unify Aufruf: " + eq.toString()); + writeLog("No of Unify " + noou); + System.out.println(noou); + Set eq = new HashSet<>(); + elems.stream().forEach(x -> eq.addAll(x)); + res = unify(eq, new ArrayList<>(), fc, parallel, rekTiefe); + } + else {//duerfte gar nicht mehr vorkommen PL 2018-04-03 + res = computeCartesianRecursiveOderConstraints(elems, remainingSets, fc, parallel, rekTiefe); + + } + if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) { + //wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen + result = res; + } + else { + if ((isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) + || (!isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) + || result.isEmpty()) { + //alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden + result.addAll(res); + } + //else { + //wenn Korrekte Ergebnisse da und Feherfälle dazukommen Fehlerfälle ignorieren + // if (isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) { + // result = result; + // } + //} + } + + + + + /* auskommentiert um alle Max und min Betrachtung auszuschalten ANFANG */ + if (!result.isEmpty() && !isUndefinedPairSetSet(res)) { + if (nextSetasList.iterator().hasNext() && nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("B")).findFirst().isPresent() && nextSetasList.size()>1) + System.out.print(""); + Iterator> nextSetasListIt = new ArrayList>(nextSetasList).iterator(); + if (variance == 1) { + System.out.println(""); + while (nextSetasListIt.hasNext()) { + Set a_next = nextSetasListIt.next(); + if (a.equals(a_next) || + (oup.compare(a, a_next) == 1)) { + nextSetasList.remove(a_next); + } + else { + System.out.println(""); + } + } + } + else { if (variance == -1) { + System.out.println(""); + while (nextSetasListIt.hasNext()) { + Set a_next = nextSetasListIt.next(); + if (a.equals(a_next) || + (oup.compare(a, a_next) == -1)) { + nextSetasList.remove(0); + } + else { + System.out.println(""); + } + } + } + else if (variance == 0) { + //break; + }} + } + /* auskommentiert um alle Max und min Betrachtung auszuschalten ENDE */ + + /* PL 2018-11-05 wird falsch weil es auf der obersten Ebene ist. + if (isUndefinedPairSetSet(res)) { + int nofstred= 0; + Set abhSubst = res.stream() + .map(b -> + b.stream() + .map(x -> x.getAllSubstitutions()) + .reduce((y,z) -> { y.addAll(z); return y;}).get()) + .reduce((y,z) -> { y.addAll(z); return y;}).get(); + Set b = a;//effective final a + Set durchschnitt = abhSubst.stream() + .filter(x -> b.contains(x)) + //.filter(y -> abhSubst.contains(y)) + .collect(Collectors.toCollection(HashSet::new)); + //Set vars = durchschnitt.stream().map(x -> (PlaceholderType)x.getLhsType()).collect(Collectors.toCollection(HashSet::new)); + int len = nextSetasList.size(); + Set undefRes = res.stream().reduce((y,z) -> { y.addAll(z); return y;}).get(); //flatten aller undef results + Set, UnifyPair>> reducedUndefResSubstGroundedBasePair = undefRes.stream() + .map(x -> { Set su = x.getAllSubstitutions(); //alle benutzten Substitutionen + su.add(x.getGroundBasePair()); // urspruengliches Paar + su.removeAll(durchschnitt); //alle aktuell genänderten Paare entfernen + return new Pair<>(su, x.getGroundBasePair());}) + .collect(Collectors.toCollection(HashSet::new)); + if (res.size() > 1) { + System.out.println(); + } + nextSetasList = nextSetasList.stream().filter(x -> { + //Boolean ret = false; + //for (PlaceholderType var : vars) { + // ret = ret || x.stream().map(b -> b.getLhsType().equals(var)).reduce((c,d) -> c || d).get(); + //} + return (!x.containsAll(durchschnitt));//Was passiert wenn durchschnitt leer ist?? + })//.filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y)) //fuer testzwecke auskommentiert um nofstred zu bestimmen PL 2018-10-10 + .collect(Collectors.toCollection(ArrayList::new)); + nofstred = nextSetasList.size(); + //NOCH NICHT korrekt PL 2018-10-12 + //nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y)) + // .collect(Collectors.toCollection(ArrayList::new)); + writeLog("res (undef): " + res.toString()); + writeLog("abhSubst: " + abhSubst.toString()); + writeLog("a: " + a.toString()); + writeLog("Durchschnitt: " + durchschnitt.toString()); + writeLog("nextSet: " + nextSet.toString()); + writeLog("nextSetasList: " + nextSetasList.toString()); + writeLog("Number first erased Elements (undef): " + (len - nofstred)); + writeLog("Number second erased Elements (undef): " + (nofstred- nextSetasList.size())); + writeLog("Number erased Elements (undef): " + (len - nextSetasList.size())); + noAllErasedElements = noAllErasedElements + (len - nextSetasList.size()); + writeLog("Number of all erased Elements (undef): " + noAllErasedElements.toString()); + noBacktracking++; + writeLog("Number of Backtracking: " + noBacktracking); + System.out.println(""); + } + */ + //if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) { + // return result; + //} + //else { + // result.removeIf(y -> isUndefinedPairSet(y)); + //} + //else result.stream().filter(y -> !isUndefinedPairSet(y)); + + + } // End of while (nextSetasList.size() > 0) + return result; + } + /** * Computes all principal type unifiers for a set of constraints. @@ -241,18 +494,22 @@ public class TypeUnifyTask extends RecursiveTask>> { * @param fc The finite closure * @return The set of all principal type unifiers */ - protected Set> unify(Set eq, IFiniteClosure fc, boolean parallel) { + protected Set> unify(final Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) { //Set aas = eq.stream().filter(x -> x.getLhsType().getName().equals("AA") //&& x.getPairOp().equals(PairOperator.SMALLERDOT) // ).collect(Collectors.toCollection(HashSet::new)); //writeLog(nOfUnify.toString() + " AA: " + aas.toString()); //if (aas.isEmpty()) { // System.out.println(""); //} + + //.collect(Collectors.toCollection(HashSet::new))); /* * Step 1: Repeated application of reduce, adapt, erase, swap */ + rekTiefe++; nOfUnify++; writeLog(nOfUnify.toString() + " Unifikation: " + eq.toString()); + writeLog(nOfUnify.toString() + " Oderconstraints: " + oderConstraints.toString()); //eq = eq.stream().map(x -> {x.setVariance((byte)-1); return x;}).collect(Collectors.toCollection(HashSet::new)); /* @@ -319,11 +576,13 @@ public class TypeUnifyTask extends RecursiveTask>> { Set undefinedPairs = new HashSet<>(); if (printtag) System.out.println("eq2s " + eq2s); //writeLog("BufferSet: " + bufferSet.toString()+"\n"); - Set>>> secondLevelSets = calculatePairSets(eq2s, fc, undefinedPairs); + List>> oderConstraintsOutput = new ArrayList<>();//new ArrayList<>(oderConstraints); + Set>>> secondLevelSets = calculatePairSets(eq2s, oderConstraints, fc, undefinedPairs, oderConstraintsOutput); //PL 2017-09-20: Im calculatePairSets wird möglicherweise O .< java.lang.Integer //nicht ausgewertet Faculty Beispiel im 1. Schritt //PL 2017-10-03 geloest, muesste noch mit FCs mit kleineren //Typen getestet werden. + writeLog(nOfUnify.toString() + " Oderconstraints2: " + oderConstraintsOutput.toString()); if (printtag) System.out.println("secondLevelSets:" +secondLevelSets); // If pairs occured that did not match one of the cartesian product cases, // those pairs are contradictory and the unification is impossible. @@ -375,12 +634,13 @@ public class TypeUnifyTask extends RecursiveTask>> { //Aufruf von computeCartesianRecursive ANFANG - return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets), eq, fc, parallel); + //writeLog("topLevelSets: " + topLevelSets.toString()); + return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets), eq, oderConstraintsOutput, fc, parallel, rekTiefe); } - Set> unify2(Set> setToFlatten, Set eq, IFiniteClosure fc, boolean parallel) { + Set> unify2(Set> setToFlatten, Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) { //Aufruf von computeCartesianRecursive ENDE //keine Ahnung woher das kommt @@ -407,11 +667,6 @@ public class TypeUnifyTask extends RecursiveTask>> { /* * Step 5: Substitution */ -<<<<<<< HEAD - //System.out.println("vor Subst: " + eqPrime); - Optional> eqPrimePrime = rules.subst(eqPrime); - -======= //writeLog("vor Subst: " + eqPrime); writeLog("vor Subst: " + oderConstraints); String ocString = oderConstraints.toString(); @@ -421,12 +676,13 @@ public class TypeUnifyTask extends RecursiveTask>> { Set> unifyres2 = null; if (!ocString.equals(newOderConstraints.toString())) writeLog("nach Subst: " + newOderConstraints); //writeLog("nach Subst: " + eqPrimePrime); ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 /* * Step 6 a) Restart (fork) for pairs where subst was applied */ + /* if(parallel) { - if (eqPrime.equals(eq) && !eqPrimePrime.isPresent()) //PL 2017-09-29 //(!eqPrimePrime.isPresent()) auskommentiert und durch + if (eqPrime.equals(eq) && !eqPrimePrime.isPresent() + && oderConstraints.isEmpty()) //PL 2017-09-29 //(!eqPrimePrime.isPresent()) auskommentiert und durch //PL 2017-09-29 dies ersetzt //(!eqPrimePrime.isPresent()) //PL 2018-05-18 beide Bedingungen muessen gelten, da eqPrime Veränderungen in allem ausser subst //eqPrimePrime Veraenderungen in subst repraesentieren. @@ -444,46 +700,32 @@ public class TypeUnifyTask extends RecursiveTask>> { fork.fork(); } } - else { // sequentiell (Step 6b is included) + else */ + {// sequentiell (Step 6b is included) if (printtag) System.out.println("nextStep: " + eqPrimePrime); - if (eqPrime.equals(eq) && !eqPrimePrime.isPresent()) { //PL 2017-09-29 //(!eqPrimePrime.isPresent()) auskommentiert und durch + if (eqPrime.equals(eq) && !eqPrimePrime.isPresent() + && oderConstraints.isEmpty()) { //PL 2017-09-29 //(!eqPrimePrime.isPresent()) auskommentiert und durch //PL 2017-09-29 dies ersetzt //(!eqPrimePrime.isPresent()) //PL 2018-05-18 beide Bedingungen muessen gelten, da eqPrime Veränderungen in allem ausser subst //eqPrimePrime Veraenderungen in subst repraesentieren. //try { if (isSolvedForm(eqPrime)) { -<<<<<<< HEAD - logFile.write(eqPrime.toString()+"\n"); - logFile.flush(); - } - } - catch (IOException e) { } -======= writeLog("eqPrime:" + eqPrime.toString()+"\n"); } //} //catch (IOException e) { // System.err.println("log-File nicht vorhanden"); //} ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 eqPrimePrimeSet.add(eqPrime); urm.notify(eqPrimePrimeSet); } else if(eqPrimePrime.isPresent()) { -<<<<<<< HEAD - Set> unifyres = unify(eqPrimePrime.get(), fc, false); -======= Set> unifyres = unifyres1 = unify(eqPrimePrime.get(), newOderConstraints, fc, parallel, rekTiefe); ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 eqPrimePrimeSet.addAll(unifyres); } else { -<<<<<<< HEAD - Set> unifyres = unify(eqPrime, fc, false); -======= Set> unifyres = unifyres2 = unify(eqPrime, newOderConstraints, fc, parallel, rekTiefe); ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 eqPrimePrimeSet.addAll(unifyres); @@ -496,23 +738,26 @@ public class TypeUnifyTask extends RecursiveTask>> { /* * Step 6 b) Build the union over everything. */ + /* + * PL 2019-01-22: geloescht if(parallel) for(TypeUnifyTask fork : forks) eqPrimePrimeSet.addAll(fork.join()); - + */ /* * Step 7: Filter empty sets; */ eqPrimePrimeSet = eqPrimePrimeSet.stream().filter(x -> isSolvedForm(x) || this.isUndefinedPairSet(x)).collect(Collectors.toCollection(HashSet::new)); - if (!eqPrimePrimeSet.isEmpty() && !isUndefinedPairSetSet(eqPrimePrimeSet)) + if (!eqPrimePrimeSet.isEmpty() && !isUndefinedPairSetSet(eqPrimePrimeSet)) { writeLog("Result1 " + eqPrimePrimeSet.toString()); + } return eqPrimePrimeSet; } - Set> computeCartesianRecursive(Set> fstElems, ArrayList>> topLevelSets, Set eq, IFiniteClosure fc, boolean parallel) { + Set> computeCartesianRecursive(Set> fstElems, ArrayList>> topLevelSets, Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) { //ArrayList>> remainingSets = new ArrayList<>(topLevelSets); fstElems.addAll(topLevelSets.stream() .filter(x -> x.size()==1) @@ -522,7 +767,7 @@ public class TypeUnifyTask extends RecursiveTask>> { .filter(x -> x.size()>1) .collect(Collectors.toCollection(ArrayList::new)); if (remainingSets.isEmpty()) {//Alle Elemente sind 1-elementig - Set> result = unify2(fstElems, eq, fc, parallel); + Set> result = unify2(fstElems, eq, oderConstraints, fc, parallel, rekTiefe); return result; } Set> nextSet = remainingSets.remove(0); @@ -540,7 +785,7 @@ public class TypeUnifyTask extends RecursiveTask>> { Optional xi = nextSetasList.stream().map(x -> x.stream().filter(y -> y.getLhsType() instanceof PlaceholderType) .filter(z -> ((PlaceholderType)z.getLhsType()).getVariance() != 0) .map(c -> ((PlaceholderType)c.getLhsType()).getVariance()) - .reduce((a,b)-> {if (a==b) return a; else return 0; })) + .reduce((a,b)-> {if (a==b) return a; else return 2; })) //2 kommt insbesondere bei Oder-Constraints vor .filter(d -> d.isPresent()) .map(e -> e.get()) .findAny(); @@ -580,11 +825,12 @@ public class TypeUnifyTask extends RecursiveTask>> { Set a = null; while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) { Set a_last = a; + List> nextSetasListRest = new ArrayList<>(); + //List> nextSetasListRestMin = new ArrayList<>(); + //List> nextSetasListRestOder = new ArrayList<>(); if (variance == 1) { a = oup.max(nextSetasList.iterator()); nextSetasList.remove(a); -<<<<<<< HEAD -======= nextSetasListRest = new ArrayList<>(nextSetasList); Iterator> nextSetasListItRest = new ArrayList>(nextSetasListRest).iterator(); while (nextSetasListItRest.hasNext()) { @@ -611,13 +857,10 @@ public class TypeUnifyTask extends RecursiveTask>> { }} } while(!nextSetasListRestTest.equals(nextSetasListRest)); ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 } else if (variance == -1) { a = oup.min(nextSetasList.iterator()); nextSetasList.remove(a); -<<<<<<< HEAD -======= nextSetasListRest = new ArrayList<>(nextSetasList); Iterator> nextSetasListItRest = new ArrayList>(nextSetasListRest).iterator(); while (nextSetasListItRest.hasNext()) { @@ -644,8 +887,11 @@ public class TypeUnifyTask extends RecursiveTask>> { }} } while(!nextSetasListRestTest.equals(nextSetasListRest)); ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 } + else if (variance == 2) { + a = nextSetasList.remove(0); + nextSetasListRest = new ArrayList<>(nextSetasList); + } else if (variance == 0) { a = nextSetasList.remove(0); } @@ -675,12 +921,6 @@ public class TypeUnifyTask extends RecursiveTask>> { //for(Set a : newSet) { i++; Set> elems = new HashSet>(fstElems); -<<<<<<< HEAD - elems.add(a); - //if (remainingSets.isEmpty()) {//muss immer gegeben sein, weil nur 1 Element der topLevelSets mehr als ein Elemet enthaelt - //writeLog("Vor unify2 Aufruf: " + eq.toString()); - Set> res = unify2(elems, eq, fc, parallel); -======= writeLog("a1: " + rekTiefe + " "+ "variance: "+ variance + " " + a.toString()+ "\n"); //elems.add(a); PL 2019-01-20 Muss weg, weil das in jeweiligen Thread erfolgen muss. Fuer den sequentiellen Fall //im else-Zweig @@ -878,32 +1118,54 @@ public class TypeUnifyTask extends RecursiveTask>> { elems.add(a); //PL 2019-01-16 muss das wirklich hin steht schon in Zeile 859 ja braucht man siehe Zeile 859 res = unify2(elems, eq, oderConstraints, fc, parallel, rekTiefe); }}} ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) { //wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen result = res; + if (res.iterator().next() instanceof WildcardType) { + System.out.println(""); + } } else { if ((isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) || (!isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) || result.isEmpty()) { - if (!result.isEmpty() && !res.isEmpty() && !isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) { + if ((!result.isEmpty() && !res.isEmpty() && !isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) //korrekte Loesungen aus und-constraints + && (a.stream().map(x-> (x.getBasePair() != null)).reduce(true, (x, y) -> (x && y)))) //bei oder-Constraints nicht ausfuehren + { + //TODO: PL 2019-01-15: Bug 129: Im Moment wird nur das Maximum und das Minimum des aktuellen Elements betrachtet. + //Die zu vereinigenden Mengen können mehrere Elemente enthalten. Das ist bisher nicht berücksichtigt //Alle Variablen bestimmen die nicht hinzugefügt wurden in a - List vars_a = a.stream().filter(x -> (x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName()) - ||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName()))).map(y -> (PlaceholderType)y.getLhsType()).collect(Collectors.toCollection(ArrayList::new)); + //PL 2018-12-28: Hier gab es eine ClassCastException, war nicht reproduzierbar + System.out.println(""); + List vars_a = + a.stream().filter(x -> ((x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName()) + && (x.getLhsType() instanceof PlaceholderType) && (x.getBasePair().getLhsType() instanceof PlaceholderType)) + || ((x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName())) + && (x.getLhsType() instanceof PlaceholderType) && (x.getBasePair().getRhsType() instanceof PlaceholderType))) + ) + .map(y -> (PlaceholderType)y.getLhsType()).collect(Collectors.toCollection(ArrayList::new)); Set fstElemRes = res.iterator().next(); Set compRes = fstElemRes.stream().filter(x -> vars_a.contains(((PlaceholderType)x.getLhsType()))).collect(Collectors.toCollection(HashSet::new)); //Alle Variablen bestimmen die nicht hinzugefügt wurden in a_last - List varsLast_a = a_last.stream().filter(x -> (x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName()) - ||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName()))).map(y -> (PlaceholderType)y.getLhsType()).collect(Collectors.toCollection(ArrayList::new)); + //System.out.println(a_last); + a_last.forEach(x -> {writeLog("a_last_elem:" + x + " basepair: " + x.getBasePair());}); + List varsLast_a = + a_last.stream().filter(x -> ((x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName()) + && (x.getLhsType() instanceof PlaceholderType) && (x.getBasePair().getLhsType() instanceof PlaceholderType)) + || ((x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName()))) + && (x.getLhsType() instanceof PlaceholderType) && (x.getBasePair().getRhsType() instanceof PlaceholderType))) + .map(y -> (PlaceholderType)y.getLhsType()).collect(Collectors.toCollection(ArrayList::new)); + //[(java.util.Vector <. gen_aq, , 1), (CEK =. ? extends gen_aq, 1)] KANN VORKOMMEN //erstes Element genügt, da vars immer auf die gleichen Elemente zugeordnet werden muessen Set fstElemResult = result.iterator().next(); Set compResult = fstElemResult.stream().filter(x -> varsLast_a.contains(((PlaceholderType)x.getLhsType()))).collect(Collectors.toCollection(HashSet::new));; - if (variance == 1) { + writeLog("a_last:" + a_last + " a: " + a); + writeLog("varsLast_a:" + varsLast_a + " vars_a: " + vars_a); + writeLog("compResult:" + compResult + " compRes: " + compRes); int resOfCompare = oup.compare(compResult, compRes); if (resOfCompare == -1) { writeLog("Geloescht result: " + result); @@ -917,6 +1179,9 @@ public class TypeUnifyTask extends RecursiveTask>> { //result = result; }}} else { if (variance == -1) { + writeLog("a_last:" + a_last + " a: " + a); + writeLog("varsLast_a:" + varsLast_a + " vars_a: " + vars_a); + writeLog("compResult:" + compResult + " compRes: " + compRes); int resOfCompare = oup.compare(compResult, compRes); if (resOfCompare == 1) { writeLog("Geloescht result: " + result); @@ -930,11 +1195,13 @@ public class TypeUnifyTask extends RecursiveTask>> { //result = result; }}}} else { if (variance == 0) { + writeLog("RES var=1 ADD:" + result.toString() + " " + res.toString()); result.addAll(res); - }}} - //alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden + }}} } else { + //alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden + writeLog("RES Fst:" + result.toString() + " " + res.toString()); result.addAll(res); } } @@ -950,6 +1217,27 @@ public class TypeUnifyTask extends RecursiveTask>> { //else {//duerfte gar nicht mehr vorkommen PL 2018-04-03 //result.addAll(computeCartesianRecursive(elems, remainingSets, eq, fc, parallel)); //} + if (parallel) { + for (Set> par_res : add_res) { + if (!isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) { + //wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen + result = par_res; + if (par_res.iterator().next() instanceof WildcardType) { + System.out.println(""); + } + } + else { + if ((isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) + || (!isUndefinedPairSetSet(par_res) && !isUndefinedPairSetSet(result)) + || result.isEmpty()) { + //alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden + writeLog("RES var1 ADD:" + result.toString() + " " + par_res.toString()); + result.addAll(par_res); + } + } + } + //break; + } /* auskommentiert um alle Max und min Betrachtung auszuschalten ANFANG */ if (!result.isEmpty() && (!isUndefinedPairSetSet(res) || !aParDef.isEmpty())) { @@ -957,17 +1245,34 @@ public class TypeUnifyTask extends RecursiveTask>> { System.out.print(""); Iterator> nextSetasListIt = new ArrayList>(nextSetasList).iterator(); if (variance == 1) { - System.out.println(""); -<<<<<<< HEAD - while (nextSetasListIt.hasNext()) { - Set a_next = nextSetasListIt.next(); - if (a.equals(a_next) || - (oup.compare(a, a_next) == 1)) { - nextSetasList.remove(a_next); + /* vorgezogen vor das if + if (parallel) { + for (Set> par_res : add_res) { + if (!isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) { + //wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen + result = par_res; + if (par_res.iterator().next() instanceof WildcardType) { + System.out.println(""); + } + } + else { + if ((isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) + || (!isUndefinedPairSetSet(par_res) && !isUndefinedPairSetSet(result)) + || result.isEmpty()) { + //alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden + writeLog("RES var1 ADD:" + result.toString() + " " + par_res.toString()); + result.addAll(par_res); + } + } } - else { - System.out.println(""); -======= + //break; + */ + + /* nextSetasList = nextSetasListRest; */ + /* wird bereits vor den unify2-Aufruf durchgefuehrt und nextSetasListRest zugeordnet + */ + + System.out.println(""); writeLog("a: " + rekTiefe + " variance: " + variance + a.toString()); writeLog("aParDef: " + aParDef.toString()); aParDef.add(a); @@ -985,28 +1290,37 @@ public class TypeUnifyTask extends RecursiveTask>> { writeLog("Not Removed: " + a_next.toString()); System.out.println(""); } ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 } } } else { if (variance == -1) { - System.out.println(""); -<<<<<<< HEAD - while (nextSetasListIt.hasNext()) { - Set a_next = nextSetasListIt.next(); - if (a.equals(a_next) || - (oup.compare(a, a_next) == -1)) { - nextSetasList.remove(0); - } - else { - System.out.println(""); + /* vorgezogen vor das if + if (parallel) { + for (Set> par_res : add_res) { + if (!isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) { + //wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen + result = par_res; + if (par_res.iterator().next() instanceof WildcardType) { + System.out.println(""); + } + } + else { + if ((isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) + || (!isUndefinedPairSetSet(par_res) && !isUndefinedPairSetSet(result)) + || result.isEmpty()) { + //alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden + writeLog("RES var-1 ADD:" + result.toString() + " " + par_res.toString()); + result.addAll(par_res); + } + } } + //break; } + } - else if (variance == 0) { - break; - } -======= + */ + + System.out.println(""); writeLog("a: " + rekTiefe + " variance: " + variance + a.toString()); writeLog("aParDef: " + aParDef.toString()); aParDef.add(a); @@ -1056,7 +1370,6 @@ public class TypeUnifyTask extends RecursiveTask>> { */ }}} writeLog("a: " + rekTiefe + " variance: " + variance + a.toString()); ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 } } /* auskommentiert um alle Max und min Betrachtung auszuschalten ENDE */ @@ -1069,6 +1382,14 @@ public class TypeUnifyTask extends RecursiveTask>> { .map(x -> x.getAllSubstitutions()) .reduce((y,z) -> { y.addAll(z); return y;}).get()) .reduce((y,z) -> { y.addAll(z); return y;}).get(); + abhSubst.addAll( + res.stream() + .map(b -> + b.stream() + .map(x -> x.getAllBases()) + .reduce((y,z) -> { y.addAll(z); return y;}).get()) + .reduce((y,z) -> { y.addAll(z); return y;}).get() + ); Set b = a;//effective final a Set durchschnitt = abhSubst.stream() .filter(x -> b.contains(x)) @@ -1100,7 +1421,7 @@ public class TypeUnifyTask extends RecursiveTask>> { // .collect(Collectors.toCollection(ArrayList::new)); writeLog("res (undef): " + res.toString()); writeLog("abhSubst: " + abhSubst.toString()); - writeLog("a: " + a.toString()); + writeLog("a2: " + rekTiefe + " " + a.toString()); writeLog("Durchschnitt: " + durchschnitt.toString()); writeLog("nextSet: " + nextSet.toString()); writeLog("nextSetasList: " + nextSetasList.toString()); @@ -1120,7 +1441,10 @@ public class TypeUnifyTask extends RecursiveTask>> { // result.removeIf(y -> isUndefinedPairSet(y)); //} //else result.stream().filter(y -> !isUndefinedPairSet(y)); + writeLog("res: " + res.toString()); } + + writeLog("Return computeCR: " + result.toString()); return result; } @@ -1397,15 +1721,18 @@ public class TypeUnifyTask extends RecursiveTask>> { * from the pairs that matched the case. Each generated set contains singleton sets or sets with few elements * (as in case 1 where sigma is added to the innermost set). */ - protected Set>>> calculatePairSets(Set eq2s, IFiniteClosure fc, Set undefined) { - List>>> result = new ArrayList<>(8); + protected Set>>> calculatePairSets(Set eq2s, List>> oderConstraintsInput, IFiniteClosure fc, Set undefined, List>> oderConstraintsOutput) { + oderConstraintsOutput.addAll(oderConstraintsInput); + List>>> result = new ArrayList<>(9); - // Init all 8 cases - for(int i = 0; i < 8; i++) + // Init all 8 cases + 9. Case: oderConstraints + for(int i = 0; i < 9; i++) result.add(new HashSet<>()); + ArrayList eq2sprime = new ArrayList<>(eq2s); Iterator eq2sprimeit = eq2sprime.iterator(); ArrayList eq2sAsList = new ArrayList<>(); + Boolean first = true; while(eq2sprimeit.hasNext()) {// alle mit Variance != 0 nach vorne schieben UnifyPair up = eq2sprimeit.next(); if ((up.getLhsType() instanceof PlaceholderType && ((PlaceholderType)up.getLhsType()).getVariance() != 0) @@ -1414,8 +1741,45 @@ public class TypeUnifyTask extends RecursiveTask>> { eq2s.remove(up); } } + if (eq2sAsList.isEmpty()) { + List>> oderConstraintsVariance = oderConstraintsOutput.stream() //Alle Elemente rauswerfen, die Variance 0 haben oder keine TPH in LHS oder RHS sind + .filter(x -> x.stream() + .filter(y -> + y.stream().filter(z -> ((z.getLhsType() instanceof PlaceholderType) + && (((PlaceholderType)(z.getLhsType())).getVariance() != 0)) + || ((z.getRhsType() instanceof PlaceholderType) + && (((PlaceholderType)(z.getRhsType())).getVariance() != 0)) + ).findFirst().isPresent() + ).findFirst().isPresent()).collect(Collectors.toList()); + if (!oderConstraintsVariance.isEmpty()) { + Set> ret = oderConstraintsVariance.get(0); + oderConstraintsOutput.remove(ret); + //Set retFlat = new HashSet<>(); + //ret.stream().forEach(x -> retFlat.addAll(x)); + ret.stream().forEach(x -> x.stream().forEach(y -> y.addSubstitutions(x))); + result.get(8).add(ret); + first = false; + } + } + eq2sAsList.addAll(eq2s); - Boolean first = true; + + if (eq2sAsList.isEmpty() && first) {//Alle eq2s sind empty und alle oderConstraints mit Variance != 0 sind bearbeitet + if (!oderConstraintsOutput.isEmpty()) { + Set> ret = oderConstraintsOutput.remove(0); + //if (ret.iterator().next().iterator().next().getLhsType().getName().equals("M")) + // System.out.println("M"); + //Set retFlat = new HashSet<>(); + //ret.stream().forEach(x -> retFlat.addAll(x)); + ret.stream().forEach(x -> x.stream().forEach(y -> y.addSubstitutions(x))); + result.get(8).add(ret); + first = false; + } + } + /* + Bei allen die Abhaengigkeit der Elemente aus eq2sAsList als evtl. als Substitution + hinzufuegen + */ for(UnifyPair pair : eq2sAsList) { PairOperator pairOp = pair.getPairOp(); UnifyType lhsType = pair.getLhsType(); @@ -1425,6 +1789,9 @@ public class TypeUnifyTask extends RecursiveTask>> { if (((pairOp == PairOperator.SMALLERDOT) || (pairOp == PairOperator.SMALLERNEQDOT)) && lhsType instanceof PlaceholderType) { //System.out.println(pair); if (first) { //writeLog(pair.toString()+"\n"); + if (((PlaceholderType)(pair.getLhsType())).getName().equals("AR")) { + System.out.println("AR"); + } Set> x1 = unifyCase1(pair, fc); if (pairOp == PairOperator.SMALLERNEQDOT) { Set remElem = new HashSet<>(); @@ -1567,9 +1934,6 @@ public class TypeUnifyTask extends RecursiveTask>> { allGen = false; break; } -<<<<<<< HEAD - -======= //if (thetaPrime.getName().equals("java.util.Vector") //Fuer Bug 127 // && thetaPrime instanceof ReferenceType // && ((ReferenceType)thetaPrime).getTypeParams().iterator().next() instanceof PlaceholderType) //.getName().equals("java.util.Vector")) @@ -1577,11 +1941,9 @@ public class TypeUnifyTask extends RecursiveTask>> { // { // System.out.println(""); //} ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 Set cs = fc.getAllTypesByName(thetaPrime.getName());//cs= [java.util.Vector, java.util.Vector>, ????java.util.Vector???] - //PL 18-02-06 entfernt, kommt durch unify wieder rein //cs.add(thetaPrime); //PL 18-02-06 entfernt @@ -1627,19 +1989,21 @@ public class TypeUnifyTask extends RecursiveTask>> { } for(UnifyType tqp : thetaQPrimes) { + Collection tphs = tqp.getInvolvedPlaceholderTypes(); Optional opt = stdUnify.unify(tqp, thetaPrime); if (!opt.isPresent()) { continue; } - Unifier unifier = opt.get(); unifier.swapPlaceholderSubstitutions(thetaPrime.getTypeParams()); Set substitutionSet = new HashSet<>(); for (Entry sigma : unifier) { - substitutionSet.add(new UnifyPair(sigma.getKey(), sigma.getValue(), PairOperator.EQUALSDOT, + if (!tphs.contains(sigma.getKey())) {//eingefuegt PL 2019-02-02 Bug 127 + substitutionSet.add(new UnifyPair(sigma.getKey(), sigma.getValue(), PairOperator.EQUALSDOT, //TODO: nochmals ueberlegen ob hier pair.getSubstitution() korrekt ist, oder ob leere Menge hin müsste //alle folgenden New UnifyPair ebenfalls ueberpruefen PL 2018-04-19 pair.getSubstitution(), pair)); + } } //List freshTphs = new ArrayList<>(); PL 18-02-06 in die For-Schleife verschoben for (UnifyType tq : thetaQs) { @@ -1664,6 +2028,7 @@ public class TypeUnifyTask extends RecursiveTask>> { for(int i = 0; !allGen && i < theta.getTypeParams().size(); i++) { if(freshTphs.size()-1 < i)//IST DAS RICHTIG??? PL 2018-12-12 freshTphs.add(PlaceholderType.freshPlaceholder()); + freshTphs.forEach(x -> ((PlaceholderType)x).setInnerType(true)); resultPrime.add(new UnifyPair(freshTphs.get(i), theta.getTypeParams().get(i), PairOperator.SMALLERDOTWC, pair.getSubstitution(), pair)); } @@ -1708,6 +2073,7 @@ public class TypeUnifyTask extends RecursiveTask>> { UnifyType aPrime = PlaceholderType.freshPlaceholder(); ((PlaceholderType)aPrime).setVariance(((PlaceholderType)a).getVariance()); + ((PlaceholderType)aPrime).disableWildcardtable(); UnifyType extAPrime = new ExtendsType(aPrime); UnifyType thetaPrime = extThetaPrime.getExtendedType(); Set resultPrime = new HashSet<>(); @@ -1728,12 +2094,14 @@ public class TypeUnifyTask extends RecursiveTask>> { */ private Set> unifyCase3(UnifyPair pair, IFiniteClosure fc) { PlaceholderType a = (PlaceholderType) pair.getLhsType(); + a.reversVariance(); SuperType subThetaPrime = (SuperType) pair.getRhsType(); byte variance = pair.getVariance(); Set> result = new HashSet<>(); UnifyType aPrime = PlaceholderType.freshPlaceholder(); ((PlaceholderType)aPrime).setVariance(((PlaceholderType)a).getVariance()); + ((PlaceholderType)aPrime).disableWildcardtable(); UnifyType supAPrime = new SuperType(aPrime); UnifyType thetaPrime = subThetaPrime.getSuperedType(); Set resultPrime = new HashSet<>(); @@ -1767,7 +2135,27 @@ public class TypeUnifyTask extends RecursiveTask>> { break; } - for(UnifyType thetaS : fc.greater(theta, pair.getfBounded())) { + //eingefuegt PL 2019-01-03 ANFANG + //fc.setLogTrue(); + //writeLog("FBOUNDED: " + pair.getfBounded()); + //writeLog("Pair: " + pair); + Set greater = fc.greater(theta, pair.getfBounded()); + //writeLog("GREATER: " + greater + pair + "THETA: " + theta + "FBOUNDED: " + pair.getfBounded() + " "); + if (a.isWildcardable()) { + Set greater_ext = greater.stream().filter(x -> !(x instanceof ExtendsType) && !(x instanceof SuperType)) + .map(x -> { + //BinaryOperator> combiner = (aa,b) -> { aa.putAll(b); return aa;}; //Variablenumbenennung rausgenommen + //HashMap hm = x.getInvolvedPlaceholderTypes().stream() //Variablen muessen wahrscheinlich erhalten bleiben + // .reduce(new HashMap(), + // (aa, b)-> { aa.put(b,PlaceholderType.freshPlaceholder()); return aa; }, combiner); + return new SuperType (x);})//.accept(new freshPlaceholder(), hm));} + .collect(Collectors.toCollection(HashSet::new)); + greater.addAll(greater_ext); + } + //eingefuegt PL 2019-01-03 ENDE + + //for(UnifyType thetaS : fc.greater(theta, pair.getfBounded())) { + for(UnifyType thetaS : greater) { Set resultPrime = new HashSet<>(); Match match = new Match(); @@ -1775,7 +2163,7 @@ public class TypeUnifyTask extends RecursiveTask>> { for(int i = 0; !allGen && i < freshTphs.length; i++) { freshTphs[i] = PlaceholderType.freshPlaceholder(); ((PlaceholderType)freshTphs[i]).setVariance(((PlaceholderType)a).getVariance()); - Set fBounded = pair.getfBounded(); + Set fBounded = new HashSet<>(pair.getfBounded()); //PL 2019-01-09 new HashSet eingefuegt int i_ef = i; BiFunction f = (x,y) -> @@ -1789,7 +2177,7 @@ public class TypeUnifyTask extends RecursiveTask>> { //} BinaryOperator bo = (x,y) -> (x || y); if (fBounded.stream().reduce(false,f,bo)) { - resultPrime.add(new UnifyPair(thetaS.getTypeParams().get(i), freshTphs[i], PairOperator.EQUALSDOT, pair.getSubstitution(), pair)); + resultPrime.add(new UnifyPair(freshTphs[i], thetaS.getTypeParams().get(i), PairOperator.EQUALSDOT, pair.getSubstitution(), pair)); } else { fBounded.add(thetaS.getTypeParams().get(i)); @@ -1803,7 +2191,8 @@ public class TypeUnifyTask extends RecursiveTask>> { resultPrime.add(new UnifyPair(a, thetaS.setTypeParams(new TypeParams(freshTphs)), PairOperator.EQUALSDOT, pair.getSubstitution(), pair)); resultPrime = resultPrime.stream().map(x -> { x.setVariance(variance); return x;}).collect(Collectors.toCollection(HashSet::new)); result.add(resultPrime); - //writeLog(resultPrime.toString()); + //writeLog("FBOUNDED2: " + pair.getfBounded()); + //writeLog("resultPrime Theta < a: " + greater + pair + "THETA: " + theta + "FBOUNDED: " + pair.getfBounded() + " " + resultPrime.toString()); } return result; @@ -1826,6 +2215,7 @@ public class TypeUnifyTask extends RecursiveTask>> { UnifyType freshTph = PlaceholderType.freshPlaceholder(); ((PlaceholderType)freshTph).setVariance(a.getVariance()); + ((PlaceholderType)freshTph).disableWildcardtable(); resultPrime = new HashSet<>(); resultPrime.add(new UnifyPair(a, new ExtendsType(freshTph), PairOperator.EQUALSDOT, pair.getSubstitution(), pair)); resultPrime.add(new UnifyPair(theta, freshTph, PairOperator.SMALLERDOT, pair.getSubstitution(), pair, pair.getfBounded())); @@ -1877,15 +2267,20 @@ public class TypeUnifyTask extends RecursiveTask>> { } void writeLog(String str) { - /* + synchronized ( this ) { if (log) { try { - logFile.write(str+"\n"); + logFile.write("Thread no.:" + thNo + "\n"); + logFile.write("noOfThread:" + noOfThread + "\n"); + logFile.write("parallel:" + parallel + "\n"); + logFile.write(str+"\n\n"); logFile.flush(); } - catch (IOException e) { } + catch (IOException e) { + System.err.println("kein LogFile"); } - */ + } + } } } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java index 3e20f433..37d70d55 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/interfaces/IFiniteClosure.java @@ -17,6 +17,7 @@ import de.dhbwstuttgart.typeinference.unify.model.UnifyType; */ public interface IFiniteClosure { + public void setLogTrue(); /** * Returns all types of the finite closure that are subtypes of the argument. * @return The set of subtypes of the argument. diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java index 87c1e821..d0497823 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java @@ -1,5 +1,7 @@ package de.dhbwstuttgart.typeinference.unify.model; +import java.io.FileWriter; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -31,6 +33,11 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IUnify; public class FiniteClosure //extends Ordering //entfernt PL 2018-12-11 implements IFiniteClosure { + FileWriter logFile; + static Boolean log = false; + public void setLogTrue() { + log = true; + } /** * A map that maps every type to the node in the inheritance graph that contains that type. */ @@ -47,10 +54,21 @@ implements IFiniteClosure { */ private Set pairs; + /** + * Hastable fuer die greater-Werte, damit sie nicht doppelt berechnet werden muessen + */ + Hashtable> greaterHash = new Hashtable<>(); + + /** + * Hastable fuer die smaller-Werte, damit sie nicht doppelt berechnet werden muessen + */ + Hashtable> smallerHash = new Hashtable<>(); + /** * Creates a new instance using the inheritance tree defined in the pairs. */ - public FiniteClosure(Set pairs) { + public FiniteClosure(Set pairs, FileWriter logFile) { + this.logFile = logFile; this.pairs = new HashSet<>(pairs); inheritanceGraph = new HashMap>(); @@ -111,12 +129,29 @@ implements IFiniteClosure { */ @Override public Set smaller(UnifyType type, Set fBounded) { + + Set ret; + if ((ret = smallerHash.get(new hashKeyType(type))) != null) { + //System.out.println(greaterHash); + return new HashSet<>(ret); + } + if(type instanceof FunNType) return computeSmallerFunN((FunNType) type, fBounded); Set>> ts = new HashSet<>(); ts.add(new Pair<>(type, fBounded)); - return computeSmaller(ts); + Set result = computeSmaller(ts); + smallerHash.put(new hashKeyType(type), result); + /* + try { + logFile.write("\ntype: " + type + "\nret: " + ret + "\nresult: " + result);//"smallerHash: " + greaterHash.toString()); + logFile.flush(); + } + catch (IOException e) { + System.err.println("no LogFile"); + }*/ + return result; } /** @@ -210,6 +245,13 @@ implements IFiniteClosure { //Eingefuegt PL 2018-05-24 F-Bounded Problematik public Set greater(UnifyType type, Set fBounded) { + Set ret; + if ((ret = greaterHash.get(new hashKeyType(type))) != null) { + //System.out.println(greaterHash); + return new HashSet<>(ret); + } + + if(type instanceof FunNType) { return computeGreaterFunN((FunNType) type, fBounded); } @@ -227,6 +269,17 @@ implements IFiniteClosure { // if T <* T' then sigma(T) <* sigma(T') Set> candidates = strInheritanceGraph.get(type.getName()); + + /* + try { + if (log) logFile.write(candidates.toString()); + //log = false; + } + catch (IOException e) { + System.err.println("no LogFile"); + } + */ + for(Node candidate : candidates) { UnifyType theta1 = candidate.getContent(); @@ -235,9 +288,9 @@ implements IFiniteClosure { termList.add(new UnifyPair(theta1,type, PairOperator.EQUALSDOT)); Optional optSigma = match.match(termList); //PL 18-04-05 Unifier durch Matcher ersetzt ENDE - if(!optSigma.isPresent()) + if(!optSigma.isPresent()) { continue; - + } Unifier sigma = optSigma.get(); sigma.swapPlaceholderSubstitutionsReverse(theta1.getTypeParams()); @@ -250,7 +303,15 @@ implements IFiniteClosure { PairResultFBounded.add(new Pair<>(theta2.apply(sigma), fBoundedNew)); } } - + /* + try { + if (log) logFile.write(PairResultFBounded.toString()); + log = false; + } + catch (IOException e) { + System.err.println("no LogFile"); + } + */ for(Pair> pt : PairResultFBounded) { UnifyType t = pt.getKey(); Set lfBounded = pt.getValue().get(); @@ -286,6 +347,16 @@ implements IFiniteClosure { //System.out.println(""); } } + + greaterHash.put(new hashKeyType(type), result); + /* + try { + logFile.write("\ntype: " + type + "\nret: " + ret + "\nresult: " + result);//"greaterHash: " + greaterHash.toString()); + logFile.flush(); + } + catch (IOException e) { + System.err.println("no LogFile"); + }*/ return result; } @@ -500,7 +571,7 @@ implements IFiniteClosure { result.add(type); return result; } - + @Override public Set getAllTypesByName(String typeName) { if(!strInheritanceGraph.containsKey(typeName)) @@ -624,8 +695,15 @@ implements IFiniteClosure { return 0; } } - if ((right instanceof PlaceholderType) && (left instanceof WildcardType)) { - return 0; + if (right instanceof PlaceholderType) {//&& (left instanceof WildcardType)) {PL geloescht 2019-01-15 analog zu oben + if ((left instanceof WildcardType) //PL eingefuegt 2019-01-15 analog zu oben + && ((ex = ((WildcardType)left).wildcardedType) instanceof PlaceholderType) + && ((PlaceholderType)right).getName().equals(((PlaceholderType)ex).getName())) {// ? extends a <. a oder ? super a <. a + return 1; + } + else { + return 0; + } } UnifyPair up = new UnifyPair(left, right, pairop); TypeUnifyTask unifyTask = new TypeUnifyTask(); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java index 29b1c59c..28da9a80 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java @@ -31,7 +31,8 @@ public class OrderingUnifyPair extends Ordering> { * in dem compare(Theta, Theta') aufgerufen wird. */ public int compareEq (UnifyPair left, UnifyPair right) { - if (left.getRhsType() instanceof WildcardType || right.getRhsType() instanceof WildcardType) { + //if (left.getRhsType() instanceof WildcardType || right.getRhsType() instanceof WildcardType) {//PL 2019-01-12 ausgetauscht + if (((PlaceholderType)left.getLhsType()).isInnerType() && ((PlaceholderType)right.getLhsType()).isInnerType()) { return fc.compare(left.getRhsType(), right.getRhsType(), PairOperator.SMALLERDOTWC); } else { @@ -55,6 +56,20 @@ public class OrderingUnifyPair extends Ordering> { UnifyPair up; if (left instanceof WildcardType || right instanceof WildcardType) { up = new UnifyPair(left, right, PairOperator.SMALLERDOTWC); + if (((left instanceof ExtendsType) + && (((ExtendsType)left).getExtendedType().getName().equals("java.util.Vector")) + && (((ReferenceType)((ExtendsType)left).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType)) || + ((right instanceof ExtendsType) + && (((ExtendsType)right).getExtendedType().getName().equals("java.util.Vector")) + && (((ReferenceType)((ExtendsType)right).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType))) + { + System.out.println(""); + } + if (((right instanceof SuperType) && (((SuperType)right).getSuperedType().getName().equals("java.lang.Object"))) + ||((left instanceof SuperType) && (((SuperType)left).getSuperedType().getName().equals("java.lang.Object")))) +{ + System.out.println(""); + } } else { up = new UnifyPair(left, right, PairOperator.SMALLERDOT); @@ -68,6 +83,19 @@ public class OrderingUnifyPair extends Ordering> { else { if (left instanceof WildcardType || right instanceof WildcardType) { up = new UnifyPair(right, left, PairOperator.SMALLERDOTWC); + if (((left instanceof ExtendsType) + && (((ExtendsType)left).getExtendedType().getName().equals("java.util.Vector")) + && (((ReferenceType)((ExtendsType)left).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType)) || + ((right instanceof ExtendsType) + && (((ExtendsType)right).getExtendedType().getName().equals("java.util.Vector")) + && (((ReferenceType)((ExtendsType)right).getExtendedType()).getTypeParams().iterator().next() instanceof ExtendsType))) + { + System.out.println(""); + } + if (right instanceof SuperType) + { + System.out.println(""); + } } else { up = new UnifyPair(right, left, PairOperator.SMALLERDOT); @@ -88,8 +116,6 @@ public class OrderingUnifyPair extends Ordering> { * @see com.google.common.collect.Ordering#compare(java.lang.Object, java.lang.Object) */ public int compare (Set left, Set right) { -<<<<<<< HEAD -======= /* //pairop = PairOperator.SMALLERDOTWC; List al = new ArrayList<>(); @@ -137,7 +163,6 @@ public class OrderingUnifyPair extends Ordering> { System.out.println(""); } } ->>>>>>> 72705ac8689aa3d283d170e673ca6663b9676ce8 Set lefteq = left.stream() .filter(x -> (x.getLhsType() instanceof PlaceholderType && x.getPairOp() == PairOperator.EQUALSDOT)) .collect(Collectors.toCollection(HashSet::new)); @@ -161,17 +186,25 @@ public class OrderingUnifyPair extends Ordering> { && x.getPairOp() == PairOperator.SMALLERDOTWC)) .collect(Collectors.toCollection(HashSet::new)); //System.out.println(left.toString()); - //Fall 2 und 3 + //Fall 2 //if (lefteq.iterator().next().getLhsType().getName().equals("AJO")) { // System.out.print(""); //} - if (lefteq.size() == 1 && leftle.size() == 1 && righteq.size() == 0 && rightle.size() == 1) { + if (lefteq.size() == 1 && lefteq.iterator().next().getRhsType() instanceof ExtendsType && leftle.size() == 1 && righteq.size() == 0 && rightle.size() == 1) { return 1; } - //Fall 2 und 3 - if (lefteq.size() == 0 && leftle.size() == 1 && righteq.size() == 1 && rightle.size() == 1) { + //Fall 2 + if (lefteq.size() == 0 && leftle.size() == 1 && righteq.size() == 1 && righteq.iterator().next().getRhsType() instanceof ExtendsType && rightle.size() == 1) { return -1; } + //Fall 3 + if (lefteq.size() == 1 && lefteq.iterator().next().getRhsType() instanceof SuperType && leftle.size() == 1 && righteq.size() == 0 && rightle.size() == 1) { + return -1; + } + //Fall 3 + if (lefteq.size() == 0 && leftle.size() == 1 && righteq.size() == 1 && righteq.iterator().next().getRhsType() instanceof SuperType && rightle.size() == 1) { + return 1; + } //Fall 5 if (lefteq.size() == 1 && leftle.size() == 0 && righteq.size() == 1 && rightle.size() == 1) { return -1; diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java index 01209998..60cf342f 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java @@ -46,6 +46,11 @@ public final class PlaceholderType extends UnifyType{ */ private boolean wildcardable = true; + /** + * is innerType gibt an, ob der Type des PlaceholderType innerhalb eines Typkonstruktorsverwendet wird + */ + private boolean innerType = false; + /** * variance shows the variance of the pair * -1: contravariant @@ -108,6 +113,15 @@ public final class PlaceholderType extends UnifyType{ return variance; } + public void reversVariance() { + if (variance == 1) { + setVariance(-1); + } else { + if (variance == -1) { + setVariance(1); + }} + } + public Boolean isWildcardable() { return wildcardable; } @@ -115,6 +129,22 @@ public final class PlaceholderType extends UnifyType{ wildcardable = false; } + public void enableWildcardtable() { + wildcardable = true; + } + + public void setWildcardtable(Boolean wildcardable) { + this.wildcardable = wildcardable; + } + + public Boolean isInnerType() { + return innerType; + } + + public void setInnerType(Boolean innerType) { + this.innerType = innerType; + } + @Override Set smArg(IFiniteClosure fc, Set fBounded) { return fc.smArg(this, fBounded); @@ -157,7 +187,7 @@ public final class PlaceholderType extends UnifyType{ @Override - public Collection getInvolvedPlaceholderTypes() { + public Collection getInvolvedPlaceholderTypes() { ArrayList ret = new ArrayList<>(); ret.add(this); return ret; diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java index d69138a7..19f6010f 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyPair.java @@ -121,6 +121,10 @@ public class UnifyPair { pairOp = po; } + public void addSubstitutions(Set sup) { + substitution.addAll(sup); + } + public byte getVariance() { return variance; } @@ -152,6 +156,15 @@ public class UnifyPair { return ret; } + public Set getAllBases () { + Set ret = new HashSet<>(); + if (basePair != null) { + ret.add(getBasePair()); + ret.addAll(basePair.getAllBases()); + } + return ret; + } + public UnifyPair getGroundBasePair () { if (basePair == null) { return this; @@ -206,12 +219,12 @@ public class UnifyPair { public String toString() { String ret = ""; if (lhs instanceof PlaceholderType) { - ret = new Integer(((PlaceholderType)lhs).getVariance()).toString(); + ret = new Integer(((PlaceholderType)lhs).getVariance()).toString() + " " + ((PlaceholderType)lhs).isInnerType(); } if (rhs instanceof PlaceholderType) { - ret = ret + ", " + new Integer(((PlaceholderType)rhs).getVariance()).toString(); + ret = ret + ", " + new Integer(((PlaceholderType)rhs).getVariance()).toString() + " " + ((PlaceholderType)rhs).isInnerType(); } - return "(" + lhs + " " + pairOp + " " + rhs + ", " + ret + ", [" + getfBounded().toString()+ "])"; + return "(" + lhs + " " + pairOp + " " + rhs + ", " + ret + ")"; //+ ", [" + getfBounded().toString()+ "])"; } /* diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java index bb7bc1c6..298f87e7 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/UnifyType.java @@ -97,7 +97,7 @@ public abstract class UnifyType { return typeName + params; } - public Collection getInvolvedPlaceholderTypes() { + public Collection getInvolvedPlaceholderTypes() { ArrayList ret = new ArrayList<>(); ret.addAll(typeParams.getInvolvedPlaceholderTypes()); return ret; diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java index 81999492..ea70139f 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/WildcardType.java @@ -64,7 +64,7 @@ public abstract class WildcardType extends UnifyType { @Override - public Collection getInvolvedPlaceholderTypes() { + public Collection getInvolvedPlaceholderTypes() { ArrayList ret = new ArrayList<>(); ret.addAll(wildcardedType.getInvolvedPlaceholderTypes()); return ret; diff --git a/src/test/java/asp/gencay/GeneratorTest.java b/src/test/java/asp/gencay/GeneratorTest.java index bd268a4b..2c9fc46f 100644 --- a/src/test/java/asp/gencay/GeneratorTest.java +++ b/src/test/java/asp/gencay/GeneratorTest.java @@ -17,8 +17,6 @@ import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.Pair; import de.dhbwstuttgart.typeinference.result.ResultSet; import de.dhbwstuttgart.typeinference.unify.model.PairOperator; - -import org.junit.Ignore; import org.junit.Test; import java.io.File; diff --git a/src/test/java/bytecode/MatrixTest.java b/src/test/java/bytecode/MatrixTest.java old mode 100644 new mode 100755 diff --git a/src/test/java/bytecode/YTest.java b/src/test/java/bytecode/YTest.java index 2a63a3ed..524170eb 100644 --- a/src/test/java/bytecode/YTest.java +++ b/src/test/java/bytecode/YTest.java @@ -26,8 +26,8 @@ public class YTest { path = System.getProperty("user.dir")+"/src/test/resources/bytecode/javFiles/Y.jav"; fileToTest = new File(path); // compiler = new JavaTXCompiler(fileToTest); -// compiler.generateBytecode(System.getProperty("user.dir")+"/testBytecode/generatedBC/"); -// pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/"; +// compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"); +// pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; // loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); // classToTest = loader.loadClass("Y"); /* diff --git a/src/test/java/javFiles/AddLong.jav b/src/test/java/javFiles/AddLong.jav deleted file mode 100644 index d6d47e9f..00000000 --- a/src/test/java/javFiles/AddLong.jav +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.Integer; -import java.lang.Long; - -public class AddLong{ - Long add(Integer a, Long b) { - Long c = a+b; - return c; - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/EmptyClass.jav b/src/test/java/javFiles/EmptyClass.jav deleted file mode 100644 index 8160d7da..00000000 --- a/src/test/java/javFiles/EmptyClass.jav +++ /dev/null @@ -1,3 +0,0 @@ -public class EmptyClass{ - -} \ No newline at end of file diff --git a/src/test/java/javFiles/EmptyMethod.jav b/src/test/java/javFiles/EmptyMethod.jav deleted file mode 100644 index dd28fc69..00000000 --- a/src/test/java/javFiles/EmptyMethod.jav +++ /dev/null @@ -1,37 +0,0 @@ -public class EmptyMethod{ - static String s1 =""; - String s2; - public void m1(){ - //String s = ""; - System.out.println("test"); - //Integer ab = Math.abs(1); - //Math.abs(1); - //String lV = "local"; - //s1 = "1"; - //s1.concat("2"); - s2 = s1; - //m2(); - Clazz i = new Clazz(); - Integer i = new Integer(1); - } - - public void m2(){} -} - -class Clazz{} -/* -public class EmptyMethod2{ - public static test = "5"; - public void m1(Integer i, String j, Boolean b){ - //String s = ""; - EmptyMethod em = new EmptyMethod(); - em.m1(); - em.s1 = ""; - //Integer ab = Math.abs(1); - //Math.abs(1); - //String lV = "local"; - //s1 = "1"; - //s1.concat("2"); - //s2 = s1; - } -}*/ \ No newline at end of file diff --git a/src/test/java/javFiles/Expressions.jav b/src/test/java/javFiles/Expressions.jav deleted file mode 100644 index e2e992a1..00000000 --- a/src/test/java/javFiles/Expressions.jav +++ /dev/null @@ -1,8 +0,0 @@ -class Expressions{ - -void test(){ - var x = 2; - x = x + 2; -} - -} \ No newline at end of file diff --git a/src/test/java/javFiles/FC_Matrix.jav b/src/test/java/javFiles/FC_Matrix.jav deleted file mode 100644 index 75ead472..00000000 --- a/src/test/java/javFiles/FC_Matrix.jav +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.Vector; - -class Matrix extends Vector> { - - methode(m) { - m.add(1); - Matrix i; - methode(i); - } - } diff --git a/src/test/java/javFiles/Faculty.jav b/src/test/java/javFiles/Faculty.jav deleted file mode 100644 index ca539add..00000000 --- a/src/test/java/javFiles/Faculty.jav +++ /dev/null @@ -1,15 +0,0 @@ -import java.lang.Integer; - -class Faculty { - - Integer mul(Integer x, Integer y) { - return x; - } - - m () { - var fact = (Integer x) -> { - return mul(x, fact.apply(x)); - }; - return fact; - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/FacultyIf.jav b/src/test/java/javFiles/FacultyIf.jav deleted file mode 100644 index 3c368923..00000000 --- a/src/test/java/javFiles/FacultyIf.jav +++ /dev/null @@ -1,17 +0,0 @@ -import java.lang.Integer; - -class Faculty { - - m () { - - var fact = (Integer x) -> { - if (x == 1) { - return x; - } - else { - return x * (fact.apply(x-1)); - } - }; - return fact; - } -} diff --git a/src/test/java/javFiles/FacultyTyped.jav b/src/test/java/javFiles/FacultyTyped.jav deleted file mode 100644 index 089d2f33..00000000 --- a/src/test/java/javFiles/FacultyTyped.jav +++ /dev/null @@ -1,19 +0,0 @@ -import java.lang.Integer; - -class Faculty { - - Integer mul(Integer x, Integer y) { - return x; - } - - Fun1 m () { - var fact = (Integer x) -> { - return mul(x, fact.apply(x)); - }; - return fact; - } -} - -interface Fun1{ - B apply(A a); -} \ No newline at end of file diff --git a/src/test/java/javFiles/Fields.jav b/src/test/java/javFiles/Fields.jav deleted file mode 100644 index cd2add71..00000000 --- a/src/test/java/javFiles/Fields.jav +++ /dev/null @@ -1,11 +0,0 @@ -import java.lang.String; - -class Fields{ -test2 = "test"; -test; -m(){ - var test3; - return test; -} - -} \ No newline at end of file diff --git a/src/test/java/javFiles/Generics.jav b/src/test/java/javFiles/Generics.jav deleted file mode 100644 index dd7b4eba..00000000 --- a/src/test/java/javFiles/Generics.jav +++ /dev/null @@ -1,22 +0,0 @@ -import java.lang.String; - -class Generics { - // A mt1(A a, B b){ - B mt1(B a, B b){ - return mt1(a, a); - } -} - -class Test { - methode(String s){ - return new Generics().mt1(s,s); - } -} - -/* -Problem: -auto test = new List(); -auto test2 = new List(); -... //code, welcher möglicherweise test und test2 vertauscht -test.add("hallo"); -*/ \ No newline at end of file diff --git a/src/test/java/javFiles/IfTest.jav b/src/test/java/javFiles/IfTest.jav deleted file mode 100644 index 1e1141df..00000000 --- a/src/test/java/javFiles/IfTest.jav +++ /dev/null @@ -1,14 +0,0 @@ -import java.lang.Integer; -import java.lang.Boolean; -import java.lang.Object; - -public class IfTest{ - Object m1(b) { - Integer i; - if(b) { - return i; - }else{ - return b; - } - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Import.jav b/src/test/java/javFiles/Import.jav deleted file mode 100644 index c48082ba..00000000 --- a/src/test/java/javFiles/Import.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.Vector; - -class Import { - void methode(){ - Vector v; - v.add(v); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Lambda.jav b/src/test/java/javFiles/Lambda.jav deleted file mode 100644 index 5bd67a0b..00000000 --- a/src/test/java/javFiles/Lambda.jav +++ /dev/null @@ -1,13 +0,0 @@ - -class Apply { } - -public class Lambda { - - m () { - var lam1 = (x) -> { - return x; - }; - return lam1.apply(new Apply()); - } -} - diff --git a/src/test/java/javFiles/Lambda2.jav b/src/test/java/javFiles/Lambda2.jav deleted file mode 100644 index cf1e910b..00000000 --- a/src/test/java/javFiles/Lambda2.jav +++ /dev/null @@ -1,33 +0,0 @@ -import java.lang.String; - -public class Lambda2 -{ - public static void main(List args){ - var listOfStrings = new List(); - var listOfObjects; - listOfObjects = map(listOfStrings, (a) -> a); -} - -public map(a , b){ - b.apply(a); - return a; -} - -/* -public static List map(List input, Function func) { - List output; - output = new List(); - output.add(func.apply(input.get())); - return output; -} -*/ -} - -class List{ - A get(); - void add(A); -} - -class Function{ - B apply(A a); -} \ No newline at end of file diff --git a/src/test/java/javFiles/Lambda3.jav b/src/test/java/javFiles/Lambda3.jav deleted file mode 100644 index 9e22f302..00000000 --- a/src/test/java/javFiles/Lambda3.jav +++ /dev/null @@ -1,24 +0,0 @@ -import java.lang.String; - -public class Lambda2 -{ - /* - public static List map(List input, - Function func){ - input.add(func.apply(input.get())); - } - */ - public map(input,func){ - input.add(func.apply(input.get())); - return map(new List(), func); - } -} - -class List{ - A get(); - void add(A); -} - -class Function{ - B apply(A a); -} \ No newline at end of file diff --git a/src/test/java/javFiles/LambdaField.jav b/src/test/java/javFiles/LambdaField.jav deleted file mode 100644 index 4eb53738..00000000 --- a/src/test/java/javFiles/LambdaField.jav +++ /dev/null @@ -1,6 +0,0 @@ -public class LambdaField { - - f = x -> x; - -} - diff --git a/src/test/java/javFiles/LambdaRunnable.jav b/src/test/java/javFiles/LambdaRunnable.jav deleted file mode 100644 index 37924ea2..00000000 --- a/src/test/java/javFiles/LambdaRunnable.jav +++ /dev/null @@ -1,14 +0,0 @@ -import java.lang.Runnable; -import java.lang.String; -import java.lang.System; - -public class LamRunnable{ - - public LamRunnable(){ - - - Runnable lam = () -> {System.out.println("lambda");}; - lam.run(); - } -} - diff --git a/src/test/java/javFiles/ListenerOverload.jav b/src/test/java/javFiles/ListenerOverload.jav deleted file mode 100644 index e1a8d65d..00000000 --- a/src/test/java/javFiles/ListenerOverload.jav +++ /dev/null @@ -1,20 +0,0 @@ -import java.lang.Integer; -import java.lang.String; - -class ListenerOverload{ - -call(p){ - call(p.left); - call(p.right); -} - -call(Integer i){} - -call(String s){} - -} - -class Pair{ - A left; - B right; -} \ No newline at end of file diff --git a/src/test/java/javFiles/Matrix.jav b/src/test/java/javFiles/Matrix.jav deleted file mode 100644 index 5e1eac08..00000000 --- a/src/test/java/javFiles/Matrix.jav +++ /dev/null @@ -1,28 +0,0 @@ -import java.util.Vector; -import java.lang.Integer; - -class Matrix extends Vector> { - Integer mul1(Integer x, Integer y) { return x;} - Integer add1(Integer x, Integer y) { return x;} - mul(m) { - var ret = new Matrix(); - var i = 0; - while(i < size()) { - var v1 = this.elementAt(i); - var v2 = new Vector(); - var j = 0; - while(j < v1.size()) { - var erg = 0; - var k = 0; - while(k < v1.size()) { - erg = erg + v1.elementAt(k) * m.elementAt(k).elementAt(j); - //erg = add1(erg, mul1(v1.elementAt(k), - // m.elementAt(k).elementAt(j))); - k++; } - v2.addElement(new Integer(erg)); - j++; } - ret.addElement(v2); - i++; } - return ret; - } -} diff --git a/src/test/java/javFiles/Meth_Gen.jav b/src/test/java/javFiles/Meth_Gen.jav deleted file mode 100644 index 056dd82f..00000000 --- a/src/test/java/javFiles/Meth_Gen.jav +++ /dev/null @@ -1,11 +0,0 @@ -class Meth_Gen { - - m1(x, y) { - m2(x); - x = y; - } - - m2(y) { - m1(y, y); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/MethodCallGenerics.jav b/src/test/java/javFiles/MethodCallGenerics.jav deleted file mode 100644 index 0d02509b..00000000 --- a/src/test/java/javFiles/MethodCallGenerics.jav +++ /dev/null @@ -1,14 +0,0 @@ -import java.lang.String; - -class Generics { - // A mt1(A a, B b){ - B mt1(B a, B b){ - return mt1(a, a); - } -} - -class Test { - methode(String s){ - return new Generics().mt1(s,s); - } -} diff --git a/src/test/java/javFiles/Methods.jav b/src/test/java/javFiles/Methods.jav deleted file mode 100644 index e45d9830..00000000 --- a/src/test/java/javFiles/Methods.jav +++ /dev/null @@ -1,17 +0,0 @@ - -class Methods { - mt4(a,b,c) { return a.add(b).sub(c) ; } - - mt1(a) {return a;} - - mt2(a) {return a.f; } - - mt3(a) {return a.add(); } -} - -class Test { - java.lang.Object f; - add(){} - add(b){return b;} - sub(b){} -} \ No newline at end of file diff --git a/src/test/java/javFiles/MethodsEasy.jav b/src/test/java/javFiles/MethodsEasy.jav deleted file mode 100644 index ee6f9daf..00000000 --- a/src/test/java/javFiles/MethodsEasy.jav +++ /dev/null @@ -1,7 +0,0 @@ - -class Methods { - mt4(a,b,c) { return a.mt3(b).mt3(c) ; } - - mt3(a) {return a.mt3(a); } -} - diff --git a/src/test/java/javFiles/Op1.jav b/src/test/java/javFiles/Op1.jav deleted file mode 100644 index 800f58b8..00000000 --- a/src/test/java/javFiles/Op1.jav +++ /dev/null @@ -1,11 +0,0 @@ -public class Op1{ - public Op1() { - - Runnable lam = () -> { - String test = ""; - String b = "b"; - test = b; - System.out.println(test);}; - //lam.run(); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Package.jav b/src/test/java/javFiles/Package.jav deleted file mode 100644 index bbc1e51d..00000000 --- a/src/test/java/javFiles/Package.jav +++ /dev/null @@ -1,5 +0,0 @@ -package strucType.input; - -class Neu -{ -} \ No newline at end of file diff --git a/src/test/java/javFiles/Sorting.jav b/src/test/java/javFiles/Sorting.jav deleted file mode 100644 index 04ef23e5..00000000 --- a/src/test/java/javFiles/Sorting.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.List; -import java.util.Collection; - -class Sorting{ - void merge(a, b){ - a.addAll(b); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Subclass.jav b/src/test/java/javFiles/Subclass.jav deleted file mode 100644 index fe6e9208..00000000 --- a/src/test/java/javFiles/Subclass.jav +++ /dev/null @@ -1,6 +0,0 @@ -public class Subclass extends Superclass { - - public void printMethod() { - super.printMethod(); - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/Superclass.jav b/src/test/java/javFiles/Superclass.jav deleted file mode 100644 index d58089de..00000000 --- a/src/test/java/javFiles/Superclass.jav +++ /dev/null @@ -1,6 +0,0 @@ -public class Superclass { - - public void printMethod() { - System.out.println("Printed in Superclass."); - } -} diff --git a/src/test/java/javFiles/Vector.jav b/src/test/java/javFiles/Vector.jav deleted file mode 100644 index 5c21cfff..00000000 --- a/src/test/java/javFiles/Vector.jav +++ /dev/null @@ -1,23 +0,0 @@ -import java.util.ArrayList; -import java.util.Vector; -import java.lang.Object; - -class MyVector{ - -id(x){ - Object i; - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - x.add(i); - return x; -} -} \ No newline at end of file diff --git a/src/test/java/javFiles/fc.jav b/src/test/java/javFiles/fc.jav deleted file mode 100644 index a3278cbc..00000000 --- a/src/test/java/javFiles/fc.jav +++ /dev/null @@ -1,18 +0,0 @@ -import java.util.List; - -class Test{ - methode(param1, param2, param3) { - param2.add(param3); - return param1.meth(param2); - } -} - -interface Klasse1{ - Klasse1 meth(List p); - Klasse1 meth(Klasse2 p); -} - -interface Klasse2{ - Klasse1 meth(Klasse1 p); - Klasse2 meth(Klasse2 p); -} \ No newline at end of file diff --git a/src/test/java/javFiles/mathStruc.jav b/src/test/java/javFiles/mathStruc.jav deleted file mode 100644 index 93f901ce..00000000 --- a/src/test/java/javFiles/mathStruc.jav +++ /dev/null @@ -1,13 +0,0 @@ - -class mathStruc { - -mathStruc(A a) { } - -A model(){ A a; return a; } - -methode(){ -var innerOp = o -> ms -> - new mathStruc(o.apply(this.model(),ms.model())); - return innerOp; - } -} \ No newline at end of file diff --git a/src/test/java/javFiles/test.jav b/src/test/java/javFiles/test.jav deleted file mode 100644 index 303d167a..00000000 --- a/src/test/java/javFiles/test.jav +++ /dev/null @@ -1,15 +0,0 @@ -class Test{ - methode(param1, param2, param3) { - return param1.meth(param2.meth(param3)); - } -} - -interface Klasse1{ - Klasse1 meth(Klasse1 p); - Klasse1 meth(Klasse2 p); -} - -interface Klasse2{ - Klasse1 meth(Klasse1 p); - Klasse2 meth(Klasse2 p); -} \ No newline at end of file diff --git a/src/test/java/javFiles/test1.jav b/src/test/java/javFiles/test1.jav deleted file mode 100644 index 4b34948e..00000000 --- a/src/test/java/javFiles/test1.jav +++ /dev/null @@ -1,7 +0,0 @@ -class Faculty { - - int a; - m (int x) { - return a+x; - } -} diff --git a/src/test/resources/bytecode/LambdaCapturetest.java b/src/test/resources/bytecode/LambdaCapturetest.java deleted file mode 100644 index 438c2315..00000000 --- a/src/test/resources/bytecode/LambdaCapturetest.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * - */ -package bytecode; - -import static org.junit.Assert.*; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.net.URLClassLoader; - -import org.junit.BeforeClass; -import org.junit.Test; - -import de.dhbwstuttgart.core.JavaTXCompiler; - -/** - * @author fayez - * - */ -public class LambdaCapturetest { - private static String path; - private static File fileToTest; - private static JavaTXCompiler compiler; - private static ClassLoader loader; - private static Class classToTest; - private static String pathToClassFile; - private static Object instanceOfClass; - - @Test - public void generateBC() throws Exception { - path = System.getProperty("user.dir")+"/test/bytecode/javFiles/LambdaCapture.jav"; - fileToTest = new File(path); - compiler = new JavaTXCompiler(fileToTest); - compiler.generateBytecode(System.getProperty("user.dir")+"/testBytecode/generatedBC/"); - pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/"; - loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); - classToTest = loader.loadClass("LambdaCapture"); - instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); - } - -} diff --git a/src/test/resources/bytecode/javFiles/Id.jav b/src/test/resources/bytecode/javFiles/Id.jav index 919b0ced..6cb5d4b0 100644 --- a/src/test/resources/bytecode/javFiles/Id.jav +++ b/src/test/resources/bytecode/javFiles/Id.jav @@ -1,6 +1,6 @@ -public class Id { +public class Id { - BVKZ id(BVLA b){ + id(b){ return b; } } \ No newline at end of file diff --git a/src/test/resources/bytecode/javFiles/Matrix.jav b/src/test/resources/bytecode/javFiles/Matrix.jav index ffd73a57..29505161 100644 --- a/src/test/resources/bytecode/javFiles/Matrix.jav +++ b/src/test/resources/bytecode/javFiles/Matrix.jav @@ -1,10 +1,10 @@ import java.util.Vector; import java.lang.Integer; -//import java.lang.Float; +import java.lang.Float; //import java.lang.Byte; -import java.lang.Boolean; +//import java.lang.Boolean; -public class Matrix extends Vector> { +public class Matrix extends Vector> { Matrix () { } @@ -19,7 +19,7 @@ public class Matrix extends Vector> { } } - mul(java.util.Vector> m) { + mul(m) { var ret = new Matrix(); var i = 0; while(i < size()) { diff --git a/src/test/resources/bytecode/javFiles/Merge.jav b/src/test/resources/bytecode/javFiles/Merge.jav index 9240146e..ad5e103e 100644 --- a/src/test/resources/bytecode/javFiles/Merge.jav +++ b/src/test/resources/bytecode/javFiles/Merge.jav @@ -1,8 +1,8 @@ import java.util.List; import java.lang.Integer; -import java.util.Collection; +//import java.util.Collection; -class Merge { +class Merge { merge(a, b) { a.addAll(b); diff --git a/src/test/resources/bytecode/javFiles/OL.jav b/src/test/resources/bytecode/javFiles/OL.jav index d0afad3f..700e50f0 100644 --- a/src/test/resources/bytecode/javFiles/OL.jav +++ b/src/test/resources/bytecode/javFiles/OL.jav @@ -4,9 +4,9 @@ import java.lang.Double; -public class OL { +public class OL { - mjava.lang.String (java.lang.String x) { return x + x; } + m(x) { return x + x; } } diff --git a/src/test/resources/bytecode/simplifyalgo/CycleTest.java b/src/test/resources/bytecode/simplifyalgo/CycleTest.java deleted file mode 100644 index 88697e6d..00000000 --- a/src/test/resources/bytecode/simplifyalgo/CycleTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * - */ -package bytecode.simplifyalgo; - -import static org.junit.Assert.*; - -import java.util.HashMap; -import java.util.HashSet; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.objectweb.asm.Type; - -import de.dhbwstuttgart.bytecode.TPHExtractor; -import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; -import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH; -import de.dhbwstuttgart.bytecode.utilities.Simplify; - -/** - * @author Fayez Abu Alia - * - */ -public class CycleTest { - - private static TPHExtractor tphExtractor; - private static String methName; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - tphExtractor = new TPHExtractor(); - // A < B - TPHConstraint c1 = new ExtendsConstraint("A", "B", Relation.EXTENDS); - // B < C - TPHConstraint c2 = new ExtendsConstraint("B", "C", Relation.EXTENDS); - // C < D - TPHConstraint c3 = new ExtendsConstraint("C", "D", Relation.EXTENDS); - // D < A - TPHConstraint c4 = new ExtendsConstraint("D", "A", Relation.EXTENDS); - // name - methName = "m"; - MethodAndTPH mtph = new MethodAndTPH("m"); - mtph.getTphs().add("A"); - mtph.getTphs().add("B"); - mtph.getTphs().add("C"); - mtph.getTphs().add("D"); - tphExtractor.ListOfMethodsAndTph.add(mtph); - tphExtractor.allCons.add(c1); - tphExtractor.allCons.add(c2); - tphExtractor.allCons.add(c3); - tphExtractor.allCons.add(c4); - - } - - @Test - public void test() { - HashMap> result = new HashMap<>(); - HashSet equals = new HashSet<>(); - equals.add("A"); - equals.add("B"); - equals.add("C"); - equals.add("D"); - TPHConstraint k = new ExtendsConstraint("A", Type.getInternalName(Object.class), Relation.EXTENDS); - result.put(k, equals); - - HashMap> sim = Simplify.simplifyConstraints(methName, tphExtractor); - boolean areEquals = SimpleCycle.areMapsEqual(result, sim); - assertTrue(areEquals); - } - -} diff --git a/src/test/resources/bytecode/simplifyalgo/SameLeftSide.java b/src/test/resources/bytecode/simplifyalgo/SameLeftSide.java deleted file mode 100644 index b5c4e875..00000000 --- a/src/test/resources/bytecode/simplifyalgo/SameLeftSide.java +++ /dev/null @@ -1,97 +0,0 @@ -package bytecode.simplifyalgo; - -import static org.junit.Assert.*; - -import java.util.HashMap; -import java.util.HashSet; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.objectweb.asm.Type; - -import de.dhbwstuttgart.bytecode.TPHExtractor; -import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; -import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH; -import de.dhbwstuttgart.bytecode.utilities.Simplify; -import de.dhbwstuttgart.typedeployment.TypeInsertPlacer; - -/** -* -* @author Fayez Abu Alia -* -*/ -public class SameLeftSide { - // Typeplaceholders können nicht definiert werden, da die Konstruktor - // private ist => Test geht nicht - private static TPHExtractor tphExtractor; - private static String methName; - private static String methName2; - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - tphExtractor = new TPHExtractor(); - // A < B - TPHConstraint c1 = new ExtendsConstraint("A", "B", Relation.EXTENDS); - // A < C - TPHConstraint c2 = new ExtendsConstraint("A", "C", Relation.EXTENDS); - // B < D - TPHConstraint c3 = new ExtendsConstraint("B", "D", Relation.EXTENDS); - // C < E - TPHConstraint c4 = new ExtendsConstraint("C", "E", Relation.EXTENDS); - // name - methName = "m1"; - MethodAndTPH m1 = new MethodAndTPH("m1"); - - methName2 = "m2"; - MethodAndTPH m2 = new MethodAndTPH("m2"); - - m1.getTphs().add("A"); - m1.getTphs().add("B"); - m1.getTphs().add("D"); - - m2.getTphs().add("C"); - m2.getTphs().add("E"); - - tphExtractor.ListOfMethodsAndTph.add(m1); - tphExtractor.ListOfMethodsAndTph.add(m2); - - tphExtractor.allCons.add(c1); - tphExtractor.allCons.add(c2); - tphExtractor.allCons.add(c3); - tphExtractor.allCons.add(c4); - } - - @Test - public void testM1() { - HashMap> result = new HashMap<>(); - - TPHConstraint d = new ExtendsConstraint("D", Type.getInternalName(Object.class), Relation.EXTENDS); - TPHConstraint a = new ExtendsConstraint("A", "D", Relation.EXTENDS); - TPHConstraint b = new ExtendsConstraint("B", "D", Relation.EXTENDS); - result.put(d, null); - result.put(a, null); - result.put(b, null); - - HashMap> sim = Simplify.simplifyConstraints(methName, tphExtractor); - boolean areEquals = SimpleCycle.areMapsEqual(result, sim); - assertTrue(areEquals); - } - - @Test - public void testM2() { - HashMap> result = new HashMap<>(); - - TPHConstraint e = new ExtendsConstraint("E", Type.getInternalName(Object.class), Relation.EXTENDS); - TPHConstraint c = new ExtendsConstraint("C", "E", Relation.EXTENDS); - - result.put(e, null); - result.put(c, null); - - HashMap> sim = Simplify.simplifyConstraints(methName2, tphExtractor); - boolean areEquals = SimpleCycle.areMapsEqual(result, sim); - assertTrue(areEquals); - } - -} diff --git a/src/test/resources/bytecode/simplifyalgo/SimpleCycle.java b/src/test/resources/bytecode/simplifyalgo/SimpleCycle.java deleted file mode 100644 index 636eb026..00000000 --- a/src/test/resources/bytecode/simplifyalgo/SimpleCycle.java +++ /dev/null @@ -1,79 +0,0 @@ -package bytecode.simplifyalgo; - -import static org.junit.Assert.*; - -import java.util.HashMap; -import java.util.HashSet; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.objectweb.asm.Type; - -import de.dhbwstuttgart.bytecode.TPHExtractor; -import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; -import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; -import de.dhbwstuttgart.bytecode.utilities.Simplify; -/** - * - * @author Fayez Abu Alia - * - */ -public class SimpleCycle { - private static TPHExtractor tphExtractor; - private static String methName; - @BeforeClass - public static void setUpBeforeClass() throws Exception { - tphExtractor = new TPHExtractor(); - // A < B - TPHConstraint c1 = new ExtendsConstraint("A", "B", Relation.EXTENDS); - // B < A - TPHConstraint c2 = new ExtendsConstraint("B", "A", Relation.EXTENDS); - // name - methName = "m"; - tphExtractor.allCons.add(c1); - tphExtractor.allCons.add(c2); - - } - - @Test - public void test() { - HashMap> result = new HashMap<>(); - HashSet equals = new HashSet<>(); - equals.add("A"); - equals.add("B"); - TPHConstraint k = new ExtendsConstraint("B", Type.getInternalName(Object.class), Relation.EXTENDS); - result.put(k, equals); - - HashMap> sim = Simplify.simplifyConstraints(methName, tphExtractor); - boolean areEquals = areMapsEqual(result, sim); - assertTrue(areEquals); - } - - public static boolean areMapsEqual(HashMap> m1, HashMap> m2) { - - for(TPHConstraint c : m1.keySet()) { - for(TPHConstraint c2 : m2.keySet()) { - if(c.getLeft().equals(c2.getLeft()) && c.getRight().equals(c2.getRight()) && c.getRel()==c2.getRel()) { - HashSet eq1 = m1.get(c); - HashSet eq2 = m2.get(c2); - - if((eq1 == null && eq2 != null) || (eq1 != null && eq2 == null)) - return false; - if(eq1 != null) { - if(eq1.size() != eq2.size()) - return false; - - for(String tph:eq1) { - if(!eq2.contains(tph)) - return false; - } - } - } - } - - } - return true; - } - -} diff --git a/src/test/resources/javFiles/Faculty.jav b/src/test/resources/javFiles/Faculty.jav index ca539add..71f40515 100644 --- a/src/test/resources/javFiles/Faculty.jav +++ b/src/test/resources/javFiles/Faculty.jav @@ -5,7 +5,7 @@ class Faculty { Integer mul(Integer x, Integer y) { return x; } - + m () { var fact = (Integer x) -> { return mul(x, fact.apply(x)); diff --git a/src/test/resources/javFiles/bytecode/AssignToLit.jav b/src/test/resources/javFiles/bytecode/AssignToLit.jav deleted file mode 100644 index 873828ed..00000000 --- a/src/test/resources/javFiles/bytecode/AssignToLit.jav +++ /dev/null @@ -1,30 +0,0 @@ -import java.lang.Integer; -import java.lang.Boolean; -import java.lang.String; -import java.lang.Byte; -import java.lang.Short; -import java.lang.Long; -import java.lang.Float; -import java.lang.Double; -import java.lang.Character; - -class AssignToLit { - void m(){ -// String s = "Test"; -// Boolean b = false; -// Byte byte1 = 5; -// Byte byte2 = 55; -// Short short1 = 5; -// Short short2 = 55; -// Integer int1 = 5; -// Integer int2 = 8888888; -// Long long1 = 1; -// Long long2 = 5; -// Long long3 = 89989898; -// Float float1 = 1; -// Float float2 = 55; -// Double d1 = 1; -// Double d2 = 55; - Character c = 'A'; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/BinaryInMeth.jav b/src/test/resources/javFiles/bytecode/BinaryInMeth.jav deleted file mode 100644 index 3b5fa77b..00000000 --- a/src/test/resources/javFiles/bytecode/BinaryInMeth.jav +++ /dev/null @@ -1,17 +0,0 @@ -import java.lang.Integer; -import java.lang.Double; - -public class BinaryInMeth { - - m(a){ - return ++a; - } - - m2(a,b){ - return m(a+b); - } - - m3(a) { - return m(++a); - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/DuMethod.jav b/src/test/resources/javFiles/bytecode/DuMethod.jav deleted file mode 100644 index 3898a7ba..00000000 --- a/src/test/resources/javFiles/bytecode/DuMethod.jav +++ /dev/null @@ -1,11 +0,0 @@ -public class DuMethod{ - - method(a){ - return a+a; - } - - method(a){ - return a; - } - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/EmptyMethod.jav b/src/test/resources/javFiles/bytecode/EmptyMethod.jav deleted file mode 100644 index 961989df..00000000 --- a/src/test/resources/javFiles/bytecode/EmptyMethod.jav +++ /dev/null @@ -1,8 +0,0 @@ -public class EmptyMethod{ - - public void m1(){ - System.out.println("test"); - } - - public void m2(){} -} diff --git a/src/test/resources/javFiles/bytecode/Example.jav b/src/test/resources/javFiles/bytecode/Example.jav deleted file mode 100644 index b7455a3f..00000000 --- a/src/test/resources/javFiles/bytecode/Example.jav +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.String; - -public class Example { - - public m() { - String x = "X"; - return x; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Exceptions.jav b/src/test/resources/javFiles/bytecode/Exceptions.jav deleted file mode 100644 index 9903511c..00000000 --- a/src/test/resources/javFiles/bytecode/Exceptions.jav +++ /dev/null @@ -1,3 +0,0 @@ -public class Exceptions { -// m(Integer i) throws -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Fac.jav b/src/test/resources/javFiles/bytecode/Fac.jav deleted file mode 100644 index 28650b45..00000000 --- a/src/test/resources/javFiles/bytecode/Fac.jav +++ /dev/null @@ -1,15 +0,0 @@ -import java.lang.Integer; -//import java.lang.Double; - -public class Fac { - - getFac(n){ - var res = 1; - var i = 1; - while(i<=n) { - res = res * i; - i++; - } - return res; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Faculty.jav b/src/test/resources/javFiles/bytecode/Faculty.jav deleted file mode 100644 index 2754b7f8..00000000 --- a/src/test/resources/javFiles/bytecode/Faculty.jav +++ /dev/null @@ -1,48 +0,0 @@ -import java.lang.Integer; - -public class Faculty { - public fact; - Faculty() { - fact = (x) -> { - if (x == 1) { - return 1; - } - else { - return x * (fact.apply(x-1)); - } - }; - } - - - public getFact(x) { - return fact.apply(x); - } -// m (x) { -// -//// var fact = (x) -> { -//// if (x == 1) { -//// return x; -//// } -//// else { -//// return x * (fact.apply(x-1)); -//// } -//// }; -//// return fact; -//// var x = 13; -//// if(x>22) { -//// return 0; -//// }else if(x <1){ -//// return x; -//// }else { -//// return 1; -//// } -// -// if (x < 0) { -// return 0; -// }else if(x<2) { -// return x; -// } else { -// return x * m(x-1); -// } -// } -} diff --git a/src/test/resources/javFiles/bytecode/Faculty2.jav b/src/test/resources/javFiles/bytecode/Faculty2.jav deleted file mode 100644 index 828f06f5..00000000 --- a/src/test/resources/javFiles/bytecode/Faculty2.jav +++ /dev/null @@ -1,10 +0,0 @@ -class Faculty2 { - - m () { - - var fact = (Integer x) -> { - return x; - }; - return fact; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Field.jav b/src/test/resources/javFiles/bytecode/Field.jav deleted file mode 100644 index b19b2308..00000000 --- a/src/test/resources/javFiles/bytecode/Field.jav +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.Integer; - -public class Field { - public Integer x = 5; - - m(){ - return x; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/For.jav b/src/test/resources/javFiles/bytecode/For.jav deleted file mode 100644 index c4bd6677..00000000 --- a/src/test/resources/javFiles/bytecode/For.jav +++ /dev/null @@ -1,30 +0,0 @@ -import java.lang.Integer; -import java.lang.Boolean; - -class For{ - Integer m(Integer x){ - var c = x + 2; -// Boolean b = true; -// c = 5; -// c++; -// ++c; -// c--; -// --c; -// while(x<2){ -// x = x +1; -// b = false; -// } - return c; -// for(int i = 0;i<10;i++) { -// x = x + 5; -// } - } - -// m2(Integer x){ -// if(x<2) { -// return 1; -// }else { -// return 2; -// } -// } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/FunOL.jav b/src/test/resources/javFiles/bytecode/FunOL.jav deleted file mode 100644 index 60736e1f..00000000 --- a/src/test/resources/javFiles/bytecode/FunOL.jav +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Vector; -import java.lang.Integer; -import java.lang.String; -//import java.lang.Byte; -//import java.lang.Boolean; - -public class FunOL { - - add(f, y) { - return f.apply() + y; - } -} diff --git a/src/test/resources/javFiles/bytecode/Gen.jav b/src/test/resources/javFiles/bytecode/Gen.jav deleted file mode 100644 index 3b58b188..00000000 --- a/src/test/resources/javFiles/bytecode/Gen.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.lang.Integer; -import java.util.Vector; - -public class Gen{ - Vector m(Vector v){ - return v; - } -} diff --git a/src/test/resources/javFiles/bytecode/Generics.jav b/src/test/resources/javFiles/bytecode/Generics.jav deleted file mode 100644 index bb7b2af5..00000000 --- a/src/test/resources/javFiles/bytecode/Generics.jav +++ /dev/null @@ -1,17 +0,0 @@ - -class Generics { - Generics(B b){ - } - B mt1(B b){ - return mt1(b); - } -} - - -/* -Problem: -auto test = new List(); -auto test2 = new List(); -... //code, welcher möglicherweise test und test2 vertauscht -test.add("hallo"); -*/ \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Generics2.jav b/src/test/resources/javFiles/bytecode/Generics2.jav deleted file mode 100644 index 52d5caa2..00000000 --- a/src/test/resources/javFiles/bytecode/Generics2.jav +++ /dev/null @@ -1,6 +0,0 @@ -class Generics2{ - B m1(B b){ - return b; - } - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/GreaterEqual.jav b/src/test/resources/javFiles/bytecode/GreaterEqual.jav deleted file mode 100644 index 3ec69e8a..00000000 --- a/src/test/resources/javFiles/bytecode/GreaterEqual.jav +++ /dev/null @@ -1,57 +0,0 @@ -import java.lang.Integer; -import java.lang.Long; -import java.lang.Float; -import java.lang.Double; - -public class GreaterEqual { - - gE(Integer a, Integer b){ - var c = a>=b; - return c; - } - - gE(Long a, Long b){ - var c = a>=b; - return c; - } - - gE(Float a, Float b){ - var c = a>=b; - return c; - } - - gE(Double a, Double b){ - var c = a>=b; - return c; - } - - gE(Long a, Integer b){ - var c = a>=b; - return c; - } - - gE(Float a, Integer b){ - var c = a>=b; - return c; - } - - gE(Double a, Integer b){ - var c = a>=b; - return c; - } - - gE(Float a, Long b){ - var c = a>=b; - return c; - } - - gE(Double a, Long b){ - var c = a>=b; - return c; - } - - gE(Double a, Float b){ - var c = a>=b; - return c; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/GreaterThan.jav b/src/test/resources/javFiles/bytecode/GreaterThan.jav deleted file mode 100644 index 9077f5b1..00000000 --- a/src/test/resources/javFiles/bytecode/GreaterThan.jav +++ /dev/null @@ -1,56 +0,0 @@ -import java.lang.Integer; -import java.lang.Long; -import java.lang.Float; -import java.lang.Double; - -public class GreaterThan { - gT(Integer a, Integer b){ - var c = a>b; - return c; - } - - gT(Long a, Long b){ - var c = a>b; - return c; - } - - gT(Float a, Float b){ - var c = a>b; - return c; - } - - gT(Double a, Double b){ - var c = a>b; - return c; - } - - gT(Long a, Integer b){ - var c = a>b; - return c; - } - - gT(Float a, Integer b){ - var c = a>b; - return c; - } - - gT(Double a, Integer b){ - var c = a>b; - return c; - } - - gT(Float a, Long b){ - var c = a>b; - return c; - } - - gT(Double a, Long b){ - var c = a>b; - return c; - } - - gT(Double a, Float b){ - var c = a>b; - return c; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/IfTest.jav b/src/test/resources/javFiles/bytecode/IfTest.jav deleted file mode 100644 index bbcda96c..00000000 --- a/src/test/resources/javFiles/bytecode/IfTest.jav +++ /dev/null @@ -1,15 +0,0 @@ -import java.lang.Integer; -import java.lang.Boolean; -import java.lang.String; - -public class IfTest{ - Integer m1(Boolean b) { - Integer i; - String b; - if(b) { - return i; - }else{ - return b; - } - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Import.jav b/src/test/resources/javFiles/bytecode/Import.jav deleted file mode 100644 index c658568f..00000000 --- a/src/test/resources/javFiles/bytecode/Import.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.Vector; - -class Import { - void methode(){ - Vector v = new Vector<>(); - v.add("X"); - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Interface1.jav b/src/test/resources/javFiles/bytecode/Interface1.jav deleted file mode 100644 index b741819c..00000000 --- a/src/test/resources/javFiles/bytecode/Interface1.jav +++ /dev/null @@ -1,3 +0,0 @@ -public interface Interface1{ - public void test(); -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/LamRunnable.jav b/src/test/resources/javFiles/bytecode/LamRunnable.jav deleted file mode 100644 index 451858f2..00000000 --- a/src/test/resources/javFiles/bytecode/LamRunnable.jav +++ /dev/null @@ -1,9 +0,0 @@ -public class LamRunnable{ - - public LamRunnable(){ - - Runnable lam = () -> {System.out.println("lambda");}; - lam.run(); - } -} - \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Lambda.jav b/src/test/resources/javFiles/bytecode/Lambda.jav deleted file mode 100644 index b0321fc2..00000000 --- a/src/test/resources/javFiles/bytecode/Lambda.jav +++ /dev/null @@ -1,10 +0,0 @@ -import java.lang.Integer; - -public class Lambda { - - m () { - var lam1 = (x) -> { - return x; - }; - return lam1; -} diff --git a/src/test/resources/javFiles/bytecode/Lambda2.jav b/src/test/resources/javFiles/bytecode/Lambda2.jav deleted file mode 100644 index 92f32b71..00000000 --- a/src/test/resources/javFiles/bytecode/Lambda2.jav +++ /dev/null @@ -1,35 +0,0 @@ -import java.lang.String; - -public class Lambda2 -{ - public static void main(List args){ - var listOfStrings = new List(); - var listOfObjects; - listOfObjects = map(listOfStrings, (a) -> a); -} - -public map(a , b){ - b.apply(a); - return a; -} - -/* -public static List map(List input, Function func) { - List output; - output = new List(); - output.add(func.apply(input.get())); - return output; -} -*/ -} - -class List{ - /* A get(); - void add(A); - */ -} -/* -class Function{ - B apply(A a); -} -*/ \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Lambda3.jav b/src/test/resources/javFiles/bytecode/Lambda3.jav deleted file mode 100644 index 9c4e960c..00000000 --- a/src/test/resources/javFiles/bytecode/Lambda3.jav +++ /dev/null @@ -1,23 +0,0 @@ - -public class Lambda2 -{ - /* - public static List map(List input, - Function func){ - input.add(func.apply(input.get())); - } - */ - public map(input,func){ - input.add(func.apply(input.get())); - return map(new List(), func); - } -} - -class List{ - A get(); - void add(A); -} - -class Function{ - B apply(A a); -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Lambda4.jav b/src/test/resources/javFiles/bytecode/Lambda4.jav deleted file mode 100644 index 378eb4d3..00000000 --- a/src/test/resources/javFiles/bytecode/Lambda4.jav +++ /dev/null @@ -1,18 +0,0 @@ -class Lambda{ - -methode(){ - return ((f) -> f); -} -} -/* -interface Fun0{ - A apply(); -} - -interface Fun1{ - A apply(B b); -} -*/ -interface Fun2{ - A apply(B b, C c); -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/LambdaCapture.jav b/src/test/resources/javFiles/bytecode/LambdaCapture.jav deleted file mode 100644 index ab1751f4..00000000 --- a/src/test/resources/javFiles/bytecode/LambdaCapture.jav +++ /dev/null @@ -1,12 +0,0 @@ -import java.lang.Integer; -public class LambdaCapture { - Integer i = 8; - f; - public LambdaCapture(){ - Integer w = 7; - f = j ->{ - return w+i;}; - - } - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/LambdaVoid.jav b/src/test/resources/javFiles/bytecode/LambdaVoid.jav deleted file mode 100644 index dc16fcbf..00000000 --- a/src/test/resources/javFiles/bytecode/LambdaVoid.jav +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.Integer; - -public class Lambda { - - m () { - var lam1 = (x) -> { }; - return lam1; - } -} diff --git a/src/test/resources/javFiles/bytecode/LessEqual.jav b/src/test/resources/javFiles/bytecode/LessEqual.jav deleted file mode 100644 index 2e3b7024..00000000 --- a/src/test/resources/javFiles/bytecode/LessEqual.jav +++ /dev/null @@ -1,56 +0,0 @@ -import java.lang.Integer; -import java.lang.Long; -import java.lang.Float; -import java.lang.Double; - -public class LessEqual { - lessEqual(Integer a, Integer b){ - var c = a<=b; - return c; - } - - lessEqual(Long a, Long b){ - var c = a<=b; - return c; - } - - lessEqual(Float a, Float b){ - var c = a<=b; - return c; - } - - lessEqual(Double a, Double b){ - var c = a<=b; - return c; - } - - lessEqual(Long a, Integer b){ - var c = a<=b; - return c; - } - - lessEqual(Float a, Integer b){ - var c = a<=b; - return c; - } - - lessEqual(Double a, Integer b){ - var c = a<=b; - return c; - } - - lessEqual(Float a, Long b){ - var c = a<=b; - return c; - } - - lessEqual(Double a, Long b){ - var c = a<=b; - return c; - } - - lessEqual(Double a, Float b){ - var c = a<=b; - return c; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/LessThan.jav b/src/test/resources/javFiles/bytecode/LessThan.jav deleted file mode 100644 index 04e1e83e..00000000 --- a/src/test/resources/javFiles/bytecode/LessThan.jav +++ /dev/null @@ -1,57 +0,0 @@ -import java.lang.Integer; -import java.lang.Long; -import java.lang.Float; -import java.lang.Double; - -public class LessThan { - - lessThan(Integer a, Integer b){ - var c = a> { - - Matrix () { - } - - Matrix(vv) { - Integer i; - i = 0; - while(i < vv.size()) { -// Boolean a = this.add(vv.elementAt(i)); - this.add(vv.elementAt(i)); - i=i+1; - } - } - - mul(m) { - var ret = new Matrix(); - var i = 0; - while(i < size()) { - var v1 = this.elementAt(i); - var v2 = new Vector(); - var j = 0; - while(j < v1.size()) { - var erg = 0; - var k = 0; - while(k < v1.size()) { - erg = erg + v1.elementAt(k) - * m.elementAt(k).elementAt(j); - k++; } -// v2.addElement(new Integer(erg)); - v2.addElement(erg); - j++; } - ret.addElement(v2); - i++; - } - return ret; - } -} diff --git a/src/test/resources/javFiles/bytecode/MatrixOP.jav b/src/test/resources/javFiles/bytecode/MatrixOP.jav deleted file mode 100644 index 828a270b..00000000 --- a/src/test/resources/javFiles/bytecode/MatrixOP.jav +++ /dev/null @@ -1,43 +0,0 @@ -import java.util.Vector; -import java.lang.Integer; -//import java.lang.Byte; -import java.lang.Boolean; - -public class MatrixOP extends Vector> { - - MatrixOP () { - } - - MatrixOP(vv) { - Integer i; - i = 0; - while(i < vv.size()) { -// Boolean a = this.add(vv.elementAt(i)); - this.add(vv.elementAt(i)); - i=i+1; - } - } - - mul = (m1, m2) -> { - var ret = new MatrixOP(); - var i = 0; - while(i < size()) { - var v1 = m1.elementAt(i); - var v2 = new Vector(); - var j = 0; - while(j < v1.size()) { - var erg = 0; - var k = 0; - while(k < v1.size()) { - erg = erg + v1.elementAt(k) - * m2.elementAt(k).elementAt(j); - k++; } -// v2.addElement(new Integer(erg)); - v2.addElement(erg); - j++; } - ret.addElement(v2); - i++; - } - return ret; - }; -} diff --git a/src/test/resources/javFiles/bytecode/Merge.jav b/src/test/resources/javFiles/bytecode/Merge.jav deleted file mode 100644 index 9240146e..00000000 --- a/src/test/resources/javFiles/bytecode/Merge.jav +++ /dev/null @@ -1,20 +0,0 @@ -import java.util.List; -import java.lang.Integer; -import java.util.Collection; - -class Merge { - - merge(a, b) { - a.addAll(b); - return a; - } - - - - sort(in){ - var firstHalf = in.subList(1,2); - var secondHalf = in.subList(1,2); - return merge(sort(firstHalf), sort(secondHalf)); - } - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Methods.jav b/src/test/resources/javFiles/bytecode/Methods.jav deleted file mode 100644 index 3c46739d..00000000 --- a/src/test/resources/javFiles/bytecode/Methods.jav +++ /dev/null @@ -1,14 +0,0 @@ -import java.lang.Integer; - -class Methods { - - m(a,b){ - var c=a+b; - return c; - } - - method2(x){ - Integer i = this.m(x,2); - return i; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/OL.jav b/src/test/resources/javFiles/bytecode/OL.jav deleted file mode 100644 index 700e50f0..00000000 --- a/src/test/resources/javFiles/bytecode/OL.jav +++ /dev/null @@ -1,22 +0,0 @@ -import java.lang.String; -import java.lang.Integer; -import java.lang.Double; - - - -public class OL { - - m(x) { return x + x; } - -} - - - -public class OLMain { - - main(x) { - var ol; - ol = new OL(); - return ol.m(x); - } -} diff --git a/src/test/resources/javFiles/bytecode/Op.jav b/src/test/resources/javFiles/bytecode/Op.jav deleted file mode 100644 index 082f48d8..00000000 --- a/src/test/resources/javFiles/bytecode/Op.jav +++ /dev/null @@ -1,16 +0,0 @@ -import java.lang.Integer; -import java.lang.String; -import java.lang.Long; -import java.lang.Float; -import java.lang.Double; -import java.lang.Boolean; -import java.lang.Short; -import java.lang.Byte; - -public class Op { - - m(a, b) { - //var c = a+b; - return a+b; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Op2.jav b/src/test/resources/javFiles/bytecode/Op2.jav deleted file mode 100644 index 9d446eb2..00000000 --- a/src/test/resources/javFiles/bytecode/Op2.jav +++ /dev/null @@ -1,11 +0,0 @@ -import java.lang.Integer; -import java.lang.String; - -public class Op2 { - m(){ - var x = ""; - var a = 5+x; - - return a; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/OverlaodGen.jav b/src/test/resources/javFiles/bytecode/OverlaodGen.jav deleted file mode 100644 index d5946496..00000000 --- a/src/test/resources/javFiles/bytecode/OverlaodGen.jav +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.Vector; - -class OverlaodGen { - void method(Vector v) { -// Integer i = v.get(0); - } - - void method(Vector v) { -// String s = v.get(0); - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Overloading.jav b/src/test/resources/javFiles/bytecode/Overloading.jav deleted file mode 100644 index fb48fe0f..00000000 --- a/src/test/resources/javFiles/bytecode/Overloading.jav +++ /dev/null @@ -1,18 +0,0 @@ -import java.lang.String; - -public class Overloading{ - - test(x){ - return x.methode(); - } - - methode(){ - return "Overloading"; - } -} - -public class Overloading2{ - methode(){ - return "Overloading2"; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Plus.jav b/src/test/resources/javFiles/bytecode/Plus.jav deleted file mode 100644 index 1cdecc8c..00000000 --- a/src/test/resources/javFiles/bytecode/Plus.jav +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.Integer; -import java.lang.String; - -public class Plus { - - m(a,b) { - return a+b; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/PostIncDec.jav b/src/test/resources/javFiles/bytecode/PostIncDec.jav deleted file mode 100644 index 29c2ef17..00000000 --- a/src/test/resources/javFiles/bytecode/PostIncDec.jav +++ /dev/null @@ -1,27 +0,0 @@ -import java.lang.Integer; - -public class PostIncDec { - m() { - var i = 0; - i++; - return i; - } - - m2() { - var i = 0; - var j = i++; - return j; - } - - d() { - var i = 0; - i--; - return i; - } - - d2() { - var i = 0; - var j = i--; - return j; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/PreInc.jav b/src/test/resources/javFiles/bytecode/PreInc.jav deleted file mode 100644 index 011501f1..00000000 --- a/src/test/resources/javFiles/bytecode/PreInc.jav +++ /dev/null @@ -1,28 +0,0 @@ -import java.lang.Integer; - -public class PreInc { - m() { - var i = 0; - ++i; - return i; - } - - m2() { - var i = 0; - var j = ++i; - return j; - } - - d() { - var i = 0; - --i; - return i; - } - - d2() { - var i = 0; - var j = --i; - return j; - } - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/RecursiveMeth.jav b/src/test/resources/javFiles/bytecode/RecursiveMeth.jav deleted file mode 100644 index be35a43c..00000000 --- a/src/test/resources/javFiles/bytecode/RecursiveMeth.jav +++ /dev/null @@ -1,5 +0,0 @@ -public class RecursiveMeth{ - public Integer test(){ - return this.test(); - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/RelOps.jav b/src/test/resources/javFiles/bytecode/RelOps.jav deleted file mode 100644 index 0fdd2cff..00000000 --- a/src/test/resources/javFiles/bytecode/RelOps.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.lang.Integer; -import java.lang.Boolean; - -public class RelOps { - m(a,b){ - return a a){ - a = merge(a,a); - } -*/ -} diff --git a/src/test/resources/javFiles/bytecode/StaticM.jav b/src/test/resources/javFiles/bytecode/StaticM.jav deleted file mode 100644 index 66890033..00000000 --- a/src/test/resources/javFiles/bytecode/StaticM.jav +++ /dev/null @@ -1,10 +0,0 @@ -public class StaticM { - - public static void m() { - System.out.println("Test"); - } - - public static void m2() { - m(); - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/SubMatrix.jav b/src/test/resources/javFiles/bytecode/SubMatrix.jav deleted file mode 100644 index f761321c..00000000 --- a/src/test/resources/javFiles/bytecode/SubMatrix.jav +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.Vector; -import java.lang.Integer; - -public class Matrix2 extends Vector { - -} - -public class SubMatrix extends Matrix2 { - m(){ - Vector v = new Vector(); - v.add(1); - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Tph.jav b/src/test/resources/javFiles/bytecode/Tph.jav deleted file mode 100644 index 4a49ac46..00000000 --- a/src/test/resources/javFiles/bytecode/Tph.jav +++ /dev/null @@ -1,12 +0,0 @@ -public class Tph { - - m(a,b){ - var c = m2(b); -// return a; - return m2(b); - } - - m2(b){ - return b; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Tph2.jav b/src/test/resources/javFiles/bytecode/Tph2.jav deleted file mode 100644 index c957eae6..00000000 --- a/src/test/resources/javFiles/bytecode/Tph2.jav +++ /dev/null @@ -1,10 +0,0 @@ -public class Tph2 { - m(a,b){ - var c = m2(a,b); - return a; - } - - m2(a,b){ - return b; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Tph3.jav b/src/test/resources/javFiles/bytecode/Tph3.jav deleted file mode 100644 index f2bcd2ef..00000000 --- a/src/test/resources/javFiles/bytecode/Tph3.jav +++ /dev/null @@ -1,13 +0,0 @@ -public class Tph3 { -// m(a,b){ -// var c = m2(a,b); -// return c; -// } -// -// m2(a,b){ -// return m(a,b); -// } - m1(x, y) { m2(x); x = y; } - - m2(y) { m1(y, y); } -} diff --git a/src/test/resources/javFiles/bytecode/Tph4.jav b/src/test/resources/javFiles/bytecode/Tph4.jav deleted file mode 100644 index 1eb529de..00000000 --- a/src/test/resources/javFiles/bytecode/Tph4.jav +++ /dev/null @@ -1,12 +0,0 @@ -public class Tph4{ - m(a,b){ - var c = m2(b); - var d = m2(c); - return a; - } - - m2(b){ - return b - } - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Tph5.jav b/src/test/resources/javFiles/bytecode/Tph5.jav deleted file mode 100644 index e73cfa2c..00000000 --- a/src/test/resources/javFiles/bytecode/Tph5.jav +++ /dev/null @@ -1,13 +0,0 @@ -public class Tph5 { -// m(a,b,c){ -// a = c; -// b = c; -// return a; -// } - - m(x,y){ - x = m2(y); - } - - m2(y) { return y; } -} diff --git a/src/test/resources/javFiles/bytecode/VectorAdd.jav b/src/test/resources/javFiles/bytecode/VectorAdd.jav deleted file mode 100644 index 814f46c2..00000000 --- a/src/test/resources/javFiles/bytecode/VectorAdd.jav +++ /dev/null @@ -1,19 +0,0 @@ -import java.util.Vector; -import java.lang.Integer; -import java.lang.String; -//import java.lang.Byte; -//import java.lang.Boolean; - -public class VectorAdd { - - add(v1, v2) { - var ret = new Vector(); - var i = 0; - var erg; - while(i < v1.size()) { - erg = v1.elementAt(i) + v2.elementAt(i); - ret.addElement(erg); - } - return ret; - } -} diff --git a/src/test/resources/javFiles/bytecode/VoidMeth.jav b/src/test/resources/javFiles/bytecode/VoidMeth.jav deleted file mode 100644 index 6b3ab212..00000000 --- a/src/test/resources/javFiles/bytecode/VoidMeth.jav +++ /dev/null @@ -1,4 +0,0 @@ -public class VoidMeth{ - public void test(){ - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/WC.jav b/src/test/resources/javFiles/bytecode/WC.jav deleted file mode 100644 index 389a4fcd..00000000 --- a/src/test/resources/javFiles/bytecode/WC.jav +++ /dev/null @@ -1,8 +0,0 @@ -import java.lang.Integer; -import java.util.List; -public class WC { - - void m (List a, List b) { - - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/While.jav b/src/test/resources/javFiles/bytecode/While.jav deleted file mode 100644 index cd2139a6..00000000 --- a/src/test/resources/javFiles/bytecode/While.jav +++ /dev/null @@ -1,12 +0,0 @@ -import java.lang.Integer; -import java.lang.Long; -import java.lang.Double; - -public class While { - m(x) { - while(x < 2) { - x = x+1; - } - return x; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/Y.jav b/src/test/resources/javFiles/bytecode/Y.jav deleted file mode 100644 index 3c3e204d..00000000 --- a/src/test/resources/javFiles/bytecode/Y.jav +++ /dev/null @@ -1,28 +0,0 @@ -import java.lang.Integer; - -class Y { - y; - //factorial; - - Y() { - y = f -> t -> f.apply(y.apply(f)).apply(t); - //factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); }); - } -} - -/* -ergibt Parse-Error -class fac1 { - factorial; - - fac1() { - var y; - y = new Y<>().y; - factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); }); - } - public static void main(String args[]) { - System.out.println(new fac1().factorial.apply(3)); - } - -} -*/ \ No newline at end of file diff --git a/src/test/resources/javFiles/bytecode/applyLambda.jav b/src/test/resources/javFiles/bytecode/applyLambda.jav deleted file mode 100644 index 331bfbfe..00000000 --- a/src/test/resources/javFiles/bytecode/applyLambda.jav +++ /dev/null @@ -1,16 +0,0 @@ -import java.util.Vector; -class Apply { } - -public class applyLambda { - - m () { - var lam1 = (x) -> { - return x; - }; - - return lam1.apply(new Apply()); - //return lam1; - //return new Vector(); - } -} - diff --git a/src/test/resources/javFiles/parser/AntlrTest.jav b/src/test/resources/javFiles/parser/AntlrTest.jav deleted file mode 100644 index 31ab067d..00000000 --- a/src/test/resources/javFiles/parser/AntlrTest.jav +++ /dev/null @@ -1,6 +0,0 @@ -class Test{ -method(){ - if(true)i++; - if(true)i--; - else i++; -}} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/BoundedParameter.jav b/src/test/resources/javFiles/parser/BoundedParameter.jav deleted file mode 100644 index 6d7518a9..00000000 --- a/src/test/resources/javFiles/parser/BoundedParameter.jav +++ /dev/null @@ -1,3 +0,0 @@ -class Matrix{ - String op = "String"; -} diff --git a/src/test/resources/javFiles/parser/CastTest.jav b/src/test/resources/javFiles/parser/CastTest.jav deleted file mode 100644 index 86ca7519..00000000 --- a/src/test/resources/javFiles/parser/CastTest.jav +++ /dev/null @@ -1,8 +0,0 @@ - -class CastTest{ -void methode(){ - Object a; - String b; - a = (Object) b; -} -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/ExtendsTest.jav b/src/test/resources/javFiles/parser/ExtendsTest.jav deleted file mode 100644 index 9103f463..00000000 --- a/src/test/resources/javFiles/parser/ExtendsTest.jav +++ /dev/null @@ -1,4 +0,0 @@ -class C1 extends Object -{ - m(para) { return para; } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/FeatherWeightJava.jav b/src/test/resources/javFiles/parser/FeatherWeightJava.jav deleted file mode 100644 index e607b12a..00000000 --- a/src/test/resources/javFiles/parser/FeatherWeightJava.jav +++ /dev/null @@ -1,11 +0,0 @@ - -class FeatherWeightJava { - mt4(a,b,c) { return a.add(b).sub(c) ; } - - mt1(a) {return a; } - - mt2(a) {return a.f; } - - mt3(a) {return a.add(); } -} - diff --git a/src/test/resources/javFiles/parser/FieldInitializationTest.jav b/src/test/resources/javFiles/parser/FieldInitializationTest.jav deleted file mode 100644 index f7818cc3..00000000 --- a/src/test/resources/javFiles/parser/FieldInitializationTest.jav +++ /dev/null @@ -1,3 +0,0 @@ -class FieldInitializationTest{ - var var = "hallo"; -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/FieldVarTest.jav b/src/test/resources/javFiles/parser/FieldVarTest.jav deleted file mode 100644 index 6e897824..00000000 --- a/src/test/resources/javFiles/parser/FieldVarTest.jav +++ /dev/null @@ -1,5 +0,0 @@ -package test; - -class Test{ -Typ a; -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/GenericFieldVarTest.jav b/src/test/resources/javFiles/parser/GenericFieldVarTest.jav deleted file mode 100644 index a47b41eb..00000000 --- a/src/test/resources/javFiles/parser/GenericFieldVarTest.jav +++ /dev/null @@ -1,3 +0,0 @@ -class Test{ - A var; -} diff --git a/src/test/resources/javFiles/parser/ImportTest.jav b/src/test/resources/javFiles/parser/ImportTest.jav deleted file mode 100644 index 2de55cee..00000000 --- a/src/test/resources/javFiles/parser/ImportTest.jav +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.*; - -class ImportTest{ -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/ImportTest2.jav b/src/test/resources/javFiles/parser/ImportTest2.jav deleted file mode 100644 index 3492e31c..00000000 --- a/src/test/resources/javFiles/parser/ImportTest2.jav +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.ArrayList; - -class ImportTest{ -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/ImportTestGeneric.jav b/src/test/resources/javFiles/parser/ImportTestGeneric.jav deleted file mode 100644 index 094f4c5e..00000000 --- a/src/test/resources/javFiles/parser/ImportTestGeneric.jav +++ /dev/null @@ -1,5 +0,0 @@ -import java.util.List; - -class ImportTest{ - List test; -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/NewTest.jav b/src/test/resources/javFiles/parser/NewTest.jav deleted file mode 100644 index 992a2e8d..00000000 --- a/src/test/resources/javFiles/parser/NewTest.jav +++ /dev/null @@ -1,5 +0,0 @@ - -class NewTest { -main() { return new NewTest<>().mt(new NewTest(1) , new NewTest(2) , new -NewTest(3)); } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/OpratorTest.jav b/src/test/resources/javFiles/parser/OpratorTest.jav deleted file mode 100644 index 2764adf4..00000000 --- a/src/test/resources/javFiles/parser/OpratorTest.jav +++ /dev/null @@ -1,12 +0,0 @@ -import java.lang.Integer; - -class OpratorTest { - m(Integer a, Integer b) { - c = a+b; -// d = a-b; -// e = a*b; -// f = a/b; - - return c; - } -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/PackageNameTest.jav b/src/test/resources/javFiles/parser/PackageNameTest.jav deleted file mode 100644 index 53c889b7..00000000 --- a/src/test/resources/javFiles/parser/PackageNameTest.jav +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.Integer; -import java.lang.Comparable; - -class PackageNameTest{ -java.lang.Integer test(a){return a;} - -Comparable test2(a){return a;} - -} \ No newline at end of file diff --git a/src/test/resources/javFiles/parser/StatementsTest.jav b/src/test/resources/javFiles/parser/StatementsTest.jav deleted file mode 100644 index 891dff12..00000000 --- a/src/test/resources/javFiles/parser/StatementsTest.jav +++ /dev/null @@ -1,8 +0,0 @@ -class Statements{ - -public void methodeTest(){ - methodeTest(); - return null; -} - -} diff --git a/src/test/resources/javFiles/parser/StructuralTypes.jav b/src/test/resources/javFiles/parser/StructuralTypes.jav deleted file mode 100644 index b3c210c8..00000000 --- a/src/test/resources/javFiles/parser/StructuralTypes.jav +++ /dev/null @@ -1,5 +0,0 @@ - -class A { - mt(x, y, z) { return x.sub(y).add(z); } -} - diff --git a/src/test/resources/javFiles/parser/WhileTest.jav b/src/test/resources/javFiles/parser/WhileTest.jav deleted file mode 100644 index 2ce192bd..00000000 --- a/src/test/resources/javFiles/parser/WhileTest.jav +++ /dev/null @@ -1,14 +0,0 @@ -class WhileTest{ - void methode(){ - Boolean test; - do{ - test=test; - }while(test); - - - while(test){ - test = test; - } - return; - } -} \ No newline at end of file diff --git a/src/test/resources/testBytecode/Field.java b/src/test/resources/testBytecode/Field.java deleted file mode 100644 index 50002082..00000000 --- a/src/test/resources/testBytecode/Field.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Field{ - public void m(){ - MethFieldVar mF = new MethFieldVar(); - mF.s1 = "Field S1"; - } -} diff --git a/src/test/resources/testBytecode/Import.java b/src/test/resources/testBytecode/Import.java deleted file mode 100644 index f3519acb..00000000 --- a/src/test/resources/testBytecode/Import.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.Vector; - -class Import { - void methode(){ - Vector v = new Vector(); - v.add(v); - } -} diff --git a/src/test/resources/testBytecode/Lam1.java b/src/test/resources/testBytecode/Lam1.java deleted file mode 100644 index 142feed2..00000000 --- a/src/test/resources/testBytecode/Lam1.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.function.Function; -public class Lam1{ - public Lam1() { - Function fun = (x) -> x+"1"; - fun.apply("2"); - - Runnable lam = () -> System.out.println("lambda"); - lam.run(); - } -} diff --git a/src/test/resources/testBytecode/LamRun.java b/src/test/resources/testBytecode/LamRun.java deleted file mode 100644 index fdaf0852..00000000 --- a/src/test/resources/testBytecode/LamRun.java +++ /dev/null @@ -1,8 +0,0 @@ -public class LamRun{ - - public void mRun(){ - - Runnable lam = () -> System.out.println("lambda"); - lam.run(); - } -} diff --git a/src/test/resources/testBytecode/MethFieldVar.java b/src/test/resources/testBytecode/MethFieldVar.java deleted file mode 100644 index 74086a01..00000000 --- a/src/test/resources/testBytecode/MethFieldVar.java +++ /dev/null @@ -1,38 +0,0 @@ -public class MethFieldVar{ - String s1;// = ""; - String s2; - -/* public void meth(Integer i, String j, Boolean b){ - //String local = "a"; - //int localL = local.length(); - //int l = s.length(); - String s = null; - //s = ""; - //return s.length();//l+localL; - } -*/ - public void mm(){ -// return "mm"; - } - public void m2(){ - System.out.println(""); - // Math.abs(1); - // String lV = "local"; - // s1 = "1"; - // s1.concat("2"); - s2 = s1; - - mm(); - - Clazz i = new Clazz(); - - Runnable lam = ()->{ - String test = ""; - String b = "b"; - test = b; - System.out.println(test); - }; - } -} - -class Clazz{} diff --git a/src/test/resources/testBytecode/Subclass.java b/src/test/resources/testBytecode/Subclass.java deleted file mode 100644 index 3e8b5853..00000000 --- a/src/test/resources/testBytecode/Subclass.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Subclass extends Superclass { - - public void printMethod() { - super.printMethod(); - } -} diff --git a/src/test/resources/testBytecode/SuperTest.java b/src/test/resources/testBytecode/SuperTest.java deleted file mode 100644 index 1b6ac268..00000000 --- a/src/test/resources/testBytecode/SuperTest.java +++ /dev/null @@ -1,14 +0,0 @@ -public class Superclass { - - public void printMethod() { - System.out.println("Printed in Superclass."); - } -} - -public class Subclass extends Superclass { - - public void printMethod() { - super.printMethod(); - - } -} diff --git a/src/test/resources/testBytecode/Superclass.java b/src/test/resources/testBytecode/Superclass.java deleted file mode 100644 index d58089de..00000000 --- a/src/test/resources/testBytecode/Superclass.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Superclass { - - public void printMethod() { - System.out.println("Printed in Superclass."); - } -} diff --git a/src/test/resources/testBytecode/TestMyTest.java b/src/test/resources/testBytecode/TestMyTest.java deleted file mode 100644 index e1305f76..00000000 --- a/src/test/resources/testBytecode/TestMyTest.java +++ /dev/null @@ -1,11 +0,0 @@ -class TestMyTest{ -public static void main(String[] a){ - //test1 - //new TestClass(); - //test if statement - //new TestIf(new Boolean(true)); - // test lambda - //new TestClass(); - new LamRun(); -} -} diff --git a/src/test/resources/testBytecode/testF.java b/src/test/resources/testBytecode/testF.java deleted file mode 100644 index fa4a50b7..00000000 --- a/src/test/resources/testBytecode/testF.java +++ /dev/null @@ -1,5 +0,0 @@ -public class testTets(){ - public static void main(String[] args){ - new tetsF(); - } -} diff --git a/src/test/resources/testBytecode/testTets.java b/src/test/resources/testBytecode/testTets.java deleted file mode 100644 index 4f95cbc0..00000000 --- a/src/test/resources/testBytecode/testTets.java +++ /dev/null @@ -1,5 +0,0 @@ -public class testTets{ - public static void main(String[] args){ - new TetsF(); - } -} diff --git a/src/test/resources/testBytecode/testTetsF.java b/src/test/resources/testBytecode/testTetsF.java deleted file mode 100644 index fa4a50b7..00000000 --- a/src/test/resources/testBytecode/testTetsF.java +++ /dev/null @@ -1,5 +0,0 @@ -public class testTets(){ - public static void main(String[] args){ - new tetsF(); - } -}