summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-02-04 15:22:03 +0000
committerPaul Phillips <paulp@improving.org>2010-02-04 15:22:03 +0000
commitbf696d016ac6d07345659e099105e62ae8d298b5 (patch)
tree174945ed169063a208fd07f91f64eda5cac8acdc /src
parenta1a6ab90ac5fe7d5db2f6fba788ce14c1613d9c6 (diff)
downloadscala-bf696d016ac6d07345659e099105e62ae8d298b5.tar.gz
scala-bf696d016ac6d07345659e099105e62ae8d298b5.tar.bz2
scala-bf696d016ac6d07345659e099105e62ae8d298b5.zip
Some minor cleanups in reflect.
into the compiler so Traversers can define whatever apply is relevant to them. No review.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala2
-rwxr-xr-xsrc/library/scala/reflect/generic/Flags.scala6
-rwxr-xr-xsrc/library/scala/reflect/generic/Symbols.scala47
-rwxr-xr-xsrc/library/scala/reflect/generic/Trees.scala1
5 files changed, 31 insertions, 29 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index 79e1a0777b..128be97d62 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -886,6 +886,10 @@ trait Trees extends reflect.generic.Trees { self: SymbolTable =>
else traverse(stat)
)
}
+
+ /** Leave apply available in the generic traverser to do something else.
+ */
+ def apply[T <: Tree](tree: T): T = { traverse(tree); tree }
}
private lazy val duplicator = new Transformer {
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index 3271ae70f6..6fae6d4e3a 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -834,7 +834,7 @@ abstract class GenJVM extends SubComponent {
cps.filter(mps contains)
}
/* The setter doesn't show up in members so we inspect the name
- * ... and clearly it helps to know how the name is encoded, see ticket #3003.
+ * ... and clearly it helps to know how the name is encoded, see ticket #3004.
* This logic is grossly inadequate! Name mangling needs a devotee.
*/
def conflictsInCommonParent(name: Name) =
diff --git a/src/library/scala/reflect/generic/Flags.scala b/src/library/scala/reflect/generic/Flags.scala
index 1cd9190f19..f0f1f14ade 100755
--- a/src/library/scala/reflect/generic/Flags.scala
+++ b/src/library/scala/reflect/generic/Flags.scala
@@ -168,9 +168,9 @@ class Flags {
var mask=m
var i=0
while (i <= 62) {
- if ((mask&1) == 1L) return i
- mask >>= 1
- i += 1
+ if ((mask&1) == 1L) return i
+ mask >>= 1
+ i += 1
}
throw new AssertionError()
}
diff --git a/src/library/scala/reflect/generic/Symbols.scala b/src/library/scala/reflect/generic/Symbols.scala
index b503d14d4b..b956f93569 100755
--- a/src/library/scala/reflect/generic/Symbols.scala
+++ b/src/library/scala/reflect/generic/Symbols.scala
@@ -46,9 +46,12 @@ trait Symbols { self: Universe =>
*/
final def fullName: String = fullName('.')
- /** Does symbol have a flag in `mask` set? */
+ /** Does symbol have ANY flag in `mask` set? */
final def hasFlag(mask: Long): Boolean = (flags & mask) != 0L
+ /** Does symbol have ALL the flags in `mask` set? */
+ final def hasAllFlags(mask: Long): Boolean = (flags & mask) == mask
+
/** Set when symbol has a modifier of the form private[X], NoSymbol otherwise.
*/
def privateWithin: Symbol
@@ -106,19 +109,13 @@ trait Symbols { self: Universe =>
// flags and kind tests
- def isTerm = false // to be overridden
- def isType = false // to be overridden
- def isClass = false // to be overridden
- def isAliasType = false //to be overridden
- def isAbstractType = false //to be overridden
+ def isTerm = false // to be overridden
+ def isType = false // to be overridden
+ def isClass = false // to be overridden
+ def isAliasType = false // to be overridden
+ def isAbstractType = false // to be overridden
private[scala] def isSkolem = false // to be overridden
- final def isImplicit = hasFlag(IMPLICIT)
- final def isFinal = hasFlag(FINAL)
- final def isPrivate = hasFlag(PRIVATE)
- final def isProtected = hasFlag(PROTECTED)
-
- /** Is this symbol a sealed class? */
def isTrait: Boolean = isClass && hasFlag(TRAIT) // refined later for virtual classes.
final def hasDefault = isParameter && hasFlag(DEFAULTPARAM)
final def isAbstractClass = isClass && hasFlag(ABSTRACT)
@@ -129,8 +126,12 @@ trait Symbols { self: Universe =>
final def isContravariant = isType && hasFlag(CONTRAVARIANT)
final def isCovariant = isType && hasFlag(COVARIANT)
final def isDeferred = hasFlag(DEFERRED) && !isClass
+ final def isEarlyInitialized: Boolean = isTerm && hasFlag(PRESUPER)
final def isExistentiallyBound = isType && hasFlag(EXISTENTIAL)
+ final def isFinal = hasFlag(FINAL)
final def isGetterOrSetter = hasFlag(ACCESSOR)
+ final def isImplClass = isClass && hasFlag(IMPLCLASS) // Is this symbol an implementation class for a mixin?
+ final def isImplicit = hasFlag(IMPLICIT)
final def isInterface = hasFlag(INTERFACE)
final def isJavaDefined = hasFlag(JAVA)
final def isLazy = hasFlag(LAZY)
@@ -140,8 +141,6 @@ trait Symbols { self: Universe =>
final def isMutable = hasFlag(MUTABLE)
final def isOverloaded = hasFlag(OVERLOADED)
final def isOverride = hasFlag(OVERRIDE)
- final def isPackage = isModule && hasFlag(PACKAGE)
- final def isPackageClass = isClass && hasFlag(PACKAGE)
final def isParamAccessor = hasFlag(PARAMACCESSOR)
final def isParameter = hasFlag(PARAM)
final def isRefinementClass = isClass && name == mkTypeName(nme.REFINE_CLASS_NAME)
@@ -151,20 +150,20 @@ trait Symbols { self: Universe =>
final def isSynthetic = hasFlag(SYNTHETIC)
final def isTypeParameter = isType && isParameter && !isSkolem
- /** Is this symbol an implementation class for a mixin? */
- final def isImplClass = isClass && hasFlag(IMPLCLASS)
-
- /** Is this symbol early initialized */
- final def isEarlyInitialized: Boolean = isTerm && hasFlag(PRESUPER)
-
+ /** Access tests */
+ final def isPrivate = hasFlag(PRIVATE)
final def isPrivateLocal = hasFlag(PRIVATE) && hasFlag(LOCAL)
+ final def isProtected = hasFlag(PROTECTED)
final def isProtectedLocal = hasFlag(PROTECTED) && hasFlag(LOCAL)
final def isPublic = !hasFlag(PRIVATE | PROTECTED) && privateWithin == NoSymbol
- final def isRoot = isPackageClass && owner == NoSymbol
- final def isRootPackage = isPackage && owner == NoSymbol
+ /** Package tests */
final def isEmptyPackage = isPackage && name == nme.EMPTY_PACKAGE_NAME
final def isEmptyPackageClass = isPackageClass && name == mkTypeName(nme.EMPTY_PACKAGE_NAME)
+ final def isPackage = isModule && hasFlag(PACKAGE)
+ final def isPackageClass = isClass && hasFlag(PACKAGE)
+ final def isRoot = isPackageClass && owner == NoSymbol
+ final def isRootPackage = isPackage && owner == NoSymbol
/** Is this symbol an effective root for fullname string?
*/
@@ -172,13 +171,13 @@ trait Symbols { self: Universe =>
// creators
- def newValue(name: Name, pos: Position = NoPosition): Symbol
def newAbstractType(name: Name, pos: Position = NoPosition): Symbol
def newAliasType(name: Name, pos: Position = NoPosition): Symbol
def newClass(name: Name, pos: Position = NoPosition): Symbol
- def newModuleClass(name: Name, pos: Position = NoPosition): Symbol
def newMethod(name: Name, pos: Position = NoPosition): Symbol
def newModule(name: Name, clazz: Symbol, pos: Position = NoPosition): Symbol
+ def newModuleClass(name: Name, pos: Position = NoPosition): Symbol
+ def newValue(name: Name, pos: Position = NoPosition): Symbol
// access to related symbols
diff --git a/src/library/scala/reflect/generic/Trees.scala b/src/library/scala/reflect/generic/Trees.scala
index 02f4f6eb35..36c7663041 100755
--- a/src/library/scala/reflect/generic/Trees.scala
+++ b/src/library/scala/reflect/generic/Trees.scala
@@ -573,7 +573,6 @@ trait Trees { self: Universe =>
else traverse(stat)
)
}
- def apply[T <: Tree](tree: T): T = { traverse(tree); tree }
def atOwner(owner: Symbol)(traverse: => Unit) {
val prevOwner = currentOwner