summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-11-02 18:25:41 +0000
committerPaul Phillips <paulp@improving.org>2010-11-02 18:25:41 +0000
commitc891ba15f2ba270f40413b64770cf6dd0a62994d (patch)
tree15a78ec8bb267d2357d779f3a407b3d0ea7bef57
parent3b0b4d7480627d3d19a5745a7163c5b9e3d8f16b (diff)
downloadscala-c891ba15f2ba270f40413b64770cf6dd0a62994d.tar.gz
scala-c891ba15f2ba270f40413b64770cf6dd0a62994d.tar.bz2
scala-c891ba15f2ba270f40413b64770cf6dd0a62994d.zip
One more mr.
This performs some Name related organization: putting similar name machinery in the same place, renaming some things to be consistent with the other things, giving some names to naked strings, beating back the creeping "if (forMSIL)" tests into class polymorphism, etc. No review.
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeInfo.scala5
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala7
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala42
-rw-r--r--src/compiler/scala/tools/nsc/symtab/NameMangling.scala114
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Names.scala105
-rw-r--r--src/compiler/scala/tools/nsc/symtab/StdNames.scala407
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala2
-rwxr-xr-xsrc/library/scala/reflect/generic/StdNames.scala13
11 files changed, 336 insertions, 367 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
index 4ca3849553..443a5a724b 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
@@ -200,10 +200,7 @@ abstract class TreeInfo {
def isLeftAssoc(operator: Name): Boolean =
operator.length > 0 && operator(operator.length - 1) != ':'
- private val reserved = new HashSet[Name]("reserved", 64)
- reserved addEntry nme.false_
- reserved addEntry nme.true_
- reserved addEntry nme.null_
+ private val reserved = Set[Name](nme.false_, nme.true_, nme.null_)
/** Is name a variable name? */
def isVariableName(name: Name): Boolean = {
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index 432640c37d..a835ac5eb9 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -1508,13 +1508,10 @@ abstract class GenICode extends SubComponent {
* @param elseCtx target context if the comparison yields false
*/
def genEqEqPrimitive(l: Tree, r: Tree, ctx: Context)(thenCtx: Context, elseCtx: Context): Unit = {
-
- def eqEqTempName: Name = "eqEqTemp$"
-
- def getTempLocal: Local = ctx.method.lookupLocal(eqEqTempName) match {
+ def getTempLocal: Local = ctx.method.lookupLocal(nme.EQEQ_LOCAL_VAR) match {
case Some(local) => local
case None =>
- val local = ctx.makeLocal(l.pos, AnyRefClass.typeConstructor, eqEqTempName.toString)
+ val local = ctx.makeLocal(l.pos, AnyRefClass.typeConstructor, nme.EQEQ_LOCAL_VAR)
//assert(!l.pos.source.isEmpty, "bad position, unit = "+unit+", tree = "+l+", pos = "+l.pos.source)
// Note - I commented these out because they were crashing the test case in ticket #2426
// (and I have also had to comment them out at various times while working on equality.)
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index cac9453904..1c0d80b0c7 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -665,7 +665,7 @@ abstract class GenJVM extends SubComponent {
if (outerField != NoSymbol) {
log("Adding fake local to represent outer 'this' for closure " + clasz)
val _this = new Local(
- method.symbol.newVariable(NoPosition, "this$"), toTypeKind(outerField.tpe), false)
+ method.symbol.newVariable(NoPosition, nme.FAKE_LOCAL_THIS), toTypeKind(outerField.tpe), false)
m.locals = m.locals ::: List(_this)
computeLocalVarsIndex(m) // since we added a new local, we need to recompute indexes
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index 08cbab7933..20f6ed9e5a 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -40,9 +40,6 @@ trait Definitions extends reflect.generic.StandardDefinitions {
lazy val RuntimePackage = getModule("scala.runtime")
lazy val RuntimePackageClass = RuntimePackage.tpe.typeSymbol
- lazy val ScalaCollectionImmutablePackage: Symbol = getModule("scala.collection.immutable")
- lazy val ScalaCollectionImmutablePackageClass: Symbol = ScalaCollectionImmutablePackage.tpe.typeSymbol
-
// convenient one-argument parameter lists
lazy val anyparam = List(AnyClass.typeConstructor)
lazy val anyvalparam = List(AnyValClass.typeConstructor)
@@ -78,7 +75,6 @@ trait Definitions extends reflect.generic.StandardDefinitions {
lazy val NothingClass = newClass(ScalaPackageClass, nme.Nothing, anyparam) setFlag (ABSTRACT | TRAIT | FINAL)
lazy val RuntimeNothingClass = getClass("scala.runtime.Nothing$")
lazy val RuntimeNullClass = getClass("scala.runtime.Null$")
-
lazy val AnyValCompanionClass = getClass("scala.runtime.AnyValCompanion").setFlag(SEALED | ABSTRACT | TRAIT)
// the scala value classes
@@ -113,14 +109,11 @@ trait Definitions extends reflect.generic.StandardDefinitions {
// exceptions and other throwables
lazy val ThrowableClass = getClass(sn.Throwable)
lazy val NullPointerExceptionClass = getClass(sn.NPException)
- lazy val NonLocalReturnControlClass = getClass(sn.NLRControl)
+ lazy val NonLocalReturnControlClass = getClass(sn.NLRControl)
lazy val IndexOutOfBoundsExceptionClass = getClass(sn.IOOBException)
lazy val UninitializedErrorClass = getClass("scala.UninitializedFieldError")
lazy val MatchErrorClass = getClass("scala.MatchError")
- lazy val InvocationTargetExceptionClass = getClass(if (forMSIL) "System.Reflection.TargetInvocationException"
- else "java.lang.reflect.InvocationTargetException")
- // java is hard coded because only used by structural values
- lazy val NoSuchMethodExceptionClass = getClass("java.lang.NoSuchMethodException")
+ lazy val InvocationTargetExceptionClass = getClass(sn.InvTargetException)
// annotations
lazy val AnnotationClass = getClass("scala.Annotation")
@@ -214,8 +207,6 @@ trait Definitions extends reflect.generic.StandardDefinitions {
lazy val SeqClass = getClass2("scala.Seq", "scala.collection.Seq")
lazy val SeqModule = getModule2("scala.Seq", "scala.collection.Seq")
def Seq_length = getMember(SeqClass, nme.length)
- lazy val RandomAccessSeqMutableClass = getMember(
- getModule2("scala.RandomAccessSeq", "scala.collection.IndexedSeq"), nme.Mutable)
lazy val ListModule = getModule2("scala.List", "scala.collection.immutable.List")
def List_apply = getMember(ListModule, nme.apply)
@@ -226,12 +217,13 @@ trait Definitions extends reflect.generic.StandardDefinitions {
lazy val ConsClass = getClass2("scala.$colon$colon", "scala.collection.immutable.$colon$colon")
lazy val NilModule = getModule2("scala.Nil", "scala.collection.immutable.Nil")
- lazy val ArrayClass = getClass("scala.Array")
- def Array_apply = getMember(ArrayClass, nme.apply)
- def Array_update = getMember(ArrayClass, nme.update)
- def Array_length = getMember(ArrayClass, nme.length)
- lazy val Array_clone = getMember(ArrayClass, nme.clone_)
+ // arrays and their members
lazy val ArrayModule = getModule("scala.Array")
+ lazy val ArrayClass = getClass("scala.Array")
+ def Array_apply = getMember(ArrayClass, nme.apply)
+ def Array_update = getMember(ArrayClass, nme.update)
+ def Array_length = getMember(ArrayClass, nme.length)
+ lazy val Array_clone = getMember(ArrayClass, nme.clone_)
// reflection / structural types
lazy val SoftReferenceClass = getClass("java.lang.ref.SoftReference")
@@ -244,14 +236,14 @@ trait Definitions extends reflect.generic.StandardDefinitions {
def methodCache_add = getMember(MethodCacheClass, nme.add_)
// scala.reflect
- lazy val PartialManifestClass = getClass("scala.reflect.ClassManifest")
- lazy val PartialManifestModule = getModule("scala.reflect.ClassManifest")
- lazy val FullManifestClass = getClass("scala.reflect.Manifest")
- lazy val FullManifestModule = getModule("scala.reflect.Manifest")
- lazy val OptManifestClass = getClass("scala.reflect.OptManifest")
- lazy val NoManifest = getModule("scala.reflect.NoManifest")
- lazy val CodeClass = getClass(sn.Code)
- lazy val CodeModule = getModule(sn.Code)
+ lazy val PartialManifestClass = getClass("scala.reflect.ClassManifest")
+ lazy val PartialManifestModule = getModule("scala.reflect.ClassManifest")
+ lazy val FullManifestClass = getClass("scala.reflect.Manifest")
+ lazy val FullManifestModule = getModule("scala.reflect.Manifest")
+ lazy val OptManifestClass = getClass("scala.reflect.OptManifest")
+ lazy val NoManifest = getModule("scala.reflect.NoManifest")
+ lazy val CodeClass = getClass(sn.Code)
+ lazy val CodeModule = getModule(sn.Code)
def Code_lift = getMember(CodeModule, nme.lift_)
lazy val ScalaSignatureAnnotation = getClass("scala.reflect.ScalaSignature")
@@ -318,7 +310,7 @@ trait Definitions extends reflect.generic.StandardDefinitions {
def Product_productPrefix = getMember(ProductRootClass, nme.productPrefix)
def Product_canEqual = getMember(ProductRootClass, nme.canEqual_)
- def productProj(z:Symbol, j: Int): Symbol = getMember(z, nme.Product_(j))
+ def productProj(z:Symbol, j: Int): Symbol = getMember(z, nme.productAccessorName(j))
def productProj(n: Int, j: Int): Symbol = productProj(ProductClass(n), j)
/** returns true if this type is exactly ProductN[T1,...,Tn], not some subclass */
diff --git a/src/compiler/scala/tools/nsc/symtab/NameMangling.scala b/src/compiler/scala/tools/nsc/symtab/NameMangling.scala
new file mode 100644
index 0000000000..525fcced84
--- /dev/null
+++ b/src/compiler/scala/tools/nsc/symtab/NameMangling.scala
@@ -0,0 +1,114 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2010 LAMP/EPFL
+ * @author Martin Odersky
+ */
+
+package scala.tools.nsc
+package symtab
+
+import util.Chars.isOperatorPart
+
+/** A trait to encapsulate name mangling. It's intended for the
+ * values and methods involved in assembling names out of other names,
+ * and not for simple synthetically named locals.
+ */
+trait NameManglers {
+ self: SymbolTable =>
+
+ trait NameMangling {
+ self: nme.type =>
+
+ val IMPL_CLASS_SUFFIX = "$class"
+ val LOCALDUMMY_PREFIX = "<local " // owner of local blocks
+ val LOCAL_SUFFIX = newTermName(LOCAL_SUFFIX_STRING)
+ val PROTECTED_PREFIX = "protected$"
+ val PROTECTED_SET_PREFIX = PROTECTED_PREFIX + "set"
+ val SELECTOR_DUMMY = "<unapply-selector>"
+ val SETTER_SUFFIX = encode("_=")
+ val SUPER_PREFIX_STRING = "super$"
+ val TRAIT_SETTER_SEPARATOR_STRING = "$_setter_$"
+
+ def isConstructorName(name: Name) = name == CONSTRUCTOR || name == MIXIN_CONSTRUCTOR
+ def isExceptionResultName(name: Name) = name startsWith EXCEPTION_RESULT_PREFIX
+ def isImplClassName(name: Name) = name endsWith IMPL_CLASS_SUFFIX
+ def isLocalDummyName(name: Name) = name startsWith LOCALDUMMY_PREFIX
+ def isLocalName(name: Name) = name endsWith LOCAL_SUFFIX
+ def isLoopHeaderLabel(name: Name) = (name startsWith WHILE_PREFIX) || (name startsWith DO_WHILE_PREFIX)
+ def isProtectedAccessorName(name: Name) = name startsWith PROTECTED_PREFIX
+ def isSetterName(name: Name) = name endsWith SETTER_SUFFIX
+ def isTraitSetterName(name: Name) = isSetterName(name) && (name containsName TRAIT_SETTER_SEPARATOR_STRING)
+
+ def isOpAssignmentName(name: Name) = name match {
+ case NEraw | LEraw | GEraw | EMPTY => false
+ case _ =>
+ name.endChar == '=' && name.startChar != '=' && isOperatorPart(name.startChar)
+ }
+
+ /** The expanded setter name of `name' relative to this class `base`
+ */
+ def expandedSetterName(name: Name, base: Symbol): Name =
+ expandedName(name, base, separator = TRAIT_SETTER_SEPARATOR_STRING)
+
+ /** If `name' is an expandedName name, the original name.
+ * Otherwise `name' itself.
+ */
+ def originalName(name: Name): Name = {
+ var i = name.length
+ while (i >= 2 && !(name(i - 1) == '$' && name(i - 2) == '$')) i -= 1
+ if (i >= 2) {
+ while (i >= 3 && name(i - 3) == '$') i -= 1
+ name.subName(i, name.length)
+ } else name
+ }
+
+ /** Return the original name and the types on which this name
+ * is specialized. For example,
+ * {{{
+ * splitSpecializedName("foo$mIcD$sp") == ('foo', "I", "D")
+ * }}}
+ * `foo$mIcD$sp` is the name of a method specialized on two type
+ * parameters, the first one belonging to the method itself, on Int,
+ * and another one belonging to the enclosing class, on Double.
+ */
+ def splitSpecializedName(name: Name): (Name, String, String) =
+ if (name.endsWith("$sp")) {
+ val name1 = name.subName(0, name.length - 3)
+ val idxC = name1.lastPos('c')
+ val idxM = name1.lastPos('m', idxC)
+ (name1.subName(0, idxM - 1).toString,
+ name1.subName(idxC + 1, name1.length).toString,
+ name1.subName(idxM + 1, idxC).toString)
+ } else
+ (name, "", "")
+
+ def getterName(name: Name): Name = if (isLocalName(name)) localToGetter(name) else name
+ def getterToLocal(name: Name): Name = name append LOCAL_SUFFIX
+ def getterToSetter(name: Name): Name = name append SETTER_SUFFIX
+ def localToGetter(name: Name): Name = name stripEnd LOCAL_SUFFIX
+
+ def setterToGetter(name: Name): Name = {
+ val p = name.pos(TRAIT_SETTER_SEPARATOR_STRING)
+ if (p < name.length)
+ setterToGetter(name.subName(p + TRAIT_SETTER_SEPARATOR_STRING.length, name.length))
+ else
+ name stripEnd SETTER_SUFFIX
+ }
+
+ def defaultGetterName(name: Name, pos: Int): Name = {
+ val prefix = if (isConstructorName(name)) "init" else name
+ newTermName(prefix + DEFAULT_GETTER_STRING + pos)
+ }
+
+ def implClassName(name: Name): Name = name.toTypeName append IMPL_CLASS_SUFFIX
+ def interfaceName(implname: Name): Name = implname stripEnd IMPL_CLASS_SUFFIX
+ def localDummyName(clazz: Symbol): Name = newTermName(LOCALDUMMY_PREFIX + clazz.name + ">")
+ def productAccessorName(i: Int): Name = newTermName("_" + i)
+ def superName(name: Name): Name = newTermName(SUPER_PREFIX_STRING + name)
+
+ /** The name of an accessor for protected symbols. */
+ def protName(name: Name): Name = newTermName(PROTECTED_PREFIX + name)
+
+ /** The name of a setter for protected symbols. Used for inherited Java fields. */
+ def protSetterName(name: Name): Name = newTermName(PROTECTED_SET_PREFIX + name)
+ }
+}
diff --git a/src/compiler/scala/tools/nsc/symtab/Names.scala b/src/compiler/scala/tools/nsc/symtab/Names.scala
index e6222a7a94..8cf95197c6 100644
--- a/src/compiler/scala/tools/nsc/symtab/Names.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Names.scala
@@ -10,7 +10,7 @@ import scala.reflect.NameTransformer
import scala.io.Codec
import java.security.MessageDigest
-/** The class <code>Names</code> ...
+/** The class Names ...
*
* @author Martin Odersky
* @version 1.0, 05/02/2005
@@ -52,13 +52,7 @@ trait Names extends reflect.generic.Names {
else 0;
/** Is (the ASCII representation of) name at given index equal to
- * <code>cs[offset..offset+len-1]</code>?
- *
- * @param index ...
- * @param cs ...
- * @param offset ...
- * @param len ...
- * @return ...
+ * cs[offset..offset+len-1]?
*/
private def equals(index: Int, cs: Array[Char], offset: Int, len: Int): Boolean = {
var i = 0
@@ -104,12 +98,7 @@ trait Names extends reflect.generic.Names {
if (s.length <= MaxClassNameLength) s
else toMD5(s, MaxClassNameLength / 4)
- /** Create a term name from the characters in <code>cs[offset..offset+len-1]</code>.
- *
- * @param cs ...
- * @param offset ...
- * @param len ...
- * @return the created term name
+ /** Create a term name from the characters in cs[offset..offset+len-1].
*/
def newTermName(cs: Array[Char], offset: Int, len: Int): Name = {
val h = hashValue(cs, offset, len) & HASH_MASK
@@ -128,37 +117,22 @@ trait Names extends reflect.generic.Names {
def newTermName(s: String): Name =
newTermName(s.toCharArray(), 0, s.length())
- /** Create a term name from the UTF8 encoded bytes in <code>bs[offset..offset+len-1]</code>.
- *
- * @param bs ...
- * @param offset ...
- * @param len ...
- * @return the created term name
+ /** Create a term name from the UTF8 encoded bytes in bs[offset..offset+len-1].
*/
def newTermName(bs: Array[Byte], offset: Int, len: Int): Name =
newTermName(Codec toUTF8 bs.slice(offset, offset + len) mkString)
- /** Create a type name from the characters in <code>cs[offset..offset+len-1]</code>.
- *
- * @param cs ...
- * @param offset ...
- * @param len ...
- * @return the created type name
+ /** Create a type name from the characters in cs[offset..offset+len-1].
*/
def newTypeName(cs: Array[Char], offset: Int, len: Int): Name =
newTermName(cs, offset, len).toTypeName
- /** create a type name from string
+ /** Create a type name from string
*/
def newTypeName(s: String): Name =
newTermName(s).toTypeName
- /** Create a type name from the UTF8 encoded bytes in <code>bs[offset..offset+len-1]</code>.
- *
- * @param bs ...
- * @param offset ...
- * @param len ...
- * @return the create type name
+ /** Create a type name from the UTF8 encoded bytes in bs[offset..offset+len-1].
*/
def newTypeName(bs: Array[Byte], offset: Int, len: Int): Name =
newTermName(bs, offset, len).toTypeName
@@ -185,7 +159,6 @@ trait Names extends reflect.generic.Names {
/** return the length of this name
*/
final def length: Int = len
-
final def isEmpty = length == 0
def isTermName: Boolean
@@ -193,12 +166,7 @@ trait Names extends reflect.generic.Names {
def toTermName: Name
def toTypeName: Name
-
- /** Copy bytes of this name to buffer <code>cs</code>, starting at position
- * <code>offset</code>.
- *
- * @param cs ...
- * @param offset ...
+ /** Copy bytes of this name to buffer cs, starting at position `offset`.
*/
final def copyChars(cs: Array[Char], offset: Int) =
compat.Platform.arraycopy(chrs, index, cs, offset, len)
@@ -240,12 +208,12 @@ trait Names extends reflect.generic.Names {
/** return the index of first occurrence of char c in this name, length if not found */
final def pos(s: String): Int = pos(s, 0)
- /** return the index of the first occurrence of character <code>c</code> in
- * this name from <code>start</code>, length if not found.
+ /** return the index of the first occurrence of character c in
+ * this name from start, length if not found.
*
* @param c the character
* @param start ...
- * @return the index of the first occurrence of <code>c</code>
+ * @return the index of the first occurrence of c
*/
final def pos(c: Char, start: Int): Int = {
var i = start
@@ -253,12 +221,12 @@ trait Names extends reflect.generic.Names {
i
}
- /** return the index of the first occurrence of nonempty string <code>s</code>
- * in this name from <code>start</code>, length if not found.
+ /** return the index of the first occurrence of nonempty string s
+ * in this name from start, length if not found.
*
* @param s the string
* @param start ...
- * @return the index of the first occurrence of <code>s</code>
+ * @return the index of the first occurrence of s
*/
final def pos(s: String, start: Int): Int = {
var i = pos(s.charAt(0), start)
@@ -273,22 +241,22 @@ trait Names extends reflect.generic.Names {
len
}
- /** return the index of last occurrence of char <code>c</code> in this
- * name, <code>-1</code> if not found.
+ /** return the index of last occurrence of char c in this
+ * name, -1 if not found.
*
* @param c the character
- * @return the index of the last occurrence of <code>c</code>
+ * @return the index of the last occurrence of c
*/
final def lastPos(c: Char): Int = lastPos(c, len - 1)
final def lastPos(s: String): Int = lastPos(s, len - s.length())
- /** return the index of the last occurrence of char <code>c</code> in this
- * name from <code>start</code>, <code>-1</code> if not found.
+ /** return the index of the last occurrence of char c in this
+ * name from start, -1 if not found.
*
* @param c the character
* @param start ...
- * @return the index of the last occurrence of <code>c</code>
+ * @return the index of the last occurrence of c
*/
final def lastPos(c: Char, start: Int): Int = {
var i = start
@@ -296,12 +264,12 @@ trait Names extends reflect.generic.Names {
i
}
- /** return the index of the last occurrence of string <code>s</code> in this
- * name from <code>start</code>, <code>-1</code> if not found.
+ /** return the index of the last occurrence of string s in this
+ * name from start, -1 if not found.
*
* @param s the string
* @param start ...
- * @return the index of the last occurrence of <code>s</code>
+ * @return the index of the last occurrence of s
*/
final def lastPos(s: String, start: Int): Int = {
var i = lastPos(s.charAt(0), start)
@@ -351,20 +319,25 @@ trait Names extends reflect.generic.Names {
start <= last
}
+ /** Some thoroughly self-explanatory convenience functions. They
+ * assume that what they're being asked to do is known to be valid.
+ */
+ final def startChar: Char = apply(0)
+ final def endChar: Char = apply(len - 1)
+ final def startsWith(char: Char): Boolean = len > 0 && startChar == char
+ final def endsWith(char: Char): Boolean = len > 0 && endChar == char
+ final def stripStart(prefix: Name): Name = subName(prefix.length, len)
+ final def stripEnd(suffix: Name): Name = subName(0, len - suffix.length)
+ final def append(suffix: Name): Name =
+ if (isTermName) newTermName(this.toString + suffix)
+ else newTypeName(this.toString + suffix)
+
/** Return the subname with characters from start to end-1.
- *
- * @param from ...
- * @param to ...
- * @return ...
*/
def subName(from: Int, to: Int): Name
- /** Replace all occurrences of <code>from</code> by </code>to</code> in
+ /** Replace all occurrences of `from` by `to` in
* name; result is always a term name.
- *
- * @param from ...
- * @param to ...
- * @return ...
*/
def replace(from: Char, to: Char): Name = {
val cs = new Array[Char](len)
@@ -377,7 +350,7 @@ trait Names extends reflect.generic.Names {
newTermName(cs, 0, len)
}
- /** Replace operator symbols by corresponding <code>$op_name</code>.
+ /** Replace operator symbols by corresponding $op_name.
*/
def encode: Name = {
val str = toString()
@@ -387,7 +360,7 @@ trait Names extends reflect.generic.Names {
else newTermName(res)
}
- /** Replace <code>$op_name</code> by corresponding operator symbol.
+ /** Replace $op_name by corresponding operator symbol.
*/
def decode: String = (
NameTransformer.decode(toString()) +
diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
index 10c5d69371..ac76dc8401 100644
--- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala
+++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
@@ -6,14 +6,13 @@
package scala.tools.nsc
package symtab
-import scala.reflect.NameTransformer
-import util.Chars.isOperatorPart
+import scala.collection.{ mutable, immutable }
-trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
+trait StdNames extends reflect.generic.StdNames with NameManglers {
+ self: SymbolTable =>
- object nme extends StandardNames {
-
- // Scala keywords; enter them first to minimize scanner.maxKey
+ object nme extends StandardNames with NameMangling {
+ // Scala keywords
val ABSTRACTkw = newTermName("abstract")
val CASEkw = newTermName("case")
val CLASSkw = newTermName("class")
@@ -32,12 +31,9 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val IMPORTkw = newTermName("import")
val LAZYkw = newTermName("lazy")
val MATCHkw = newTermName("match")
- val MIXINkw = newTermName("mixin")
val NEWkw = newTermName("new")
val NULLkw = newTermName("null")
val OBJECTkw = newTermName("object")
- val OUTER = newTermName("$outer")
- val OUTER_LOCAL = newTermName("$outer ")
val OVERRIDEkw = newTermName("override")
val PACKAGEkw = newTermName("package")
val PRIVATEkw = newTermName("private")
@@ -50,7 +46,6 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val THROWkw = newTermName("throw")
val TRAITkw = newTermName("trait")
val TRUEkw = newTermName("true")
- val TYPE_ = newTermName("TYPE")
val TRYkw = newTermName("try")
val TYPEkw = newTermName("type")
val VALkw = newTermName("val")
@@ -70,171 +65,61 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val HASHkw = newTermName("#")
val ATkw = newTermName("@")
- val LOCALDUMMY_PREFIX_STRING = "<local "
- val SUPER_PREFIX_STRING = "super$"
- val TRAIT_SETTER_SEPARATOR_STRING = "$_setter_$"
- val TUPLE_FIELD_PREFIX_STRING = "_"
- val CHECK_IF_REFUTABLE_STRING = "check$ifrefutable$"
- val DEFAULT_GETTER_STRING = "$default$"
-
- val INTERPRETER_WRAPPER_SUFFIX = "$object"
- val INTERPRETER_LINE_PREFIX = "line"
- val INTERPRETER_VAR_PREFIX = "res"
- val INTERPRETER_IMPORT_WRAPPER = "$iw"
- val INTERPRETER_SYNTHVAR_PREFIX = "synthvar$"
- val EVIDENCE_PARAM_PREFIX = "evidence$"
-
- def LOCAL(clazz: Symbol) = newTermName(LOCALDUMMY_PREFIX_STRING + clazz.name+">")
- def TUPLE_FIELD(index: Int) = newTermName(TUPLE_FIELD_PREFIX_STRING + index)
-
- val LOCAL_SUFFIX = newTermName(LOCAL_SUFFIX_STRING)
- val SETTER_SUFFIX = encode("_=")
- val IMPL_CLASS_SUFFIX = newTermName("$class")
- val LOCALDUMMY_PREFIX = newTermName(LOCALDUMMY_PREFIX_STRING)
- val SELECTOR_DUMMY = newTermName("<unapply-selector>")
-
- val MODULE_INSTANCE_FIELD = newTermName("MODULE$")
- val SPECIALIZED_INSTANCE = newTermName("specInstance$")
-
- def isLocalName(name: Name) = name.endsWith(LOCAL_SUFFIX)
- def isSetterName(name: Name) = name.endsWith(SETTER_SUFFIX)
- def isLocalDummyName(name: Name) = name.startsWith(LOCALDUMMY_PREFIX)
- def isTraitSetterName(name: Name) = isSetterName(name) && name.pos(TRAIT_SETTER_SEPARATOR_STRING) < name.length
- def isConstructorName(name: Name) = name == CONSTRUCTOR || name == MIXIN_CONSTRUCTOR
- def isOpAssignmentName(name: Name) =
- name(name.length - 1) == '=' &&
- isOperatorPart(name(0)) &&
- name(0) != '=' && name != NEraw && name != LEraw && name != GEraw
-
- /** The expanded setter name of `name' relative to this class `base`
- */
- def expandedSetterName(name: Name, base: Symbol): Name =
- expandedName(name, base, separator = TRAIT_SETTER_SEPARATOR_STRING)
-
- /** If `name' is an expandedName name, the original name.
- * Otherwise `name' itself.
- */
- def originalName(name: Name): Name = {
- var i = name.length
- while (i >= 2 && !(name(i - 1) == '$' && name(i - 2) == '$')) i -= 1
- if (i >= 2) {
- while (i >= 3 && name(i - 3) == '$') i -= 1
- name.subName(i, name.length)
- } else name
- }
-
- /** Return the original name and the types on which this name
- * is specialized. For example,
- * {{{
- * splitSpecializedName("foo$mIcD$sp") == ('foo', "I", "D")
- * }}}
- * `foo$mIcD$sp` is the name of a method specialized on two type
- * parameters, the first one belonging to the method itself, on Int,
- * and another one belonging to the enclosing class, on Double.
- */
- def splitSpecializedName(name: Name): (Name, String, String) =
- if (name.endsWith("$sp")) {
- val name1 = name.subName(0, name.length - 3)
- val idxC = name1.lastPos('c')
- val idxM = name1.lastPos('m', idxC)
- (name1.subName(0, idxM - 1).toString,
- name1.subName(idxC + 1, name1.length).toString,
- name1.subName(idxM + 1, idxC).toString)
- } else
- (name, "", "")
-
- def localToGetter(name: Name): Name = {
- assert(isLocalName(name))//debug
- name.subName(0, name.length - LOCAL_SUFFIX.length)
- }
-
- def getterToLocal(name: Name): Name = {
- newTermName(name.toString() + LOCAL_SUFFIX)
- }
-
- def getterToSetter(name: Name): Name = {
- newTermName(name.toString() + SETTER_SUFFIX)
- }
-
- def setterToGetter(name: Name): Name = {
- val p = name.pos(TRAIT_SETTER_SEPARATOR_STRING)
- if (p < name.length)
- setterToGetter(name.subName(p + TRAIT_SETTER_SEPARATOR_STRING.length, name.length))
- else
- name.subName(0, name.length - SETTER_SUFFIX.length)
- }
-
- def defaultGetterName(name: Name, pos: Int): Name = {
- val prefix = if (isConstructorName(name)) "init" else name
- newTermName(prefix + DEFAULT_GETTER_STRING + pos)
- }
-
- def getterName(name: Name): Name =
- if (isLocalName(name)) localToGetter(name) else name;
-
- def isExceptionResultName(name: Name) =
- (name startsWith EXCEPTION_RESULT_PREFIX)
-
- def isLoopHeaderLabel(name: Name): Boolean =
- (name startsWith WHILE_PREFIX) || (name startsWith DO_WHILE_PREFIX)
-
- def isImplClassName(name: Name): Boolean =
- name endsWith IMPL_CLASS_SUFFIX;
+ val INTERPRETER_IMPORT_WRAPPER = "$iw"
+ val INTERPRETER_LINE_PREFIX = "line"
+ val INTERPRETER_SYNTHVAR_PREFIX = "synthvar$"
+ val INTERPRETER_VAR_PREFIX = "res"
+ val INTERPRETER_WRAPPER_SUFFIX = "$object"
- def implClassName(name: Name): Name =
- newTypeName(name.toString() + IMPL_CLASS_SUFFIX)
-
- def interfaceName(implname: Name): Name =
- implname.subName(0, implname.length - IMPL_CLASS_SUFFIX.length)
-
- def superName(name: Name) = newTermName("super$" + name)
-
- val PROTECTED_PREFIX = "protected$"
- def isProtectedAccessor(name: Name) = name.startsWith(PROTECTED_PREFIX)
-
- /** The name of an accessor for protected symbols. */
- def protName(name: Name): Name = newTermName(PROTECTED_PREFIX + name)
-
- /** The name of a setter for protected symbols. Used for inherited Java fields. */
- def protSetterName(name: Name): Name = newTermName(PROTECTED_PREFIX + "set" + name)
-
- private def bitmapName(n: Int, suffix: String): Name = newTermName("bitmap$" + suffix + n)
+ private def bitmapName(n: Int, suffix: String): Name =
+ newTermName(BITMAP_PREFIX + suffix + n)
/** The name of bitmaps for initialized (public or protected) lazy vals. */
def bitmapName(n: Int): Name = bitmapName(n, "")
- /** The name of bitmaps for initialized transitive lazy vals. */
+ /** The name of bitmaps for initialized transient lazy vals. */
def bitmapNameForTransitive(n: Int): Name = bitmapName(n, "trans$")
/** The name of bitmaps for initialized private lazy vals. */
def bitmapNameForPrivate(n: Int): Name = bitmapName(n, "priv$")
+ /** Base strings from which synthetic names are derived. */
+ val BITMAP_PREFIX = "bitmap$"
+ val CHECK_IF_REFUTABLE_STRING = "check$ifrefutable$"
+ val DEFAULT_GETTER_STRING = "$default$"
+ val DO_WHILE_PREFIX = "doWhile$"
+ val EQEQ_LOCAL_VAR = "eqEqTemp$"
+ val EVIDENCE_PARAM_PREFIX = "evidence$"
+ val EXCEPTION_RESULT_PREFIX = "exceptionResult"
+ val MODULE_INSTANCE_FIELD = "MODULE$"
+ val SPECIALIZED_INSTANCE = "specInstance$"
+ val WHILE_PREFIX = "while$"
+
+ /** Internal names */
+ val ANYNAME = newTermName("<anyname>")
+ val BYNAME_PARAM_CLASS_NAME = newTermName("<byname>")
+ val EQUALS_PATTERN_NAME = newTermName("<equals>")
+ val ERROR = newTermName("<error>")
+ val JAVA_REPEATED_PARAM_CLASS_NAME = newTermName("<repeated...>")
+ val LOCALCHILD = newTypeName("<local child>")
+ val NOSYMBOL = newTermName("<none>")
+ val REPEATED_PARAM_CLASS_NAME = newTermName("<repeated>")
- /** The label prefixes for generated while and do loops. */
- val WHILE_PREFIX = "while$"
- val DO_WHILE_PREFIX = "doWhile$"
- val EXCEPTION_RESULT_PREFIX = "exceptionResult"
+ val CONSTRUCTOR = newTermName("<init>")
+ val INITIALIZER = newTermName("<init>")
+ val INLINED_INITIALIZER = newTermName("$init$")
+ val MIXIN_CONSTRUCTOR = newTermName("$init$")
- val ERROR = newTermName("<error>")
- val LOCALCHILD = newTypeName("<local child>")
+ val OUTER = newTermName("$outer")
+ val OUTER_LOCAL = newTermName("$outer ")
+ val SELF = newTermName("$this")
+ val THIS = newTermName("_$this")
+ val FAKE_LOCAL_THIS = newTermName("this$")
- val NOSYMBOL = newTermName("<none>")
- val ANYNAME = newTermName("<anyname>")
- val WILDCARD = newTermName("_")
+ val TYPE_ = newTermName("TYPE")
+ val WILDCARD = newTermName("_")
val WILDCARD_STAR = newTermName("_*")
-
- val STAR = newTermName("*")
- val REPEATED_PARAM_CLASS_NAME = newTermName("<repeated>")
- val JAVA_REPEATED_PARAM_CLASS_NAME = newTermName("<repeated...>")
- val BYNAME_PARAM_CLASS_NAME = newTermName("<byname>")
- val EQUALS_PATTERN_NAME = newTermName("<equals>")
- val SELF = newTermName("$this")
- val THIS = newTermName("_$this")
-
- val CONSTRUCTOR = newTermName("<init>")
- val MIXIN_CONSTRUCTOR = newTermName("$init$")
- val INITIALIZER = newTermName("<init>")
- val INLINED_INITIALIZER = newTermName("$init$")
+ val STAR = newTermName("*")
val MINUS = encode("-")
val PLUS = encode("+")
@@ -247,7 +132,6 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val COLONCOLON = encode("::")
val PERCENT = encode("%")
val EQL = encode("=")
- val USCOREEQL = encode("_=")
val HASHHASH = encode("##")
val Nothing = newTermName("Nothing")
@@ -258,14 +142,11 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val Array = newTermName("Array")
val Boolean = newTermName("Boolean")
val Byte = newTermName("Byte")
- val Catch = newTermName("Catch")
val Char = newTermName("Char")
val Do = newTermName("Do")
val Double = newTermName("Double")
- val Finally = newTermName("Finally")
val Float = newTermName("Float")
val Function = newTermName("Function")
- val Function1 = newTermName("Function1")
val Int = newTermName("Int")
val List = newTermName("List")
val Long = newTermName("Long")
@@ -274,7 +155,6 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val PartialFunction = newTermName("PartialFunction")
val Predef = newTermName("Predef")
val Product = newTermName("Product")
- def Product_(i:Int) = newTermName("_" + i)
val ScalaObject = newTermName("ScalaObject")
val ScalaRunTime = newTermName("ScalaRunTime")
val Seq = newTermName("Seq")
@@ -285,9 +165,7 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val Symbol = newTermName("Symbol")
val System = newTermName("System")
val Throwable = newTermName("Throwable")
- val Try = newTermName("Try")
val Tuple = newTermName("Tuple")
- val Tuple2 = newTermName("Tuple2")
val Unit = newTermName("Unit")
val apply = newTermName("apply")
@@ -309,7 +187,6 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val elem = newTermName("elem")
val eq = newTermName("eq")
val equals_ = newTermName("equals")
- val _equals = newTermName("_equals")
val inlinedEquals = newTermName("inlinedEquals")
val error = newTermName("error")
val ex = newTermName("ex")
@@ -319,18 +196,16 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val finalize_ = newTermName("finalize")
val find_ = newTermName("find")
val flatMap = newTermName("flatMap")
- val forName = newTermName(if (forMSIL) "GetType" else "forName")
val foreach = newTermName("foreach")
val get = newTermName("get")
- val getCause = newTermName(if (forMSIL) "InnerException" /* System.Reflection.TargetInvocationException.InnerException */
- else "getCause")
- val getClass_ = newTermName(if (forMSIL) "GetType" else "getClass")
- val getMethod_ = newTermName(if (forMSIL) "GetMethod" else "getMethod")
+ def getCause = sn.GetCause
+ def getClass_ = sn.GetClass
+ def getMethod_ = sn.GetMethod
val hash_ = newTermName("hash")
val hashCode_ = newTermName("hashCode")
val hasNext = newTermName("hasNext")
val head = newTermName("head")
- val invoke_ = newTermName(if (forMSIL) "Invoke" else "invoke")
+ def invoke_ = sn.Invoke
val isArray = newTermName("isArray")
val isInstanceOf_ = newTermName("isInstanceOf")
val isDefinedAt = newTermName("isDefinedAt")
@@ -342,7 +217,6 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val lift_ = newTermName("lift")
val main = newTermName("main")
val map = newTermName("map")
- val Mutable = newTypeName("Mutable")
val ne = newTermName("ne")
val newArray = newTermName("newArray")
val next = newTermName("next")
@@ -350,7 +224,6 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val notifyAll_ = newTermName("notifyAll")
val null_ = newTermName("null")
val ofDim = newTermName("ofDim")
- val print = newTermName("print")
val productArity = newTermName("productArity")
val productElement = newTermName("productElement")
// val productElementName = newTermName("productElementName")
@@ -445,98 +318,116 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val ScalaATTR = newTermName("Scala")
}
- def encode(str: String): Name = newTermName(NameTransformer.encode(str))
-
abstract class SymbolNames {
- val JavaLang : Name
- val Object : Name
- val Class : Name
- val String : Name
- val Throwable : Name
- val NPException : Name // NullPointerException
- val NLRControl : Name = newTermName("scala.runtime.NonLocalReturnControl")
- val ValueType : Name
- val Serializable : Name
- val BeanProperty : Name
- val BooleanBeanProperty: Name
- val Delegate : Name
- val IOOBException: Name // IndexOutOfBoundsException
- val Code : Name
- val BoxedNumber : Name
- val BoxedCharacter : Name
- val BoxedBoolean : Name
- val MethodAsObject : Name
-
- import scala.collection.mutable.HashMap
- val Boxed = new HashMap[Name, Name]
+ val BeanProperty : Name
+ val BooleanBeanProperty : Name
+ val BoxedBoolean : Name
+ val BoxedCharacter : Name
+ val BoxedNumber : Name
+ val Class : Name
+ val Code : Name
+ val Delegate : Name
+ val ForName : Name
+ val GetCause : Name
+ val GetClass : Name
+ val GetMethod : Name
+ val IOOBException : Name // IndexOutOfBoundsException
+ val InvTargetException : Name // InvocationTargetException
+ val Invoke : Name
+ val JavaLang : Name
+ val MethodAsObject : Name
+ val NLRControl : Name = newTermName("scala.runtime.NonLocalReturnControl")
+ val NPException : Name // NullPointerException
+ val Object : Name
+ val Serializable : Name
+ val String : Name
+ val Throwable : Name
+ val ValueType : Name
+
+ val Boxed: immutable.Map[Name, Name]
}
private abstract class JavaNames extends SymbolNames {
- final val JavaLang = newTermName("java.lang")
- final val Object = newTermName("java.lang.Object")
- final val Class = newTermName("java.lang.Class")
- final val String = newTermName("java.lang.String")
- final val Throwable = newTermName("java.lang.Throwable")
- final val NPException = newTermName("java.lang.NullPointerException")
- final val ValueType = nme.NOSYMBOL
- final val Delegate = nme.NOSYMBOL
- final val IOOBException = newTermName("java.lang.IndexOutOfBoundsException")
- final val BoxedNumber = newTermName("java.lang.Number")
- final val BoxedCharacter = newTermName("java.lang.Character")
- final val BoxedBoolean = newTermName("java.lang.Boolean")
- final val BoxedByte = newTermName("java.lang.Byte")
- final val BoxedShort = newTermName("java.lang.Short")
- final val BoxedInteger = newTermName("java.lang.Integer")
- final val BoxedLong = newTermName("java.lang.Long")
- final val BoxedFloat = newTermName("java.lang.Float")
- final val BoxedDouble = newTermName("java.lang.Double")
-
- final val MethodAsObject = newTermName("java.lang.reflect.Method")
-
- Boxed += (nme.Boolean -> BoxedBoolean)
- Boxed += (nme.Byte -> BoxedByte)
- Boxed += (nme.Char -> BoxedCharacter)
- Boxed += (nme.Short -> BoxedShort)
- Boxed += (nme.Int -> BoxedInteger)
- Boxed += (nme.Long -> BoxedLong)
- Boxed += (nme.Float -> BoxedFloat)
- Boxed += (nme.Double -> BoxedDouble)
+ final val BoxedBoolean = newTermName("java.lang.Boolean")
+ final val BoxedByte = newTermName("java.lang.Byte")
+ final val BoxedCharacter = newTermName("java.lang.Character")
+ final val BoxedDouble = newTermName("java.lang.Double")
+ final val BoxedFloat = newTermName("java.lang.Float")
+ final val BoxedInteger = newTermName("java.lang.Integer")
+ final val BoxedLong = newTermName("java.lang.Long")
+ final val BoxedNumber = newTermName("java.lang.Number")
+ final val BoxedShort = newTermName("java.lang.Short")
+ final val Class = newTermName("java.lang.Class")
+ final val Delegate = nme.NOSYMBOL
+ final val ForName = newTermName("forName")
+ final val GetCause = newTermName("getCause")
+ final val GetClass = newTermName("getClass")
+ final val GetMethod = newTermName("getMethod")
+ final val IOOBException = newTermName("java.lang.IndexOutOfBoundsException")
+ final val InvTargetException = newTermName("java.lang.reflect.InvocationTargetException")
+ final val Invoke = newTermName("invoke")
+ final val JavaLang = newTermName("java.lang")
+ final val MethodAsObject = newTermName("java.lang.reflect.Method")
+ final val NPException = newTermName("java.lang.NullPointerException")
+ final val Object = newTermName("java.lang.Object")
+ final val String = newTermName("java.lang.String")
+ final val Throwable = newTermName("java.lang.Throwable")
+ final val ValueType = nme.NOSYMBOL
+
+ val Boxed = immutable.Map[Name, Name](
+ nme.Boolean -> BoxedBoolean,
+ nme.Byte -> BoxedByte,
+ nme.Char -> BoxedCharacter,
+ nme.Short -> BoxedShort,
+ nme.Int -> BoxedInteger,
+ nme.Long -> BoxedLong,
+ nme.Float -> BoxedFloat,
+ nme.Double -> BoxedDouble
+ )
}
private class MSILNames extends SymbolNames {
- final val JavaLang = newTermName("System")
- final val Object = newTermName("System.Object")
- final val Class = newTermName("System.Type")
- final val String = newTermName("System.String")
- final val Throwable = newTermName("System.Exception")
- final val NPException = newTermName("System.NullReferenceException")
- final val ValueType = newTermName("System.ValueType")
- final val Serializable = nme.NOSYMBOL
- final val BeanProperty = nme.NOSYMBOL
+ final val BeanProperty = nme.NOSYMBOL
final val BooleanBeanProperty = nme.NOSYMBOL
- final val Delegate = newTermName("System.MulticastDelegate")
- final val IOOBException = newTermName("System.IndexOutOfRangeException")
- final val Code = nme.NOSYMBOL
- final val BoxedNumber = newTermName("System.IConvertible")
- final val BoxedCharacter = newTermName("System.IConvertible")
- final val BoxedBoolean = newTermName("System.IConvertible")
- final val MethodAsObject = newTermName("System.Reflection.MethodInfo")
-
- Boxed += (nme.Boolean -> newTermName("System.Boolean"))
- Boxed += (nme.Byte -> newTermName("System.Byte"))
- Boxed += (nme.Char -> newTermName("System.Char"))
- Boxed += (nme.Short -> newTermName("System.Int16"))
- Boxed += (nme.Int -> newTermName("System.Int32"))
- Boxed += (nme.Long -> newTermName("System.Int64"))
- Boxed += (nme.Float -> newTermName("System.Single"))
- Boxed += (nme.Double -> newTermName("System.Double"))
+ final val BoxedBoolean = newTermName("System.IConvertible")
+ final val BoxedCharacter = newTermName("System.IConvertible")
+ final val BoxedNumber = newTermName("System.IConvertible")
+ final val Class = newTermName("System.Type")
+ final val Code = nme.NOSYMBOL
+ final val Delegate = newTermName("System.MulticastDelegate")
+ final val ForName = newTermName("GetType")
+ final val GetCause = newTermName("InnerException") /* System.Reflection.TargetInvocationException.InnerException */
+ final val GetClass = newTermName("GetType")
+ final val GetMethod = newTermName("GetMethod")
+ final val IOOBException = newTermName("System.IndexOutOfRangeException")
+ final val InvTargetException = newTermName("System.Reflection.TargetInvocationException")
+ final val Invoke = newTermName("Invoke")
+ final val JavaLang = newTermName("System")
+ final val MethodAsObject = newTermName("System.Reflection.MethodInfo")
+ final val NPException = newTermName("System.NullReferenceException")
+ final val Object = newTermName("System.Object")
+ final val Serializable = nme.NOSYMBOL
+ final val String = newTermName("System.String")
+ final val Throwable = newTermName("System.Exception")
+ final val ValueType = newTermName("System.ValueType")
+
+ val Boxed = immutable.Map[Name, Name](
+ nme.Boolean -> newTermName("System.Boolean"),
+ nme.Byte -> newTermName("System.Byte"),
+ nme.Char -> newTermName("System.Char"),
+ nme.Short -> newTermName("System.Int16"),
+ nme.Int -> newTermName("System.Int32"),
+ nme.Long -> newTermName("System.Int64"),
+ nme.Float -> newTermName("System.Single"),
+ nme.Double -> newTermName("System.Double")
+ )
}
private class J2SENames extends JavaNames {
- final val Serializable = newTermName("java.io.Serializable")
- final val BeanProperty = newTermName("scala.reflect.BeanProperty")
- final val BooleanBeanProperty = newTermName("scala.reflect.BooleanBeanProperty")
- final val Code = newTermName("scala.reflect.Code")
+ final val BeanProperty = newTermName("scala.reflect.BeanProperty")
+ final val BooleanBeanProperty = newTermName("scala.reflect.BooleanBeanProperty")
+ final val Code = newTermName("scala.reflect.Code")
+ final val Serializable = newTermName("java.io.Serializable")
}
lazy val sn: SymbolNames =
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 4bc9477a40..7ffc168c6e 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -116,7 +116,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
newValue(pos, name).setFlag(PARAM)
/** Create local dummy for template (owner of local blocks) */
final def newLocalDummy(pos: Position) =
- newValue(pos, nme.LOCAL(this)).setInfo(NoType)
+ newValue(pos, nme.localDummyName(this)).setInfo(NoType)
final def newMethod(pos: Position, name: Name) =
new MethodSymbol(this, pos, name).setFlag(METHOD)
final def newMethod(name: Name, pos: Position = NoPosition) =
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
index 0c4dc9a961..d22d5c1602 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
@@ -193,8 +193,8 @@ abstract class ICodeReader extends ClassfileParser {
definitions.NothingClass
else if (name == nullName)
definitions.NullClass
- else if (name.endsWith("$class")) {
- val iface = definitions.getClass(name.subName(0, name.length - "$class".length))
+ else if (nme.isImplClassName(name)) {
+ val iface = definitions.getClass(nme.interfaceName(name))
log("forcing " + iface.owner + " at phase: " + phase + " impl: " + iface.implClass)
iface.owner.info // force the mixin type-transformer
definitions.getClass(name)
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 5c6c3a846f..78341f6046 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -99,7 +99,7 @@ abstract class RefChecks extends InfoTransform {
private def checkDefaultsInOverloaded(clazz: Symbol) {
def check(members: List[Symbol]): Unit = members match {
case x :: xs =>
- if ((x hasParamWhich (_.hasDefaultFlag)) && !nme.isProtectedAccessor(x.name)) {
+ if (x.hasParamWhich(_.hasDefaultFlag) && !nme.isProtectedAccessorName(x.name)) {
val others = xs.filter(alt => {
alt.name == x.name &&
(alt hasParamWhich (_.hasDefaultFlag)) &&
diff --git a/src/library/scala/reflect/generic/StdNames.scala b/src/library/scala/reflect/generic/StdNames.scala
index 03cee8c909..f6f89c9100 100755
--- a/src/library/scala/reflect/generic/StdNames.scala
+++ b/src/library/scala/reflect/generic/StdNames.scala
@@ -1,23 +1,28 @@
package scala.reflect
package generic
+import scala.reflect.NameTransformer
+
trait StdNames { self: Universe =>
val nme: StandardNames
+ def encode(str: String): Name = newTermName(NameTransformer.encode(str))
+
class StandardNames {
val EXPAND_SEPARATOR_STRING = "$$"
val LOCAL_SUFFIX_STRING = " "
- val ANON_CLASS_NAME = newTermName("$anon")
- val ANON_FUN_NAME = newTermName("$anonfun")
+ val EMPTY = newTermName("")
val EMPTY_PACKAGE_NAME = newTermName("<empty>")
val IMPORT = newTermName("<import>")
val REFINE_CLASS_NAME = newTermName("<refinement>")
val ROOT = newTermName("<root>")
- val ROOTPKG = newTermName("_root_")
- val EMPTY = newTermName("")
+
+ val ANON_CLASS_NAME = newTermName("$anon")
+ val ANON_FUN_NAME = newTermName("$anonfun")
val MODULE_SUFFIX = newTermName("$module")
+ val ROOTPKG = newTermName("_root_")
/** The expanded name of `name' relative to this class `base` with given `separator`
*/