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) {
}
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)) {
}
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) {
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() {
}
public TempDescriptor getDst() {
- return dest;
+ return dst;
+ }
+
+ public TempDescriptor [] writesTemps() {
+ return new TempDescriptor[] {dst};
}
}
return fd;
}
- public ClassDescriptor getClassDesc() {
- return td.getClassDesc();
+ public TypeDescriptor getClassType() {
+ return td;
}
public TypeDescriptor getType() {
return;
case Kind.OffsetNode:
- checkOffsetNode(md, nametable, (OffsetNode)en, new TypeDescriptor(TypeDescriptor.OFFSET));
+ checkOffsetNode(md, nametable, (OffsetNode)en, td);
return;
case Kind.TertiaryNode:
}
private boolean isSuper(ClassDescriptor possiblesuper, ClassDescriptor cd2) {
+
while(cd2!=null) {
cd2=getSuper(cd2);
if (cd2==possiblesuper)