From: bdemsky Date: Mon, 9 Mar 2009 22:08:24 +0000 (+0000) Subject: bug fix for alokika X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ed83fc53d088de7d55647746dafea554ba212d21;p=IRC.git bug fix for alokika --- diff --git a/Robust/src/IR/Tree/OffsetNode.java b/Robust/src/IR/Tree/OffsetNode.java index c73fd429..2c032a00 100644 --- a/Robust/src/IR/Tree/OffsetNode.java +++ b/Robust/src/IR/Tree/OffsetNode.java @@ -5,8 +5,6 @@ import IR.ClassDescriptor; public class OffsetNode extends ExpressionNode { TypeDescriptor td; - TypeDescriptor type; - ClassDescriptor cd; FieldDescriptor fd; String fieldname; @@ -16,12 +14,6 @@ public class OffsetNode extends ExpressionNode { this.fd = null; } - public OffsetNode(ClassDescriptor cd, String fieldname) { - this.cd = cd; - this.fieldname = fieldname; - this.fd = null; - } - public void setField(FieldDescriptor fd) { this.fd = fd; } @@ -34,20 +26,12 @@ public class OffsetNode extends ExpressionNode { return fd; } - public void setType(TypeDescriptor argtype) { - this.type=argtype; - } - - public void setClassDesc(ClassDescriptor cd) { - this.cd = cd; - } - public ClassDescriptor getClassDesc() { - return cd; + return td.getClassDesc(); } public TypeDescriptor getType() { - return type; + return new TypeDescriptor(TypeDescriptor.SHORT); } public String printNode(int indent) { diff --git a/Robust/src/IR/Tree/SemanticCheck.java b/Robust/src/IR/Tree/SemanticCheck.java index 59dba60c..50737a4b 100644 --- a/Robust/src/IR/Tree/SemanticCheck.java +++ b/Robust/src/IR/Tree/SemanticCheck.java @@ -29,7 +29,6 @@ public class SemanticCheck { if (!completed.contains(cd)) { completed.add(cd); - //System.out.println("Checking class: "+cd); //Set superclass link up if (cd.getSuper()!=null) { cd.setSuper(getClass(cd.getSuper())); @@ -43,7 +42,6 @@ public class SemanticCheck { /* 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); } @@ -74,7 +72,9 @@ public class SemanticCheck { } else { ClassDescriptor cd=(ClassDescriptor)obj; toanalyze.remove(cd); - checkClass(cd); + //need to initialize typeutil object here...only place we can + //get class descriptors without first calling getclass + getClass(cd.getSymbol()); for(Iterator method_it=cd.getMethods(); method_it.hasNext();) { MethodDescriptor md=(MethodDescriptor)method_it.next(); try { @@ -558,30 +558,30 @@ public class SemanticCheck { } void checkOffsetNode(Descriptor md, SymbolTable nameTable, OffsetNode ofn, TypeDescriptor td) { - TypeDescriptor ltd = ofn.td; - //System.out.println("Testing TypeDescriptor ltd = " + ofn.td); - String fieldname = ofn.fieldname; - //System.out.println("Testing String fieldname = " + ofn.fieldname); - Descriptor d = (Descriptor) nameTable.get(fieldname); - //System.out.println("Testing Descriptor d = " + d.toString()); - - ClassDescriptor cd = null; + TypeDescriptor ltd=ofn.td; checkTypeDescriptor(ltd); - cd = ltd.getClassDesc(); - ofn.setClassDesc(cd); - //System.out.println("Testing for ClassDescriptor cd = " + cd.toString()); - + + String fieldname = ofn.fieldname; FieldDescriptor fd=null; if (ltd.isArray()&&fieldname.equals("length")) { fd=FieldDescriptor.arrayLength; } else { - fd=(FieldDescriptor) cd.getFieldTable().get(fieldname); + fd=(FieldDescriptor) ltd.getClassDesc().getFieldTable().get(fieldname); } - //System.out.println("Testing for FieldDescriptor fd = " + fd.toString()); + ofn.setField(fd); + checkField(ltd.getClassDesc(), fd); + if (fd==null) throw new Error("Unknown field "+fieldname + " in "+ofn.printNode(1)+" in "+md); - ofn.setType(td); + + if (td!=null) { + if (!typeutil.isSuperorType(td, ofn.getType())) { + System.out.println(td); + System.out.println(ofn.getType()); + throw new Error("Type of rside not compatible with type of lside"+ofn.printNode(0)); + } + } }