NichtHaskell/Source/abstractSyntaxTree/Class/FieldDecl.java
2024-05-08 10:10:44 +02:00

24 lines
630 B
Java

package abstractSyntaxTree.Class;
import TypeCheck.TypeCheckResult;
import java.util.ArrayList;
import java.util.List;
public class FieldDecl implements IClass {
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;
}
}