fixed some tests, cleaned up, etc

This commit is contained in:
JonathanFleischmann 2024-07-02 21:49:53 +02:00
parent a5d13fd2a9
commit cc674625b0
165 changed files with 752 additions and 1130 deletions

View File

@ -34,4 +34,5 @@
- keine Accessmodifier/alles ist public
- logische Statements MÜSSEN geklammert werden, ansonsten wird ununterbrochen von links nach rechts berechnet
(so würde z.B. (true || false == false) false zurückgeben)
- i++ und i-- sind nicht erlaubt, stattdessen i = i + 1 und i = i - 1 bzw i += 1 und i -= 1
- i++ und i-- sind nur in for-Schleifen oder Statements erlaubt, --i und ++i sind generell nicht erlaubt
- ein File kann nur eine Klasse enthalten

View File

@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test;
import java.util.List;
import static HelpFiles.TestFileTester.run;
import static HelpClasses.TestFileTester.run;
import static org.junit.jupiter.api.Assertions.assertThrows;
class AllNegativeTests {

View File

@ -1,148 +0,0 @@
import org.junit.jupiter.api.Test;
import testResources.CodeGen.Features.*;
import static HelpFiles.TestFileTester.run;
class CodegeneratorTests {
// @Test
// void testPublicClass() {
// byte[] resultBytecode = Compiler.generateByteCodeArrayFromTypedAst();
// assertEquals(AbstractSyntax_PublicClass.get(), resultBytecode);
// }
// @Test
// void testMethodCall() {
// assertDoesNotThrow(() -> {
// BytecodeTestUtil testUtility = new BytecodeTestUtil("src/test/testFiles/ASTandTypedASTFeatures/MethodCall.java", "MethodCall");
//
// assertEquals(0, testUtility.invokeMethod("method", null));
// assertEquals(1, testUtility.invokeMethod("method1", new Class<?>[]{int.class}, 1));
// assertEquals(3, testUtility.invokeMethod("method2", new Class<?>[]{int.class, int.class}, 1, 2));
// });
// }
@Test
void runByteCodeBreakTests() {
run(ByteCode_Break.class);
}
@Test
void runByteCodeClassTests() {
run(ByteCode_Class.class);
}
@Test
void runByteCodeClassObjectsTests() {
run(ByteCode_ClassObjects.class);
}
@Test
void runByteCodeCommentTests() {
run(ByteCode_Comment.class);
}
@Test
void runByteCodeCompAssignTests() {
run(ByteCode_CompAssign.class);
}
@Test
void runByteCodeComplexCallsTests() {
run(ByteCode_ComplexCalls.class);
}
@Test
void runByteCodeConstructorTests() {
run(ByteCode_Constructor.class);
}
@Test
void runByteCodeContinueTests() {
run(ByteCode_Continue.class);
}
@Test
void runByteCodeDataTypesTests() {
run(ByteCode_DataTypes.class);
}
@Test
void runByteCodeFieldTests() {
run(ByteCode_Field.class);
}
@Test
void runByteCodeForTests() {
run(ByteCode_For.class);
}
@Test
void runByteCodeIfTests() {
run(ByteCode_If.class);
}
@Test
void runByteCodeLogicExprTests() {
run(ByteCode_LogicExpr.class);
}
@Test
void runByteCodeMainTests() {
run(ByteCode_Main.class);
}
@Test
void runByteCodeMethodTests() {
run(ByteCode_Method.class);
}
@Test
void runByteCodeMethodCallTests() {
run(ByteCode_MethodCall.class);
}
@Test
void runByteCodeMultipleClassesTests() {
run(ByteCode_MultipleClasses.class);
}
@Test
void runByteCodeOperatorsTests() {
run(ByteCode_Operators.class);
}
@Test
void runByteCodeOverloadedTests() {
run(ByteCode_Overloaded.class);
}
@Test
void runByteCodePrintTests() {
run(ByteCode_Print.class);
}
@Test
void runByteCodeReturnTests() {
run(ByteCode_Return.class);
}
@Test
void runByteCodeUnaryTests() {
run(ByteCode_Unary.class);
}
@Test
void runByteCodeVariableDefWithDeclTests() {
run(ByteCode_VariableDefWithDecl.class);
}
@Test
void runByteCodeWhileTests() {
run(ByteCode_While.class);
}
}

View File

@ -1,30 +1,145 @@
public class E2ETests {
char ZZ;
import E2ETests.Features.*;
import org.junit.jupiter.api.Test;
public E2ETests() {
this.ZZ = 'z';
// if (stuff1) {
// ifcontent
// } else if (stuff2) {
// content2
// } else if (stuffs3) {
// content3
// } else {
// contents4
// }
import static HelpClasses.TestFileTester.run;
class E2ETests {
// @Test
// void testPublicClass() {
// byte[] resultBytecode = Compiler.generateByteCodeArrayFromTypedAst();
// assertEquals(AbstractSyntax_PublicClass.get(), resultBytecode);
// }
// @Test
// void testMethodCall() {
// assertDoesNotThrow(() -> {
// BytecodeTestUtil testUtility = new BytecodeTestUtil("src/test/testFiles/ASTandTypedASTFeatures/MethodCall.java", "MethodCall");
//
// if (stuff1) {
// ifcontent
// } else {
// if (stuff2) {
// content2
// } else {
// if (stuff3) {
// content3
// } else {
// content4
// }
// }
// }
// assertEquals(0, testUtility.invokeMethod("method", null));
// assertEquals(1, testUtility.invokeMethod("method1", new Class<?>[]{int.class}, 1));
// assertEquals(3, testUtility.invokeMethod("method2", new Class<?>[]{int.class, int.class}, 1, 2));
// });
// }
@Test
void runByteCodeBreakTests() {
run(ByteCode_Break.class);
}
}
@Test
void runByteCodeClassTests() {
run(ByteCode_Class.class);
}
@Test
void runByteCodeClassObjectsTests() {
run(ByteCode_ClassObjects.class);
}
@Test
void runByteCodeCommentTests() {
run(ByteCode_Comment.class);
}
@Test
void runByteCodeCompAssignTests() {
run(ByteCode_CompAssign.class);
}
@Test
void runByteCodeComplexCallsTests() {
run(ByteCode_ComplexCalls.class);
}
@Test
void runByteCodeConstructorTests() {
run(ByteCode_Constructor.class);
}
@Test
void runByteCodeContinueTests() {
run(ByteCode_Continue.class);
}
@Test
void runByteCodeDataTypesTests() {
run(ByteCode_DataTypes.class);
}
@Test
void runByteCodeFieldTests() {
run(ByteCode_Field.class);
}
@Test
void runByteCodeForTests() {
run(ByteCode_For.class);
}
@Test
void runByteCodeIfTests() {
run(ByteCode_If.class);
}
@Test
void runByteCodeLogicExprTests() {
run(ByteCode_LogicExpr.class);
}
@Test
void runByteCodeMainTests() {
run(ByteCode_Main.class);
}
@Test
void runByteCodeMethodTests() {
run(ByteCode_Method.class);
}
@Test
void runByteCodeMethodCallTests() {
run(ByteCode_MethodCall.class);
}
// @Test
// void runByteCodeMultipleClassesTests() {
// run(ByteCode_MultipleClasses.class);
// } TODO: Fix this test or remove it
@Test
void runByteCodeOperatorsTests() {
run(ByteCode_Operators.class);
}
@Test
void runByteCodeOverloadedTests() {
run(ByteCode_Overloaded.class);
}
@Test
void runByteCodePrintTests() {
run(ByteCode_Print.class);
}
@Test
void runByteCodeReturnTests() {
run(ByteCode_Return.class);
}
@Test
void runByteCodeUnaryTests() {
run(ByteCode_Unary.class);
}
@Test
void runByteCodeVariableDefWithDeclTests() {
run(ByteCode_VariableDefWithDecl.class);
}
@Test
void runByteCodeWhileTests() {
run(ByteCode_While.class);
}
}

View File

@ -0,0 +1,28 @@
package E2ETests;
import java.util.HashMap;
import java.util.Map;
public class ByteClassLoader extends ClassLoader {
// Map to store the class name and its corresponding byte array
private final Map<String, byte[]> classesBytes = new HashMap<>();
public ByteClassLoader() {
super(ClassLoader.getSystemClassLoader());
}
// Method to add a class byte array to the loader
public void addClass(String name, byte[] classData) {
classesBytes.put(name, classData);
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
byte[] classData = classesBytes.get(name);
if (classData == null) {
return super.findClass(name);
}
return defineClass(name, classData, 0, classData.length);
}
}

View File

@ -1,4 +1,4 @@
package testResources.CodeGen;
package E2ETests;
import de.maishai.Compiler;
@ -31,7 +31,7 @@ public class BytecodeTestUtil {
clazz = classLoader.loadClass(className);
this.instance = clazz.getDeclaredConstructor().newInstance();
} catch (ClassNotFoundException | SecurityException | NoSuchMethodException e) {
LOGGER.log(Level.SEVERE, "Exception occur", e);
LOGGER.log(Level.SEVERE, "Exception occurred", e);
throw new RuntimeException(e);
}
}

View File

@ -0,0 +1,32 @@
package E2ETests;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;
public class ClassNameExtractor {
public static String getClassName(byte[] classBytes) {
ClassReader classReader = new ClassReader(classBytes);
ClassNameVisitor classNameVisitor = new ClassNameVisitor();
classReader.accept(classNameVisitor, 0);
return classNameVisitor.getClassName();
}
private static class ClassNameVisitor extends ClassVisitor {
private String className;
public ClassNameVisitor() {
super(Opcodes.ASM9);
}
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
this.className = name.replace('/', '.');
}
public String getClassName() {
return className;
}
}
}

View File

@ -1,9 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import E2ETests.BytecodeTestUtil;
import java.util.List;
@ -14,7 +14,7 @@ public class ByteCode_Break {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Break.java"), "Break");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Break.java"), "Break");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,9 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import E2ETests.BytecodeTestUtil;
import java.util.List;
@ -14,7 +14,7 @@ public class ByteCode_Class {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Class.java"), "Class");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Class.java"), "Class");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,9 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import E2ETests.BytecodeTestUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.util.List;
@ -14,7 +14,7 @@ public class ByteCode_ClassObjects {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/ClassObjects.java"), "ClassObjects");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/ClassObjects.java"), "ClassObjects");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,14 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.TypedBlock;
import de.maishai.typedast.typedclass.TypedClass;
import de.maishai.typedast.typedclass.TypedConstructor;
import de.maishai.typedast.typedclass.TypedProgram;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import E2ETests.BytecodeTestUtil;
import java.util.List;
@ -19,7 +14,7 @@ public class ByteCode_Comment {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Comment.java"), "Comment");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Comment.java"), "Comment");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,9 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import E2ETests.BytecodeTestUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.util.List;
@ -14,7 +14,7 @@ public class ByteCode_CompAssign {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/CompAssign.java"), "CompAssign");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/CompAssign.java"), "CompAssign");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,11 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import E2ETests.BytecodeTestUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.util.List;
@ -16,7 +14,7 @@ public class ByteCode_ComplexCalls {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/ComplexCalls.java"), "ComplexCalls");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/ComplexCalls.java"), "ComplexCalls");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,12 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import E2ETests.BytecodeTestUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.util.List;
@ -17,7 +14,7 @@ public class ByteCode_Constructor {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Constructor.java"), "Constructor");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Constructor.java"), "Constructor");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,12 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import E2ETests.BytecodeTestUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.util.List;
@ -17,7 +14,7 @@ public class ByteCode_Continue {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Continue.java"), "Continue");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Continue.java"), "Continue");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,11 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import E2ETests.BytecodeTestUtil;
import java.util.List;
@ -16,7 +14,7 @@ public class ByteCode_DataTypes {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/DataTypes.java"), "DataTypes");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/DataTypes.java"), "DataTypes");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,11 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import E2ETests.BytecodeTestUtil;
import java.util.List;
@ -16,7 +14,7 @@ public class ByteCode_Field {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Field.java"), "Field");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Field.java"), "Field");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,12 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import E2ETests.BytecodeTestUtil;
import java.util.List;
@ -17,7 +14,7 @@ public class ByteCode_For {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/For.java"), "For");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/For.java"), "For");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,9 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import E2ETests.BytecodeTestUtil;
import java.util.List;
@ -14,7 +14,7 @@ public class ByteCode_If {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/If.java"), "If");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/If.java"), "If");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,12 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import E2ETests.BytecodeTestUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.util.List;
@ -17,7 +14,7 @@ public class ByteCode_LogicExpr {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/LogicExpr.java"), "LogicExpr");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/LogicExpr.java"), "LogicExpr");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,10 +1,12 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import E2ETests.BytecodeTestUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.List;
public class ByteCode_Main {
@ -13,7 +15,7 @@ public class ByteCode_Main {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Main.java"), "Main");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Main.java"), "Main");
} catch (Exception e) {
throw new RuntimeException(e);
}
@ -102,5 +104,23 @@ public class ByteCode_Main {
}
}
//TODO: Add test for invoking main method, how to?
@Test
public void testInvokeMainMethod() {
try {
PrintStream originalOut = System.out;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
PrintStream newOut = new PrintStream(byteArrayOutputStream);
System.setOut(newOut);
Object returnValue = util.invokeMethod("main", new Class<?>[]{String[].class}, new Object[]{new String[0]});
Assertions.assertNull(returnValue);
Assertions.assertEquals(3, byteArrayOutputStream.toString().length());
// durch die newline wird die Ausgabe um 2 Zeichen länger
Assertions.assertEquals("3", byteArrayOutputStream.toString().substring(0, byteArrayOutputStream.toString().length() - 2));
System.setOut(originalOut);
} catch (Exception e) {
Assertions.fail();
}
}
//TODO: Add test for invoking main method by starting the compiled class file?
}

View File

@ -1,11 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import E2ETests.BytecodeTestUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.util.List;
@ -16,7 +14,7 @@ public class ByteCode_Method {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Method.java"), "Method");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Method.java"), "Method");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,12 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import E2ETests.BytecodeTestUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.util.List;
@ -17,7 +14,7 @@ public class ByteCode_MethodCall {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/MethodCall.java"), "MethodCall");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/MethodCall.java"), "MethodCall");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,9 +1,10 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import E2ETests.BytecodeTestUtil;
import de.maishai.Compiler;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.util.List;
@ -14,8 +15,8 @@ public class ByteCode_MultipleClasses {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/MultipleClasses1.java",
"src/test/testFiles/CodeGenFeatures/MultipleClasses2.java"), "MultipleClasses1");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/MultipleClasses1.java",
"src/test/testFiles/E2EFeatures/MultipleClasses2.java"), "MultipleClasses1");
} catch (Exception e) {
throw new RuntimeException(e);
}
@ -116,4 +117,9 @@ public class ByteCode_MultipleClasses {
Assertions.fail();
}
}
public static void main(String[] args) {
Compiler.generateByteCodeFilesFromFiles(List.of("src/test/testFiles/E2EFeatures/MultipleClasses1.java",
"src/test/testFiles/E2EFeatures/MultipleClasses2.java"));
}
}

View File

@ -1,9 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import E2ETests.BytecodeTestUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.util.List;
@ -15,7 +15,7 @@ public class ByteCode_Operators {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Operators.java"), "Operators");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Operators.java"), "Operators");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,9 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import E2ETests.BytecodeTestUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.util.List;
@ -14,7 +14,7 @@ public class ByteCode_Overloaded {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Overloaded.java"), "Overloaded");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Overloaded.java"), "Overloaded");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,9 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import E2ETests.BytecodeTestUtil;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
@ -16,7 +16,7 @@ public class ByteCode_Print {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Print.java"), "Print");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Print.java"), "Print");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,9 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import E2ETests.BytecodeTestUtil;
import java.util.List;
@ -14,7 +14,7 @@ public class ByteCode_Return {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Return.java"), "Return");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Return.java"), "Return");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,12 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import de.maishai.ast.UnaryOperator;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
import E2ETests.BytecodeTestUtil;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import java.util.List;
@ -17,7 +14,7 @@ public class ByteCode_Unary {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/Unary.java"), "Unary");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/Unary.java"), "Unary");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,9 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import E2ETests.BytecodeTestUtil;
import java.util.List;
@ -14,7 +14,7 @@ public class ByteCode_VariableDefWithDecl {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/VariableDefWithDecl.java"),
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/VariableDefWithDecl.java"),
"VariableDefWithDecl");
} catch (Exception e) {
throw new RuntimeException(e);

View File

@ -1,9 +1,9 @@
package testResources.CodeGen.Features;
package E2ETests.Features;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import testResources.CodeGen.BytecodeTestUtil;
import E2ETests.BytecodeTestUtil;
import java.util.List;
@ -14,7 +14,7 @@ public class ByteCode_While {
@BeforeEach
public void setUp() {
try {
util = new BytecodeTestUtil(List.of("src/test/testFiles/CodeGenFeatures/While.java"), "While");
util = new BytecodeTestUtil(List.of("src/test/testFiles/E2EFeatures/While.java"), "While");
} catch (Exception e) {
throw new RuntimeException(e);
}

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.records.Block;
import de.maishai.ast.records.Constructor;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.records.Block;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.UnaryOperator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.records.*;
import de.maishai.ast.records.Class;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTFeatures;
package FeatureTestResources.AST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.TypedBlock;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.TypedBlock;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;

View File

@ -1,7 +1,5 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;
@ -130,7 +130,6 @@ public class TypedAST_Continue {
Type.VOID
),
Type.VOID,
// TODO: ist Konstruktor nicht immer vom Typ der Klasse?
List.of()
)
),

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;

View File

@ -1,7 +1,5 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;
@ -17,7 +17,34 @@ public class TypedAST_MultipleClasses {
Type.REFERENCE("MultipleClasses2")
)
),
List.of(),
List.of(
new TypedMethod(
"getIFromAnotherClass",
Type.INT,
List.of(),
List.of(),
new TypedBlock(
List.of(),
List.of(
new TypedReturn(
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
true,
null,
"anotherClass",
Type.REFERENCE("MultipleClasses2")
),
"i",
Type.INT
),
Type.INT
)
),
Type.INT
)
)
),
List.of(
new TypedConstructor(
"MultipleClasses1",

View File

@ -1,7 +1,6 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.FieldVarAccess;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;

View File

@ -1,6 +1,5 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;

View File

@ -1,8 +1,6 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.UnaryOperator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.TypedClass;
import de.maishai.typedast.typedclass.*;

View File

@ -1,7 +1,5 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;

View File

@ -1,8 +1,6 @@
package testResources.TypedAST.TypedASTFeatures;
package FeatureTestResources.TypedAST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.Class;
import de.maishai.ast.records.*;
import de.maishai.typedast.Type;
import de.maishai.typedast.typedclass.*;

View File

@ -1,4 +1,4 @@
package HelpFiles;
package HelpClasses;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

View File

@ -1,16 +1,4 @@
package testResources.AST.ASTMore;//public class ClassWithConstructor {
// int x;
// public classWithConstructor() {
// this.x = 10;
// int i;
// for (i = 0; i < 6; i = i + 1) {
// int j;
// for (j = 0; j < this.x; j += 1) {
// this.x = this.x * this.x;
// }
// }
// }
//}
package MoreTestResources.AST;
import de.maishai.ast.*;
import de.maishai.ast.records.*;
@ -33,6 +21,7 @@ public class AbstractSyntax_ClassWithConstructor {
List.of(
new Class(
"ClassWithConstructor",
null,
declarations,
methods,
constructors

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTMore;//public class ClassWithConstructorAndMethodCall {
package MoreTestResources.AST;//public class ClassWithConstructorAndMethodCall {
// int x;
//
// public ClassWithConstructorAndMethodCall() {

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTMore;//public class ClassWithConstructorWithCodeInComments {
package MoreTestResources.AST;//public class ClassWithConstructorWithCodeInComments {
// int x;
// public ClassWithConstructorWithCodeInComments() {
// this.x = 10;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTMore;//public class ClassWithConstructorWithParameters {
package MoreTestResources.AST;//public class ClassWithConstructorWithParameters {
// int x;
// public ClassWithConstructorWithParameters(int startValue, int repetitions) {
// this.x = startValue;

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTMore;//public class ClassWithField {
package MoreTestResources.AST;//public class ClassWithField {
// int x;
//}

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTMore;//public class ClassWithMethod {
package MoreTestResources.AST;//public class ClassWithMethod {
// public boolean method() {
// return false;
// }

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTMore;//public class ClassWithMethodAndField {
package MoreTestResources.AST;//public class ClassWithMethodAndField {
// char c;
//
// public ClassWithMethodAndField(char character) {
@ -16,7 +16,7 @@ import de.maishai.typedast.Type;
import java.util.List;
class AbstractSyntax_ClassWithMethodAndField {
public class AbstractSyntax_ClassWithMethodAndField {
public static Program get() {
List<Declaration> declarations = List.of(
new Declaration(

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTMore;//public class ClassWithMoreComplexMethodAndMain {
package MoreTestResources.AST;//public class ClassWithMoreComplexMethodAndMain {
// ClassWithMoreComplexMethodAndMain instance;
//
// public boolean moreComplexMethod() {

View File

@ -1,92 +1,4 @@
package testResources.AST.ASTMore;//public class ComplexClass {
//
// int x;
// int y;
// ComplexClass b;
// ComplexClass c;
//
// public ComplexClass() {
// this.y = 10;
// this.x = 2;
// int i;
// for (i = 0; i < (this.y + 1); i = i + 1) {
// int j;
// for (j = 0; j < this.y; j += 1) {
// this.x = this.x * this.x;
// if (this.x == 100) {
// break;
// }
// }
// }
// this.y = 2;
// do {
// this.y = this.y + 1;
// } while (this.y < 10);
//
// int k = 0;
// for (k = 0; k < 10; k = k + 1) {
// if (k == 5) {
// return;
// }
// }
//
// }
//
// public ComplexClass(int x) {
// this.b = new ComplexClass();
// this.c = new ComplexClass();
// this.x = x;
// this.b.x = 7;
// this.b.y = 13;
// this.c.x = this.b.getX() * this.b.y * this.b.getX('g');
// this.c.y = 25;
// }
//
// public ComplexClass(int x, int y) {
// this.x = x;
// this.y = y;
// }
//
// public ComplexClass initComplexClass(int x) {
// int a;
// a = 10;
// this.b = new ComplexClass(x);
// this.b.x = 10 + a;
// this.b.y = 20;
// this.b.c.x = 20 + a;
// if (methodCall()) {
// this.b.getC().b.y = this.b.x;
// }
// return this.b;
// }
//
// public ComplexClass init(int x, int y) {
// return new ComplexClass(x, y);
// }
//
// public ComplexClass(int x, int y, char z) {
// this.x = x;
// this.y = y;
// }
//
// public int getX(char z) {
// return this.x;
// }
//
// public ComplexClass getC() {
// return this.c;
// }
//
// public int getX() {
// return this.x;
// }
//
// public boolean methodCall() {
// return false;
// }
//
//}
package MoreTestResources.AST;
import de.maishai.ast.Operator;
import de.maishai.ast.records.*;
@ -710,7 +622,7 @@ public class AbstractSyntax_ComplexClass {
true,
new MethodCall(
new FieldVarAccess(
false,
true,
new FieldVarAccess(
true,
null,

View File

@ -1,4 +1,4 @@
package testResources.AST.ASTMore;//public class PublicClass {
package MoreTestResources.AST;//public class PublicClass {
//}
import de.maishai.ast.records.Block;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTMore;//public class ClassWithConstructor {
package MoreTestResources.TypedAST;//public class ClassWithConstructor {
// int x;
// public classWithConstructor() {
// this.x = 10;
@ -226,16 +226,7 @@ public class TypedAbstractSyntax_ClassWithConstructor {
typedParameters,
typedBlock,
Type.VOID,
List.of(
new TypedLocalVariable(
"i",
Type.INT
),
new TypedLocalVariable(
"j",
Type.INT
)
)
List.of()
);
}
}

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTMore;//public class ClassWithConstructorAndMethodCall {
package MoreTestResources.TypedAST;//public class ClassWithConstructorAndMethodCall {
// int x;
//
// public ClassWithConstructorAndMethodCall() {

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTMore;//public class ClassWithConstructorWithCodeInComments {
package MoreTestResources.TypedAST;//public class ClassWithConstructorWithCodeInComments {
// int x;
// public ClassWithConstructorWithCodeInComments() {
// this.x = 10;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTMore;//public class ClassWithConstructorWithParameters {
package MoreTestResources.TypedAST;//public class ClassWithConstructorWithParameters {
// int x;
// public classWithConstructorWithParameters(int startValue, int repetitions) {
// this.x = startValue;

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTMore;//public class ClassWithField {
package MoreTestResources.TypedAST;//public class ClassWithField {
// int x;
//}

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTMore;//public class ClassWithMethod {
package MoreTestResources.TypedAST;//public class ClassWithMethod {
// public boolean method() {
// return false;
// }

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTMore;//public class ClassWithMethodAndField {
package MoreTestResources.TypedAST;//public class ClassWithMethodAndField {
// char c;
//
// public ClassWithMethodAndField(char character) {

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTMore;//public class ClassWithMoreComplexMethodAndMain {
package MoreTestResources.TypedAST;//public class ClassWithMoreComplexMethodAndMain {
// ClassWithMoreComplexMethodAndMain instance;
//
// public boolean moreComplexMethod() {

View File

@ -1,93 +1,4 @@
package testResources.TypedAST.TypedASTMore;//public class ComplexClass {
//
// int x;
// int y;
// ComplexClass b;
// ComplexClass c;
//
// public ComplexClass() {
// this.y = 10;
// this.x = 2;
// int i;
// for (i = 0; i < (this.y + 1); i = i + 1) {
// int j;
// for (j = 0; j < this.y; j += 1) {
// this.x = this.x * this.x;
// if (this.x == 100) {
// break;
// }
// }
// }
// this.y = 2;
// do {
// this.y = this.y + 1;
// } while (this.y < 10);
//
// int k;
// k = 0;
// for (k = 0; k < 10; k = k + 1) {
// if (k == 5) {
// return this;
// }
// }
//
// }
//
// public ComplexClass(int x) {
// this.b = new ComplexClass();
// this.c = new ComplexClass();
// this.x = x;
// this.b.x = 7;
// this.b.y = 13;
// this.c.x = this.b.getX() * this.b.y * this.b.getX('g');
// this.c.y = 25;
// }
//
// public ComplexClass(int x, int y) {
// this.x = x;
// this.y = y;
// }
//
// public ComplexClass initComplexClass(int x) {
// int a;
// a = 10;
// this.b = new ComplexClass(x);
// this.b.x = 10 + a;
// this.b.y = 20;
// this.b.c.x = 20 + a;
// if (methodCall()) {
// this.b.getC().b.y = this.b.x;
// }
// return this.b;
// }
//
// public ComplexClass init(int x, int y) {
// return new ComplexClass(x, y);
// }
//
// public ComplexClass(int x, int y, char z) {
// this.x = x;
// this.y = y;
// }
//
// public int getX(char z) {
// return this.x;
// }
//
// public ComplexClass getC() {
// return this.c;
// }
//
// public int getX() {
// return this.x;
// }
//
// public boolean methodCall() {
// return false;
// }
//
//}
package MoreTestResources.TypedAST;
import de.maishai.ast.Operator;
import de.maishai.typedast.Type;
@ -251,14 +162,14 @@ public class TypedAbstractSyntax_ComplexClass {
),
new TypedAssignment(
new TypedBinary(
new TypedIntLiteral(1, Type.INT),
Operator.ADD,
new TypedFieldVarAccess(
false,
null,
"j",
Type.INT
),
Operator.ADD,
new TypedIntLiteral(1, Type.INT),
Type.INT
),
new TypedFieldVarAccess(
@ -454,6 +365,8 @@ public class TypedAbstractSyntax_ComplexClass {
List.of(),
List.of(
new TypedReturn(
null,
Type.VOID
)
),
Type.VOID
@ -477,12 +390,8 @@ public class TypedAbstractSyntax_ComplexClass {
"ComplexClass",
List.of(),
block,
Type.REFERENCE("ComplexClass"),
List.of(
new TypedLocalVariable("i", Type.INT),
new TypedLocalVariable("k", Type.INT),
new TypedLocalVariable("j", Type.INT)
)
Type.VOID,
List.of()
);
}
@ -511,7 +420,7 @@ public class TypedAbstractSyntax_ComplexClass {
new TypedFieldVarAccess(
true,
null,
"b",
"c",
Type.REFERENCE("ComplexClass")
),
Type.REFERENCE("ComplexClass")
@ -532,7 +441,10 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
),
new TypedAssignment(
new TypedIntLiteral(7, Type.INT),
new TypedIntLiteral(
7,
Type.INT
),
new TypedFieldVarAccess(
true,
new TypedFieldVarAccess(
@ -656,9 +568,12 @@ public class TypedAbstractSyntax_ComplexClass {
)
),
block,
Type.REFERENCE("ComplexClass"),
Type.VOID,
List.of(
new TypedLocalVariable("x", Type.INT)
new TypedLocalVariable(
"x",
Type.INT
)
)
);
}
@ -713,10 +628,16 @@ public class TypedAbstractSyntax_ComplexClass {
)
),
block,
Type.REFERENCE("ComplexClass"),
Type.VOID,
List.of(
new TypedLocalVariable("x", Type.INT),
new TypedLocalVariable("y", Type.INT)
new TypedLocalVariable(
"x",
Type.INT
),
new TypedLocalVariable(
"y",
Type.INT
)
)
);
}
@ -775,11 +696,20 @@ public class TypedAbstractSyntax_ComplexClass {
)
),
block,
Type.REFERENCE("ComplexClass"),
Type.VOID,
List.of(
new TypedLocalVariable("x", Type.INT),
new TypedLocalVariable("y", Type.INT),
new TypedLocalVariable("z", Type.CHAR)
new TypedLocalVariable(
"x",
Type.INT
),
new TypedLocalVariable(
"y",
Type.INT
),
new TypedLocalVariable(
"z",
Type.CHAR
)
)
);
}
@ -933,7 +863,7 @@ public class TypedAbstractSyntax_ComplexClass {
true,
new TypedMethodCall(
new TypedFieldVarAccess(
false,
true,
new TypedFieldVarAccess(
true,
null,
@ -974,7 +904,7 @@ public class TypedAbstractSyntax_ComplexClass {
Type.REFERENCE("ComplexClass")
)
),
Type.REFERENCE("ComplexClass")
Type.VOID
);
return new TypedMethod(
"initComplexClass",
@ -985,10 +915,7 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
)
),
List.of(
new TypedLocalVariable("x", Type.INT),
new TypedLocalVariable("a", Type.INT)
),
List.of(),
block
);
}
@ -1018,7 +945,7 @@ public class TypedAbstractSyntax_ComplexClass {
Type.REFERENCE("ComplexClass")
)
),
Type.REFERENCE("ComplexClass")
Type.VOID
);
return new TypedMethod(
"init",
@ -1033,10 +960,7 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
)
),
List.of(
new TypedLocalVariable("x", Type.INT),
new TypedLocalVariable("y", Type.INT)
),
List.of(),
block
);
}
@ -1055,7 +979,7 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
)
),
Type.INT
Type.VOID
);
return new TypedMethod(
"getX",
@ -1066,9 +990,7 @@ public class TypedAbstractSyntax_ComplexClass {
Type.CHAR
)
),
List.of(
new TypedLocalVariable("z", Type.CHAR)
),
List.of(),
block
);
}
@ -1087,7 +1009,7 @@ public class TypedAbstractSyntax_ComplexClass {
Type.REFERENCE("ComplexClass")
)
),
Type.REFERENCE("ComplexClass")
Type.VOID
);
return new TypedMethod(
"getC",
@ -1112,7 +1034,7 @@ public class TypedAbstractSyntax_ComplexClass {
Type.INT
)
),
Type.INT
Type.VOID
);
return new TypedMethod(
"getX",
@ -1135,7 +1057,7 @@ public class TypedAbstractSyntax_ComplexClass {
Type.BOOL
)
),
Type.BOOL
Type.VOID
);
return new TypedMethod(
"methodCall",

View File

@ -1,4 +1,4 @@
package testResources.TypedAST.TypedASTMore;//public class PublicClass {
package MoreTestResources.TypedAST;//public class PublicClass {
//}
import de.maishai.typedast.Type;

Some files were not shown because too many files have changed in this diff Show More