2024-05-08 08:10:44 +00:00
|
|
|
package abstractSyntaxTree;
|
|
|
|
|
|
|
|
import TypeCheck.TypeCheckResult;
|
2024-05-08 10:48:56 +00:00
|
|
|
import abstractSyntaxTree.Class.FieldDecl;
|
2024-05-08 12:15:11 +00:00
|
|
|
import abstractSyntaxTree.Class.RefType;
|
|
|
|
import org.objectweb.asm.ClassWriter;
|
|
|
|
import org.objectweb.asm.Opcodes;
|
2024-05-08 08:10:44 +00:00
|
|
|
|
2024-05-08 09:22:12 +00:00
|
|
|
import java.util.HashMap;
|
2024-05-08 08:10:44 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class Program {
|
|
|
|
public List<RefType> classes;
|
|
|
|
|
2024-05-08 10:48:56 +00:00
|
|
|
public HashMap<String, HashMap<String, String>> typeContext; // (class, (type, identifier))
|
|
|
|
public HashMap<String, HashMap<String, HashMap<String, String>>> methodContext; // (class, (returntype, (identifier, parameter)))
|
2024-05-08 09:22:12 +00:00
|
|
|
|
2024-05-08 08:10:44 +00:00
|
|
|
public TypeCheckResult typeCheck() throws Exception{
|
2024-05-08 09:22:12 +00:00
|
|
|
for(RefType oneClass : classes){
|
2024-05-08 10:48:56 +00:00
|
|
|
HashMap<String, String> classVars = new HashMap<>();
|
|
|
|
for (FieldDecl fielsDecl: oneClass.fieldDecls)
|
|
|
|
classVars.put(fielsDecl.type, fielsDecl.identifier);
|
2024-05-08 09:22:12 +00:00
|
|
|
oneClass.typeCheck();
|
|
|
|
}
|
2024-05-08 08:10:44 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2024-05-08 09:22:12 +00:00
|
|
|
public void codeGen() throws Exception{
|
|
|
|
for(RefType oneClass : classes){
|
2024-05-08 12:15:11 +00:00
|
|
|
//Get the name of the class
|
|
|
|
typeContext.get()
|
|
|
|
|
|
|
|
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
|
|
|
cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC,
|
|
|
|
);
|
|
|
|
oneClass.codeGen(ClassWriter cw);
|
2024-05-08 09:22:12 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-08 08:10:44 +00:00
|
|
|
}
|