mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 15:58:03 +00:00
empty class now working
This commit is contained in:
parent
8c1ae8712e
commit
4b071ea149
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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<TypedField> typedFields;
|
||||
@ -52,6 +56,10 @@ public class TypedClass implements TypedNode {
|
||||
public TypedNode convertToTypedAST(Map<String, Type> localVar, Map<String, TypedClass> 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();
|
||||
|
@ -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<Declaration> declarations = List.of(
|
||||
new Declaration(
|
Loading…
Reference in New Issue
Block a user