summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-07-24 17:22:25 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-07-24 17:46:24 +0200
commit2926dfc526296e6575a0a54f68e07c7e7d6d347e (patch)
tree6666d30e90511305a988edf33480784b9aa395cc /src/library
parentf5f7570778586e8230439c4dbacb5f49dea185ff (diff)
downloadscala-2926dfc526296e6575a0a54f68e07c7e7d6d347e.tar.gz
scala-2926dfc526296e6575a0a54f68e07c7e7d6d347e.tar.bz2
scala-2926dfc526296e6575a0a54f68e07c7e7d6d347e.zip
SI-6075 cleans up api.StandardNames
I removed most of the stuff from api.StandardNames and reorganized all names. In the new scheme of things (as documented in the comments to StandardNames): 1) base.StandardNames contains names necessary for building trees. For example, tpnme.WILDCARD_STAR is necessary to build some invocations of varargs methods, and nme.CONSTRUCTOR is necessary to build invocations of constructors. 2) api.StandardNames hosts names that are core to doing reflection. E.g., to get to a package object, you need to find a member named nme.PACKAGE, to strip off the whitespace from the name of an underlying field of a val, you need nme.LOCAL_SUFFIX_STRING. Note that we don't need nme.MODULE_SUFFIX_STRING, because module name mangling is encapsulated in java mirrors.
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/reflect/base/Base.scala21
-rw-r--r--src/library/scala/reflect/base/StandardNames.scala17
2 files changed, 22 insertions, 16 deletions
diff --git a/src/library/scala/reflect/base/Base.scala b/src/library/scala/reflect/base/Base.scala
index 5df48307fe..53854f160d 100644
--- a/src/library/scala/reflect/base/Base.scala
+++ b/src/library/scala/reflect/base/Base.scala
@@ -52,7 +52,6 @@ class Base extends Universe { self =>
else if (isFreeTerm) "free term"
else if (isTerm) "value"
else "symbol"
- // [Eugene++ to Martin] base names should expose `decode`
override def toString() = s"$kindString $name"
}
implicit val SymbolTag = ClassTag[Symbol](classOf[Symbol])
@@ -204,20 +203,22 @@ class Base extends Universe { self =>
object nme extends TermNamesBase {
type NameType = TermName
- val EMPTY = newTermName("")
- val ROOT = newTermName("<root>")
- val EMPTY_PACKAGE_NAME = newTermName("<empty>")
- val CONSTRUCTOR = newTermName("<init>")
+ val WILDCARD = newTermName("_")
+ val CONSTRUCTOR = newTermName("<init>")
+ val ROOTPKG = newTermName("_root_")
+ val EMPTY = newTermName("")
+ val EMPTY_PACKAGE_NAME = newTermName("<empty>")
+ val ROOT = newTermName("<root>")
val NO_NAME = newTermName("<none>")
- val WILDCARD = newTermName("_")
}
object tpnme extends TypeNamesBase {
type NameType = TypeName
- val EMPTY = nme.EMPTY.toTypeName
- val ROOT = nme.ROOT.toTypeName
- val EMPTY_PACKAGE_NAME = nme.EMPTY_PACKAGE_NAME.toTypeName
- val WILDCARD = nme.WILDCARD.toTypeName
+ val WILDCARD = nme.WILDCARD.toTypeName
+ val EMPTY = nme.EMPTY.toTypeName
+ val WILDCARD_STAR = newTypeName("_*")
+ val EMPTY_PACKAGE_NAME = nme.EMPTY_PACKAGE_NAME.toTypeName
+ val ROOT = nme.ROOT.toTypeName
}
type FlagSet = Long
diff --git a/src/library/scala/reflect/base/StandardNames.scala b/src/library/scala/reflect/base/StandardNames.scala
index 8a3fbe9683..50399a4a1e 100644
--- a/src/library/scala/reflect/base/StandardNames.scala
+++ b/src/library/scala/reflect/base/StandardNames.scala
@@ -6,6 +6,11 @@
package scala.reflect
package base
+// Q: I have a pretty name. Where do I put it - into base.StandardNames or into api.StandardNames?
+// A: Is it necessary to construct trees (like EMPTY or WILDCARD_STAR)? If yes, then it goes to base.StandardNames.
+// Is it necessary to perform reflection (like ERROR or LOCAL_SUFFIX_STRING)? If yes, then it goes to api.StandardNames.
+// Otherwise it goes nowhere - reflection API should stay minimalistic.
+
trait StandardNames {
self: Universe =>
@@ -14,16 +19,16 @@ trait StandardNames {
trait NamesBase {
type NameType >: Null <: Name
- val EMPTY: NameType
- val ROOT: NameType
- val EMPTY_PACKAGE_NAME: NameType
val WILDCARD: NameType
}
- trait TypeNamesBase extends NamesBase
-
trait TermNamesBase extends NamesBase {
val CONSTRUCTOR: TermName
- val NO_NAME: NameType
+ val ROOTPKG: TermName
+ }
+
+ trait TypeNamesBase extends NamesBase {
+ val EMPTY: NameType
+ val WILDCARD_STAR: NameType
}
}