47 lines
1.5 KiB
Java
47 lines
1.5 KiB
Java
package abstractSyntaxTree.Class;
|
|
|
|
import TypeCheck.AbstractType;
|
|
import TypeCheck.TypeCheckHelper;
|
|
import TypeCheck.TypeCheckResult;
|
|
import abstractSyntaxTree.Program;
|
|
import org.objectweb.asm.ClassWriter;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
public class FieldDecl extends AbstractType implements IClass{
|
|
|
|
private HashMap<String, HashMap<String, String>> typeContext; // form class from program
|
|
public String type; // from parser
|
|
public String identifier; // from parser
|
|
|
|
public FieldDecl(HashMap<String, HashMap<String, String>> typeContext){
|
|
this.typeContext = typeContext;
|
|
}
|
|
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
|
|
}
|
|
|
|
@Override
|
|
public TypeCheckResult typeCheck(HashMap<String, HashMap<String, HashMap<String, List<String>>>> methodContext, HashMap<String, HashMap<String, String>> typeContext, List<MethodDecl> fieldsOrMethods) throws Exception {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void codeGen(ClassWriter cw) {
|
|
|
|
}
|
|
}
|