24 lines
630 B
Java
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;
|
|
}
|
|
}
|