Merge remote-tracking branch 'origin/master'

# Conflicts:
#	Source/abstractSyntaxTree/Program.java
This commit is contained in:
Jochen Seyfried 2024-05-08 13:52:11 +02:00
commit 777e5b9c5b
5 changed files with 3 additions and 32 deletions

View File

@ -8,6 +8,8 @@ import java.util.List;
public class MethodDecl implements IClass { public class MethodDecl implements IClass {
// name
private HashMap<String, HashMap<String, HashMap<String, String>>> methodContext; private HashMap<String, HashMap<String, HashMap<String, String>>> methodContext;
private HashMap<String, HashMap<String, String>> typeContext; private HashMap<String, HashMap<String, String>> typeContext;

View File

@ -1,11 +0,0 @@
package abstractSyntaxTree.Modifier;
public interface IModifier {
//TODO: Maybe we can just use an enum for the Modifier
// if there is no typeCheck and no CodeGen
// not type or type check
// visit method for code generation
}

View File

@ -1,4 +0,0 @@
package abstractSyntaxTree.Modifier;
public class PrivateModifier implements IModifier{
}

View File

@ -1,4 +0,0 @@
package abstractSyntaxTree.Modifier;
public class PublicModifier implements IModifier{
}

View File

@ -3,9 +3,7 @@ package abstractSyntaxTree;
import TypeCheck.TypeCheckResult; import TypeCheck.TypeCheckResult;
import abstractSyntaxTree.Class.FieldDecl; import abstractSyntaxTree.Class.FieldDecl;
import abstractSyntaxTree.Datatype.RefType; import abstractSyntaxTree.Datatype.RefType;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -13,10 +11,7 @@ import java.util.List;
public class Program { public class Program {
public List<RefType> classes; public List<RefType> classes;
//TODO: Rename typeContext to attributeContext or something
public HashMap<String, HashMap<String, String>> typeContext; // (class, (type, identifier)) public HashMap<String, HashMap<String, String>> typeContext; // (class, (type, identifier))
//TODO: Change Data structure and make parameter a list
public HashMap<String, HashMap<String, HashMap<String, String>>> methodContext; // (class, (returntype, (identifier, parameter))) public HashMap<String, HashMap<String, HashMap<String, String>>> methodContext; // (class, (returntype, (identifier, parameter)))
public TypeCheckResult typeCheck() throws Exception{ public TypeCheckResult typeCheck() throws Exception{
@ -31,14 +26,7 @@ public class Program {
public void codeGen() throws Exception{ public void codeGen() throws Exception{
for(RefType oneClass : classes){ for(RefType oneClass : classes){
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES); oneClass.codeGen();
cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, "oneClass.className",
null, "java/lang/Object", null);
oneClass.codeGen(cw);
cw.visitEnd();
byte[] bytecode = cw.toByteArray();
//Write the bytecode to a .class file
} }
} }
} }