33 lines
937 B
Java
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
|
|
}
|
|
}
|