Merge branch 'main' of https://gitea.hb.dhbw-stuttgart.de/i22005/JavaCompiler
This commit is contained in:
commit
275eceb80a
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user