Fixed nullPointer Exception for missing class name
This commit is contained in:
parent
965b758fba
commit
80917ec222
@ -15,7 +15,7 @@ public class Compiler {
|
||||
Program abstractSyntaxTree = new Program(new ArrayList<>());
|
||||
List<FieldDecl> emptyFieldDecl = 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, "MyClass"));
|
||||
|
||||
abstractSyntaxTree.typeCheck();
|
||||
|
||||
|
@ -26,7 +26,8 @@ public class RefType extends AbstractType implements IClass {
|
||||
public RefType(List<FieldDecl> fieldDecls,
|
||||
List<MethodDecl> methodDecls,
|
||||
HashMap<String, HashMap<String, String>> typeContext,
|
||||
HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext){
|
||||
HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext, String name){
|
||||
this.name = name;
|
||||
this.fieldDecls = fieldDecls;
|
||||
this.methodDecls = methodDecls;
|
||||
this.typeContext = typeContext;
|
||||
@ -36,7 +37,8 @@ public class RefType extends AbstractType implements IClass {
|
||||
|
||||
|
||||
@Override
|
||||
public TypeCheckResult typeCheck(HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext, HashMap<String, HashMap<String, String>> typeContext, List<MethodDecl> fieldsOrMethods) throws Exception {
|
||||
public TypeCheckResult typeCheck(HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext,
|
||||
HashMap<String, HashMap<String, String>> typeContext, List<MethodDecl> fieldsOrMethods) throws Exception {
|
||||
TypeCheckResult result = new TypeCheckResult();
|
||||
|
||||
for (FieldDecl fieldDecl : fieldDecls) {
|
||||
|
Loading…
Reference in New Issue
Block a user