X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FIR%2FTree%2FSemanticCheck.java;h=32577cc55e14b7dfd2a6a72db34ff03fcb5e10c2;hb=cdcf09c40af1419fa42932aae249cb79b69b5daf;hp=12538e16e10872d4752c002ae5eeeeebe4f985bd;hpb=24f4e575e7d74134ca6418fd4b06af8500bf812e;p=IRC.git diff --git a/Robust/src/IR/Tree/SemanticCheck.java b/Robust/src/IR/Tree/SemanticCheck.java deleted file mode 100644 index 12538e16..00000000 --- a/Robust/src/IR/Tree/SemanticCheck.java +++ /dev/null @@ -1,962 +0,0 @@ -package IR.Tree; - -import java.util.*; -import IR.*; - -public class SemanticCheck { - State state; - TypeUtil typeutil; - - public SemanticCheck(State state, TypeUtil tu) { - this.state=state; - this.typeutil=tu; - } - - public void semanticCheck() { - SymbolTable classtable=state.getClassSymbolTable(); - Iterator it=classtable.getDescriptorsIterator(); - // Do descriptors first - while(it.hasNext()) { - ClassDescriptor cd=(ClassDescriptor)it.next(); - //System.out.println("Checking class: "+cd); - //Set superclass link up - if (cd.getSuper()!=null) { - cd.setSuper(typeutil.getClass(cd.getSuper())); - // Link together Field, Method, and Flag tables so classes - // inherit these from their superclasses - cd.getFieldTable().setParent(cd.getSuperDesc().getFieldTable()); - cd.getMethodTable().setParent(cd.getSuperDesc().getMethodTable()); - cd.getFlagTable().setParent(cd.getSuperDesc().getFlagTable()); - } - - /* Check to see that fields are well typed */ - for(Iterator field_it=cd.getFields();field_it.hasNext();) { - FieldDescriptor fd=(FieldDescriptor)field_it.next(); - //System.out.println("Checking field: "+fd); - checkField(cd,fd); - } - - for(Iterator method_it=cd.getMethods();method_it.hasNext();) { - MethodDescriptor md=(MethodDescriptor)method_it.next(); - checkMethod(cd,md); - } - } - - it=classtable.getDescriptorsIterator(); - // Do descriptors first - while(it.hasNext()) { - ClassDescriptor cd=(ClassDescriptor)it.next(); - for(Iterator method_it=cd.getMethods();method_it.hasNext();) { - MethodDescriptor md=(MethodDescriptor)method_it.next(); - checkMethodBody(cd,md); - } - } - - for(Iterator task_it=state.getTaskSymbolTable().getDescriptorsIterator();task_it.hasNext();) { - TaskDescriptor td=(TaskDescriptor)task_it.next(); - checkTask(td); - - } - } - - public void checkTypeDescriptor(TypeDescriptor td) { - if (td.isPrimitive()) - return; /* Done */ - else if (td.isClass()) { - String name=td.toString(); - ClassDescriptor field_cd=(ClassDescriptor)state.getClassSymbolTable().get(name); - if (field_cd==null) - throw new Error("Undefined class "+name); - td.setClassDescriptor(field_cd); - return; - } else if (td.isTag()) - return; - else - throw new Error(); - } - - public void checkField(ClassDescriptor cd, FieldDescriptor fd) { - checkTypeDescriptor(fd.getType()); - } - - public void checkConstraintCheck(TaskDescriptor td, SymbolTable nametable, Vector ccs) { - if (ccs==null) - return; /* No constraint checks to check */ - for(int i=0;i