diff --git a/src/main/java/de/maishai/Compiler.java b/src/main/java/de/maishai/Compiler.java index 92e75fc..7d2dd81 100644 --- a/src/main/java/de/maishai/Compiler.java +++ b/src/main/java/de/maishai/Compiler.java @@ -27,7 +27,7 @@ public class Compiler { public static TypedClass generateTypedASTFromAst(Class ast) { TypedClass typedAST = new TypedClass(); - typedAST.startConversion(ast); + typedAST = (TypedClass) typedAST.startConversion(ast); return typedAST; } @@ -64,6 +64,6 @@ public class Compiler { } public static void main(String[] args) { - generateByteCodeFileFromFile("src/main/resources/JavaTestfiles/PublicClass.java", "OnlyClass"); + generateByteCodeFileFromFile("src/main/resources/JavaTestfiles/ClassWithConstructor.java", "ClassWithConstructor"); } } diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedClass.java b/src/main/java/de/maishai/typedast/typedclass/TypedClass.java index aeea51e..e859eca 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedClass.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedClass.java @@ -6,7 +6,9 @@ import de.maishai.typedast.CodeGenUtils; import de.maishai.typedast.TypedNode; import de.maishai.typedast.Type; import de.maishai.typedast.TypedStatement; +import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; @@ -16,6 +18,8 @@ import java.util.List; import java.util.Map; @Data +@AllArgsConstructor +@NoArgsConstructor public class TypedClass implements TypedNode { private String className; private List typedFields; @@ -52,6 +56,10 @@ public class TypedClass implements TypedNode { public TypedNode convertToTypedAST(Map localVar, Map classes, de.maishai.ast.records.Node unTypedAST) { TypedClass typedClass = new TypedClass(); Class c = (Class) unTypedAST; + typedClass.setClassName(c.classname()); + typedClass.setTypedFields(new ArrayList<>()); + typedClass.setTypedMethods(new ArrayList<>()); + typedClass.setTypedConstructors(new ArrayList<>()); for (Declaration field : c.fieldDeclarations()) { TypedField typedField = new TypedField(); diff --git a/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMoreComplexMethodAndMain.java b/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMultipleMethods.java similarity index 99% rename from src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMoreComplexMethodAndMain.java rename to src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMultipleMethods.java index d96a105..e67b321 100644 --- a/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMoreComplexMethodAndMain.java +++ b/src/main/resources/AbstractSyntax/AbstractSyntax_ClassWithMultipleMethods.java @@ -25,7 +25,7 @@ import de.maishai.typedast.Type; import java.util.List; -public class AbstractSyntax_ClassWithMoreComplexMethodAndMain { +public class AbstractSyntax_ClassWithMultipleMethods { public static Class get() { List declarations = List.of( new Declaration( diff --git a/src/main/resources/JavaTestfiles/ClassWithMoreComplexMethodAndMain.java b/src/main/resources/JavaTestfiles/ClassWithMultipleMethods.java similarity index 100% rename from src/main/resources/JavaTestfiles/ClassWithMoreComplexMethodAndMain.java rename to src/main/resources/JavaTestfiles/ClassWithMultipleMethods.java