From 1617e3ec625d1fbbdf6fde47b05cced83b819700 Mon Sep 17 00:00:00 2001 From: Jochen Seyfried Date: Wed, 8 May 2024 14:42:56 +0200 Subject: [PATCH] Added RefType codeGen logic --- Source/abstractSyntaxTree/Class/MethodDecl.java | 4 ++++ Source/abstractSyntaxTree/Class/RefType.java | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Source/abstractSyntaxTree/Class/MethodDecl.java b/Source/abstractSyntaxTree/Class/MethodDecl.java index d1d5c93..15f96ac 100644 --- a/Source/abstractSyntaxTree/Class/MethodDecl.java +++ b/Source/abstractSyntaxTree/Class/MethodDecl.java @@ -26,4 +26,8 @@ public class MethodDecl implements IClass { return null; } + @Override + public void codeGen(ClassWriter cw) throws Exception { + + } } diff --git a/Source/abstractSyntaxTree/Class/RefType.java b/Source/abstractSyntaxTree/Class/RefType.java index 291f29c..151bab5 100644 --- a/Source/abstractSyntaxTree/Class/RefType.java +++ b/Source/abstractSyntaxTree/Class/RefType.java @@ -9,6 +9,7 @@ import abstractSyntaxTree.Program; import jdk.jshell.spi.ExecutionControl; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; import java.util.HashMap; import java.util.List; @@ -54,7 +55,18 @@ public class RefType extends AbstractType implements IClass { // and method declarations and calls their CodeGen methods @Override public void codeGen(ClassWriter cw) throws Exception { - throw new ExecutionControl.NotImplementedException("CodeGen not implemented for RefType"); + + cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, name, null, + "java/lang/Object", null); + + for (FieldDecl field : fieldDecls) { + field.codeGen(cw); + } + + for (MethodDecl method : methodDecls) { + method.codeGen(cw); + } + cw.visitEnd(); }