diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2010-04-09 15:42:34 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2010-04-09 15:42:34 +0000 |
commit | 710e1cb6c4029f39bdd1eece975dbb3cdfafdeda (patch) | |
tree | 9d2fd741d17d2410b571f72bed5d7e5525ad5440 /src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala | |
parent | d76943f9ae43176980f21f90f400053fe2da3fbf (diff) | |
download | scala-710e1cb6c4029f39bdd1eece975dbb3cdfafdeda.tar.gz scala-710e1cb6c4029f39bdd1eece975dbb3cdfafdeda.tar.bz2 scala-710e1cb6c4029f39bdd1eece975dbb3cdfafdeda.zip |
Changed the syntax of the specialized annotation:
instead of a flaky string, it now takes a
repeated parameter list of primitive types:
@specialized("Int, Double") becomes @specialized(Int, Double). No
review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 0284745243..25943af964 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -243,51 +243,30 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { } } - lazy val primitiveTypes = Map( - "Unit" -> definitions.UnitClass.tpe, - "Boolean" -> definitions.BooleanClass.tpe, - "Byte" -> definitions.ByteClass.tpe, - "Short" -> definitions.ShortClass.tpe, - "Char" -> definitions.CharClass.tpe, - "Int" -> definitions.IntClass.tpe, - "Long" -> definitions.LongClass.tpe, - "Float" -> definitions.FloatClass.tpe, - "Double" -> definitions.DoubleClass.tpe) - - - - /** Parse the given string into the list of types it contains. - * - * @param str comma-separated string of distinct primitive types. - */ - def parseTypes(str: String): List[Type] = { - if (str.trim == "") - List() - else { - val buf = new mutable.ListBuffer[Type] - for (t <- str.split(',')) - primitiveTypes.get(t.trim) match { - case Some(tpe) => buf += tpe - case None => - error("Invalid type " + t + ". Expected one of " + primitiveTypes.keysIterator.mkString("", ", ", ".")) - } - buf.toList - } - } - - /** Return the concrete types `sym' should be specialized at. + lazy val primitiveTypes = List( + definitions.UnitClass.tpe, + definitions.BooleanClass.tpe, + definitions.ByteClass.tpe, + definitions.ShortClass.tpe, + definitions.CharClass.tpe, + definitions.IntClass.tpe, + definitions.LongClass.tpe, + definitions.FloatClass.tpe, + definitions.DoubleClass.tpe) + + /** Return the concrete types `sym' should be specialized at. */ def concreteTypes(sym: Symbol): List[Type] = sym.getAnnotation(SpecializedClass) match { case Some(AnnotationInfo(_, args, _)) => args match { - case Literal(ct) :: _ => - val tpes = parseTypes(ct.stringValue) + case Nil => + log(sym + " specialized on everything") + primitiveTypes.toList + case _ => + val tpes = args.map(_.symbol.companionClass.tpe) log(sym + " specialized on " + tpes) tpes - case _ => - log(sym + " specialized on everything") - primitiveTypes.valuesIterator.toList } case _ => Nil |