aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-04-20 13:49:26 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-04-20 13:49:26 +0200
commit6dfeaa26c93e8110a54c6e2f6ebf6480dfc74257 (patch)
tree743cac97d29b93805cf4ccc3faa96c839313a194 /src
parent9a80b7de405a1e3c41f39383daf9b5b68c737030 (diff)
downloaddotty-6dfeaa26c93e8110a54c6e2f6ebf6480dfc74257.tar.gz
dotty-6dfeaa26c93e8110a54c6e2f6ebf6480dfc74257.tar.bz2
dotty-6dfeaa26c93e8110a54c6e2f6ebf6480dfc74257.zip
Specialization-specific names.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/NameOps.scala26
-rw-r--r--src/dotty/tools/dotc/core/StdNames.scala16
2 files changed, 40 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala
index 35607cf74..ebf016acc 100644
--- a/src/dotty/tools/dotc/core/NameOps.scala
+++ b/src/dotty/tools/dotc/core/NameOps.scala
@@ -113,7 +113,7 @@ object NameOps {
def stripAnonNumberSuffix: Name = {
var pos = name.length
while (pos > 0 && name(pos - 1).isDigit)
- pos -= 1
+ pos -= 1
if (pos > 0 && pos < name.length && name(pos - 1) == '$')
name take (pos - 1)
@@ -145,7 +145,7 @@ object NameOps {
}.asInstanceOf[N]
/** The superaccessor for method with given name */
- def superName: TermName = (nme.SUPER_PREFIX ++ name).toTermName
+ def superName: TermName = (nme.SUPER_PREFIX ++ name).toTermName
/** The expanded name of `name` relative to given class `base`.
*/
@@ -224,6 +224,28 @@ object NameOps {
case nme.clone_ => nme.clone_
}
+ def specializedFor(returnType: Types.Type, args: List[Types.Type])(implicit ctx: Context): name.ThisName = {
+
+ def typeToTag(tp: Types.Type): Name = {
+ tp.classSymbol match {
+ case t if t eq defn.IntClass => nme.specializedTypeNames.Int
+ case t if t eq defn.BooleanClass => nme.specializedTypeNames.Boolean
+ case t if t eq defn.ByteClass => nme.specializedTypeNames.Byte
+ case t if t eq defn.LongClass => nme.specializedTypeNames.Long
+ case t if t eq defn.ShortClass => nme.specializedTypeNames.Short
+ case t if t eq defn.FloatClass => nme.specializedTypeNames.Float
+ case t if t eq defn.UnitClass => nme.specializedTypeNames.Void
+ case t if t eq defn.DoubleClass => nme.specializedTypeNames.Double
+ case t if t eq defn.CharClass => nme.specializedTypeNames.Char
+ case _ => nme.specializedTypeNames.Object
+ }
+ }
+
+ name.fromName(name ++ nme.specializedTypeNames.prefix ++
+ args.map(typeToTag).foldRight(typeToTag(returnType))(_ ++ _) ++
+ nme.specializedTypeNames.suffix)
+ }
+
/** If name length exceeds allowable limit, replace part of it by hash */
def compactified(implicit ctx: Context): TermName = termName(compactify(name.toString))
}
diff --git a/src/dotty/tools/dotc/core/StdNames.scala b/src/dotty/tools/dotc/core/StdNames.scala
index a4471ebb4..0a6c43f4e 100644
--- a/src/dotty/tools/dotc/core/StdNames.scala
+++ b/src/dotty/tools/dotc/core/StdNames.scala
@@ -540,6 +540,22 @@ object StdNames {
final val isUnary: Set[Name] = Set(MINUS, PLUS, TILDE, BANG)
}
+ object specializedTypeNames {
+ final val Boolean: N = "Z"
+ final val Byte: N = "B"
+ final val Char: N = "C"
+ final val Short: N = "S"
+ final val Int: N = "I"
+ final val Long: N = "J"
+ final val Float: N = "F"
+ final val Double: N = "D"
+ final val Void: N = "V"
+ final val Object: N = "L"
+
+ final val prefix: N = "$mc"
+ final val suffix: N = "$sp"
+ }
+
// value-conversion methods
val toByte: N = "toByte"
val toShort: N = "toShort"