From: adam Date: Mon, 5 Feb 2007 19:03:01 +0000 (+0100) Subject: improved toString() methods in api X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=33f64674245e12f7c05afce117fa6e2c6b2abcd2;p=fleet.git improved toString() methods in api --- diff --git a/src/edu/berkeley/fleet/api/Instruction.java b/src/edu/berkeley/fleet/api/Instruction.java index f72fcec..789aff3 100644 --- a/src/edu/berkeley/fleet/api/Instruction.java +++ b/src/edu/berkeley/fleet/api/Instruction.java @@ -54,7 +54,7 @@ public abstract class Instruction { } public String toString() { - String ret = ""; + String ret = benkoBox.toString() + ": "; if (count==0 || count>1 || recycle) { ret += "["; if (count>1) ret += count; @@ -86,15 +86,20 @@ public abstract class Instruction { public static class Absolute extends Literal { public final long value; public Absolute(BenkoBox dest, long value) { super(dest); this.value = value; } - public String toString() { return value + ": sendto " + dest; } + public String toString() { + return value + ": sendto " + dest; + } } public static class Relative extends Literal { /** value transmitted will be offset plus the address from which this instruction was loaded */ public final long offset; public Relative(BenkoBox dest, long offset) { super(dest); this.offset = offset; } - // FIXME: not final form! - public String toString() { return "(relative "+offset+"): sendto " + dest; } + public String toString() { + String off = ""+offset; + if (offset > 0) off = "+"+off; + return "(@"+offset+"): sendto " + dest; + } } public static class CodeBagDescriptor extends Literal { @@ -103,8 +108,11 @@ public abstract class Instruction { public final long size; public CodeBagDescriptor(BenkoBox dest, long offset, long size) { super(dest); this.offset = offset; this.size = size; } - // FIXME: not final form! - public String toString() { return "(CBD "+offset+":"+size+"): sendto " + dest; } + public String toString() { + String off = ""+offset; + if (offset > 0) off = "+"+off; + return "(@"+off+":"+size+"): sendto " + dest; + } } } }