NichtHaskell/Source/abstractSyntaxTree/Class/FieldDecl.java
Krauß, Josefine fe249c5b2a try to run main
2024-05-08 15:14:58 +02:00

47 lines
1.3 KiB
Java

package abstractSyntaxTree.Class;
import TypeCheck.AbstractType;
import TypeCheck.TypeCheckHelper;
import TypeCheck.TypeCheckResult;
import abstractSyntaxTree.Program;
import org.objectweb.asm.ClassWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class FieldDecl extends AbstractType implements IClass{
private HashMap<String, HashMap<String, String>> typeContext; // form class from program
public String type; // from parser
public String identifier; // from parser
public FieldDecl(HashMap<String, HashMap<String, String>> typeContext){
this.typeContext = typeContext;
}
public TypeCheckResult typeCheck(List<FieldDecl> classFieldsIdentifier) throws Exception {
TypeCheckResult result = new TypeCheckResult();
if (classFieldsIdentifier.contains(this.identifier)){
throw new Exception("field already defined");
} else {
classFieldsIdentifier.add(this);
}
//TypeCheckHelper.typeExists(type, ) // need all types of classes
setTypeCheckResult(result);
return result;
//write field table
}
@Override
public TypeCheckResult typeCheck() throws Exception {
return null;
}
@Override
public void codeGen(ClassWriter cw) {
}
}