johns-branch #9

Merged
i22005 merged 13 commits from johns-branch into main 2024-05-30 17:11:51 +00:00
Showing only changes of commit 275eceb80a - Show all commits

View File

@ -4,6 +4,7 @@ import ast.ClassNode;
import ast.FieldNode; import ast.FieldNode;
import ast.MemberNode; import ast.MemberNode;
import ast.MethodNode; import ast.MethodNode;
import java.io.File;
import org.objectweb.asm.ClassWriter; import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
@ -34,8 +35,13 @@ public class ClassCodeGen {
} }
private void printIntoClassFile(byte[] byteCode, String name) { private void printIntoClassFile(byte[] byteCode, String name) {
String filePath = "./classFileOutput/" + name + ".class"; String directoryPath = "src/main/java/classFileOutput";
File directory = new File(directoryPath);
if (!directory.exists()) {
directory.mkdirs();
}
String filePath = directoryPath + "/" + name + ".class";
try { try {
FileOutputStream fileOutputStream = new FileOutputStream(filePath); FileOutputStream fileOutputStream = new FileOutputStream(filePath);
fileOutputStream.write(byteCode); fileOutputStream.write(byteCode);