summaryrefslogtreecommitdiff
path: root/sources/scalac/util
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-02-29 12:16:51 +0000
committerpaltherr <paltherr@epfl.ch>2004-02-29 12:16:51 +0000
commit124944fb5b5304ff3ef6f0c1e3a1dcf78c47a0be (patch)
treeac0296d1285f067db5f110d6cc1f43a2e08b0382 /sources/scalac/util
parent4342030b006393809ac6561618bbee95922e5c9a (diff)
downloadscala-124944fb5b5304ff3ef6f0c1e3a1dcf78c47a0be.tar.gz
scala-124944fb5b5304ff3ef6f0c1e3a1dcf78c47a0be.tar.bz2
scala-124944fb5b5304ff3ef6f0c1e3a1dcf78c47a0be.zip
- Rewrote SourceRepresentation.externalizeFileN...
- Rewrote SourceRepresentation.externalizeFileName to use SymbolNameWriter
Diffstat (limited to 'sources/scalac/util')
-rw-r--r--sources/scalac/util/SourceRepresentation.java30
1 files changed, 20 insertions, 10 deletions
diff --git a/sources/scalac/util/SourceRepresentation.java b/sources/scalac/util/SourceRepresentation.java
index e5cb210090..becd53b26c 100644
--- a/sources/scalac/util/SourceRepresentation.java
+++ b/sources/scalac/util/SourceRepresentation.java
@@ -2,16 +2,24 @@
** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
** /_____/\____/\___/\____/____/ **
-** **
-** $Id
\* */
+// $Id$
+
package scalac.util;
import java.io.File;
+import scalac.symtab.Symbol;
+import scalac.symtab.SymbolNameWriter;
+
public final class SourceRepresentation {
+ /** The file name writer */
+ private static SymbolNameWriter fileNameWriter = new SymbolNameWriter()
+ .setAllSeparators(File.separatorChar)
+ .setRootSeparator('\0');
+
public static int digit2int(byte ch, int base) {
if ('0' <= ch && ch <= '9' && ch < '0' + base)
return ch - '0';
@@ -205,14 +213,16 @@ public final class SourceRepresentation {
return escape(new String(s));
}
- /** return external representation of file name s,
- * converting '.' to File.separatorChar
+ /**
+ * Returns the external file name with given suffix associated to
+ * given class. The file name use File.separatorChar as file
+ * separator.
*/
- public static String externalizeFileName(Name n) {
- if ((n == null) || (n.length() == 0))
- return ".";
- byte[] ascii = n.toAscii();
- String s = ascii2string(ascii, 0, ascii.length);
- return s.replace('.', File.separatorChar);
+ public static String externalizeFileName(Symbol clasz, String suffix) {
+ assert clasz.isClassType(): Debug.show(clasz);
+ String name = fileNameWriter.appendSymbol(clasz, suffix).toString();
+ fileNameWriter.setStringBuffer(null);
+ return name;
}
+
}