summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeoffrey Washburn <geoffrey.washburn@epfl.ch>2008-07-09 15:17:01 +0000
committerGeoffrey Washburn <geoffrey.washburn@epfl.ch>2008-07-09 15:17:01 +0000
commitf3bfae5a987ad9e8d61b214fb4c8d0f2f159d080 (patch)
tree2dc2bfcdf5c4c0d118f24f7fb2931bcc7b30b2b2
parent01a20f46ef7a6c94edf31b13f7ca8cf10fbb87b9 (diff)
downloadscala-f3bfae5a987ad9e8d61b214fb4c8d0f2f159d080.tar.gz
scala-f3bfae5a987ad9e8d61b214fb4c8d0f2f159d080.tar.bz2
scala-f3bfae5a987ad9e8d61b214fb4c8d0f2f159d080.zip
Now encoded glyphs in identifiers that are not ...
Now encoded glyphs in identifiers that are not valid for Java/JVM. New STARR built with this encoding.
-rw-r--r--lib/scala-compiler.jar.desired.sha12
-rw-r--r--lib/scala-library-src.jar.desired.sha12
-rw-r--r--lib/scala-library.jar.desired.sha12
-rw-r--r--src/compiler/scala/tools/nsc/util/NameTransformer.scala46
4 files changed, 45 insertions, 7 deletions
diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1
index ce9b06c06e..32c6514177 100644
--- a/lib/scala-compiler.jar.desired.sha1
+++ b/lib/scala-compiler.jar.desired.sha1
@@ -1 +1 @@
-436474a1bef0763932e2748ff608a9aa2d40c528 ?scala-compiler.jar
+8d957dadcf13934718fbb88dc6c1eeef1db94a0d ?scala-compiler.jar
diff --git a/lib/scala-library-src.jar.desired.sha1 b/lib/scala-library-src.jar.desired.sha1
index c87cc589ef..91c08a516d 100644
--- a/lib/scala-library-src.jar.desired.sha1
+++ b/lib/scala-library-src.jar.desired.sha1
@@ -1 +1 @@
-459731230e6c2f0fe3c89f8a7f1093c51b3c7e3a ?scala-library-src.jar
+38c066271cfb6339c993f690695993acff17a94c ?scala-library-src.jar
diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1
index 69054d1d4f..8258d18305 100644
--- a/lib/scala-library.jar.desired.sha1
+++ b/lib/scala-library.jar.desired.sha1
@@ -1 +1 @@
-7e0c0a761c9f6a9eb5d79d97c15db5664ea3fced ?scala-library.jar
+82a7268922263933d0a114636799f1d0113272f0 ?scala-library.jar
diff --git a/src/compiler/scala/tools/nsc/util/NameTransformer.scala b/src/compiler/scala/tools/nsc/util/NameTransformer.scala
index 43108a4501..eb8a88f87b 100644
--- a/src/compiler/scala/tools/nsc/util/NameTransformer.scala
+++ b/src/compiler/scala/tools/nsc/util/NameTransformer.scala
@@ -21,6 +21,7 @@ object NameTransformer {
code2op(c) = new OpCodes(op, code, code2op(c))
}
+ /* Note: decoding assumes opcodes are only ever lowercase. */
enterOp('~', "$tilde")
enterOp('=', "$eq")
enterOp('<', "$less")
@@ -57,6 +58,16 @@ object NameTransformer {
buf.append(name.substring(0, i))
}
buf.append(op2code(c))
+ /* Handle glyphs that are not valid Java/JVM identifiers */
+ } else if (!Character.isJavaLetterOrDigit(c)) {
+ if (buf eq null) {
+ buf = new StringBuilder()
+ buf.append(name.substring(0, i))
+ }
+ /* Annoying hack to format a hexadeciaml number with leading
+ zeros -- there does not appear to be any function pre-Java
+ 1.5 to do this. */
+ buf.append("$u" + Integer.toHexString(c + 0x10000).substring(1).toUpperCase)
} else if (buf ne null) {
buf.append(c)
}
@@ -79,6 +90,7 @@ object NameTransformer {
var i = 0
while (i < len) {
var ops: OpCodes = null
+ var unicode = false
val c = name charAt i
if (c == '$' && i + 2 < len) {
val ch1 = name.charAt(i+1)
@@ -95,12 +107,38 @@ object NameTransformer {
buf.append(ops.op)
i += ops.code.length()
}
- }
+ /* Handle the decoding of Unicode glyphs that are
+ not valid Java/JVM identifiers */
+ } else if (ch1 == 'u' &&
+ (Character.isDigit(ch2)) ||
+ ('A' <= ch2 && ch2 <= 'F')) {
+ /* Skip past "$u", next four should be hexadecimal */
+ val hex = name.substring(i+2, i+6)
+ try {
+ val str = Integer.parseInt(hex, 16).toChar
+ if (buf eq null) {
+ buf = new StringBuilder()
+ buf.append(name.substring(0, i))
+ }
+ buf.append(str)
+ /* 2 for "$u", 4 for hexadecimal number */
+ i += 6
+ unicode = true
+ } catch {
+ case _:NumberFormatException =>
+ /* <code>hex</code> did not decode to a hexadecimal number, so
+ do nothing. */
+ }
+ }
}
}
- if (ops eq null) {
- if (buf ne null) buf.append(c)
- i += 1
+ /* If we didn't see an opcode or encoded Unicode glyph, and the
+ buffer is non-empty, write the current character and advance
+ one */
+ if ((ops eq null) && !unicode) {
+ if (buf ne null)
+ buf.append(c)
+ i += 1
}
}
//System.out.println("= " + (if (buf == null) name else buf.toString()));//DEBUG