diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..905ecb00 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/JavaCompilerCore.iml b/JavaCompilerCore.iml new file mode 100644 index 00000000..cb1e6970 --- /dev/null +++ b/JavaCompilerCore.iml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/commons-bcel6-6.0-SNAPSHOT.jar b/lib/commons-bcel6-6.0-SNAPSHOT.jar index 1dab98d7..13725c50 100644 Binary files a/lib/commons-bcel6-6.0-SNAPSHOT.jar and b/lib/commons-bcel6-6.0-SNAPSHOT.jar differ diff --git a/src/de/dhbwstuttgart/bytecode/MethodGenerator.java b/src/de/dhbwstuttgart/bytecode/MethodGenerator.java index 88add712..effb63e2 100644 --- a/src/de/dhbwstuttgart/bytecode/MethodGenerator.java +++ b/src/de/dhbwstuttgart/bytecode/MethodGenerator.java @@ -70,7 +70,8 @@ public class MethodGenerator extends MethodGen{ il.append(factory.createReturn( org.apache.commons.bcel6.generic.Type.VOID)); } } - + + method.getInstructionList().setPositions(); method.stripAttributes(true); method.setMaxStack(); //Die Stack Größe automatisch berechnen lassen (erst nach dem alle Instructions angehängt wurden) method.setMaxLocals(); diff --git a/test/KomplexeMenge/KeineDoppeltenVerweise.java b/test/KomplexeMenge/KeineDoppeltenVerweise.java index 43eea37c..606783f8 100644 --- a/test/KomplexeMenge/KeineDoppeltenVerweise.java +++ b/test/KomplexeMenge/KeineDoppeltenVerweise.java @@ -2,6 +2,7 @@ package KomplexeMenge; import static org.junit.Assert.*; +import java.util.Set; import java.util.Vector; import org.junit.Test; @@ -36,7 +37,7 @@ class TestKlasseOderMenge extends OderMenge{ } public void addItem(TestKlasse string) { - TestUndMenge toAdd = new TestKlasseUndMenge(); + TestKlasseUndMenge toAdd = new TestKlasseUndMenge(); toAdd.addItem(string); set.add(toAdd); } @@ -61,24 +62,28 @@ class TestKlasseUndMenge extends UndMenge{ } } +/** + * @Depreciated + * Tests möglicherweise obsolet + */ public class KeineDoppeltenVerweise { @Test public void test() { - OderMenge oM1 = new TestOderMenge(); - OderMenge oM2 = new OderMenge<>(); - UndMenge oM3 = new UndMenge<>(); + TestKlasseOderMenge oM1 = new TestKlasseOderMenge(); + TestKlasseOderMenge oM2 = new TestKlasseOderMenge(); + TestKlasseUndMenge oM3 = new TestKlasseUndMenge(); oM1.addItem(new TestKlasse("Menge 1, Item 1")); oM1.addItem(new TestKlasse("Menge 1, Item 2")); oM2.addItem(new TestKlasse("Menge 2, Item 1")); oM2.addItem(new TestKlasse("Menge 2, Item 2")); oM3.addItems(oM1); oM3.addItems(oM2); - Menge> cP = oM3.cartesianProduct(); + Set> cP = oM3.cartesianProduct(); System.out.println(cP); - cP.firstElement().firstElement().name="neu"; + cP.iterator().next().iterator().next().name="neu"; System.out.println(cP); - check(cP); + //check(cP); //TODO Muss neu implementiert werden } private void check(Menge> cP){ diff --git a/test/bytecode/IfTest.java b/test/bytecode/IfTest.java deleted file mode 100644 index 1c2c1464..00000000 --- a/test/bytecode/IfTest.java +++ /dev/null @@ -1,9 +0,0 @@ -class IfTest{ - -public static void main(String[] args){ - - System.out.println(new IfElseStatement().method(true)); - System.out.println(new IfElseStatement().method(false)); -} - -} diff --git a/test/bytecode/SourceFileBytecodeTest.java b/test/bytecode/SourceFileBytecodeTest.java index 8e1245ba..3cf8ce2a 100644 --- a/test/bytecode/SourceFileBytecodeTest.java +++ b/test/bytecode/SourceFileBytecodeTest.java @@ -21,6 +21,7 @@ public abstract class SourceFileBytecodeTest extends TestCase{ protected String testName; public SourceFileBytecodeTest(){ + super("Bytecode Test"); init(); if(testName != null){ @@ -29,6 +30,7 @@ public abstract class SourceFileBytecodeTest extends TestCase{ outputDirectory = ""; SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputDirectory); + System.out.println("Test"); }else{ throw new RuntimeException("rootDirectory, testFile or outputFile is null."); } diff --git a/test/bytecode/Test.java b/test/bytecode/Test.java deleted file mode 100644 index cd86d699..00000000 --- a/test/bytecode/Test.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Diese Klasse testet die generierte EmptyClass.class-Datei - */ -class Test{ -public static void main(String[] args){ - new EmptyClass(); - new Assign(); - System.out.println(new Return().method()); - new MethodCall().method(); - System.out.println(new FieldDeclaration().field); - System.out.println(new Runnable().method().apply()); - Runnable r = new Runnable().method().apply(); - Test t = new Identity().op.apply(new Test()); - System.out.println(t); -} -} - -class Test2{ - Fun1 m() { - Fun1 f = new Identity().op; - return f; - } -public static void main(String[] args){ - Matrix2 m2 = new Matrix2<>(); - System.out.println(m2.op.apply((Integer x) -> x)); -} -} diff --git a/test/bytecode/Test2.java b/test/bytecode/Test2.java deleted file mode 100644 index 767f6522..00000000 --- a/test/bytecode/Test2.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test2{ - - public static void main(java.lang.String[] args){ - new NewStatement(1).method(); -} -} diff --git a/test/bytecode/Test3.java b/test/bytecode/Test3.java deleted file mode 100644 index 6bc9a737..00000000 --- a/test/bytecode/Test3.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test3{ - -public static void main(String[] args){ -System.out.println(new LambdaExpr2Test().op.apply()); -} -} diff --git a/test/bytecode/TestStackMap.java b/test/bytecode/TestStackMap.java deleted file mode 100644 index a9931cbe..00000000 --- a/test/bytecode/TestStackMap.java +++ /dev/null @@ -1,8 +0,0 @@ -class TestStackMap{ - -public static void main(String[] args){ - IfElseStatement test = new IfElseStatement(); - System.out.println(test.method(false)); -} - -} diff --git a/test/bytecode/WhileTest.java b/test/bytecode/WhileTest.java index be51a813..dde969ed 100644 --- a/test/bytecode/WhileTest.java +++ b/test/bytecode/WhileTest.java @@ -1,8 +1,14 @@ package bytecode; import org.junit.Test; +import org.junit.runners.Suite; public class WhileTest extends SourceFileBytecodeTest{ + + public WhileTest(){ + super(); + } + @Override protected void init() { testName = "WhileTest"; diff --git a/test/plugindevelopment/InsertSingleTypeTest.java b/test/plugindevelopment/InsertSingleTypeTest.java index ac88cdd9..916f45fc 100644 --- a/test/plugindevelopment/InsertSingleTypeTest.java +++ b/test/plugindevelopment/InsertSingleTypeTest.java @@ -7,6 +7,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; +import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.typeinference.Menge; import org.junit.Test; @@ -43,8 +44,9 @@ public class InsertSingleTypeTest { String inferedSource = ""; MyCompilerAPI compiler = MyCompiler.getAPI(new LoggerConfiguration().setOutput(Section.TYPEINFERENCE, System.out)); try { - compiler.parse(new File(rootDirectory + sourceFileToInfere)); - Menge results = compiler.typeReconstruction(); + SourceFile parsed = compiler.parse(new File(rootDirectory + sourceFileToInfere));Menge sourceFiles = new Menge<>(); + sourceFiles.add(parsed); + Menge results = compiler.typeReconstruction(sourceFiles); TestCase.assertTrue("Es darf nicht mehr als eine L�sungsm�glichkeit geben und nicht "+results.size(), results.size()==1); return results.firstElement(); } catch (IOException | yyException e) { diff --git a/test/plugindevelopment/MartinTestCases/Tester.java b/test/plugindevelopment/MartinTestCases/Tester.java index 66488c7a..d739fd49 100644 --- a/test/plugindevelopment/MartinTestCases/Tester.java +++ b/test/plugindevelopment/MartinTestCases/Tester.java @@ -3,6 +3,7 @@ package plugindevelopment.MartinTestCases; import java.io.File; import java.io.IOException; +import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.typeinference.Menge; import org.junit.Test; @@ -27,8 +28,10 @@ public class Tester extends TypeInsertTester{ String inferedSource = ""; MyCompilerAPI compiler = MyCompiler.getAPI(new LoggerConfiguration().setOutput(Section.TYPEINFERENCE, System.out)); try { - compiler.parse(new File(rootDirectory + sourceFileToInfere)); - Menge results = compiler.typeReconstruction(); + SourceFile parsed = compiler.parse(new File(rootDirectory + sourceFileToInfere)); + Menge sourceFiles = new Menge<>(); + sourceFiles.add(parsed); + Menge results = compiler.typeReconstruction(sourceFiles); //TestCase.assertTrue("Es darf nicht mehr als eine L�sungsm�glichkeit geben und nicht "+results.size(), results.size()==1); for(TypeinferenceResultSet result : results){ TypeInsertSet point = result.getTypeInsertionPoints(); diff --git a/test/plugindevelopment/TypeInsertTester.java b/test/plugindevelopment/TypeInsertTester.java index 25f8676a..6737c6a3 100755 --- a/test/plugindevelopment/TypeInsertTester.java +++ b/test/plugindevelopment/TypeInsertTester.java @@ -8,6 +8,8 @@ import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; + +import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.typeinference.Menge; import de.dhbwstuttgart.logger.Logger; @@ -44,8 +46,10 @@ public class TypeInsertTester{ String inferedSource = ""; MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); try { - compiler.parse(new File(rootDirectory + sourceFileToInfere)); - Menge results = compiler.typeReconstruction(); + SourceFile parsed = compiler.parse(new File(rootDirectory + sourceFileToInfere)); + Menge sourceFiles = new Menge<>(); + sourceFiles.add(parsed); + Menge results = compiler.typeReconstruction(sourceFiles); TestCase.assertTrue("Es darf nicht mehr als eine Lösungsmöglichkeit geben und nicht "+results.size(), results.size()==1); for(TypeinferenceResultSet result : results){ TypeInsertSet point = result.getTypeInsertionPoints();