NichtHaskell/Source/abstractSyntaxTree/Class/FieldDecl.java

24 lines
630 B
Java
Raw Normal View History

package abstractSyntaxTree.Class;
2024-05-08 08:10:44 +00:00
import TypeCheck.TypeCheckResult;
import java.util.ArrayList;
import java.util.List;
public class FieldDecl implements IClass {
2024-05-08 08:10:44 +00:00
private String type;
private String identifier;
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);
}
result.type = this.type;
return result;
}
}