aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/NameOps.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-02-01 17:52:00 +0100
committerMartin Odersky <odersky@gmail.com>2013-02-01 17:52:00 +0100
commitabc8f5e1c382b1ead761976227878c4c38ebfbf5 (patch)
treeb135a1bd0945f375e256af8e4ddfbd818c567865 /src/dotty/tools/dotc/core/NameOps.scala
parent5610fe1abbb8e4cb005d644f37669f872327828b (diff)
downloaddotty-abc8f5e1c382b1ead761976227878c4c38ebfbf5.tar.gz
dotty-abc8f5e1c382b1ead761976227878c4c38ebfbf5.tar.bz2
dotty-abc8f5e1c382b1ead761976227878c4c38ebfbf5.zip
Added config package with settings, platform.
Diffstat (limited to 'src/dotty/tools/dotc/core/NameOps.scala')
-rw-r--r--src/dotty/tools/dotc/core/NameOps.scala63
1 files changed, 32 insertions, 31 deletions
diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala
index 2bbfa1360..5aa7e2e25 100644
--- a/src/dotty/tools/dotc/core/NameOps.scala
+++ b/src/dotty/tools/dotc/core/NameOps.scala
@@ -10,25 +10,24 @@ import Decorators.StringDecorator
object NameOps {
- trait NameOpsBase { this: ContextBase =>
-
- final object compactify extends (String => String) {
- val md5 = MessageDigest.getInstance("MD5")
-
- /** COMPACTIFY
- *
- * The hashed name has the form (prefix + marker + md5 + marker + suffix), where
- * - prefix/suffix.length = MaxNameLength / 4
- * - md5.length = 32
- *
- * We obtain the formula:
- *
- * FileNameLength = 2*(MaxNameLength / 4) + 2.marker.length + 32 + 6
- *
- * (+6 for ".class"). MaxNameLength can therefore be computed as follows:
- */
+ final object compactify {
+ lazy val md5 = MessageDigest.getInstance("MD5")
+
+ /** COMPACTIFY
+ *
+ * The hashed name has the form (prefix + marker + md5 + marker + suffix), where
+ * - prefix/suffix.length = MaxNameLength / 4
+ * - md5.length = 32
+ *
+ * We obtain the formula:
+ *
+ * FileNameLength = 2*(MaxNameLength / 4) + 2.marker.length + 32 + 6
+ *
+ * (+6 for ".class"). MaxNameLength can therefore be computed as follows:
+ */
+ def apply(s: String)(implicit ctx: Context): String = {
val marker = "$$$$"
- val limit: Int = ??? // !!! settings.maxClassfileName.value
+ val limit: Int = ctx.settings.XmaxClassfileName.value
val MaxNameLength = (limit - 6) min 2 * (limit - 6 - 2 * marker.length - 32)
def toMD5(s: String, edge: Int): String = {
@@ -42,21 +41,11 @@ object NameOps {
prefix + marker + md5chars + marker + suffix
}
- def apply(s: String): String =
- if (s.length <= MaxNameLength) s else toMD5(s, MaxNameLength / 4)
+
+ if (s.length <= MaxNameLength) s else toMD5(s, MaxNameLength / 4)
}
}
- private val Boxed = Map[TypeName, TypeName](
- tpnme.Boolean -> jtpnme.BoxedBoolean,
- tpnme.Byte -> jtpnme.BoxedByte,
- tpnme.Char -> jtpnme.BoxedCharacter,
- tpnme.Short -> jtpnme.BoxedShort,
- tpnme.Int -> jtpnme.BoxedInteger,
- tpnme.Long -> jtpnme.BoxedLong,
- tpnme.Float -> jtpnme.BoxedFloat,
- tpnme.Double -> jtpnme.BoxedDouble)
-
implicit class NameDecorator(val name: Name) extends AnyVal {
import nme._
@@ -147,9 +136,21 @@ object NameOps {
}
/** If name length exceeds allowable limit, replace part of it by hash */
- def compactified(implicit ctx: Context): TermName = termName(ctx.compactify(name.toString))
+ def compactified(implicit ctx: Context): TermName = termName(compactify(name.toString))
}
+ // needed???
+ private val Boxed = Map[TypeName, TypeName](
+ tpnme.Boolean -> jtpnme.BoxedBoolean,
+ tpnme.Byte -> jtpnme.BoxedByte,
+ tpnme.Char -> jtpnme.BoxedCharacter,
+ tpnme.Short -> jtpnme.BoxedShort,
+ tpnme.Int -> jtpnme.BoxedInteger,
+ tpnme.Long -> jtpnme.BoxedLong,
+ tpnme.Float -> jtpnme.BoxedFloat,
+ tpnme.Double -> jtpnme.BoxedDouble)
+
+ // needed???
implicit class TypeNameDecorator(val name: TypeName) extends AnyVal {
def isUnboxedName = Boxed contains name
def boxedName: TypeName = Boxed(name)