NichtHaskell/Source/abstractSyntaxTree/Class/FieldDecl.java
2024-05-08 11:22:12 +02:00

33 lines
937 B
Java

package abstractSyntaxTree.Class;
import TypeCheck.AbstractType;
import TypeCheck.TypeCheckHelper;
import TypeCheck.TypeCheckResult;
import abstractSyntaxTree.Program;
import java.util.ArrayList;
import java.util.List;
public class FieldDecl extends AbstractType implements IClass{
private Program program;
private String identifier;
public FieldDecl(Program program){
this.program = program;
}
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
}
}