diff options
Diffstat (limited to 'src/compiler/scala')
-rw-r--r-- | src/compiler/scala/tools/util/ByteArrayFile.java | 54 | ||||
-rw-r--r-- | src/compiler/scala/tools/util/DirectoryPath.java | 222 | ||||
-rw-r--r-- | src/compiler/scala/tools/util/DummyTimer.java | 44 | ||||
-rw-r--r-- | src/compiler/scala/tools/util/StringBufferWriter.java | 69 | ||||
-rw-r--r-- | src/compiler/scala/tools/util/VirtualDirectory.java | 39 | ||||
-rw-r--r-- | src/compiler/scala/tools/util/debug/AbortError.java | 43 | ||||
-rw-r--r-- | src/compiler/scala/tools/util/debug/ArrayDebugger.java | 94 | ||||
-rw-r--r-- | src/compiler/scala/tools/util/debug/Debug.java | 244 | ||||
-rw-r--r-- | src/compiler/scala/tools/util/debug/Debugger.java | 34 | ||||
-rw-r--r-- | src/compiler/scala/tools/util/debug/ObjectDebugger.java | 54 | ||||
-rw-r--r-- | src/compiler/scala/tools/util/debug/ThrowableDebugger.java | 48 | ||||
-rw-r--r-- | src/compiler/scala/tools/util/debug/ToStringDebugger.java | 44 |
12 files changed, 0 insertions, 989 deletions
diff --git a/src/compiler/scala/tools/util/ByteArrayFile.java b/src/compiler/scala/tools/util/ByteArrayFile.java deleted file mode 100644 index afbc9ce089..0000000000 --- a/src/compiler/scala/tools/util/ByteArrayFile.java +++ /dev/null @@ -1,54 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.util; - -/** - * This class implements an abstract regular file backed by a - * character array. - */ -public class ByteArrayFile extends VirtualFile { - - //######################################################################## - // Private Fields - - /** The character array */ - private final byte[] bytes; - - //######################################################################## - // Public Constructors - - /** - * Initializes this instance with the specified name, an identical - * path and the specified character array. - */ - public ByteArrayFile(String name, byte[] bytes) { - this(name, name, bytes); - } - - /** - * Initializes this instance with the specified name, path and - * character array. - */ - public ByteArrayFile(String name, String path, byte[] bytes) { - super(name, path); - this.bytes = bytes; - } - - //######################################################################## - // Public Methods - - /** Reads the content of this abstract file into a byte array. */ - public byte[] read() { - byte[] newBytes = new byte[bytes.length]; - System.arraycopy(bytes, 0, newBytes, 0, bytes.length); - return newBytes; - } - - //######################################################################## -} diff --git a/src/compiler/scala/tools/util/DirectoryPath.java b/src/compiler/scala/tools/util/DirectoryPath.java deleted file mode 100644 index 2b114f8efe..0000000000 --- a/src/compiler/scala/tools/util/DirectoryPath.java +++ /dev/null @@ -1,222 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.util; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map.Entry; -import java.util.NoSuchElementException; - -/** - * This class implements an abstract directory backed by a list of - * abstract directories. The content of the directories are merged - * together. If a subfile occurs in several directories, then the - * first occurrence hides the next ones. If a subdirectory occurs in - * several directories then the content of the different occurrences - * are merged together in the same way. - */ -public class DirectoryPath extends VirtualDirectory { - - //######################################################################## - // Public Factories - - /** - * Returns an abstract directory with the specified name and - * backed by the specified array of abstract directories. - */ - public static AbstractFile fromArray(String name, AbstractFile[] dirs) { - if (dirs.length == 0) return new VirtualDirectory(name, ""); - if (dirs.length == 1 && dirs[0].getName().equals(name)) return dirs[1]; - return new DirectoryPath(name, dirs); - } - - //######################################################################## - // Private Fields - - /** The directories composing this directory path */ - private final AbstractFile[] dirs; - - //######################################################################## - // Protected Constructor - - /** Initializes this instance with given name and directories. */ - protected DirectoryPath(String name, AbstractFile[] dirs) { - super(name); - this.dirs = dirs; - for (int i = 0; i < dirs.length; i++) - assert dirs[i].isDirectory(): dirs[i]; - } - - //######################################################################## - // Public Methods - - /** Returns the path of this abstract file. */ - public String getPath() { - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < dirs.length; i++) { - if (i > 0) buffer.append(File.pathSeparator); - buffer.append(dirs[i]); - } - return buffer.toString(); - } - - /** Returns all abstract subfiles of this abstract directory. */ - public Iterator/*<AbstractFile>*/ list() { - return new ListIterator(); - } - - /** - * Returns the abstract file in this abstract directory with the - * specified name. If there is no such file, returns null. The - * argument "directory" tells whether to look for a directory or - * or a regular file. - */ - public AbstractFile lookupName(String name, boolean directory) { - if (directory) { - AbstractFile first = null; - AbstractFile[] subdirs = null; - int count = 0; - for (int i = 0; i < dirs.length; i++) { - AbstractFile subdir = dirs[i].lookupName(name, directory); - if (subdir == null) continue; - if (count == 0) { - first = subdir; - count++; - } else { - if (count == 1) { - subdirs = new AbstractFile[dirs.length]; - subdirs[0] = first; - } - subdirs[count++] = subdir; - } - } - if (count == 0) return null; - if (count == 1) return first; - if (count != subdirs.length) { - AbstractFile[] array = new AbstractFile[count]; - for (int i = 0; i < array.length; i++) array[i] = subdirs[i]; - subdirs = array; - } - return new DirectoryPath(name, subdirs); - } else { - for (int i = 0; i < dirs.length; i++) { - AbstractFile file = dirs[i].lookupName(name, directory); - if (file != null) return file; - } - return null; - } - } - - //######################################################################## - // Private Class - ListIterator - - /** An iterator over the files contained in this directory. */ - private class ListIterator implements Iterator { - - /** The type of the values in the subdirectory table */ - // type SubDirs = AbstractFile | ArrayList<AbstractFile> - - /** A table to collect subdirectories */ - private final HashMap/*<String,SubDirs>*/ subdirs = new HashMap(); - - /** A table to track already returned regular subfiles */ - private final HashSet/*<String>*/ subfiles = new HashSet(); - - /** The current iterator */ - private Iterator iterator; - - /** The index of the current directory */ - private int index; - - /** The next iteration value or null if no more */ - private Object next; - - /** Initializes this instance. */ - public ListIterator() { - this.next = getNextValue(); - } - - /** Does this iteration have more elements? */ - public boolean hasNext() { - return next != null; - } - - /** Returns the next element in this iteration. */ - public Object next() { - if (next == null) throw new NoSuchElementException(); - Object value = next; - next = getNextValue(); - return value; - } - - /** Throws UnsupportedOperationException. */ - public void remove() { - throw new UnsupportedOperationException(); - } - - /** Returns the next iteration value or null if no more. */ - private AbstractFile getNextValue() { - for (; index < dirs.length; iterator = null, index++) { - // iterate over the files of directory "index" - if (iterator == null) iterator = dirs[index].list(); - while (iterator.hasNext()) { - AbstractFile subfile = (AbstractFile)iterator.next(); - String name = subfile.getName(); - if (subfile.isDirectory()) { - addSubDir(name, subfile); - } else if (!subfiles.contains(name)) { - subfiles.add(name); - return subfile; - } - } - } - // iterate over the collected subdirectories - if (iterator == null) iterator = subdirs.entrySet().iterator(); - if (iterator.hasNext()) return getSubDir((Entry)iterator.next()); - return null; - } - - /** Adds given subdirectory to the subdirectory table. */ - private void addSubDir(String name, AbstractFile subdir) { - Object value = subdirs.get(name); - if (value == null) { - subdirs.put(name, subdir); - } else { - ArrayList list; - if (value instanceof ArrayList) { - list = (ArrayList)value; - } else { - list = new ArrayList(); - subdirs.put(name, list); - list.add(value); - } - list.add(subdir); - } - } - - /** Turns given entry into an abstract directory. */ - private AbstractFile getSubDir(Entry/*<String,SubDirs>*/ entry) { - Object value = entry.getValue(); - if (value instanceof ArrayList) { - ArrayList list = (ArrayList)value; - AbstractFile[] array = new AbstractFile[list.size()]; - list.toArray(array); - return new DirectoryPath((String)entry.getKey(), array); - } else { - return (AbstractFile)value; - } - } - - } - - //######################################################################## -} diff --git a/src/compiler/scala/tools/util/DummyTimer.java b/src/compiler/scala/tools/util/DummyTimer.java deleted file mode 100644 index e16c44b6be..0000000000 --- a/src/compiler/scala/tools/util/DummyTimer.java +++ /dev/null @@ -1,44 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.util; - -import java.util.ArrayList; - -/** This class implements a timer that does nothing. */ -public class DummyTimer implements Timer { - - //######################################################################## - // Public Constants - - /** The unique instance of this class. */ - public static final DummyTimer object = new DummyTimer(); - - //######################################################################## - // Private Constructors - - /** Initializes this instance. */ - private DummyTimer() {} - - //######################################################################## - // Public Methods - - /** Starts a new timer. */ - public void start() { - } - - /** Ends the current timer. */ - public void stop(String message) { - } - - /** Drops the current timer. */ - public void drop() { - } - - //######################################################################## -} diff --git a/src/compiler/scala/tools/util/StringBufferWriter.java b/src/compiler/scala/tools/util/StringBufferWriter.java deleted file mode 100644 index 3e239b08cb..0000000000 --- a/src/compiler/scala/tools/util/StringBufferWriter.java +++ /dev/null @@ -1,69 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.util; - -import java.io.Writer; -import java.io.PrintWriter; - -/** This class implements a writer that writes to a string buffer. */ -public class StringBufferWriter extends Writer { - - //######################################################################## - // Private Fields - - private final StringBuffer buffer; - - //######################################################################## - // Public Constructors - - /** Initializes this instance with the specified string buffer. */ - public StringBufferWriter(StringBuffer buffer) { - this.buffer = buffer; - } - - //######################################################################## - // Public Methods - - /** Returns the underlying string buffer. */ - public StringBuffer getStringBuffer() { - return buffer; - } - - public void close() { - } - - public void flush() { - } - - public void write(int c) { - buffer.append((char)c); - } - - public void write(char[] cs) { - buffer.append(cs); - } - - public void write(char[] cs, int start, int count) { - buffer.append(cs, start, count); - } - - public void write(String string) { - buffer.append(string); - } - - public void write(String string, int start, int count) { - buffer.append(string.substring(start, start + count)); - } - - public String toString() { - return buffer.toString(); - } - - //######################################################################## -} diff --git a/src/compiler/scala/tools/util/VirtualDirectory.java b/src/compiler/scala/tools/util/VirtualDirectory.java deleted file mode 100644 index 597f52d14b..0000000000 --- a/src/compiler/scala/tools/util/VirtualDirectory.java +++ /dev/null @@ -1,39 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.util; - -/** This class implements an empty abstract directory. */ -public class VirtualDirectory extends VirtualFile { - - //######################################################################## - // Public Constructors - - /** - * Initializes this instance with the specified name and an - * identical path. - */ - public VirtualDirectory(String name) { - this(name, name); - } - - /** Initializes this instance with the specified name and path. */ - public VirtualDirectory(String name, String path) { - super(name, path); - } - - //######################################################################## - // Public Methods - - /** Is this abstract file a directory? */ - public boolean isDirectory() { - return true; - } - - //######################################################################## -} diff --git a/src/compiler/scala/tools/util/debug/AbortError.java b/src/compiler/scala/tools/util/debug/AbortError.java deleted file mode 100644 index e3c84a7cda..0000000000 --- a/src/compiler/scala/tools/util/debug/AbortError.java +++ /dev/null @@ -1,43 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.util.debug; - -/** - * This class implements an error that can be used to abort an - * application after an internal error. - */ -public class AbortError extends Error { - - //######################################################################## - // Protected Constructors - - /** Initializes this instance. */ - protected AbortError() { - super(); - } - - /** Initializes this instance with the specified message. */ - protected AbortError(String message) { - super(message); - } - - /** Initializes this instance with the specified cause. */ - protected AbortError(Throwable cause) { - super(cause); - } - - /** - * Initializes this instance with the specified message and cause. - */ - protected AbortError(String message, Throwable cause) { - super(message, cause); - } - - //######################################################################## -} diff --git a/src/compiler/scala/tools/util/debug/ArrayDebugger.java b/src/compiler/scala/tools/util/debug/ArrayDebugger.java deleted file mode 100644 index 6bc6621ab4..0000000000 --- a/src/compiler/scala/tools/util/debug/ArrayDebugger.java +++ /dev/null @@ -1,94 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.util.debug; - -/** This class implements a debugger that appends arrays. */ -public class ArrayDebugger implements Debugger { - - //######################################################################## - // Public Constants - - /** The unique instance of this class. */ - public static final ArrayDebugger object = new ArrayDebugger(); - - //######################################################################## - // Protected Constructors - - /** Initializes this instance. */ - protected ArrayDebugger() {} - - //######################################################################## - // Public Methods - - public boolean canAppend(Object object) { - return object.getClass().isArray(); - } - - public void append(StringBuffer buffer, Object object) { - buffer.append('['); - if (object instanceof Object[]) { - Object[] array = (Object[])object; - for (int i = 0; i < array.length; i++) { - if (i > 0) buffer.append(','); - Debug.append(buffer, array[i]); - } - } else if (object instanceof boolean[]) { - boolean[] array = (boolean[])object; - for (int i = 0; i < array.length; i++) { - if (i > 0) buffer.append(','); - buffer.append(array[i]); - } - } else if (object instanceof byte[]) { - byte[] array = (byte[])object; - for (int i = 0; i < array.length; i++) { - if (i > 0) buffer.append(','); - buffer.append(array[i]); - } - } else if (object instanceof short[]) { - short[] array = (short[])object; - for (int i = 0; i < array.length; i++) { - if (i > 0) buffer.append(','); - buffer.append(array[i]); - } - } else if (object instanceof char[]) { - char[] array = (char[])object; - for (int i = 0; i < array.length; i++) { - if (i > 0) buffer.append(','); - buffer.append(array[i]); - } - } else if (object instanceof int[]) { - int[] array = (int[])object; - for (int i = 0; i < array.length; i++) { - if (i > 0) buffer.append(','); - buffer.append(array[i]); - } - } else if (object instanceof long[]) { - long[] array = (long[])object; - for (int i = 0; i < array.length; i++) { - if (i > 0) buffer.append(','); - buffer.append(array[i]); - } - } else if (object instanceof float[]) { - float[] array = (float[])object; - for (int i = 0; i < array.length; i++) { - if (i > 0) buffer.append(','); - buffer.append(array[i]); - } - } else if (object instanceof double[]) { - double[] array = (double[])object; - for (int i = 0; i < array.length; i++) { - if (i > 0) buffer.append(','); - buffer.append(array[i]); - } - } - buffer.append(']'); - } - - //######################################################################## -} diff --git a/src/compiler/scala/tools/util/debug/Debug.java b/src/compiler/scala/tools/util/debug/Debug.java deleted file mode 100644 index 38ee3c7b9a..0000000000 --- a/src/compiler/scala/tools/util/debug/Debug.java +++ /dev/null @@ -1,244 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.util.debug; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.ArrayList; - -/** - * This class is intended to help debugging applications. It provides - * functions to abort the application and to turn objects into - * strings. - * - * In order to turn objects into strings, the class maintains a list - * of debuggers. An application using this class should configure it - * by adding debuggers for its data types (see method "addDebugger"). - * - * Each time an object has to be transformed into a string, the list - * of debuggers is searched from the last added one to the first one - * for a debugger that is able to make that transformation. The first - * that is found, is then used to make the transformation. - */ -public class Debug { - - //######################################################################## - // Private Variables - - /** The list of all available debuggers */ - private static final ArrayList/*<Debugger>*/ debuggers = new ArrayList(); - - static { - addDebugger(ObjectDebugger.object); - addDebugger(ArrayDebugger.object); - addDebugger(ThrowableDebugger.object); - addDebugger(new ToStringDebugger(String.class)); - } - - //######################################################################## - // Public Methods - Configuring - - /** Adds the specified debugger to the list of debuggers. */ - public static void addDebugger(Debugger debugger) { - debuggers.add(debugger); - } - - //######################################################################## - // Public Methods - Aborting - - /** Aborts the application by throwing an AbortError. */ - public static Error abort() { - throw new AbortError(); - } - public static Error abort(Throwable cause) { - throw new AbortError(cause); - } - public static Error abort(Object object) { - return abort(show(object)); - } - public static Error abort(Object object, Throwable cause) { - return abort(show(object), cause); - } - public static Error abort(String message) { - throw new AbortError(message); - } - public static Error abort(String message, Throwable cause) { - throw new AbortError(message, cause); - } - public static Error abort(String message, Object object) { - return abort(message + ": " + show(object)); - } - public static Error abort(String message, Object object, Throwable cause) { - return abort(message + ": " + show(object), cause); - } - - /** Aborts the application by throwing an AbortError. */ - public static Error abortIllegalCase(int value) { - return abort("illegal case: " + value); - } - public static Error abortIllegalCase(Object object) { - return abort("illegal case", object); - } - - //######################################################################## - // Public Methods - Showing - - /** - * Makes a string out of the object(s) using for each the first - * matching debugger and separating them with dash(es). - */ - public static String show(Object a) { - return showAll(new Object[] {a}); - } - public static String show(Object a, Object b) { - return showAll(new Object[] {a, b}); - } - public static String show(Object a, Object b, Object c) { - return showAll(new Object[] {a, b, c}); - } - public static String show(Object a, Object b, Object c, Object d) { - return showAll(new Object[] {a, b, c, d}); - } - public static String show(Object a, Object b, Object c, Object d, Object e) - { - return showAll(new Object[] {a, b, c, d, e}); - } - public static String show(Object a, Object b, Object c, Object d, Object e, - Object f) - { - return showAll(new Object[] {a, b, c, d, e, f}); - } - public static String show(Object a, Object b, Object c, Object d, Object e, - Object f, Object g) - { - return showAll(new Object[] {a, b, c, d, e, f, g}); - } - public static String show(Object a, Object b, Object c, Object d, Object e, - Object f, Object g, Object h) - { - return showAll(new Object[] {a, b, c, d, e, f, g, h}); - } - public static String show(Object a, Object b, Object c, Object d, Object e, - Object f, Object g, Object h, Object i) - { - return showAll(new Object[] {a, b, c, d, e, f, g, h, i}); - } - public static String show(Object a, Object b, Object c, Object d, Object e, - Object f, Object g, Object h, Object i, Object j) - { - return showAll(new Object[] {a, b, c, d, e, f, g, h, i, j}); - } - public static String show(Object a, Object b, Object c, Object d, Object e, - Object f, Object g, Object h, Object i, Object j, Object k) - { - return showAll(new Object[] {a, b, c, d, e, f, g, h, i, j, k}); - } - public static String show(Object a, Object b, Object c, Object d, Object e, - Object f, Object g, Object h, Object i, Object j, Object k, Object l) - { - return showAll(new Object[] {a, b, c, d, e, f, g, h, i, j, k, l}); - } - - /** - * Makes a string out of all objects using for each the first - * matching debugger and separating them with dashes. - */ - public static String showAll(Object[] objects) { - return showAll(objects, " - "); - } - - /** - * Makes a string out of all objects using for each the first - * matching debugger and separating them with the specified - * separator if it is non-null and by nothing otherwise. - */ - public static String showAll(Object[] objects, String separator) { - StringBuffer buffer = new StringBuffer(); - appendAll(buffer, objects, separator); - return buffer.toString(); - } - - //######################################################################## - // Public Methods - Appending - - /** - * Appends the object to the buffer using the first matching - * debugger. - */ - public static void append(StringBuffer buffer, Object object) { - if (object != null) { - for (int i = debuggers.size() - 1; i >= 0; i--) { - Debugger debugger = (Debugger)debuggers.get(i); - if (!debugger.canAppend(object)) continue; - debugger.append(buffer, object); - return; - } - } - buffer.append(object); - } - - /** - * Appends all the objects to the buffer using for each the first - * matching debugger. The object are separated by the specified - * separator if it is non-null and by nothing otherwise. - */ - public static void appendAll(StringBuffer buffer, Object[] objects, - String separator) - { - for (int i = 0; i < objects.length; i++) { - if (i > 0 && separator != null) buffer.append(separator); - append(buffer, objects[i]); - } - } - - //######################################################################## - // Public Methods - Miscellaneous - - /** - * Returns the class name of the object. Does some pretty printing - * for parameterless pico case classes. - */ - public static String getClassNameOf(Object object) { - if (object == null) return "null"; - Class clasz = object.getClass(); - String name = clasz.getName(); - if (!name.endsWith("$$Var")) return name; - Class superclass = clasz.getSuperclass(); - Field[] fields = superclass.getDeclaredFields(); - for (int i = 0; i < fields.length; i++) { - try { - Field field = fields[i]; - if (field.getType() != clasz) continue; - if (!Modifier.isStatic(field.getModifiers())) continue; - Object value = field.get(null); - if (value != object) continue; - return name + "[" + field.getName() + "]"; - } catch (IllegalAccessException exception) { - // continue - } - } - return name; - } - - /** Returns true iff the object overrides "Object.toString()". */ - public static boolean overridesToString(Object object) { - try { - Class clasz = object.getClass(); - Method toString = clasz.getMethod("toString", new Class[0]); - return toString.getDeclaringClass() != Object.class; - } catch (NoSuchMethodException exception) { - return false; - } catch (SecurityException exception) { - return false; - } - } - - //######################################################################## -} diff --git a/src/compiler/scala/tools/util/debug/Debugger.java b/src/compiler/scala/tools/util/debug/Debugger.java deleted file mode 100644 index 0a40f74768..0000000000 --- a/src/compiler/scala/tools/util/debug/Debugger.java +++ /dev/null @@ -1,34 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.util.debug; - -/** - * This interface defines methods used by the class Debug to turn - * objects into strings. - */ -public interface Debugger { - - //######################################################################## - // Public Methods - - /** - * Returns "true" if the specified object may be passed as an - * argument to the method "append". - */ - public boolean canAppend(Object object); - - /** - * Appends the object to the string buffer. This method must be - * invoked only with objects for which the method "canAppend" - * returns "true". - */ - public void append(StringBuffer buffer, Object object); - - //######################################################################## -} diff --git a/src/compiler/scala/tools/util/debug/ObjectDebugger.java b/src/compiler/scala/tools/util/debug/ObjectDebugger.java deleted file mode 100644 index 7edcdbd0f0..0000000000 --- a/src/compiler/scala/tools/util/debug/ObjectDebugger.java +++ /dev/null @@ -1,54 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.util.debug; - -/** - * This class implements a debugger that appends any object. It - * appends the class name of the object and either the string returned - * by its method "toString" if it overridden or its identity hash code - * otherwise. - */ -public class ObjectDebugger implements Debugger { - - //######################################################################## - // Public Constants - - /** The unique instance of this class. */ - public static final ObjectDebugger object = new ObjectDebugger(); - - //######################################################################## - // Protected Constructors - - /** Initializes this instance. */ - protected ObjectDebugger() {} - - //######################################################################## - // Public Methods - - public boolean canAppend(Object object) { - return true; - } - - public void append(StringBuffer buffer, Object object) { - buffer.append(Debug.getClassNameOf(object)); - Class owner = null; - if (Debug.overridesToString(object)) { - buffer.append('('); - buffer.append(object); - buffer.append(')'); - } else { - String code = Integer.toHexString(System.identityHashCode(object)); - buffer.append('@'); - for (int i = code.length(); i < 8; i++) buffer.append('0'); - buffer.append(code); - } - } - - //######################################################################## -} diff --git a/src/compiler/scala/tools/util/debug/ThrowableDebugger.java b/src/compiler/scala/tools/util/debug/ThrowableDebugger.java deleted file mode 100644 index 8bdf93cbcb..0000000000 --- a/src/compiler/scala/tools/util/debug/ThrowableDebugger.java +++ /dev/null @@ -1,48 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.util.debug; - -import java.io.Writer; -import java.io.PrintWriter; - -import scala.tools.util.StringBufferWriter; - -/** - * This class implements a debugger that appends instances of - * Throwable. - */ -public class ThrowableDebugger implements Debugger { - - //######################################################################## - // Public Constants - - /** The unique instance of this class. */ - public static final ThrowableDebugger object = new ThrowableDebugger(); - - //######################################################################## - // Protected Constructors - - /** Initializes this instance. */ - protected ThrowableDebugger() {} - - //######################################################################## - // Public Methods - - public boolean canAppend(Object object) { - return object instanceof Throwable; - } - - public void append(StringBuffer buffer, Object object) { - PrintWriter writer = new PrintWriter(new StringBufferWriter(buffer)); - ((Throwable)object).printStackTrace(writer); - writer.close(); - } - - //######################################################################## -} diff --git a/src/compiler/scala/tools/util/debug/ToStringDebugger.java b/src/compiler/scala/tools/util/debug/ToStringDebugger.java deleted file mode 100644 index 85e0e18776..0000000000 --- a/src/compiler/scala/tools/util/debug/ToStringDebugger.java +++ /dev/null @@ -1,44 +0,0 @@ -/* ____ ____ ____ ____ ______ *\ -** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala ** -** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL ** -** /_____/\____/\___/\____/____/ ** -\* */ - -// $Id$ - -package scala.tools.util.debug; - -/** - * This class implements a debugger that appends objects that are - * instances of a specified class (or of one of its subclass) by - * simply appending the string returned by their method "toString". - */ -public class ToStringDebugger implements Debugger { - - //######################################################################## - // Private Fields - - /** The class whose instances can be appended */ - private final Class clasz; - - //######################################################################## - // Public Constructors - - /** Initializes this instance. */ - public ToStringDebugger(Class clasz) { - this.clasz = clasz; - } - - //######################################################################## - // Public Methods - - public boolean canAppend(Object object) { - return clasz.isInstance(object); - } - - public void append(StringBuffer buffer, Object object) { - buffer.append(object.toString()); - } - - //######################################################################## -} |