diff options
author | paltherr <paltherr@epfl.ch> | 2003-10-21 12:19:02 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-10-21 12:19:02 +0000 |
commit | 5fe89984bfb229cb35bd631ddaff334aac7cf9c0 (patch) | |
tree | 340fc0673394106036ba91f74f2ec8565b8c9b25 /sources/scalac/util/Debug.java | |
parent | e1e0fa0c7ba4fab3435ae2ffc51c9dad7909333c (diff) | |
download | scala-5fe89984bfb229cb35bd631ddaff334aac7cf9c0.tar.gz scala-5fe89984bfb229cb35bd631ddaff334aac7cf9c0.tar.bz2 scala-5fe89984bfb229cb35bd631ddaff334aac7cf9c0.zip |
- Added methods to print arrays of primitive types
Diffstat (limited to 'sources/scalac/util/Debug.java')
-rw-r--r-- | sources/scalac/util/Debug.java | 105 |
1 files changed, 101 insertions, 4 deletions
diff --git a/sources/scalac/util/Debug.java b/sources/scalac/util/Debug.java index 65919b480f..d0be664884 100644 --- a/sources/scalac/util/Debug.java +++ b/sources/scalac/util/Debug.java @@ -208,11 +208,28 @@ public abstract class Debug { public static void appendDefault(StringBuffer buffer, Object that) { if (that == null) { buffer.append("null"); return; } - if (!that.getClass().isArray()) { + if (!that.getClass().isArray()) + appendObject(buffer, that); + else if (that instanceof Object []) + appendArray(buffer, (Object [])that); + else if (that instanceof boolean[]) + appendArray(buffer, (boolean[])that); + else if (that instanceof byte []) + appendArray(buffer, (byte [])that); + else if (that instanceof short []) + appendArray(buffer, (short [])that); + else if (that instanceof char []) + appendArray(buffer, (char [])that); + else if (that instanceof int []) + appendArray(buffer, (int [])that); + else if (that instanceof long []) + appendArray(buffer, (long [])that); + else if (that instanceof float []) + appendArray(buffer, (float [])that); + else if (that instanceof double []) + appendArray(buffer, (double [])that); + else appendObject(buffer, that); - } else { - appendArray(buffer, (Object[])that); - } } public static void appendObject(StringBuffer buffer, Object that) { @@ -240,6 +257,86 @@ public abstract class Debug { buffer.append(']'); } + public static void appendArray(StringBuffer buffer, boolean[] that) { + if (that == null) { buffer.append("null"); return; } + buffer.append('['); + for (int i = 0; i < that.length; i++) { + if (i > 0) buffer.append(','); + buffer.append(that[i]); + } + buffer.append(']'); + } + + public static void appendArray(StringBuffer buffer, byte[] that) { + if (that == null) { buffer.append("null"); return; } + buffer.append('['); + for (int i = 0; i < that.length; i++) { + if (i > 0) buffer.append(','); + buffer.append(that[i]); + } + buffer.append(']'); + } + + public static void appendArray(StringBuffer buffer, short[] that) { + if (that == null) { buffer.append("null"); return; } + buffer.append('['); + for (int i = 0; i < that.length; i++) { + if (i > 0) buffer.append(','); + buffer.append(that[i]); + } + buffer.append(']'); + } + + public static void appendArray(StringBuffer buffer, char[] that) { + if (that == null) { buffer.append("null"); return; } + buffer.append('['); + for (int i = 0; i < that.length; i++) { + if (i > 0) buffer.append(','); + buffer.append(that[i]); + } + buffer.append(']'); + } + + public static void appendArray(StringBuffer buffer, int[] that) { + if (that == null) { buffer.append("null"); return; } + buffer.append('['); + for (int i = 0; i < that.length; i++) { + if (i > 0) buffer.append(','); + buffer.append(that[i]); + } + buffer.append(']'); + } + + public static void appendArray(StringBuffer buffer, long[] that) { + if (that == null) { buffer.append("null"); return; } + buffer.append('['); + for (int i = 0; i < that.length; i++) { + if (i > 0) buffer.append(','); + buffer.append(that[i]); + } + buffer.append(']'); + } + + public static void appendArray(StringBuffer buffer, float[] that) { + if (that == null) { buffer.append("null"); return; } + buffer.append('['); + for (int i = 0; i < that.length; i++) { + if (i > 0) buffer.append(','); + buffer.append(that[i]); + } + buffer.append(']'); + } + + public static void appendArray(StringBuffer buffer, double[] that) { + if (that == null) { buffer.append("null"); return; } + buffer.append('['); + for (int i = 0; i < that.length; i++) { + if (i > 0) buffer.append(','); + buffer.append(that[i]); + } + buffer.append(']'); + } + //######################################################################## // Debug interface - utils |