From 153388af9df7e476af771e6d2e7aa3ce9d308364 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Mon, 9 Mar 2009 23:29:02 +0000 Subject: [PATCH] fix bug --- Robust/src/IR/Flat/BuildCode.java | 18 +++-------------- Robust/src/IR/Flat/BuildFlat.java | 10 +-------- Robust/src/IR/Flat/FlatOffsetNode.java | 28 +++++++++++++++----------- Robust/src/IR/Tree/OffsetNode.java | 4 ++-- Robust/src/IR/Tree/SemanticCheck.java | 2 +- Robust/src/IR/TypeUtil.java | 1 + 6 files changed, 24 insertions(+), 39 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 0e69ab91..6ef224b1 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -1605,11 +1605,9 @@ public class BuildCode { public void generateFlatOffsetNode(FlatMethod fm, LocalityBinding lb, FlatOffsetNode fofn, PrintWriter output) { output.println("/* FlatOffsetNode */"); - ClassDescriptor cn = fofn.getClassDesc(); - FieldDescriptor fd = fofn.getField(); - System.out.println("ClassDescriptor cn =" + cn.toString() + " FieldDescriptor fd =" + fd.toString()); - System.out.println("TempDescriptor td =" + fofn.getDst().toString() + "Type of TempDescriptor =" + fofn.getDst().getType()); - output.println("((struct "+cn.getSafeSymbol() +" *)0)->"+ fd.getSafeSymbol()+";"); + FieldDescriptor fd=fofn.getField(); + output.println(generateTemp(fm, fofn.getDst(),lb)+ " = (short) (&((struct "+fofn.getClassType().getSafeSymbol() +" *)0)->"+ fd.getSafeSymbol()+");"); + output.println("/* offset */"); } public void generateFlatPrefetchNode(FlatMethod fm, LocalityBinding lb, FlatPrefetchNode fpn, PrintWriter output) { @@ -2368,16 +2366,6 @@ public class BuildCode { } private void generateFlatLiteralNode(FlatMethod fm, LocalityBinding lb, FlatLiteralNode fln, PrintWriter output) { - if (fln.getType().isOffset()) { - if (fln.getValue() instanceof OffsetNode) { - OffsetNode ofn = (OffsetNode) fln.getValue(); - output.println(generateTemp(fm, fln.getDst(),lb)+ - " = (short) (&((struct "+ofn.getClassDesc().getSafeSymbol() +" *)0)->"+ - ofn.getField().getSafeSymbol()+");"); - } - output.println("/* offset */"); - return; - } if (fln.getValue()==null) output.println(generateTemp(fm, fln.getDst(),lb)+"=0;"); else if (fln.getType().getSymbol().equals(TypeUtil.StringClass)) { diff --git a/Robust/src/IR/Flat/BuildFlat.java b/Robust/src/IR/Flat/BuildFlat.java index 069c178d..ff9553f4 100644 --- a/Robust/src/IR/Flat/BuildFlat.java +++ b/Robust/src/IR/Flat/BuildFlat.java @@ -205,16 +205,8 @@ public class BuildFlat { } private NodePair flattenOffsetNode(OffsetNode ofn, TempDescriptor out_temp) { - FlatLiteralNode fln = new FlatLiteralNode(ofn.getType(), ofn, out_temp); + FlatOffsetNode fln = new FlatOffsetNode(ofn.getClassType(), ofn.getField(), out_temp); return new NodePair(fln, fln); - /* Another possible approach - ClassDescriptor cd = ofn.getClassDesc(); - FieldDescriptor fd = ofn.getField(); - FlatOffsetNode fon = new FlatOffsetNode(fd, cd, out_temp); - TypeDescriptor type=new TypeDescriptor(ofn.getType()); - System.out.println("TempDescriptor out_temp = " + out_temp.toString() + "Type of out_temp = " + out_temp.getType()); - return new NodePair(fon, fon); - */ } private NodePair flattenCreateObjectNode(CreateObjectNode con,TempDescriptor out_temp) { diff --git a/Robust/src/IR/Flat/FlatOffsetNode.java b/Robust/src/IR/Flat/FlatOffsetNode.java index def02ea7..e9c61db2 100644 --- a/Robust/src/IR/Flat/FlatOffsetNode.java +++ b/Robust/src/IR/Flat/FlatOffsetNode.java @@ -1,28 +1,28 @@ package IR.Flat; -import IR.ClassDescriptor; +import IR.TypeDescriptor; import IR.FieldDescriptor; public class FlatOffsetNode extends FlatNode { - TempDescriptor dest; - ClassDescriptor cd; + TempDescriptor dst; FieldDescriptor field; + TypeDescriptor baseclass; - public FlatOffsetNode(FieldDescriptor field, ClassDescriptor cd, TempDescriptor dest) { - this.cd = cd; + public FlatOffsetNode(TypeDescriptor classtype, FieldDescriptor field, TempDescriptor dst) { + this.baseclass=classtype; this.field = field; - this.dest = dest; + this.dst = dst; } - public FieldDescriptor getField() { - return field; + public TypeDescriptor getClassType() { + return baseclass; } - public ClassDescriptor getClassDesc() { - return cd; + public FieldDescriptor getField() { + return field; } public String toString() { - return "FlatOffsetNode_"+ dest.toString()+"="+"{ "+ cd.toString()+", "+field.getSymbol()+" }"; + return "FlatOffsetNode_"+ dst.toString()+"="+"{ "+ field.getSymbol()+" }"; } public int kind() { @@ -30,6 +30,10 @@ public class FlatOffsetNode extends FlatNode { } public TempDescriptor getDst() { - return dest; + return dst; + } + + public TempDescriptor [] writesTemps() { + return new TempDescriptor[] {dst}; } } diff --git a/Robust/src/IR/Tree/OffsetNode.java b/Robust/src/IR/Tree/OffsetNode.java index 2c032a00..74ba651d 100644 --- a/Robust/src/IR/Tree/OffsetNode.java +++ b/Robust/src/IR/Tree/OffsetNode.java @@ -26,8 +26,8 @@ public class OffsetNode extends ExpressionNode { return fd; } - public ClassDescriptor getClassDesc() { - return td.getClassDesc(); + public TypeDescriptor getClassType() { + return td; } public TypeDescriptor getType() { diff --git a/Robust/src/IR/Tree/SemanticCheck.java b/Robust/src/IR/Tree/SemanticCheck.java index 50737a4b..50eb360c 100644 --- a/Robust/src/IR/Tree/SemanticCheck.java +++ b/Robust/src/IR/Tree/SemanticCheck.java @@ -419,7 +419,7 @@ public class SemanticCheck { return; case Kind.OffsetNode: - checkOffsetNode(md, nametable, (OffsetNode)en, new TypeDescriptor(TypeDescriptor.OFFSET)); + checkOffsetNode(md, nametable, (OffsetNode)en, td); return; case Kind.TertiaryNode: diff --git a/Robust/src/IR/TypeUtil.java b/Robust/src/IR/TypeUtil.java index 4bdc79e6..f80b2a77 100644 --- a/Robust/src/IR/TypeUtil.java +++ b/Robust/src/IR/TypeUtil.java @@ -292,6 +292,7 @@ NextMethod: } private boolean isSuper(ClassDescriptor possiblesuper, ClassDescriptor cd2) { + while(cd2!=null) { cd2=getSuper(cd2); if (cd2==possiblesuper) -- 2.34.1