Added RefType codeGen logic

This commit is contained in:
Jochen Seyfried 2024-05-08 14:42:56 +02:00
parent f273c74693
commit 1617e3ec62
2 changed files with 17 additions and 1 deletions

View File

@ -26,4 +26,8 @@ public class MethodDecl implements IClass {
return null;
}
@Override
public void codeGen(ClassWriter cw) throws Exception {
}
}

View File

@ -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();
}