Fixed the Program call

This commit is contained in:
Jochen Seyfried 2024-05-09 14:28:32 +02:00
parent 5de106876a
commit 965b758fba
2 changed files with 8 additions and 2 deletions

View File

@ -12,7 +12,7 @@ public class Compiler {
// get file // get file
Program abstractSyntaxTree = new Program(); Program abstractSyntaxTree = new Program(new ArrayList<>());
List<FieldDecl> emptyFieldDecl = new ArrayList<>(); List<FieldDecl> emptyFieldDecl = new ArrayList<>();
List<MethodDecl> emptyMethodDecl = new ArrayList<>(); List<MethodDecl> emptyMethodDecl = new ArrayList<>();
abstractSyntaxTree.classes.add(new RefType(emptyFieldDecl, emptyMethodDecl, null, null)); abstractSyntaxTree.classes.add(new RefType(emptyFieldDecl, emptyMethodDecl, null, null));

View File

@ -18,10 +18,16 @@ import java.util.jar.JarOutputStream;
public class Program { public class Program {
public List<RefType> classes; public List<RefType> classes;
public HashMap<String, HashMap<String, String>> typeContext; // (class, (type, identifier)) public HashMap<String, HashMap<String, String>> typeContext; // (class, (type, identifier))
public HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext; // (class, (returntype, (identifier, parameter))) public HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext; // (class, (returntype, (identifier, parameter)))
public Program(List<RefType> classes){
this.classes = classes;
this.typeContext = new HashMap<>();
this.methodContext = new HashMap<>();
}
public TypeCheckResult typeCheck() throws Exception{ public TypeCheckResult typeCheck() throws Exception{
for(RefType oneClass : classes){ for(RefType oneClass : classes){
HashMap<String, String> classVars = new HashMap<>(); HashMap<String, String> classVars = new HashMap<>();