From 5355c120efcca2ce8e00793c7ab90ef5d06b6176 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 30 Sep 2011 16:42:52 +0000 Subject: Elininated previously deprecated package reflec... Elininated previously deprecated package reflect.generic --- .../scala/reflect/generic/AnnotationInfos.scala | 42 -- src/library/scala/reflect/generic/Constants.scala | 238 ------ src/library/scala/reflect/generic/Flags.scala | 252 ------- src/library/scala/reflect/generic/HasFlags.scala | 168 ----- src/library/scala/reflect/generic/Names.scala | 24 - .../scala/reflect/generic/PickleBuffer.scala | 186 ----- .../scala/reflect/generic/PickleFormat.scala | 224 ------ src/library/scala/reflect/generic/Scopes.scala | 15 - .../reflect/generic/StandardDefinitions.scala | 66 -- src/library/scala/reflect/generic/StdNames.scala | 44 -- src/library/scala/reflect/generic/Symbols.scala | 187 ----- src/library/scala/reflect/generic/Trees.scala | 735 ------------------ src/library/scala/reflect/generic/Types.scala | 165 ---- src/library/scala/reflect/generic/UnPickler.scala | 826 --------------------- src/library/scala/reflect/generic/Universe.scala | 17 - 15 files changed, 3189 deletions(-) delete mode 100755 src/library/scala/reflect/generic/AnnotationInfos.scala delete mode 100755 src/library/scala/reflect/generic/Constants.scala delete mode 100755 src/library/scala/reflect/generic/Flags.scala delete mode 100644 src/library/scala/reflect/generic/HasFlags.scala delete mode 100755 src/library/scala/reflect/generic/Names.scala delete mode 100755 src/library/scala/reflect/generic/PickleBuffer.scala delete mode 100755 src/library/scala/reflect/generic/PickleFormat.scala delete mode 100755 src/library/scala/reflect/generic/Scopes.scala delete mode 100755 src/library/scala/reflect/generic/StandardDefinitions.scala delete mode 100755 src/library/scala/reflect/generic/StdNames.scala delete mode 100755 src/library/scala/reflect/generic/Symbols.scala delete mode 100755 src/library/scala/reflect/generic/Trees.scala delete mode 100755 src/library/scala/reflect/generic/Types.scala delete mode 100755 src/library/scala/reflect/generic/UnPickler.scala delete mode 100755 src/library/scala/reflect/generic/Universe.scala (limited to 'src') diff --git a/src/library/scala/reflect/generic/AnnotationInfos.scala b/src/library/scala/reflect/generic/AnnotationInfos.scala deleted file mode 100755 index f995a2b340..0000000000 --- a/src/library/scala/reflect/generic/AnnotationInfos.scala +++ /dev/null @@ -1,42 +0,0 @@ -package scala.reflect -package generic - -@deprecated("scala.reflect.generic will be removed", "2.9.1") trait AnnotationInfos { self: Universe => - - type AnnotationInfo <: AnyRef - val AnnotationInfo: AnnotationInfoExtractor - - abstract class AnnotationInfoExtractor { - def apply(atp: Type, args: List[Tree], assocs: List[(Name, ClassfileAnnotArg)]): AnnotationInfo - def unapply(info: AnnotationInfo): Option[(Type, List[Tree], List[(Name, ClassfileAnnotArg)])] - } - - type ClassfileAnnotArg <: AnyRef - implicit def classfileAnnotArgManifest: ClassManifest[ClassfileAnnotArg] // need a precise manifest to pass to UnPickle's toArray call - - type LiteralAnnotArg <: ClassfileAnnotArg - val LiteralAnnotArg: LiteralAnnotArgExtractor - - type ArrayAnnotArg <: ClassfileAnnotArg - val ArrayAnnotArg: ArrayAnnotArgExtractor - - type NestedAnnotArg <: ClassfileAnnotArg - val NestedAnnotArg: NestedAnnotArgExtractor - - abstract class LiteralAnnotArgExtractor { - def apply(const: Constant): LiteralAnnotArg - def unapply(arg: LiteralAnnotArg): Option[Constant] - } - - abstract class ArrayAnnotArgExtractor { - def apply(const: Array[ClassfileAnnotArg]): ArrayAnnotArg - def unapply(arg: ArrayAnnotArg): Option[Array[ClassfileAnnotArg]] - } - - abstract class NestedAnnotArgExtractor { - def apply(anninfo: AnnotationInfo): NestedAnnotArg - def unapply(arg: NestedAnnotArg): Option[AnnotationInfo] - } -} - - diff --git a/src/library/scala/reflect/generic/Constants.scala b/src/library/scala/reflect/generic/Constants.scala deleted file mode 100755 index ca04fdac9e..0000000000 --- a/src/library/scala/reflect/generic/Constants.scala +++ /dev/null @@ -1,238 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL - * @author Martin Odersky - */ - -package scala.reflect -package generic - -import java.lang.Integer.toOctalString -import annotation.switch - -@deprecated("scala.reflect.generic will be removed", "2.9.1") trait Constants { - self: Universe => - - import definitions._ - - final val NoTag = 0 - final val UnitTag = 1 - final val BooleanTag = 2 - final val ByteTag = 3 - final val ShortTag = 4 - final val CharTag = 5 - final val IntTag = 6 - final val LongTag = 7 - final val FloatTag = 8 - final val DoubleTag = 9 - final val StringTag = 10 - final val NullTag = 11 - final val ClassTag = 12 - // For supporting java enumerations inside java annotations (see ClassfileParser) - final val EnumTag = 13 - - case class Constant(value: Any) { - val tag: Int = value match { - case null => NullTag - case x: Unit => UnitTag - case x: Boolean => BooleanTag - case x: Byte => ByteTag - case x: Short => ShortTag - case x: Int => IntTag - case x: Long => LongTag - case x: Float => FloatTag - case x: Double => DoubleTag - case x: String => StringTag - case x: Char => CharTag - case x: AbsType => ClassTag - case x: AbsSymbol => EnumTag - case _ => throw new Error("bad constant value: " + value) - } - - def isByteRange: Boolean = isIntRange && Byte.MinValue <= intValue && intValue <= Byte.MaxValue - def isShortRange: Boolean = isIntRange && Short.MinValue <= intValue && intValue <= Short.MaxValue - def isCharRange: Boolean = isIntRange && Char.MinValue <= intValue && intValue <= Char.MaxValue - def isIntRange: Boolean = ByteTag <= tag && tag <= IntTag - def isLongRange: Boolean = ByteTag <= tag && tag <= LongTag - def isFloatRange: Boolean = ByteTag <= tag && tag <= FloatTag - def isNumeric: Boolean = ByteTag <= tag && tag <= DoubleTag - - def tpe: Type = tag match { - case UnitTag => UnitClass.tpe - case BooleanTag => BooleanClass.tpe - case ByteTag => ByteClass.tpe - case ShortTag => ShortClass.tpe - case CharTag => CharClass.tpe - case IntTag => IntClass.tpe - case LongTag => LongClass.tpe - case FloatTag => FloatClass.tpe - case DoubleTag => DoubleClass.tpe - case StringTag => StringClass.tpe - case NullTag => NullClass.tpe - case ClassTag => ClassType(value.asInstanceOf[Type]) - case EnumTag => - // given (in java): "class A { enum E { VAL1 } }" - // - symbolValue: the symbol of the actual enumeration value (VAL1) - // - .owner: the ModuleClasSymbol of the enumeration (object E) - // - .linkedClassOfClass: the ClassSymbol of the enumeration (class E) - symbolValue.owner.linkedClassOfClass.tpe - } - - /** We need the equals method to take account of tags as well as values. - */ - override def equals(other: Any): Boolean = other match { - case that: Constant => - this.tag == that.tag && - (this.value == that.value || this.isNaN && that.isNaN) - case _ => false - } - - def isNaN = value match { - case f: Float => f.isNaN - case d: Double => d.isNaN - case _ => false - } - - def booleanValue: Boolean = - if (tag == BooleanTag) value.asInstanceOf[Boolean] - else throw new Error("value " + value + " is not a boolean"); - - def byteValue: Byte = tag match { - case ByteTag => value.asInstanceOf[Byte] - case ShortTag => value.asInstanceOf[Short].toByte - case CharTag => value.asInstanceOf[Char].toByte - case IntTag => value.asInstanceOf[Int].toByte - case LongTag => value.asInstanceOf[Long].toByte - case FloatTag => value.asInstanceOf[Float].toByte - case DoubleTag => value.asInstanceOf[Double].toByte - case _ => throw new Error("value " + value + " is not a Byte") - } - - def shortValue: Short = tag match { - case ByteTag => value.asInstanceOf[Byte].toShort - case ShortTag => value.asInstanceOf[Short] - case CharTag => value.asInstanceOf[Char].toShort - case IntTag => value.asInstanceOf[Int].toShort - case LongTag => value.asInstanceOf[Long].toShort - case FloatTag => value.asInstanceOf[Float].toShort - case DoubleTag => value.asInstanceOf[Double].toShort - case _ => throw new Error("value " + value + " is not a Short") - } - - def charValue: Char = tag match { - case ByteTag => value.asInstanceOf[Byte].toChar - case ShortTag => value.asInstanceOf[Short].toChar - case CharTag => value.asInstanceOf[Char] - case IntTag => value.asInstanceOf[Int].toChar - case LongTag => value.asInstanceOf[Long].toChar - case FloatTag => value.asInstanceOf[Float].toChar - case DoubleTag => value.asInstanceOf[Double].toChar - case _ => throw new Error("value " + value + " is not a Char") - } - - def intValue: Int = tag match { - case ByteTag => value.asInstanceOf[Byte].toInt - case ShortTag => value.asInstanceOf[Short].toInt - case CharTag => value.asInstanceOf[Char].toInt - case IntTag => value.asInstanceOf[Int] - case LongTag => value.asInstanceOf[Long].toInt - case FloatTag => value.asInstanceOf[Float].toInt - case DoubleTag => value.asInstanceOf[Double].toInt - case _ => throw new Error("value " + value + " is not an Int") - } - - def longValue: Long = tag match { - case ByteTag => value.asInstanceOf[Byte].toLong - case ShortTag => value.asInstanceOf[Short].toLong - case CharTag => value.asInstanceOf[Char].toLong - case IntTag => value.asInstanceOf[Int].toLong - case LongTag => value.asInstanceOf[Long] - case FloatTag => value.asInstanceOf[Float].toLong - case DoubleTag => value.asInstanceOf[Double].toLong - case _ => throw new Error("value " + value + " is not a Long") - } - - def floatValue: Float = tag match { - case ByteTag => value.asInstanceOf[Byte].toFloat - case ShortTag => value.asInstanceOf[Short].toFloat - case CharTag => value.asInstanceOf[Char].toFloat - case IntTag => value.asInstanceOf[Int].toFloat - case LongTag => value.asInstanceOf[Long].toFloat - case FloatTag => value.asInstanceOf[Float] - case DoubleTag => value.asInstanceOf[Double].toFloat - case _ => throw new Error("value " + value + " is not a Float") - } - - def doubleValue: Double = tag match { - case ByteTag => value.asInstanceOf[Byte].toDouble - case ShortTag => value.asInstanceOf[Short].toDouble - case CharTag => value.asInstanceOf[Char].toDouble - case IntTag => value.asInstanceOf[Int].toDouble - case LongTag => value.asInstanceOf[Long].toDouble - case FloatTag => value.asInstanceOf[Float].toDouble - case DoubleTag => value.asInstanceOf[Double] - case _ => throw new Error("value " + value + " is not a Double") - } - - /** Convert constant value to conform to given type. - */ - def convertTo(pt: Type): Constant = { - val target = pt.typeSymbol - if (target == tpe.typeSymbol) - this - else if (target == ByteClass && isByteRange) - Constant(byteValue) - else if (target == ShortClass && isShortRange) - Constant(shortValue) - else if (target == CharClass && isCharRange) - Constant(charValue) - else if (target == IntClass && isIntRange) - Constant(intValue) - else if (target == LongClass && isLongRange) - Constant(longValue) - else if (target == FloatClass && isFloatRange) - Constant(floatValue) - else if (target == DoubleClass && isNumeric) - Constant(doubleValue) - else - null - } - - def stringValue: String = - if (value == null) "null" - else if (tag == ClassTag) signature(typeValue) - else value.toString() - - @switch def escapedChar(ch: Char): String = ch match { - case '\b' => "\\b" - case '\t' => "\\t" - case '\n' => "\\n" - case '\f' => "\\f" - case '\r' => "\\r" - case '"' => "\\\"" - case '\'' => "\\\'" - case '\\' => "\\\\" - case _ => String.valueOf(ch) - } - - def escapedStringValue: String = { - def escape(text: String): String = { - text map { ch => - if (ch.isControl) "\\0" + toOctalString(ch) - else escapedChar(ch) - } mkString "" - } - tag match { - case NullTag => "null" - case StringTag => "\"" + escape(stringValue) + "\"" - case ClassTag => "classOf[" + signature(typeValue) + "]" - case CharTag => escape("'" + escapedChar(charValue) + "'") - case LongTag => longValue.toString() + "L" - case _ => String.valueOf(value) - } - } - def typeValue: Type = value.asInstanceOf[Type] - def symbolValue: Symbol = value.asInstanceOf[Symbol] - - override def hashCode: Int = value.## * 41 + 17 - } -} diff --git a/src/library/scala/reflect/generic/Flags.scala b/src/library/scala/reflect/generic/Flags.scala deleted file mode 100755 index 61dd93928c..0000000000 --- a/src/library/scala/reflect/generic/Flags.scala +++ /dev/null @@ -1,252 +0,0 @@ -package scala.reflect -package generic - -/** Flags set on Modifiers instances in the parsing stage. - */ -@deprecated("scala.reflect.generic will be removed", "2.9.1") class ModifierFlags { - final val IMPLICIT = 0x00000200 - final val FINAL = 0x00000020 - final val PRIVATE = 0x00000004 - final val PROTECTED = 0x00000001 - - final val SEALED = 0x00000400 - final val OVERRIDE = 0x00000002 - final val CASE = 0x00000800 - final val ABSTRACT = 0x00000008 // abstract class, or used in conjunction with abstract override. - // Note difference to DEFERRED! - final val DEFERRED = 0x00000010 // was `abstract` for members | trait is virtual - final val INTERFACE = 0x00000080 // symbol is an interface (i.e. a trait which defines only abstract methods) - final val MUTABLE = 0x00001000 // symbol is a mutable variable. - final val PARAM = 0x00002000 // symbol is a (value or type) parameter to a method - - final val COVARIANT = 0x00010000 // symbol is a covariant type variable - final val BYNAMEPARAM = 0x00010000 // parameter is by name - final val CONTRAVARIANT = 0x00020000 // symbol is a contravariant type variable - final val ABSOVERRIDE = 0x00040000 // combination of abstract & override - final val LOCAL = 0x00080000 // symbol is local to current class (i.e. private[this] or protected[this] - // pre: PRIVATE or PROTECTED are also set - final val JAVA = 0x00100000 // symbol was defined by a Java class - final val STATIC = 0x00800000 // static field, method or class - final val CASEACCESSOR = 0x01000000 // symbol is a case parameter (or its accessor) - final val TRAIT = 0x02000000 // symbol is a trait - final val DEFAULTPARAM = 0x02000000 // the parameter has a default value - final val PARAMACCESSOR = 0x20000000 // for field definitions generated for primary constructor - // parameters (no matter if it's a 'val' parameter or not) - // for parameters of a primary constructor ('val' or not) - // for the accessor methods generated for 'val' or 'var' parameters - final val LAZY = 0x80000000L // symbol is a lazy val. can't have MUTABLE unless transformed by typer - final val PRESUPER = 0x2000000000L // value is evaluated before super call - final val DEFAULTINIT = 0x20000000000L// symbol is initialized to the default value: used by -Xcheckinit - - // Overridden. - def flagToString(flag: Long): String = "" -} -object ModifierFlags extends ModifierFlags - -@deprecated("scala.reflect.generic will be removed", "2.9.1") class Flags extends ModifierFlags { - final val METHOD = 0x00000040 // a method - final val MODULE = 0x00000100 // symbol is module or class implementing a module - final val PACKAGE = 0x00004000 // symbol is a java package - - final val CAPTURED = 0x00010000 // variable is accessed from nested function. Set by LambdaLift. - final val LABEL = 0x00020000 // method symbol is a label. Set by TailCall - final val INCONSTRUCTOR = 0x00020000 // class symbol is defined in this/superclass constructor. - final val SYNTHETIC = 0x00200000 // symbol is compiler-generated - final val STABLE = 0x00400000 // functions that are assumed to be stable - // (typically, access methods for valdefs) - // or classes that do not contain abstract types. - final val BRIDGE = 0x04000000 // function is a bridge method. Set by Erasure - final val ACCESSOR = 0x08000000 // a value or variable accessor (getter or setter) - - final val SUPERACCESSOR = 0x10000000 // a super accessor - final val MODULEVAR = 0x40000000 // for variables: is the variable caching a module value - - final val IS_ERROR = 0x100000000L // symbol is an error symbol - final val OVERLOADED = 0x200000000L // symbol is overloaded - final val LIFTED = 0x400000000L // class has been lifted out to package level - // local value has been lifted out to class level - // todo: make LIFTED = latePRIVATE? - final val MIXEDIN = 0x800000000L // term member has been mixed in - final val EXISTENTIAL = 0x800000000L // type is an existential parameter or skolem - final val EXPANDEDNAME = 0x1000000000L // name has been expanded with class suffix - final val IMPLCLASS = 0x2000000000L // symbol is an implementation class - final val TRANS_FLAG = 0x4000000000L // transient flag guaranteed to be reset after each phase. - - final val LOCKED = 0x8000000000L // temporary flag to catch cyclic dependencies - final val SPECIALIZED = 0x10000000000L// symbol is a generated specialized member - final val VBRIDGE = 0x40000000000L// symbol is a varargs bridge - - final val VARARGS = 0x80000000000L// symbol is a Java-style varargs method - final val TRIEDCOOKING = 0x100000000000L // "Cooking" has been tried on this symbol - // A Java method's type is "cooked" by transforming raw types to existentials - - // pickling and unpickling of flags - - // The flags from 0x001 to 0x800 are different in the raw flags - // and in the pickled format. - - private final val IMPLICIT_PKL = (1 << 0) - private final val FINAL_PKL = (1 << 1) - private final val PRIVATE_PKL = (1 << 2) - private final val PROTECTED_PKL = (1 << 3) - private final val SEALED_PKL = (1 << 4) - private final val OVERRIDE_PKL = (1 << 5) - private final val CASE_PKL = (1 << 6) - private final val ABSTRACT_PKL = (1 << 7) - private final val DEFERRED_PKL = (1 << 8) - private final val METHOD_PKL = (1 << 9) - private final val MODULE_PKL = (1 << 10) - private final val INTERFACE_PKL = (1 << 11) - - private final val PKL_MASK = 0x00000FFF - - final val PickledFlags: Long = 0xFFFFFFFFL - - private def rawPickledCorrespondence = Array( - (IMPLICIT, IMPLICIT_PKL), - (FINAL, FINAL_PKL), - (PRIVATE, PRIVATE_PKL), - (PROTECTED, PROTECTED_PKL), - (SEALED, SEALED_PKL), - (OVERRIDE, OVERRIDE_PKL), - (CASE, CASE_PKL), - (ABSTRACT, ABSTRACT_PKL), - (DEFERRED, DEFERRED_PKL), - (METHOD, METHOD_PKL), - (MODULE, MODULE_PKL), - (INTERFACE, INTERFACE_PKL) - ) - private val rawFlags: Array[Int] = rawPickledCorrespondence map (_._1) - private val pickledFlags: Array[Int] = rawPickledCorrespondence map (_._2) - - private def r2p(flags: Int): Int = { - var result = 0 - var i = 0 - while (i < rawFlags.length) { - if ((flags & rawFlags(i)) != 0) - result |= pickledFlags(i) - - i += 1 - } - result - } - private def p2r(flags: Int): Int = { - var result = 0 - var i = 0 - while (i < rawFlags.length) { - if ((flags & pickledFlags(i)) != 0) - result |= rawFlags(i) - - i += 1 - } - result - } - - // Generated by mkFlagToStringMethod() at Mon Oct 11 10:07:29 PDT 2010 - @annotation.switch override def flagToString(flag: Long): String = flag match { - case PROTECTED => "protected" // (1L << 0) - case OVERRIDE => "override" // (1L << 1) - case PRIVATE => "private" // (1L << 2) - case ABSTRACT => "abstract" // (1L << 3) - case DEFERRED => "" // (1L << 4) - case FINAL => "final" // (1L << 5) - case METHOD => "" // (1L << 6) - case INTERFACE => "" // (1L << 7) - case MODULE => "" // (1L << 8) - case IMPLICIT => "implicit" // (1L << 9) - case SEALED => "sealed" // (1L << 10) - case CASE => "case" // (1L << 11) - case MUTABLE => "" // (1L << 12) - case PARAM => "" // (1L << 13) - case PACKAGE => "" // (1L << 14) - case 0x8000L => "" // (1L << 15) - case BYNAMEPARAM => "" // (1L << 16) - case CONTRAVARIANT => "" // (1L << 17) - case ABSOVERRIDE => "absoverride" // (1L << 18) - case LOCAL => "" // (1L << 19) - case JAVA => "" // (1L << 20) - case SYNTHETIC => "" // (1L << 21) - case STABLE => "" // (1L << 22) - case STATIC => "" // (1L << 23) - case CASEACCESSOR => "" // (1L << 24) - case DEFAULTPARAM => "" // (1L << 25) - case BRIDGE => "" // (1L << 26) - case ACCESSOR => "" // (1L << 27) - case SUPERACCESSOR => "" // (1L << 28) - case PARAMACCESSOR => "" // (1L << 29) - case MODULEVAR => "" // (1L << 30) - case LAZY => "lazy" // (1L << 31) - case IS_ERROR => "" // (1L << 32) - case OVERLOADED => "" // (1L << 33) - case LIFTED => "" // (1L << 34) - case EXISTENTIAL => "" // (1L << 35) - case EXPANDEDNAME => "" // (1L << 36) - case IMPLCLASS => "" // (1L << 37) - case TRANS_FLAG => "" // (1L << 38) - case LOCKED => "" // (1L << 39) - case SPECIALIZED => "" // (1L << 40) - case DEFAULTINIT => "" // (1L << 41) - case VBRIDGE => "" // (1L << 42) - case 0x80000000000L => "" // (1L << 43) - case 0x100000000000L => "" // (1L << 44) - case 0x200000000000L => "" // (1L << 45) - case 0x400000000000L => "" // (1L << 46) - case 0x800000000000L => "" // (1L << 47) - case 0x1000000000000L => "" // (1L << 48) - case 0x2000000000000L => "" // (1L << 49) - case 0x4000000000000L => "" // (1L << 50) - case 0x8000000000000L => "" // (1L << 51) - case 0x10000000000000L => "" // (1L << 52) - case 0x20000000000000L => "" // (1L << 53) - case 0x40000000000000L => "" // (1L << 54) - case 0x80000000000000L => "" // (1L << 55) - case 0x100000000000000L => "" // (1L << 56) - case 0x200000000000000L => "" // (1L << 57) - case 0x400000000000000L => "" // (1L << 58) - case 0x800000000000000L => "" // (1L << 59) - case 0x1000000000000000L => "" // (1L << 60) - case 0x2000000000000000L => "" // (1L << 61) - case 0x4000000000000000L => "" // (1L << 62) - case 0x8000000000000000L => "" // (1L << 63) - case _ => "" - } - def flagsToString(flags: Long, privateWithin: String): String = { - var f = flags - val pw = - if (privateWithin == "") { - if ((flags & (PRIVATE | LOCAL)) == (PRIVATE | LOCAL).toLong) { - f = f & ~(PRIVATE | LOCAL) - "private[this]" - } else if ((flags & (PROTECTED | LOCAL)) == (PROTECTED | LOCAL).toLong) { - f = f & ~(PROTECTED | LOCAL) - "protected[this]" - } else { - "" - } - } else if ((f & PROTECTED) != 0L) { - f = f & ~PROTECTED - "protected[" + privateWithin + "]" - } else { - "private[" + privateWithin + "]" - } - List(flagsToString(f), pw) filterNot (_ == "") mkString " " - } - def flagsToString(flags: Long): String = - pickledListOrder map (mask => flagToString(flags & mask)) filterNot (_ == "") mkString " " - - def rawFlagsToPickled(flags: Long): Long = - (flags & ~PKL_MASK) | r2p(flags.toInt & PKL_MASK) - - def pickledToRawFlags(pflags: Long): Long = - (pflags & ~PKL_MASK) | p2r(pflags.toInt & PKL_MASK) - - // List of the raw flags, in pickled order - protected val pickledListOrder: List[Long] = { - val all = 0 to 62 map (1L << _) - val front = rawFlags map (_.toLong) - - front.toList ++ (all filterNot (front contains _)) - } -} - -object Flags extends Flags diff --git a/src/library/scala/reflect/generic/HasFlags.scala b/src/library/scala/reflect/generic/HasFlags.scala deleted file mode 100644 index 33d0a51243..0000000000 --- a/src/library/scala/reflect/generic/HasFlags.scala +++ /dev/null @@ -1,168 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL - * @author Martin Odersky - */ - -package scala.reflect -package generic - -/** Comment deleted, see internal.HasFlags. */ -import Flags._ - -/** Common code utilized by `Modifiers` (which carry the flags associated - * with `Trees`) and `Symbol`. - */ -@deprecated("scala.reflect.generic will be removed", "2.9.1") -trait HasFlags { - type FlagsType - type AccessBoundaryType - type AnnotationType - - /** Though both `Symbol` and `Modifiers` widen this method to public, it's - * defined protected here to give us the option in the future to route - * flag methods through accessors and disallow raw flag manipulation. - * And after that, perhaps, on some magical day: a typesafe enumeration. - */ - protected def flags: FlagsType - - /** The printable representation of this entity's flags and access boundary, - * restricted to flags in the given mask. - */ - def hasFlagsToString(mask: FlagsType): String - - /** Access level encoding: there are three scala flags (`PRIVATE`, `PROTECTED`, - * and `LOCAL`) which combine with value privateWithin (the `foo` in `private[foo]`) - * to define from where an entity can be accessed. The meanings are as follows: - * - * PRIVATE access restricted to class only. - * PROTECTED access restricted to class and subclasses only. - * LOCAL can only be set in conjunction with PRIVATE or PROTECTED. - * Further restricts access to the same object instance. - * - * In addition, `privateWithin` can be used to set a visibility barrier. - * When set, everything contained in the named enclosing package or class - * has access. It is incompatible with `PRIVATE` or `LOCAL`, but is additive - * with `PROTECTED` (i.e. if either the flags or privateWithin allow access, - * then it is allowed.) - * - * The Java access levels translate as follows: - * {{{ - * java private: hasFlag(PRIVATE) && !hasAccessBoundary - * java package: !hasFlag(PRIVATE | PROTECTED) && (privateWithin == enclosing package) - * java protected: hasFlag(PROTECTED) && (privateWithin == enclosing package) - * java public: !hasFlag(PRIVATE | PROTECTED) && !hasAccessBoundary - * }}} - */ - def privateWithin: AccessBoundaryType - - /** A list of annotations attached to this entity. - */ - def annotations: List[AnnotationType] - - /** Whether this entity has a "privateWithin" visibility barrier attached. - */ - def hasAccessBoundary: Boolean - - /** Whether this entity has ANY of the flags in the given mask. - */ - def hasFlag(flag: Long): Boolean - - /** Whether this entity has ALL of the flags in the given mask. - */ - def hasAllFlags(mask: Long): Boolean - - /** Whether this entity has NONE of the flags in the given mask. - */ - def hasNoFlags(mask: Long): Boolean = !hasFlag(mask) - - // Tests which come through cleanly: both Symbol and Modifiers use these - // identically, testing for a single flag. - def isCase = hasFlag(CASE ) - def isFinal = hasFlag(FINAL ) - def isImplicit = hasFlag(IMPLICIT ) - def isLazy = hasFlag(LAZY ) - def isMutable = hasFlag(MUTABLE ) // in Modifiers, formerly isVariable - def isOverride = hasFlag(OVERRIDE ) - def isPrivate = hasFlag(PRIVATE ) - def isProtected = hasFlag(PROTECTED) - def isSynthetic = hasFlag(SYNTHETIC) - def isInterface = hasFlag(INTERFACE) - - // Newly introduced based on having a reasonably obvious clean translation. - def isPrivateLocal = hasAllFlags(PRIVATE | LOCAL) - def isProtectedLocal = hasAllFlags(PROTECTED | LOCAL) - def isParamAccessor = hasFlag(PARAMACCESSOR) - def isCaseAccessor = hasFlag(CASEACCESSOR) - def isSuperAccessor = hasFlag(SUPERACCESSOR) - def isLifted = hasFlag(LIFTED) - - // Formerly the `Modifiers` impl did not include the access boundary check, - // which must have been a bug. - def isPublic = hasNoFlags(PRIVATE | PROTECTED) && !hasAccessBoundary - - // Renamed the Modifiers impl from isArgument. - def isParameter = hasFlag(PARAM) - - // Removed isClass qualification since the flag isn't overloaded and - // sym.isClass is enforced in Namers#validate. - def isSealed = hasFlag(SEALED) - - // Removed !isClass qualification since the flag isn't overloaded. - def isDeferred = hasFlag(DEFERRED ) - - // Dropped isTerm condition because flag isn't overloaded. - def isAbstractOverride = hasFlag(ABSOVERRIDE) - - def isDefaultInit = hasFlag(DEFAULTINIT) - - // Disambiguating: DEFAULTPARAM, TRAIT - def hasDefault = hasAllFlags(DEFAULTPARAM | PARAM) - def isTrait = hasFlag(TRAIT) && !hasFlag(PARAM) - def hasTraitFlag = hasFlag(TRAIT) - def hasDefaultFlag = hasFlag(DEFAULTPARAM) - - // Straightforwardly named accessors already being used differently. - // These names are most likely temporary. - def hasAbstractFlag = hasFlag(ABSTRACT) - def hasAccessorFlag = hasFlag(ACCESSOR) - def hasLocalFlag = hasFlag(LOCAL) - def hasModuleFlag = hasFlag(MODULE) - def hasPackageFlag = hasFlag(PACKAGE) - def hasPreSuperFlag = hasFlag(PRESUPER) - def hasStableFlag = hasFlag(STABLE) - def hasStaticFlag = hasFlag(STATIC) - - // Disambiguating: BYNAMEPARAM, CAPTURED, COVARIANT. - def isByNameParam = hasAllFlags(BYNAMEPARAM | PARAM) - // Nope, these aren't going to fly: - // def isCapturedVariable = hasAllFlags(CAPTURED | MUTABLE) - // def isCovariant = hasFlag(COVARIANT) && hasNoFlags(PARAM | MUTABLE) - - // Disambiguating: LABEL, CONTRAVARIANT, INCONSTRUCTOR - def isLabel = hasAllFlags(LABEL | METHOD) && !hasAccessorFlag - // Cannot effectively disambiguate the others at this level. - def hasContravariantFlag = hasFlag(CONTRAVARIANT) - def hasInConstructorFlag = hasFlag(INCONSTRUCTOR) - - // Name - def isJavaDefined = hasFlag(JAVA) - - // Keeping some potentially ambiguous names around so as not to break - // the rest of the world - @deprecated("", "2.9.0") - def isAbstract = hasFlag(ABSTRACT) - // Problematic: - // ABSTRACT and DEFERRED too easy to confuse, and - // ABSTRACT + OVERRIDE ==> ABSOVERRIDE adds to it. - // - // final def isAbstractClass = isClass && hasFlag(ABSTRACT) - // def isAbstractType = false // to be overridden - - // Question: - // Which name? All other flags are isFlag so it's probably a mistake to - // vary from that, but isAccessor does sound like it includes the other - // *ACCESSOR flags. Perhaps something like isSimpleAccessor. - // - // def isAccessor = hasFlag(ACCESSOR ) - // final def isGetterOrSetter = hasAccessorFlag -} diff --git a/src/library/scala/reflect/generic/Names.scala b/src/library/scala/reflect/generic/Names.scala deleted file mode 100755 index 1906a99b8b..0000000000 --- a/src/library/scala/reflect/generic/Names.scala +++ /dev/null @@ -1,24 +0,0 @@ -package scala.reflect -package generic - -@deprecated("scala.reflect.generic will be removed", "2.9.1") trait Names { - type Name >: Null <: AnyRef - type TypeName <: Name - type TermName <: Name - - def newTermName(cs: Array[Char], offset: Int, len: Int): TermName - def newTermName(cs: Array[Byte], offset: Int, len: Int): TermName - def newTermName(s: String): TermName - def mkTermName(name: Name): TermName - - def newTypeName(cs: Array[Char], offset: Int, len: Int): TypeName - def newTypeName(cs: Array[Byte], offset: Int, len: Int): TypeName - def newTypeName(s: String): TypeName - def mkTypeName(name: Name): TypeName - - def isTermName(name: Name): Boolean - def isTypeName(name: Name): Boolean - - implicit def promoteTermNamesAsNecessary(name: Name): TermName = mkTermName(name) -} - diff --git a/src/library/scala/reflect/generic/PickleBuffer.scala b/src/library/scala/reflect/generic/PickleBuffer.scala deleted file mode 100755 index a42e673361..0000000000 --- a/src/library/scala/reflect/generic/PickleBuffer.scala +++ /dev/null @@ -1,186 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL - * @author Martin Odersky - */ - -package scala.reflect -package generic - -/** Variable length byte arrays, with methods for basic pickling and unpickling. - * - * @param data The initial buffer - * @param from The first index where defined data are found - * @param to The first index where new data can be written - */ -@deprecated("scala.reflect.generic will be removed", "2.9.1") class PickleBuffer(data: Array[Byte], from: Int, to: Int) { - - var bytes = data - var readIndex = from - var writeIndex = to - - /** Double bytes array */ - private def dble() { - val bytes1 = new Array[Byte](bytes.length * 2) - Array.copy(bytes, 0, bytes1, 0, writeIndex) - bytes = bytes1 - } - - def ensureCapacity(capacity: Int) = - while (bytes.length < writeIndex + capacity) dble() - - // -- Basic output routines -------------------------------------------- - - /** Write a byte of data */ - def writeByte(b: Int) { - if (writeIndex == bytes.length) dble() - bytes(writeIndex) = b.toByte - writeIndex += 1 - } - - /** Write a natural number in big endian format, base 128. - * All but the last digits have bit 0x80 set. - */ - def writeNat(x: Int) = - writeLongNat(x.toLong & 0x00000000FFFFFFFFL) - - /** - * Like writeNat, but for longs. This is not the same as - * writeLong, which writes in base 256. Note that the - * binary representation of LongNat is identical to Nat - * if the long value is in the range Int.MIN_VALUE to - * Int.MAX_VALUE. - */ - def writeLongNat(x: Long) { - def writeNatPrefix(x: Long) { - val y = x >>> 7 - if (y != 0L) writeNatPrefix(y) - writeByte(((x & 0x7f) | 0x80).toInt) - } - val y = x >>> 7 - if (y != 0L) writeNatPrefix(y) - writeByte((x & 0x7f).toInt) - } - - /** Write a natural number `x` at position `pos`. - * If number is more than one byte, shift rest of array to make space. - * - * @param pos ... - * @param x ... - */ - def patchNat(pos: Int, x: Int) { - def patchNatPrefix(x: Int) { - writeByte(0) - Array.copy(bytes, pos, bytes, pos+1, writeIndex - (pos+1)) - bytes(pos) = ((x & 0x7f) | 0x80).toByte - val y = x >>> 7 - if (y != 0) patchNatPrefix(y) - } - bytes(pos) = (x & 0x7f).toByte - val y = x >>> 7 - if (y != 0) patchNatPrefix(y) - } - - /** Write a long number x in signed big endian format, base 256. - * - * @param x The long number to be written. - */ - def writeLong(x: Long) { - val y = x >> 8 - val z = x & 0xff - if (-y != (z >> 7)) writeLong(y) - writeByte(z.toInt) - } - - // -- Basic input routines -------------------------------------------- - - /** Peek at the current byte without moving the read index */ - def peekByte(): Int = bytes(readIndex) - - /** Read a byte */ - def readByte(): Int = { - val x = bytes(readIndex); readIndex += 1; x - } - - /** Read a natural number in big endian format, base 128. - * All but the last digits have bit 0x80 set.*/ - def readNat(): Int = readLongNat().toInt - - def readLongNat(): Long = { - var b = 0L - var x = 0L - do { - b = readByte() - x = (x << 7) + (b & 0x7f) - } while ((b & 0x80) != 0L); - x - } - - /** Read a long number in signed big endian format, base 256. */ - def readLong(len: Int): Long = { - var x = 0L - var i = 0 - while (i < len) { - x = (x << 8) + (readByte() & 0xff) - i += 1 - } - val leading = 64 - (len << 3) - x << leading >> leading - } - - /** Returns the buffer as a sequence of (Int, Array[Byte]) representing - * (tag, data) of the individual entries. Saves and restores buffer state. - */ - - def toIndexedSeq: IndexedSeq[(Int, Array[Byte])] = { - val saved = readIndex - readIndex = 0 - readNat() ; readNat() // discarding version - val result = new Array[(Int, Array[Byte])](readNat()) - - result.indices foreach { index => - val tag = readNat() - val len = readNat() - val bytes = data.slice(readIndex, len + readIndex) - readIndex += len - - result(index) = tag -> bytes - } - - readIndex = saved - result.toIndexedSeq - } - - /** Perform operation `op` until the condition `readIndex == end` is - * satisfied. Concatenate results into a list. - * - * @param end ... - * @param op ... - * @return ... - */ - def until[T](end: Int, op: () => T): List[T] = - if (readIndex == end) List() else op() :: until(end, op); - - /** Perform operation `op` the number of times specified. - * Concatenate the results into a list. - */ - def times[T](n: Int, op: ()=>T): List[T] = - if (n == 0) List() else op() :: times(n-1, op) - - /** Pickle = majorVersion_Nat minorVersion_Nat nbEntries_Nat {Entry} - * Entry = type_Nat length_Nat [actual entries] - * - * Assumes that the ..Version_Nat are already consumed. - * - * @return an array mapping entry numbers to locations in - * the byte array where the entries start. - */ - def createIndex: Array[Int] = { - val index = new Array[Int](readNat()) // nbEntries_Nat - for (i <- 0 until index.length) { - index(i) = readIndex - readByte() // skip type_Nat - readIndex = readNat() + readIndex // read length_Nat, jump to next entry - } - index - } -} diff --git a/src/library/scala/reflect/generic/PickleFormat.scala b/src/library/scala/reflect/generic/PickleFormat.scala deleted file mode 100755 index 9c7dc72d69..0000000000 --- a/src/library/scala/reflect/generic/PickleFormat.scala +++ /dev/null @@ -1,224 +0,0 @@ -package scala.reflect -package generic - -/** This object provides constants for pickling attributes. - * - * If you extend the format, be sure to increase the - * version minor number. - * - * @author Martin Odersky - * @version 1.0 - */ -@deprecated("scala.reflect.generic will be removed", "2.9.1") object PickleFormat { - -/*************************************************** - * Symbol table attribute format: - * Symtab = nentries_Nat {Entry} - * Entry = 1 TERMNAME len_Nat NameInfo - * | 2 TYPENAME len_Nat NameInfo - * | 3 NONEsym len_Nat - * | 4 TYPEsym len_Nat SymbolInfo - * | 5 ALIASsym len_Nat SymbolInfo - * | 6 CLASSsym len_Nat SymbolInfo [thistype_Ref] - * | 7 MODULEsym len_Nat SymbolInfo - * | 8 VALsym len_Nat [defaultGetter_Ref /* no longer needed*/] SymbolInfo [alias_Ref] - * | 9 EXTref len_Nat name_Ref [owner_Ref] - * | 10 EXTMODCLASSref len_Nat name_Ref [owner_Ref] - * | 11 NOtpe len_Nat - * | 12 NOPREFIXtpe len_Nat - * | 13 THIStpe len_Nat sym_Ref - * | 14 SINGLEtpe len_Nat type_Ref sym_Ref - * | 15 CONSTANTtpe len_Nat constant_Ref - * | 16 TYPEREFtpe len_Nat type_Ref sym_Ref {targ_Ref} - * | 17 TYPEBOUNDStpe len_Nat tpe_Ref tpe_Ref - * | 18 REFINEDtpe len_Nat classsym_Ref {tpe_Ref} - * | 19 CLASSINFOtpe len_Nat classsym_Ref {tpe_Ref} - * | 20 METHODtpe len_Nat tpe_Ref {sym_Ref} - * | 21 POLYTtpe len_Nat tpe_Ref {sym_Ref} - * | 22 IMPLICITMETHODtpe len_Nat tpe_Ref {sym_Ref} /* no longer needed */ - * | 52 SUPERtpe len_Nat tpe_Ref tpe_Ref - * | 24 LITERALunit len_Nat - * | 25 LITERALboolean len_Nat value_Long - * | 26 LITERALbyte len_Nat value_Long - * | 27 LITERALshort len_Nat value_Long - * | 28 LITERALchar len_Nat value_Long - * | 29 LITERALint len_Nat value_Long - * | 30 LITERALlong len_Nat value_Long - * | 31 LITERALfloat len_Nat value_Long - * | 32 LITERALdouble len_Nat value_Long - * | 33 LITERALstring len_Nat name_Ref - * | 34 LITERALnull len_Nat - * | 35 LITERALclass len_Nat tpe_Ref - * | 36 LITERALenum len_Nat sym_Ref - * | 40 SYMANNOT len_Nat sym_Ref AnnotInfoBody - * | 41 CHILDREN len_Nat sym_Ref {sym_Ref} - * | 42 ANNOTATEDtpe len_Nat [sym_Ref /* no longer needed */] tpe_Ref {annotinfo_Ref} - * | 43 ANNOTINFO len_Nat AnnotInfoBody - * | 44 ANNOTARGARRAY len_Nat {constAnnotArg_Ref} - * | 47 DEBRUIJNINDEXtpe len_Nat level_Nat index_Nat - * | 48 EXISTENTIALtpe len_Nat type_Ref {symbol_Ref} - * | 49 TREE len_Nat 1 EMPTYtree - * | 49 TREE len_Nat 2 PACKAGEtree type_Ref sym_Ref mods_Ref name_Ref {tree_Ref} - * | 49 TREE len_Nat 3 CLASStree type_Ref sym_Ref mods_Ref name_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 4 MODULEtree type_Ref sym_Ref mods_Ref name_Ref tree_Ref - * | 49 TREE len_Nat 5 VALDEFtree type_Ref sym_Ref mods_Ref name_Ref tree_Ref tree_Ref - * | 49 TREE len_Nat 6 DEFDEFtree type_Ref sym_Ref mods_Ref name_Ref numtparams_Nat {tree_Ref} numparamss_Nat {numparams_Nat {tree_Ref}} tree_Ref tree_Ref - * | 49 TREE len_Nat 7 TYPEDEFtree type_Ref sym_Ref mods_Ref name_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 8 LABELtree type_Ref sym_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 9 IMPORTtree type_Ref sym_Ref tree_Ref {name_Ref name_Ref} - * | 49 TREE len_Nat 11 DOCDEFtree type_Ref sym_Ref string_Ref tree_Ref - * | 49 TREE len_Nat 12 TEMPLATEtree type_Ref sym_Ref numparents_Nat {tree_Ref} tree_Ref {tree_Ref} - * | 49 TREE len_Nat 13 BLOCKtree type_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 14 CASEtree type_Ref tree_Ref tree_Ref tree_Ref - * | 49 TREE len_Nat 15 SEQUENCEtree type_Ref {tree_Ref} - * | 49 TREE len_Nat 16 ALTERNATIVEtree type_Ref {tree_Ref} - * | 49 TREE len_Nat 17 STARtree type_Ref {tree_Ref} - * | 49 TREE len_Nat 18 BINDtree type_Ref sym_Ref name_Ref tree_Ref - * | 49 TREE len_Nat 19 UNAPPLYtree type_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 20 ARRAYVALUEtree type_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 21 FUNCTIONtree type_Ref sym_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 22 ASSIGNtree type_Ref tree_Ref tree_Ref - * | 49 TREE len_Nat 23 IFtree type_Ref tree_Ref tree_Ref tree_Ref - * | 49 TREE len_Nat 24 MATCHtree type_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 25 RETURNtree type_Ref sym_Ref tree_Ref - * | 49 TREE len_Nat 26 TREtree type_Ref tree_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 27 THROWtree type_Ref tree_Ref - * | 49 TREE len_Nat 28 NEWtree type_Ref tree_Ref - * | 49 TREE len_Nat 29 TYPEDtree type_Ref tree_Ref tree_Ref - * | 49 TREE len_Nat 30 TYPEAPPLYtree type_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 31 APPLYtree type_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 32 APPLYDYNAMICtree type_Ref sym_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 33 SUPERtree type_Ref sym_Ref tree_Ref name_Ref - * | 49 TREE len_Nat 34 THIStree type_Ref sym_Ref name_Ref - * | 49 TREE len_Nat 35 SELECTtree type_Ref sym_Ref tree_Ref name_Ref - * | 49 TREE len_Nat 36 IDENTtree type_Ref sym_Ref name_Ref - * | 49 TREE len_Nat 37 LITERALtree type_Ref constant_Ref - * | 49 TREE len_Nat 38 TYPEtree type_Ref - * | 49 TREE len_Nat 39 ANNOTATEDtree type_Ref tree_Ref tree_Ref - * | 49 TREE len_Nat 40 SINGLETONTYPEtree type_Ref tree_Ref - * | 49 TREE len_Nat 41 SELECTFROMTYPEtree type_Ref tree_Ref name_Ref - * | 49 TREE len_Nat 42 COMPOUNDTYPEtree type_Ref tree_Ref - * | 49 TREE len_Nat 43 APPLIEDTYPEtree type_Ref tree_Ref {tree_Ref} - * | 49 TREE len_Nat 44 TYPEBOUNDStree type_Ref tree_Ref tree_Ref - * | 49 TREE len_Nat 45 EXISTENTIALTYPEtree type_Ref tree_Ref {tree_Ref} - * | 50 MODIFIERS len_Nat flags_Long privateWithin_Ref - * SymbolInfo = name_Ref owner_Ref flags_LongNat [privateWithin_Ref] info_Ref - * NameInfo = - * NumInfo = - * Ref = Nat - * AnnotInfoBody = info_Ref {annotArg_Ref} {name_Ref constAnnotArg_Ref} - * AnnotArg = Tree | Constant - * ConstAnnotArg = Constant | AnnotInfo | AnnotArgArray - * - * len is remaining length after `len`. - */ - val MajorVersion = 5 - val MinorVersion = 0 - def VersionString = "V" + MajorVersion + "." + MinorVersion - - final val TERMname = 1 - final val TYPEname = 2 - final val NONEsym = 3 - final val TYPEsym = 4 - final val ALIASsym = 5 - final val CLASSsym = 6 - final val MODULEsym = 7 - final val VALsym = 8 - final val EXTref = 9 - final val EXTMODCLASSref = 10 - final val NOtpe = 11 - final val NOPREFIXtpe = 12 - final val THIStpe = 13 - final val SINGLEtpe = 14 - final val CONSTANTtpe = 15 - final val TYPEREFtpe = 16 - final val TYPEBOUNDStpe = 17 - final val REFINEDtpe = 18 - final val CLASSINFOtpe = 19 - final val METHODtpe = 20 - final val POLYtpe = 21 - final val IMPLICITMETHODtpe = 22 // no longer generated - - final val LITERAL = 23 // base line for literals - final val LITERALunit = 24 - final val LITERALboolean = 25 - final val LITERALbyte = 26 - final val LITERALshort = 27 - final val LITERALchar = 28 - final val LITERALint = 29 - final val LITERALlong = 30 - final val LITERALfloat = 31 - final val LITERALdouble = 32 - final val LITERALstring = 33 - final val LITERALnull = 34 - final val LITERALclass = 35 - final val LITERALenum = 36 - final val SYMANNOT = 40 - final val CHILDREN = 41 - final val ANNOTATEDtpe = 42 - final val ANNOTINFO = 43 - final val ANNOTARGARRAY = 44 - - final val SUPERtpe = 46 - final val DEBRUIJNINDEXtpe = 47 - final val EXISTENTIALtpe = 48 - - final val TREE = 49 // prefix code that means a tree is coming - final val EMPTYtree = 1 - final val PACKAGEtree = 2 - final val CLASStree = 3 - final val MODULEtree = 4 - final val VALDEFtree = 5 - final val DEFDEFtree = 6 - final val TYPEDEFtree = 7 - final val LABELtree = 8 - final val IMPORTtree = 9 - final val DOCDEFtree = 11 - final val TEMPLATEtree = 12 - final val BLOCKtree = 13 - final val CASEtree = 14 - // This node type has been removed. - // final val SEQUENCEtree = 15 - final val ALTERNATIVEtree = 16 - final val STARtree = 17 - final val BINDtree = 18 - final val UNAPPLYtree = 19 - final val ARRAYVALUEtree = 20 - final val FUNCTIONtree = 21 - final val ASSIGNtree = 22 - final val IFtree = 23 - final val MATCHtree = 24 - final val RETURNtree = 25 - final val TREtree = 26 - final val THROWtree = 27 - final val NEWtree = 28 - final val TYPEDtree = 29 - final val TYPEAPPLYtree = 30 - final val APPLYtree = 31 - final val APPLYDYNAMICtree = 32 - final val SUPERtree = 33 - final val THIStree = 34 - final val SELECTtree = 35 - final val IDENTtree = 36 - final val LITERALtree = 37 - final val TYPEtree = 38 - final val ANNOTATEDtree = 39 - final val SINGLETONTYPEtree = 40 - final val SELECTFROMTYPEtree = 41 - final val COMPOUNDTYPEtree = 42 - final val APPLIEDTYPEtree = 43 - final val TYPEBOUNDStree = 44 - final val EXISTENTIALTYPEtree = 45 - - final val MODIFIERS = 50 - - final val firstSymTag = NONEsym - final val lastSymTag = VALsym - final val lastExtSymTag = EXTMODCLASSref - - - //The following two are no longer accurate, because ANNOTATEDtpe, - //SUPERtpe, ... are not in the same range as the other types - //final val firstTypeTag = NOtpe - //final val lastTypeTag = POLYtpe -} diff --git a/src/library/scala/reflect/generic/Scopes.scala b/src/library/scala/reflect/generic/Scopes.scala deleted file mode 100755 index 5ca7c95467..0000000000 --- a/src/library/scala/reflect/generic/Scopes.scala +++ /dev/null @@ -1,15 +0,0 @@ -package scala.reflect -package generic - -@deprecated("scala.reflect.generic will be removed", "2.9.1") trait Scopes { self: Universe => - - abstract class AbsScope extends Iterable[Symbol] { - private[reflect] def enter(sym: Symbol): Symbol - } - - type Scope <: AbsScope - - def newScope(): Scope -} - - diff --git a/src/library/scala/reflect/generic/StandardDefinitions.scala b/src/library/scala/reflect/generic/StandardDefinitions.scala deleted file mode 100755 index 49ac1d37a9..0000000000 --- a/src/library/scala/reflect/generic/StandardDefinitions.scala +++ /dev/null @@ -1,66 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL - * @author Martin Odersky - */ - -package scala.reflect -package generic - -@deprecated("scala.reflect.generic will be removed", "2.9.1") trait StandardDefinitions { self: Universe => - - val definitions: AbsDefinitions - - abstract class AbsDefinitions { - - // outer packages and their classes - def RootPackage: Symbol - def RootClass: Symbol - def EmptyPackage: Symbol - def EmptyPackageClass: Symbol - - def ScalaPackage: Symbol - def ScalaPackageClass: Symbol - - // top types - def AnyClass : Symbol - def AnyValClass: Symbol - def AnyRefClass: Symbol - def ObjectClass: Symbol - - // bottom types - def NullClass : Symbol - def NothingClass: Symbol - - // the scala value classes - def UnitClass : Symbol - def ByteClass : Symbol - def ShortClass : Symbol - def CharClass : Symbol - def IntClass : Symbol - def LongClass : Symbol - def FloatClass : Symbol - def DoubleClass : Symbol - def BooleanClass: Symbol - - // fundamental reference classes - def SymbolClass : Symbol - def StringClass : Symbol - def ClassClass : Symbol - - // fundamental modules - def PredefModule: Symbol - - // fundamental type constructions - def ClassType(arg: Type): Type - - /** The string representation used by the given type in the VM. - */ - def signature(tp: Type): String - - /** Is symbol one of the value classes? */ - def isValueClass(sym: Symbol): Boolean - - /** Is symbol one of the numeric value classes? */ - def isNumericValueClass(sym: Symbol): Boolean - } -} diff --git a/src/library/scala/reflect/generic/StdNames.scala b/src/library/scala/reflect/generic/StdNames.scala deleted file mode 100755 index de5c98886b..0000000000 --- a/src/library/scala/reflect/generic/StdNames.scala +++ /dev/null @@ -1,44 +0,0 @@ -package scala.reflect -package generic - -import scala.reflect.NameTransformer - -@deprecated("scala.reflect.generic will be removed", "2.9.1") trait StdNames { - self: Universe => - - val nme: LibraryTermNames - val tpnme: LibraryTypeNames - - def encode(str: String): TermName = newTermName(NameTransformer.encode(str)) - - implicit def stringToTermName(s: String): TermName = newTermName(s) - - trait LibraryCommonNames { - type NameType <: Name - implicit def createNameType(name: String): NameType - - val EMPTY: NameType = "" - val ANON_FUN_NAME: NameType = "$anonfun" - val EMPTY_PACKAGE_NAME: NameType = "" - val IMPORT: NameType = "" - val MODULE_SUFFIX: NameType = "$module" - val ROOT: NameType = "" - } - - trait LibraryTermNames extends LibraryCommonNames { - val EXPAND_SEPARATOR_STRING = "$$" - val LOCAL_SUFFIX_STRING = " " - val ROOTPKG: NameType = "_root_" - - /** The expanded name of `name` relative to this class `base` with given `separator` - */ - def expandedName(name: TermName, base: Symbol, separator: String = EXPAND_SEPARATOR_STRING): TermName = - newTermName(base.fullName('$') + separator + name) - - def moduleVarName(name: TermName): TermName = newTermName("" + name + MODULE_SUFFIX) - } - trait LibraryTypeNames extends LibraryCommonNames { - val REFINE_CLASS_NAME: NameType = "" - val ANON_CLASS_NAME: NameType = "$anon" - } -} diff --git a/src/library/scala/reflect/generic/Symbols.scala b/src/library/scala/reflect/generic/Symbols.scala deleted file mode 100755 index 7efb87676f..0000000000 --- a/src/library/scala/reflect/generic/Symbols.scala +++ /dev/null @@ -1,187 +0,0 @@ -package scala.reflect -package generic - -import Flags._ - -@deprecated("scala.reflect.generic will be removed", "2.9.1") trait Symbols { self: Universe => - - type Symbol >: Null <: AbsSymbol - - abstract class AbsSymbol extends HasFlags { - this: Symbol => - - type FlagsType = Long - type AccessBoundaryType = Symbol - type AnnotationType = AnnotationInfo - - /** The owner of this symbol. - */ - def owner: Symbol - - /** The flags of this symbol */ - def flags: Long - - /** The name of the symbol as a member of the `Name` type. - */ - def name: Name - - /** The name of the symbol before decoding, e.g. `\$eq\$eq` instead of `==`. - */ - def encodedName: String = name.toString - - /** The decoded name of the symbol, e.g. `==` instead of `\$eq\$eq`. - */ - def decodedName: String = stripLocalSuffix(NameTransformer.decode(encodedName)) - - /** The encoded full path name of this symbol, where outer names and inner names - * are separated by `separator` characters. - * Never translates expansions of operators back to operator symbol. - * Never adds id. - */ - final def fullName(separator: Char): String = stripLocalSuffix { - if (isRoot || isRootPackage || this == NoSymbol) this.toString - else if (owner.isEffectiveRoot) encodedName - else owner.enclClass.fullName(separator) + separator + encodedName - } - - private def stripLocalSuffix(s: String) = s stripSuffix nme.LOCAL_SUFFIX_STRING - - /** The encoded full path name of this symbol, where outer names and inner names - * are separated by periods. - */ - final def fullName: String = fullName('.') - - /** 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 - - final def hasAccessBoundary = (privateWithin != null) && (privateWithin != NoSymbol) - - /** The raw info of the type - */ - def rawInfo: Type - - /** The type of the symbol - */ - def tpe: Type = info - - /** The info of the symbol. This is like tpe, except for class symbols where the `info` - * describes the contents of the class whereas the `tpe` is a reference to the class. - */ - def info: Type = { - val tp = rawInfo - tp.complete(this) - tp - } - - /** If this symbol is a class or trait, its self type, otherwise the type of the symbol itse;lf - */ - def typeOfThis: Type - - def owner_=(sym: Symbol) { throw new UnsupportedOperationException("owner_= inapplicable for " + this) } - def flags_=(flags: Long) { throw new UnsupportedOperationException("flags_= inapplicable for " + this) } - def info_=(tp: Type) { throw new UnsupportedOperationException("info_= inapplicable for " + this) } - def typeOfThis_=(tp: Type) { throw new UnsupportedOperationException("typeOfThis_= inapplicable for " + this) } - def privateWithin_=(sym: Symbol) { throw new UnsupportedOperationException("privateWithin_= inapplicable for " + this) } - def sourceModule_=(sym: Symbol) { throw new UnsupportedOperationException("sourceModule_= inapplicable for " + this) } - def addChild(sym: Symbol) { throw new UnsupportedOperationException("addChild inapplicable for " + this) } - def addAnnotation(annot: AnnotationInfo) { throw new UnsupportedOperationException("addAnnotation inapplicable for " + this) } - - /** For a module class its linked class, for a plain class - * the module class of its linked module. - * For instance - * object Foo - * class Foo - * - * Then object Foo has a `moduleClass` (invisible to the user, the backend calls it Foo$ - * linkedClassOfClass goes from class Foo$ to class Foo, and back. - */ - def linkedClassOfClass: Symbol - - /** The module corresponding to this module class (note that this - * is not updated when a module is cloned), or NoSymbol if this is not a ModuleClass - */ - def sourceModule: Symbol = NoSymbol - - /** If symbol is an object definition, it's implied associated class, - * otherwise NoSymbol - */ - def moduleClass: Symbol - - /** - * If symbol is a lazy val, it's lazy accessor - */ - def lazyAccessor: Symbol - -// 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 - private[scala] def isSkolem = false // to be overridden - - override def isTrait: Boolean = isClass && hasFlag(TRAIT) // refined later for virtual classes. - final def isAbstractClass = isClass && hasFlag(ABSTRACT) - final def isBridge = hasFlag(BRIDGE) - final def isContravariant = isType && hasFlag(CONTRAVARIANT) - final def isCovariant = isType && hasFlag(COVARIANT) - final def isEarlyInitialized: Boolean = isTerm && hasFlag(PRESUPER) - final def isExistentiallyBound = isType && hasFlag(EXISTENTIAL) - final def isImplClass = isClass && hasFlag(IMPLCLASS) // Is this symbol an implementation class for a mixin? - final def isLazyAccessor = isLazy && lazyAccessor != NoSymbol - final def isMethod = isTerm && hasFlag(METHOD) - final def isVarargsMethod = isMethod && hasFlag(VARARGS) - final def isModule = isTerm && hasFlag(MODULE) - final def isModuleClass = isClass && hasFlag(MODULE) - final def isOverloaded = hasFlag(OVERLOADED) - final def isRefinementClass = isClass && name == tpnme.REFINE_CLASS_NAME - final def isSourceMethod = isMethod && !hasFlag(STABLE) // exclude all accessors!!! - final def isTypeParameter = isType && isParameter && !isSkolem - - /** Package tests */ - final def isEmptyPackage = isPackage && name == nme.EMPTY_PACKAGE_NAME - final def isEmptyPackageClass = isPackageClass && name == tpnme.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? - */ - def isEffectiveRoot = isRoot || isEmptyPackageClass - - /** If this is NoSymbol, evaluate the argument: otherwise, this. - */ - def orElse[T](alt: => Symbol): Symbol = if (this ne NoSymbol) this else alt - - // creators - - def newAbstractType(name: TypeName, pos: Position = NoPosition): Symbol - def newAliasType(name: TypeName, pos: Position = NoPosition): Symbol - def newClass(name: TypeName, pos: Position = NoPosition): Symbol - def newMethod(name: TermName, pos: Position = NoPosition): Symbol - def newModule(name: TermName, clazz: Symbol, pos: Position = NoPosition): Symbol - def newModuleClass(name: TypeName, pos: Position = NoPosition): Symbol - def newValue(name: TermName, pos: Position = NoPosition): Symbol - - // access to related symbols - - /** The next enclosing class */ - def enclClass: Symbol = if (isClass) this else owner.enclClass - - /** The next enclosing method */ - def enclMethod: Symbol = if (isSourceMethod) this else owner.enclMethod - } - - val NoSymbol: Symbol -} - - diff --git a/src/library/scala/reflect/generic/Trees.scala b/src/library/scala/reflect/generic/Trees.scala deleted file mode 100755 index a094e33e7c..0000000000 --- a/src/library/scala/reflect/generic/Trees.scala +++ /dev/null @@ -1,735 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.reflect -package generic - -import java.io.{ PrintWriter, StringWriter } -import Flags._ - -@deprecated("scala.reflect.generic will be removed", "2.9.1") trait Trees { self: Universe => - - abstract class AbsTreePrinter(out: PrintWriter) { - def print(tree: Tree) - def flush() - } - - def newTreePrinter(out: PrintWriter): AbsTreePrinter - - private[scala] var nodeCount = 0 - - protected def flagsIntoString(flags: Long, privateWithin: String): String - - /** @param privateWithin the qualifier for a private (a type name) - * or tpnme.EMPTY, if none is given. - * @param annotations the annotations for the definition. - * Note: the typechecker drops these annotations, - * use the AnnotationInfo's (Symbol.annotations) in later phases. - */ - case class Modifiers(flags: Long, privateWithin: Name, annotations: List[Tree], positions: Map[Long, Position]) extends HasFlags { - /* Abstract types from HasFlags. */ - type FlagsType = Long - type AccessBoundaryType = Name - type AnnotationType = Tree - - def hasAccessBoundary = privateWithin != tpnme.EMPTY - def hasAllFlags(mask: Long): Boolean = (flags & mask) == mask - def hasFlag(flag: Long) = (flag & flags) != 0L - def hasFlagsToString(mask: Long): String = flagsToString( - flags & mask, - if (hasAccessBoundary) privateWithin.toString else "" - ) - def & (flag: Long): Modifiers = { - val flags1 = flags & flag - if (flags1 == flags) this - else Modifiers(flags1, privateWithin, annotations, positions) - } - def &~ (flag: Long): Modifiers = { - val flags1 = flags & (~flag) - if (flags1 == flags) this - else Modifiers(flags1, privateWithin, annotations, positions) - } - def | (flag: Long): Modifiers = { - val flags1 = flags | flag - if (flags1 == flags) this - else Modifiers(flags1, privateWithin, annotations, positions) - } - def withAnnotations(annots: List[Tree]) = - if (annots.isEmpty) this - else copy(annotations = annotations ::: annots) - def withPosition(flag: Long, position: Position) = - copy(positions = positions + (flag -> position)) - - override def toString = "Modifiers(%s, %s, %s)".format(hasFlagsToString(-1L), annotations mkString ", ", positions) - } - - def Modifiers(flags: Long, privateWithin: Name): Modifiers = Modifiers(flags, privateWithin, List(), Map.empty) - def Modifiers(flags: Long): Modifiers = Modifiers(flags, tpnme.EMPTY) - - lazy val NoMods = Modifiers(0) - - abstract class Tree extends Product { - val id = nodeCount - nodeCount += 1 - - private[this] var rawpos: Position = NoPosition - - def pos = rawpos - def pos_=(pos: Position) = rawpos = pos - def setPos(pos: Position): this.type = { rawpos = pos; this } - - private[this] var rawtpe: Type = _ - - def tpe = rawtpe - def tpe_=(t: Type) = rawtpe = t - - /** Set tpe to give `tp` and return this. - */ - def setType(tp: Type): this.type = { rawtpe = tp; this } - - /** Like `setType`, but if this is a previously empty TypeTree - * that fact is remembered so that resetType will snap back. - */ - def defineType(tp: Type): this.type = setType(tp) - - def symbol: Symbol = null - def symbol_=(sym: Symbol) { throw new UnsupportedOperationException("symbol_= inapplicable for " + this) } - def setSymbol(sym: Symbol): this.type = { symbol = sym; this } - - def hasSymbol = false - def isDef = false - def isEmpty = false - - def hasSymbolWhich(f: Symbol => Boolean) = hasSymbol && f(symbol) - - /** The direct child trees of this tree - * EmptyTrees are always omitted. Lists are collapsed. - */ - def children: List[Tree] = { - def subtrees(x: Any): List[Tree] = x match { - case EmptyTree => Nil - case t: Tree => List(t) - case xs: List[_] => xs flatMap subtrees - case _ => Nil - } - productIterator.toList flatMap subtrees - } - - /** In compiler: Make a copy of this tree, keeping all attributes, - * except that all positions are focussed (so nothing - * in this tree will be found when searching by position). - * If not in compiler may also return tree unchanged. - */ - private[scala] def duplicate: this.type = - duplicateTree(this).asInstanceOf[this.type] - - private[scala] def copyAttrs(tree: Tree): this.type = { - pos = tree.pos - tpe = tree.tpe - if (hasSymbol) symbol = tree.symbol - this - } - - override def toString(): String = { - val buffer = new StringWriter() - val printer = newTreePrinter(new PrintWriter(buffer)) - printer.print(this) - printer.flush() - buffer.toString - } - - override def hashCode(): Int = System.identityHashCode(this) - override def equals(that: Any) = this eq that.asInstanceOf[AnyRef] - } - - private[scala] def duplicateTree(tree: Tree): Tree = tree - - trait SymTree extends Tree { - override def hasSymbol = true - override var symbol: Symbol = NoSymbol - } - - trait RefTree extends SymTree { - def name: Name - } - - abstract class DefTree extends SymTree { - def name: Name - override def isDef = true - } - - trait TermTree extends Tree - - /** A tree for a type. Note that not all type trees implement - * this trait; in particular, Ident's are an exception. */ - trait TypTree extends Tree - -// ----- tree node alternatives -------------------------------------- - - /** The empty tree */ - case object EmptyTree extends TermTree { - super.tpe_=(NoType) - override def tpe_=(t: Type) = - if (t != NoType) throw new UnsupportedOperationException("tpe_=("+t+") inapplicable for ") - override def isEmpty = true - } - - abstract class MemberDef extends DefTree { - def mods: Modifiers - def keyword: String = this match { - case TypeDef(_, _, _, _) => "type" - case ClassDef(mods, _, _, _) => if (mods hasFlag TRAIT) "trait" else "class" - case DefDef(_, _, _, _, _, _) => "def" - case ModuleDef(_, _, _) => "object" - case PackageDef(_, _) => "package" - case ValDef(mods, _, _, _) => if (mods.isMutable) "var" else "val" - case _ => "" - } - // final def hasFlag(mask: Long): Boolean = mods hasFlag mask - } - - /** Package clause - */ - case class PackageDef(pid: RefTree, stats: List[Tree]) - extends MemberDef { - def name = pid.name - def mods = NoMods - } - - abstract class ImplDef extends MemberDef { - def impl: Template - } - - /** Class definition */ - case class ClassDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], impl: Template) - extends ImplDef - - /** Singleton object definition - */ - case class ModuleDef(mods: Modifiers, name: TermName, impl: Template) - extends ImplDef - - abstract class ValOrDefDef extends MemberDef { - def name: TermName - def tpt: Tree - def rhs: Tree - } - - /** Value definition - */ - case class ValDef(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree) extends ValOrDefDef - - /** Method definition - */ - case class DefDef(mods: Modifiers, name: TermName, tparams: List[TypeDef], - vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree) extends ValOrDefDef - - /** Abstract type, type parameter, or type alias */ - case class TypeDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], rhs: Tree) - extends MemberDef - - /** Labelled expression - the symbols in the array (must be Idents!) - * are those the label takes as argument. - * - * The symbol that is given to the `labeldef` should have a `MethodType` - * (as if it were a nested function). - * - * Jumps are apply nodes attributed with label symbol, the arguments - * will get assigned to the idents. - * - * '''Note''': on 2005-06-09 Martin, Iuli, Burak agreed to have forward - * jumps within a `Block`. - */ - case class LabelDef(name: TermName, params: List[Ident], rhs: Tree) - extends DefTree with TermTree - - - /** Import selector - * - * Representation of an imported name its optional rename and their optional positions - * - * @param name the imported name - * @param namePos its position or -1 if undefined - * @param rename the name the import is renamed to (== name if no renaming) - * @param renamePos the position of the rename or -1 if undefined - */ - case class ImportSelector(name: Name, namePos: Int, rename: Name, renamePos: Int) - - /** Import clause - * - * @param expr - * @param selectors - */ - case class Import(expr: Tree, selectors: List[ImportSelector]) - extends SymTree - // The symbol of an Import is an import symbol @see Symbol.newImport - // It's used primarily as a marker to check that the import has been typechecked. - - /** Instantiation template of a class or trait - * - * @param parents - * @param body - */ - case class Template(parents: List[Tree], self: ValDef, body: List[Tree]) - extends SymTree { - // the symbol of a template is a local dummy. @see Symbol.newLocalDummy - // the owner of the local dummy is the enclosing trait or class. - // the local dummy is itself the owner of any local blocks - // For example: - // - // class C { - // def foo // owner is C - // { - // def bar // owner is local dummy - // } - // System.err.println("TEMPLATE: " + parents) - } - - /** Block of expressions (semicolon separated expressions) */ - case class Block(stats: List[Tree], expr: Tree) - extends TermTree - - /** Case clause in a pattern match, eliminated during explicitouter - * (except for occurrences in switch statements) - */ - case class CaseDef(pat: Tree, guard: Tree, body: Tree) - extends Tree - - /** Alternatives of patterns, eliminated by explicitouter, except for - * occurrences in encoded Switch stmt (=remaining Match(CaseDef(...)) - */ - case class Alternative(trees: List[Tree]) - extends TermTree - - /** Repetition of pattern, eliminated by explicitouter */ - case class Star(elem: Tree) - extends TermTree - - /** Bind of a variable to a rhs pattern, eliminated by explicitouter - * - * @param name - * @param body - */ - case class Bind(name: Name, body: Tree) - extends DefTree - - case class UnApply(fun: Tree, args: List[Tree]) - extends TermTree - - /** Array of expressions, needs to be translated in backend, - */ - case class ArrayValue(elemtpt: Tree, elems: List[Tree]) - extends TermTree - - /** Anonymous function, eliminated by analyzer */ - case class Function(vparams: List[ValDef], body: Tree) - extends TermTree with SymTree - // The symbol of a Function is a synthetic value of name nme.ANON_FUN_NAME - // It is the owner of the function's parameters. - - /** Assignment */ - case class Assign(lhs: Tree, rhs: Tree) - extends TermTree - - /** Conditional expression */ - case class If(cond: Tree, thenp: Tree, elsep: Tree) - extends TermTree - - /** - * - Pattern matching expression (before explicitouter) - * - Switch statements (after explicitouter) - * - * After explicitouter, cases will satisfy the following constraints: - * - * - all guards are EmptyTree, - * - all patterns will be either `Literal(Constant(x:Int))` - * or `Alternative(lit|...|lit)` - * - except for an "otherwise" branch, which has pattern - * `Ident(nme.WILDCARD)` - */ - case class Match(selector: Tree, cases: List[CaseDef]) - extends TermTree - - /** Return expression */ - case class Return(expr: Tree) - extends TermTree with SymTree - // The symbol of a Return node is the enclosing method. - - case class Try(block: Tree, catches: List[CaseDef], finalizer: Tree) - extends TermTree - - /** Throw expression */ - case class Throw(expr: Tree) - extends TermTree - - /** Object instantiation - * One should always use factory method below to build a user level new. - * - * @param tpt a class type - */ - case class New(tpt: Tree) extends TermTree - - /** Type annotation, eliminated by explicit outer */ - case class Typed(expr: Tree, tpt: Tree) - extends TermTree - - // Martin to Sean: Should GenericApply/TypeApply/Apply not be SymTree's? After all, - // ApplyDynamic is a SymTree. - abstract class GenericApply extends TermTree { - val fun: Tree - val args: List[Tree] - } - - /** Type application */ - case class TypeApply(fun: Tree, args: List[Tree]) - extends GenericApply { - override def symbol: Symbol = fun.symbol - override def symbol_=(sym: Symbol) { fun.symbol = sym } - } - - /** Value application */ - case class Apply(fun: Tree, args: List[Tree]) - extends GenericApply { - override def symbol: Symbol = fun.symbol - override def symbol_=(sym: Symbol) { fun.symbol = sym } - } - - /** Dynamic value application. - * In a dynamic application `q.f(as)` - * - `q` is stored in parameter `qual` - * - `as` is stored in parameter `args` - * - `f` is stored as the node's symbol field. - */ - case class ApplyDynamic(qual: Tree, args: List[Tree]) - extends TermTree with SymTree - // The symbol of an ApplyDynamic is the function symbol of `qual`, or NoSymbol, if there is none. - - /** Super reference, qual = corresponding this reference */ - case class Super(qual: Tree, mix: TypeName) extends TermTree { - // The symbol of a Super is the class _from_ which the super reference is made. - // For instance in C.super(...), it would be C. - override def symbol: Symbol = qual.symbol - override def symbol_=(sym: Symbol) { qual.symbol = sym } - } - - /** Self reference */ - case class This(qual: TypeName) - extends TermTree with SymTree - // The symbol of a This is the class to which the this refers. - // For instance in C.this, it would be C. - - /** Designator . */ - case class Select(qualifier: Tree, name: Name) - extends RefTree - - /** Identifier */ - case class Ident(name: Name) extends RefTree { } - - class BackQuotedIdent(name: Name) extends Ident(name) - - /** Literal */ - case class Literal(value: Constant) - extends TermTree { - assert(value ne null) - } - - def Literal(value: Any): Literal = - Literal(Constant(value)) - - type TypeTree <: AbsTypeTree - val TypeTree: TypeTreeExtractor - - abstract class TypeTreeExtractor { - def apply(): TypeTree - def unapply(tree: TypeTree): Boolean - } - - class Traverser { - protected var currentOwner: Symbol = definitions.RootClass - def traverse(tree: Tree): Unit = tree match { - case EmptyTree => - ; - case PackageDef(pid, stats) => - traverse(pid) - atOwner(tree.symbol.moduleClass) { - traverseTrees(stats) - } - case ClassDef(mods, name, tparams, impl) => - atOwner(tree.symbol) { - traverseTrees(mods.annotations); traverseTrees(tparams); traverse(impl) - } - case ModuleDef(mods, name, impl) => - atOwner(tree.symbol.moduleClass) { - traverseTrees(mods.annotations); traverse(impl) - } - case ValDef(mods, name, tpt, rhs) => - atOwner(tree.symbol) { - traverseTrees(mods.annotations); traverse(tpt); traverse(rhs) - } - case DefDef(mods, name, tparams, vparamss, tpt, rhs) => - atOwner(tree.symbol) { - traverseTrees(mods.annotations); traverseTrees(tparams); traverseTreess(vparamss); traverse(tpt); traverse(rhs) - } - case TypeDef(mods, name, tparams, rhs) => - atOwner(tree.symbol) { - traverseTrees(mods.annotations); traverseTrees(tparams); traverse(rhs) - } - case LabelDef(name, params, rhs) => - traverseTrees(params); traverse(rhs) - case Import(expr, selectors) => - traverse(expr) - case Annotated(annot, arg) => - traverse(annot); traverse(arg) - case Template(parents, self, body) => - traverseTrees(parents) - if (!self.isEmpty) traverse(self) - traverseStats(body, tree.symbol) - case Block(stats, expr) => - traverseTrees(stats); traverse(expr) - case CaseDef(pat, guard, body) => - traverse(pat); traverse(guard); traverse(body) - case Alternative(trees) => - traverseTrees(trees) - case Star(elem) => - traverse(elem) - case Bind(name, body) => - traverse(body) - case UnApply(fun, args) => - traverse(fun); traverseTrees(args) - case ArrayValue(elemtpt, trees) => - traverse(elemtpt); traverseTrees(trees) - case Function(vparams, body) => - atOwner(tree.symbol) { - traverseTrees(vparams); traverse(body) - } - case Assign(lhs, rhs) => - traverse(lhs); traverse(rhs) - case If(cond, thenp, elsep) => - traverse(cond); traverse(thenp); traverse(elsep) - case Match(selector, cases) => - traverse(selector); traverseTrees(cases) - case Return(expr) => - traverse(expr) - case Try(block, catches, finalizer) => - traverse(block); traverseTrees(catches); traverse(finalizer) - case Throw(expr) => - traverse(expr) - case New(tpt) => - traverse(tpt) - case Typed(expr, tpt) => - traverse(expr); traverse(tpt) - case TypeApply(fun, args) => - traverse(fun); traverseTrees(args) - case Apply(fun, args) => - traverse(fun); traverseTrees(args) - case ApplyDynamic(qual, args) => - traverse(qual); traverseTrees(args) - case Super(_, _) => - ; - case This(_) => - ; - case Select(qualifier, selector) => - traverse(qualifier) - case Ident(_) => - ; - case Literal(_) => - ; - // commented out to eliminate warning - this file destined for removal anyway - // case TypeTree() => - // ; - case SingletonTypeTree(ref) => - traverse(ref) - case SelectFromTypeTree(qualifier, selector) => - traverse(qualifier) - case CompoundTypeTree(templ) => - traverse(templ) - case AppliedTypeTree(tpt, args) => - traverse(tpt); traverseTrees(args) - case TypeBoundsTree(lo, hi) => - traverse(lo); traverse(hi) - case ExistentialTypeTree(tpt, whereClauses) => - traverse(tpt); traverseTrees(whereClauses) - case SelectFromArray(qualifier, selector, erasure) => - traverse(qualifier) - } - - def traverseTrees(trees: List[Tree]) { - trees foreach traverse - } - def traverseTreess(treess: List[List[Tree]]) { - treess foreach traverseTrees - } - def traverseStats(stats: List[Tree], exprOwner: Symbol) { - stats foreach (stat => - if (exprOwner != currentOwner) atOwner(exprOwner)(traverse(stat)) - else traverse(stat) - ) - } - - def atOwner(owner: Symbol)(traverse: => Unit) { - val prevOwner = currentOwner - currentOwner = owner - traverse - currentOwner = prevOwner - } - } - - /** A synthetic term holding an arbitrary type. Not to be confused with - * `TypTree`, the trait for trees that are only used for type trees. - * `TypeTree`'s are inserted in several places, but most notably in - * `RefCheck`, where the arbitrary type trees are all replaced by - * TypeTree's. */ - abstract class AbsTypeTree extends TypTree { - override def symbol = if (tpe == null) null else tpe.typeSymbol - override def isEmpty = (tpe eq null) || tpe == NoType - } - - /** A tree that has an annotation attached to it. Only used for annotated - * types and annotation ascriptions, annotations on definitions are stored - * in the Modifiers. Eliminated by typechecker (`typedAnnotated`), the - * annotations are then stored in an `AnnotatedType`. - */ - case class Annotated(annot: Tree, arg: Tree) extends Tree - - /** Singleton type, eliminated by RefCheck */ - case class SingletonTypeTree(ref: Tree) - extends TypTree - - /** Type selection # , eliminated by RefCheck */ - case class SelectFromTypeTree(qualifier: Tree, name: TypeName) - extends TypTree with RefTree - - /** Intersection type with ... with { }, eliminated by RefCheck */ - case class CompoundTypeTree(templ: Template) - extends TypTree - - /** Applied type [ ], eliminated by RefCheck */ - case class AppliedTypeTree(tpt: Tree, args: List[Tree]) - extends TypTree { - override def symbol: Symbol = tpt.symbol - override def symbol_=(sym: Symbol) { tpt.symbol = sym } - } - - case class TypeBoundsTree(lo: Tree, hi: Tree) - extends TypTree - - case class ExistentialTypeTree(tpt: Tree, whereClauses: List[Tree]) - extends TypTree - - /** Array selection . only used during erasure */ - case class SelectFromArray(qualifier: Tree, name: Name, erasure: Type) - extends TermTree with RefTree { } - -/* A standard pattern match - case EmptyTree => - case PackageDef(pid, stats) => - // package pid { stats } - case ClassDef(mods, name, tparams, impl) => - // mods class name [tparams] impl where impl = extends parents { defs } - case ModuleDef(mods, name, impl) => (eliminated by refcheck) - // mods object name impl where impl = extends parents { defs } - case ValDef(mods, name, tpt, rhs) => - // mods val name: tpt = rhs - // note missing type information is expressed by tpt = TypeTree() - case DefDef(mods, name, tparams, vparamss, tpt, rhs) => - // mods def name[tparams](vparams_1)...(vparams_n): tpt = rhs - // note missing type information is expressed by tpt = TypeTree() - case TypeDef(mods, name, tparams, rhs) => (eliminated by erasure) - // mods type name[tparams] = rhs - // mods type name[tparams] >: lo <: hi, where lo, hi are in a TypeBoundsTree, - and DEFERRED is set in mods - case LabelDef(name, params, rhs) => - // used for tailcalls and like - // while/do are desugared to label defs as follows: - // while (cond) body ==> LabelDef($L, List(), if (cond) { body; L$() } else ()) - // do body while (cond) ==> LabelDef($L, List(), body; if (cond) L$() else ()) - case Import(expr, selectors) => (eliminated by typecheck) - // import expr.{selectors} - // Selectors are a list of pairs of names (from, to). - // The last (and maybe only name) may be a nme.WILDCARD - // for instance - // import qual.{x, y => z, _} would be represented as - // Import(qual, List(("x", "x"), ("y", "z"), (WILDCARD, null))) - case Template(parents, self, body) => - // extends parents { self => body } - // if self is missing it is represented as emptyValDef - case Block(stats, expr) => - // { stats; expr } - case CaseDef(pat, guard, body) => (eliminated by transmatch/explicitouter) - // case pat if guard => body - case Alternative(trees) => (eliminated by transmatch/explicitouter) - // pat1 | ... | patn - case Star(elem) => (eliminated by transmatch/explicitouter) - // pat* - case Bind(name, body) => (eliminated by transmatch/explicitouter) - // name @ pat - case UnApply(fun: Tree, args) (introduced by typer, eliminated by transmatch/explicitouter) - // used for unapply's - case ArrayValue(elemtpt, trees) => (introduced by uncurry) - // used to pass arguments to vararg arguments - // for instance, printf("%s%d", foo, 42) is translated to after uncurry to: - // Apply( - // Ident("printf"), - // Literal("%s%d"), - // ArrayValue(, List(Ident("foo"), Literal(42)))) - case Function(vparams, body) => (eliminated by lambdaLift) - // vparams => body where vparams:List[ValDef] - case Assign(lhs, rhs) => - // lhs = rhs - case If(cond, thenp, elsep) => - // if (cond) thenp else elsep - case Match(selector, cases) => - // selector match { cases } - case Return(expr) => - // return expr - case Try(block, catches, finalizer) => - // try block catch { catches } finally finalizer where catches: List[CaseDef] - case Throw(expr) => - // throw expr - case New(tpt) => - // new tpt always in the context: (new tpt).[targs](args) - case Typed(expr, tpt) => (eliminated by erasure) - // expr: tpt - case TypeApply(fun, args) => - // fun[args] - case Apply(fun, args) => - // fun(args) - // for instance fun[targs](args) is expressed as Apply(TypeApply(fun, targs), args) - case ApplyDynamic(qual, args) (introduced by erasure, eliminated by cleanup) - // fun(args) - case Super(qual, mix) => - // qual.super[mix] if qual and/or mix is empty, ther are tpnme.EMPTY - case This(qual) => - // qual.this - case Select(qualifier, selector) => - // qualifier.selector - case Ident(name) => - // name - // note: type checker converts idents that refer to enclosing fields or methods - // to selects; name ==> this.name - case Literal(value) => - // value - case TypeTree() => (introduced by refcheck) - // a type that's not written out, but given in the tpe attribute - case Annotated(annot, arg) => (eliminated by typer) - // arg @annot for types, arg: @annot for exprs - case SingletonTypeTree(ref) => (eliminated by uncurry) - // ref.type - case SelectFromTypeTree(qualifier, selector) => (eliminated by uncurry) - // qualifier # selector, a path-dependent type p.T is expressed as p.type # T - case CompoundTypeTree(templ: Template) => (eliminated by uncurry) - // parent1 with ... with parentN { refinement } - case AppliedTypeTree(tpt, args) => (eliminated by uncurry) - // tpt[args] - case TypeBoundsTree(lo, hi) => (eliminated by uncurry) - // >: lo <: hi - case ExistentialTypeTree(tpt, whereClauses) => (eliminated by uncurry) - // tpt forSome { whereClauses } - -*/ -} diff --git a/src/library/scala/reflect/generic/Types.scala b/src/library/scala/reflect/generic/Types.scala deleted file mode 100755 index b3601cf364..0000000000 --- a/src/library/scala/reflect/generic/Types.scala +++ /dev/null @@ -1,165 +0,0 @@ -package scala.reflect -package generic - -@deprecated("scala.reflect.generic will be removed", "2.9.1") trait Types { self: Universe => - - abstract class AbsType { - def typeSymbol: Symbol - def decl(name: Name): Symbol - - /** Is this type completed (i.e. not a lazy type)? - */ - def isComplete: Boolean = true - - /** If this is a lazy type, assign a new type to `sym`. */ - def complete(sym: Symbol) {} - - /** Convert toString avoiding infinite recursions by cutting off - * after `maxTostringRecursions` recursion levels. Uses `safeToString` - * to produce a string on each level. - */ - override def toString: String = - if (tostringRecursions >= maxTostringRecursions) - "..." - else - try { - tostringRecursions += 1 - safeToString - } finally { - tostringRecursions -= 1 - } - - /** Method to be implemented in subclasses. - * Converts this type to a string in calling toString for its parts. - */ - def safeToString: String = super.toString - } - - type Type >: Null <: AbsType - type SingletonType >: Null <: Type - - val NoType: Type - val NoPrefix: Type - - type ThisType <: SingletonType - val ThisType: ThisTypeExtractor - - type TypeRef <: Type - val TypeRef: TypeRefExtractor - - type SingleType <: SingletonType - val SingleType: SingleTypeExtractor - - type SuperType <: SingletonType - val SuperType: SuperTypeExtractor - - type TypeBounds <: Type - val TypeBounds: TypeBoundsExtractor - - type CompoundType <: Type - - type RefinedType <: CompoundType - val RefinedType: RefinedTypeExtractor - - type ClassInfoType <: CompoundType - val ClassInfoType: ClassInfoTypeExtractor - - type ConstantType <: Type - val ConstantType: ConstantTypeExtractor - - type MethodType <: Type - val MethodType: MethodTypeExtractor - - type NullaryMethodType <: Type - val NullaryMethodType: NullaryMethodTypeExtractor - - type PolyType <: Type - val PolyType: PolyTypeExtractor - - type ExistentialType <: Type - val ExistentialType: ExistentialTypeExtractor - - type AnnotatedType <: Type - val AnnotatedType: AnnotatedTypeExtractor - - type LazyType <: Type with AbsLazyType - - trait AbsLazyType extends AbsType { - override def isComplete: Boolean = false - override def complete(sym: Symbol) - override def safeToString = "" - } - - abstract class ThisTypeExtractor { - def apply(sym: Symbol): Type - def unapply(tpe: ThisType): Option[Symbol] - } - - abstract class SingleTypeExtractor { - def apply(pre: Type, sym: Symbol): Type - def unapply(tpe: SingleType): Option[(Type, Symbol)] - } - - abstract class SuperTypeExtractor { - def apply(thistpe: Type, supertpe: Type): Type - def unapply(tpe: SuperType): Option[(Type, Type)] - } - - abstract class TypeRefExtractor { - def apply(pre: Type, sym: Symbol, args: List[Type]): Type - def unapply(tpe: TypeRef): Option[(Type, Symbol, List[Type])] - } - - abstract class TypeBoundsExtractor { - def apply(lo: Type, hi: Type): TypeBounds - def unapply(tpe: TypeBounds): Option[(Type, Type)] - } - - abstract class RefinedTypeExtractor { - def apply(parents: List[Type], decls: Scope): RefinedType - def apply(parents: List[Type], decls: Scope, clazz: Symbol): RefinedType - def unapply(tpe: RefinedType): Option[(List[Type], Scope)] - } - - abstract class ClassInfoTypeExtractor { - def apply(parents: List[Type], decls: Scope, clazz: Symbol): ClassInfoType - def unapply(tpe: ClassInfoType): Option[(List[Type], Scope, Symbol)] - } - - abstract class ConstantTypeExtractor { - def apply(value: Constant): ConstantType - def unapply(tpe: ConstantType): Option[Constant] - } - - abstract class MethodTypeExtractor { - def apply(params: List[Symbol], resultType: Type): MethodType - def unapply(tpe: MethodType): Option[(List[Symbol], Type)] - } - - abstract class NullaryMethodTypeExtractor { - def apply(resultType: Type): NullaryMethodType - def unapply(tpe: NullaryMethodType): Option[(Type)] - } - - abstract class PolyTypeExtractor { - def apply(typeParams: List[Symbol], resultType: Type): PolyType - def unapply(tpe: PolyType): Option[(List[Symbol], Type)] - } - - abstract class ExistentialTypeExtractor { - def apply(quantified: List[Symbol], underlying: Type): ExistentialType - def unapply(tpe: ExistentialType): Option[(List[Symbol], Type)] - } - - abstract class AnnotatedTypeExtractor { - def apply(annotations: List[AnnotationInfo], underlying: Type, selfsym: Symbol): AnnotatedType - def unapply(tpe: AnnotatedType): Option[(List[AnnotationInfo], Type, Symbol)] - } - - /** The maximum number of recursions allowed in toString - */ - final val maxTostringRecursions = 50 - - private var tostringRecursions = 0 -} - diff --git a/src/library/scala/reflect/generic/UnPickler.scala b/src/library/scala/reflect/generic/UnPickler.scala deleted file mode 100755 index e390dbb54b..0000000000 --- a/src/library/scala/reflect/generic/UnPickler.scala +++ /dev/null @@ -1,826 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2011 LAMP/EPFL - * @author Martin Odersky - */ - -package scala.reflect -package generic - -import java.io.IOException -import java.lang.Float.intBitsToFloat -import java.lang.Double.longBitsToDouble - -import Flags._ -import PickleFormat._ -import scala.collection.{ mutable, immutable } -import mutable.ListBuffer -import annotation.switch - -/** @author Martin Odersky - * @version 1.0 - */ -@deprecated("scala.reflect.generic will be removed", "2.9.1") -abstract class UnPickler { - - val global: Universe - import global._ - - /** Unpickle symbol table information descending from a class and/or module root - * from an array of bytes. - * @param bytes bytearray from which we unpickle - * @param offset offset from which unpickling starts - * @param classroot the top-level class which is unpickled, or NoSymbol if inapplicable - * @param moduleroot the top-level module which is unpickled, or NoSymbol if inapplicable - * @param filename filename associated with bytearray, only used for error messages - */ - def unpickle(bytes: Array[Byte], offset: Int, classRoot: Symbol, moduleRoot: Symbol, filename: String) { - try { - scan(bytes, offset, classRoot, moduleRoot, filename) - } catch { - case ex: IOException => - throw ex - case ex: Throwable => - /*if (settings.debug.value)*/ ex.printStackTrace() - throw new RuntimeException("error reading Scala signature of "+filename+": "+ex.getMessage()) - } - } - - /** To be implemented in subclasses. Like `unpickle` but without the catch-all error handling. - */ - def scan(bytes: Array[Byte], offset: Int, classRoot: Symbol, moduleRoot: Symbol, filename: String) - - abstract class Scan(bytes: Array[Byte], offset: Int, classRoot: Symbol, moduleRoot: Symbol, filename: String) extends PickleBuffer(bytes, offset, -1) { - //println("unpickle " + classRoot + " and " + moduleRoot)//debug - - protected def debug = false - - checkVersion() - - /** A map from entry numbers to array offsets */ - private val index = createIndex - - /** A map from entry numbers to symbols, types, or annotations */ - private val entries = new Array[AnyRef](index.length) - - /** A map from symbols to their associated `decls` scopes */ - private val symScopes = new mutable.HashMap[Symbol, Scope] - - //println("unpickled " + classRoot + ":" + classRoot.rawInfo + ", " + moduleRoot + ":" + moduleRoot.rawInfo);//debug - - def run() { - // read children last, fix for #3951 - val queue = new ListBuffer[() => Unit]() - def delay(i: Int, action: => Unit) { - queue += (() => at(i, {() => action; null})) - } - - for (i <- 0 until index.length) { - if (isSymbolEntry(i)) - at(i, readSymbol) - else if (isSymbolAnnotationEntry(i)) - delay(i, readSymbolAnnotation()) - else if (isChildrenEntry(i)) - delay(i, readChildren()) - } - - for (action <- queue) - action() - } - - private def checkVersion() { - val major = readNat() - val minor = readNat() - if (major != MajorVersion || minor > MinorVersion) - throw new IOException("Scala signature " + classRoot.decodedName + - " has wrong version\n expected: " + - MajorVersion + "." + MinorVersion + - "\n found: " + major + "." + minor + - " in "+filename) - } - - /** The `decls` scope associated with given symbol */ - protected def symScope(sym: Symbol) = symScopes.getOrElseUpdate(sym, newScope) - - /** Does entry represent an (internal) symbol */ - protected def isSymbolEntry(i: Int): Boolean = { - val tag = bytes(index(i)).toInt - (firstSymTag <= tag && tag <= lastSymTag && - (tag != CLASSsym || !isRefinementSymbolEntry(i))) - } - - /** Does entry represent an (internal or external) symbol */ - protected def isSymbolRef(i: Int): Boolean = { - val tag = bytes(index(i)) - (firstSymTag <= tag && tag <= lastExtSymTag) - } - - /** Does entry represent a name? */ - protected def isNameEntry(i: Int): Boolean = { - val tag = bytes(index(i)).toInt - tag == TERMname || tag == TYPEname - } - - /** Does entry represent a symbol annotation? */ - protected def isSymbolAnnotationEntry(i: Int): Boolean = { - val tag = bytes(index(i)).toInt - tag == SYMANNOT - } - - /** Does the entry represent children of a symbol? */ - protected def isChildrenEntry(i: Int): Boolean = { - val tag = bytes(index(i)).toInt - tag == CHILDREN - } - - /** Does entry represent a refinement symbol? - * pre: Entry is a class symbol - */ - protected def isRefinementSymbolEntry(i: Int): Boolean = { - val savedIndex = readIndex - readIndex = index(i) - val tag = readByte().toInt - assert(tag == CLASSsym) - - readNat(); // read length - val result = readNameRef() == tpnme.REFINE_CLASS_NAME - readIndex = savedIndex - result - } - - /** If entry at `i` is undefined, define it by performing operation `op` - * with `readIndex` at start of `i`'th entry. Restore `readIndex` - * afterwards. - */ - protected def at[T <: AnyRef](i: Int, op: () => T): T = { - var r = entries(i) - if (r eq null) { - val savedIndex = readIndex - readIndex = index(i) - r = op() - assert(entries(i) eq null, entries(i)) - entries(i) = r - readIndex = savedIndex - } - r.asInstanceOf[T] - } - - /** Read a name */ - protected def readName(): Name = { - val tag = readByte() - val len = readNat() - tag match { - case TERMname => newTermName(bytes, readIndex, len) - case TYPEname => newTypeName(bytes, readIndex, len) - case _ => errorBadSignature("bad name tag: " + tag) - } - } - - /** Read a symbol */ - protected def readSymbol(): Symbol = { - val tag = readByte() - val end = readNat() + readIndex - def atEnd = readIndex == end - - def readExtSymbol(): Symbol = { - val name = readNameRef() - val owner = if (atEnd) definitions.RootClass else readSymbolRef() - - def fromName(name: Name) = mkTermName(name) match { - case nme.ROOT => definitions.RootClass - case nme.ROOTPKG => definitions.RootPackage - case _ => - val s = owner.info.decl(name) - if (tag == EXTref) s else s.moduleClass - } - def nestedObjectSymbol: Symbol = { - // If the owner is overloaded (i.e. a method), it's not possible to select the - // right member, so return NoSymbol. This can only happen when unpickling a tree. - // the "case Apply" in readTree() takes care of selecting the correct alternative - // after parsing the arguments. - if (owner.isOverloaded) - return NoSymbol - - if (tag == EXTMODCLASSref) { - val moduleVar = owner.info.decl(nme.moduleVarName(name)) - if (moduleVar.isLazyAccessor) - return moduleVar.lazyAccessor.lazyAccessor - } - NoSymbol - } - - // (1) Try name. - fromName(name) orElse { - // (2) Try with expanded name. Can happen if references to private - // symbols are read from outside: for instance when checking the children - // of a class. See #1722. - fromName(nme.expandedName(name, owner)) orElse { - // (3) Try as a nested object symbol. - nestedObjectSymbol orElse { - // (4) Otherwise, fail. - errorMissingRequirement(name, owner) - } - } - } - } - - tag match { - case NONEsym => return NoSymbol - case EXTref | EXTMODCLASSref => return readExtSymbol() - case _ => () - } - - // symbols that were pickled with Pickler.writeSymInfo - val nameref = readNat() - val name = at(nameref, readName) - val owner = readSymbolRef() - val flags = pickledToRawFlags(readLongNat()) - var inforef = readNat() - val privateWithin = - if (!isSymbolRef(inforef)) NoSymbol - else { - val pw = at(inforef, readSymbol) - inforef = readNat() - pw - } - - def isModuleFlag = (flags & MODULE) != 0L - def isMethodFlag = (flags & METHOD) != 0L - def isClassRoot = (name == classRoot.name) && (owner == classRoot.owner) - def isModuleRoot = (name == moduleRoot.name) && (owner == moduleRoot.owner) - - def finishSym(sym: Symbol): Symbol = { - sym.flags = flags & PickledFlags - sym.privateWithin = privateWithin - sym.info = ( - if (atEnd) { - assert(!sym.isSuperAccessor, sym) - newLazyTypeRef(inforef) - } - else { - assert(sym.isSuperAccessor || sym.isParamAccessor, sym) - newLazyTypeRefAndAlias(inforef, readNat()) - } - ) - if (sym.owner.isClass && sym != classRoot && sym != moduleRoot && - !sym.isModuleClass && !sym.isRefinementClass && !sym.isTypeParameter && !sym.isExistentiallyBound) - symScope(sym.owner) enter sym - - sym - } - - finishSym(tag match { - case TYPEsym => owner.newAbstractType(mkTypeName(name)) - case ALIASsym => owner.newAliasType(mkTypeName(name)) - case CLASSsym => - val sym = (isClassRoot, isModuleFlag) match { - case (true, true) => moduleRoot.moduleClass - case (true, false) => classRoot - case (false, true) => owner.newModuleClass(mkTypeName(name)) - case (false, false) => owner.newClass(mkTypeName(name)) - } - if (!atEnd) - sym.typeOfThis = newLazyTypeRef(readNat()) - - sym - case MODULEsym => - val clazz = at(inforef, () => readType()).typeSymbol // after the NMT_TRANSITION period, we can leave off the () => ... () - if (isModuleRoot) moduleRoot - else { - val m = owner.newModule(name, clazz) - clazz.sourceModule = m - m - } - case VALsym => - if (isModuleRoot) { assert(false); NoSymbol } - else if (isMethodFlag) owner.newMethod(name) - else owner.newValue(name) - - case _ => - errorBadSignature("bad symbol tag: " + tag) - }) - } - - /** Read a type - * - * @param forceProperType is used to ease the transition to NullaryMethodTypes (commentmarker: NMT_TRANSITION) - * the flag say that a type of kind * is expected, so that PolyType(tps, restpe) can be disambiguated to PolyType(tps, NullaryMethodType(restpe)) - * (if restpe is not a ClassInfoType, a MethodType or a NullaryMethodType, which leaves TypeRef/SingletonType -- the latter would make the polytype a type constructor) - */ - protected def readType(forceProperType: Boolean = false): Type = { - val tag = readByte() - val end = readNat() + readIndex - (tag: @switch) match { - case NOtpe => - NoType - case NOPREFIXtpe => - NoPrefix - case THIStpe => - ThisType(readSymbolRef()) - case SINGLEtpe => - SingleType(readTypeRef(), readSymbolRef()) // !!! was singleType - case SUPERtpe => - val thistpe = readTypeRef() - val supertpe = readTypeRef() - SuperType(thistpe, supertpe) - case CONSTANTtpe => - ConstantType(readConstantRef()) - case TYPEREFtpe => - val pre = readTypeRef() - val sym = readSymbolRef() - var args = until(end, readTypeRef) - TypeRef(pre, sym, args) - case TYPEBOUNDStpe => - TypeBounds(readTypeRef(), readTypeRef()) - case REFINEDtpe => - val clazz = readSymbolRef() - RefinedType(until(end, readTypeRef), symScope(clazz), clazz) - case CLASSINFOtpe => - val clazz = readSymbolRef() - ClassInfoType(until(end, readTypeRef), symScope(clazz), clazz) - case METHODtpe | IMPLICITMETHODtpe => - val restpe = readTypeRef() - val params = until(end, readSymbolRef) - // if the method is overloaded, the params cannot be determined (see readSymbol) => return NoType. - // Only happen for trees, "case Apply" in readTree() takes care of selecting the correct - // alternative after parsing the arguments. - if (params.contains(NoSymbol) || restpe == NoType) NoType - else MethodType(params, restpe) - case POLYtpe => - val restpe = readTypeRef() - val typeParams = until(end, readSymbolRef) - if(typeParams nonEmpty) { - // NMT_TRANSITION: old class files denoted a polymorphic nullary method as PolyType(tps, restpe), we now require PolyType(tps, NullaryMethodType(restpe)) - // when a type of kind * is expected (forceProperType is true), we know restpe should be wrapped in a NullaryMethodType (if it wasn't suitably wrapped yet) - def transitionNMT(restpe: Type) = { - val resTpeCls = restpe.getClass.toString // what's uglier than isInstanceOf? right! -- isInstanceOf does not work since the concrete types are defined in the compiler (not in scope here) - if(forceProperType /*&& pickleformat < 2.9 */ && !(resTpeCls.endsWith("MethodType"))) { assert(!resTpeCls.contains("ClassInfoType")) - NullaryMethodType(restpe) } - else restpe - } - PolyType(typeParams, transitionNMT(restpe)) - } - else - NullaryMethodType(restpe) - case EXISTENTIALtpe => - val restpe = readTypeRef() - ExistentialType(until(end, readSymbolRef), restpe) - case ANNOTATEDtpe => - var typeRef = readNat() - val selfsym = if (isSymbolRef(typeRef)) { - val s = at(typeRef, readSymbol) - typeRef = readNat() - s - } else NoSymbol // selfsym can go. - val tp = at(typeRef, () => readType(forceProperType)) // NMT_TRANSITION - val annots = until(end, readAnnotationRef) - if (selfsym == NoSymbol) AnnotatedType(annots, tp, selfsym) - else tp - case _ => - noSuchTypeTag(tag, end) - } - } - - def noSuchTypeTag(tag: Int, end: Int): Type = - errorBadSignature("bad type tag: " + tag) - - /** Read a constant */ - protected def readConstant(): Constant = { - val tag = readByte().toInt - val len = readNat() - (tag: @switch) match { - case LITERALunit => Constant(()) - case LITERALboolean => Constant(readLong(len) != 0L) - case LITERALbyte => Constant(readLong(len).toByte) - case LITERALshort => Constant(readLong(len).toShort) - case LITERALchar => Constant(readLong(len).toChar) - case LITERALint => Constant(readLong(len).toInt) - case LITERALlong => Constant(readLong(len)) - case LITERALfloat => Constant(intBitsToFloat(readLong(len).toInt)) - case LITERALdouble => Constant(longBitsToDouble(readLong(len))) - case LITERALstring => Constant(readNameRef().toString()) - case LITERALnull => Constant(null) - case LITERALclass => Constant(readTypeRef()) - case LITERALenum => Constant(readSymbolRef()) - case _ => noSuchConstantTag(tag, len) - } - } - - def noSuchConstantTag(tag: Int, len: Int): Constant = - errorBadSignature("bad constant tag: " + tag) - - /** Read children and store them into the corresponding symbol. - */ - protected def readChildren() { - val tag = readByte() - assert(tag == CHILDREN) - val end = readNat() + readIndex - val target = readSymbolRef() - while (readIndex != end) target addChild readSymbolRef() - } - - /** Read an annotation argument, which is pickled either - * as a Constant or a Tree. - */ - protected def readAnnotArg(i: Int): Tree = bytes(index(i)) match { - case TREE => at(i, readTree) - case _ => - val const = at(i, readConstant) - Literal(const) setType const.tpe - } - - /** Read a ClassfileAnnotArg (argument to a classfile annotation) - */ - private def readArrayAnnot() = { - readByte() // skip the `annotargarray` tag - val end = readNat() + readIndex - until(end, () => readClassfileAnnotArg(readNat())).toArray(classfileAnnotArgManifest) - } - protected def readClassfileAnnotArg(i: Int): ClassfileAnnotArg = bytes(index(i)) match { - case ANNOTINFO => NestedAnnotArg(at(i, readAnnotation)) - case ANNOTARGARRAY => at(i, () => ArrayAnnotArg(readArrayAnnot())) - case _ => LiteralAnnotArg(at(i, readConstant)) - } - - /** Read an AnnotationInfo. Not to be called directly, use - * readAnnotation or readSymbolAnnotation - */ - protected def readAnnotationInfo(end: Int): AnnotationInfo = { - val atp = readTypeRef() - val args = new ListBuffer[Tree] - val assocs = new ListBuffer[(Name, ClassfileAnnotArg)] - while (readIndex != end) { - val argref = readNat() - if (isNameEntry(argref)) { - val name = at(argref, readName) - val arg = readClassfileAnnotArg(readNat()) - assocs += ((name, arg)) - } - else - args += readAnnotArg(argref) - } - AnnotationInfo(atp, args.toList, assocs.toList) - } - - /** Read an annotation and as a side effect store it into - * the symbol it requests. Called at top-level, for all - * (symbol, annotInfo) entries. */ - protected def readSymbolAnnotation() { - val tag = readByte() - if (tag != SYMANNOT) - errorBadSignature("symbol annotation expected ("+ tag +")") - val end = readNat() + readIndex - val target = readSymbolRef() - target.addAnnotation(readAnnotationInfo(end)) - } - - /** Read an annotation and return it. Used when unpickling - * an ANNOTATED(WSELF)tpe or a NestedAnnotArg */ - protected def readAnnotation(): AnnotationInfo = { - val tag = readByte() - if (tag != ANNOTINFO) - errorBadSignature("annotation expected (" + tag + ")") - val end = readNat() + readIndex - readAnnotationInfo(end) - } - - /* Read an abstract syntax tree */ - protected def readTree(): Tree = { - val outerTag = readByte() - if (outerTag != TREE) - errorBadSignature("tree expected (" + outerTag + ")") - val end = readNat() + readIndex - val tag = readByte() - val tpe = if (tag == EMPTYtree) NoType else readTypeRef() - - // Set by the three functions to follow. If symbol is non-null - // after the the new tree 't' has been created, t has its Symbol - // set to symbol; and it always has its Type set to tpe. - var symbol: Symbol = null - var mods: Modifiers = null - var name: Name = null - - /** Read a Symbol, Modifiers, and a Name */ - def setSymModsName() { - symbol = readSymbolRef() - mods = readModifiersRef() - name = readNameRef() - } - /** Read a Symbol and a Name */ - def setSymName() { - symbol = readSymbolRef() - name = readNameRef() - } - /** Read a Symbol */ - def setSym() { - symbol = readSymbolRef() - } - - val t = tag match { - case EMPTYtree => - EmptyTree - - case PACKAGEtree => - setSym() - val pid = readTreeRef().asInstanceOf[RefTree] - val stats = until(end, readTreeRef) - PackageDef(pid, stats) - - case CLASStree => - setSymModsName() - val impl = readTemplateRef() - val tparams = until(end, readTypeDefRef) - ClassDef(mods, mkTypeName(name), tparams, impl) - - case MODULEtree => - setSymModsName() - ModuleDef(mods, name, readTemplateRef()) - - case VALDEFtree => - setSymModsName() - val tpt = readTreeRef() - val rhs = readTreeRef() - ValDef(mods, name, tpt, rhs) - - case DEFDEFtree => - setSymModsName() - val tparams = times(readNat(), readTypeDefRef) - val vparamss = times(readNat(), () => times(readNat(), readValDefRef)) - val tpt = readTreeRef() - val rhs = readTreeRef() - DefDef(mods, name, tparams, vparamss, tpt, rhs) - - case TYPEDEFtree => - setSymModsName() - val rhs = readTreeRef() - val tparams = until(end, readTypeDefRef) - TypeDef(mods, mkTypeName(name), tparams, rhs) - - case LABELtree => - setSymName() - val rhs = readTreeRef() - val params = until(end, readIdentRef) - LabelDef(name, params, rhs) - - case IMPORTtree => - setSym() - val expr = readTreeRef() - val selectors = until(end, () => { - val from = readNameRef() - val to = readNameRef() - ImportSelector(from, -1, to, -1) - }) - - Import(expr, selectors) - - case TEMPLATEtree => - setSym() - val parents = times(readNat(), readTreeRef) - val self = readValDefRef() - val body = until(end, readTreeRef) - - Template(parents, self, body) - - case BLOCKtree => - val expr = readTreeRef() - val stats = until(end, readTreeRef) - Block(stats, expr) - - case CASEtree => - val pat = readTreeRef() - val guard = readTreeRef() - val body = readTreeRef() - CaseDef(pat, guard, body) - - case ALTERNATIVEtree => - Alternative(until(end, readTreeRef)) - - case STARtree => - Star(readTreeRef()) - - case BINDtree => - setSymName() - Bind(name, readTreeRef()) - - case UNAPPLYtree => - val fun = readTreeRef() - val args = until(end, readTreeRef) - UnApply(fun, args) - - case ARRAYVALUEtree => - val elemtpt = readTreeRef() - val trees = until(end, readTreeRef) - ArrayValue(elemtpt, trees) - - case FUNCTIONtree => - setSym() - val body = readTreeRef() - val vparams = until(end, readValDefRef) - Function(vparams, body) - - case ASSIGNtree => - val lhs = readTreeRef() - val rhs = readTreeRef() - Assign(lhs, rhs) - - case IFtree => - val cond = readTreeRef() - val thenp = readTreeRef() - val elsep = readTreeRef() - If(cond, thenp, elsep) - - case MATCHtree => - val selector = readTreeRef() - val cases = until(end, readCaseDefRef) - Match(selector, cases) - - case RETURNtree => - setSym() - Return(readTreeRef()) - - case TREtree => - val block = readTreeRef() - val finalizer = readTreeRef() - val catches = until(end, readCaseDefRef) - Try(block, catches, finalizer) - - case THROWtree => - Throw(readTreeRef()) - - case NEWtree => - New(readTreeRef()) - - case TYPEDtree => - val expr = readTreeRef() - val tpt = readTreeRef() - Typed(expr, tpt) - - case TYPEAPPLYtree => - val fun = readTreeRef() - val args = until(end, readTreeRef) - TypeApply(fun, args) - - case APPLYtree => - val fun = readTreeRef() - val args = until(end, readTreeRef) - if (fun.symbol.isOverloaded) { - fun.setType(fun.symbol.info) - inferMethodAlternative(fun, args map (_.tpe), tpe) - } - Apply(fun, args) - - case APPLYDYNAMICtree => - setSym() - val qual = readTreeRef() - val args = until(end, readTreeRef) - ApplyDynamic(qual, args) - - case SUPERtree => - setSym() - val qual = readTreeRef() - val mix = readTypeNameRef() - Super(qual, mix) - - case THIStree => - setSym() - This(readTypeNameRef()) - - case SELECTtree => - setSym() - val qualifier = readTreeRef() - val selector = readNameRef() - Select(qualifier, selector) - - case IDENTtree => - setSymName() - Ident(name) - - case LITERALtree => - Literal(readConstantRef()) - - case TYPEtree => - TypeTree() - - case ANNOTATEDtree => - val annot = readTreeRef() - val arg = readTreeRef() - Annotated(annot, arg) - - case SINGLETONTYPEtree => - SingletonTypeTree(readTreeRef()) - - case SELECTFROMTYPEtree => - val qualifier = readTreeRef() - val selector = readTypeNameRef() - SelectFromTypeTree(qualifier, selector) - - case COMPOUNDTYPEtree => - CompoundTypeTree(readTemplateRef()) - - case APPLIEDTYPEtree => - val tpt = readTreeRef() - val args = until(end, readTreeRef) - AppliedTypeTree(tpt, args) - - case TYPEBOUNDStree => - val lo = readTreeRef() - val hi = readTreeRef() - TypeBoundsTree(lo, hi) - - case EXISTENTIALTYPEtree => - val tpt = readTreeRef() - val whereClauses = until(end, readTreeRef) - ExistentialTypeTree(tpt, whereClauses) - - case _ => - noSuchTreeTag(tag, end) - } - - if (symbol == null) t setType tpe - else t setSymbol symbol setType tpe - } - - def noSuchTreeTag(tag: Int, end: Int) = - errorBadSignature("unknown tree type (" + tag + ")") - - def readModifiers(): Modifiers = { - val tag = readNat() - if (tag != MODIFIERS) - errorBadSignature("expected a modifiers tag (" + tag + ")") - val end = readNat() + readIndex - val pflagsHi = readNat() - val pflagsLo = readNat() - val pflags = (pflagsHi.toLong << 32) + pflagsLo - val flags = pickledToRawFlags(pflags) - val privateWithin = readNameRef() - Modifiers(flags, privateWithin, Nil, Map.empty) - } - - /* Read a reference to a pickled item */ - protected def readNameRef(): Name = at(readNat(), readName) - protected def readSymbolRef(): Symbol = at(readNat(), readSymbol) - protected def readTypeRef(): Type = at(readNat(), () => readType()) // after the NMT_TRANSITION period, we can leave off the () => ... () - protected def readConstantRef(): Constant = at(readNat(), readConstant) - protected def readAnnotationRef(): AnnotationInfo = at(readNat(), readAnnotation) - protected def readModifiersRef(): Modifiers = at(readNat(), readModifiers) - protected def readTreeRef(): Tree = at(readNat(), readTree) - - protected def readTypeNameRef(): TypeName = mkTypeName(readNameRef()) - protected def readTermNameRef(): TermName = mkTermName(readNameRef()) - - protected def readTemplateRef(): Template = - readTreeRef() match { - case templ:Template => templ - case other => - errorBadSignature("expected a template (" + other + ")") - } - protected def readCaseDefRef(): CaseDef = - readTreeRef() match { - case tree:CaseDef => tree - case other => - errorBadSignature("expected a case def (" + other + ")") - } - protected def readValDefRef(): ValDef = - readTreeRef() match { - case tree:ValDef => tree - case other => - errorBadSignature("expected a ValDef (" + other + ")") - } - protected def readIdentRef(): Ident = - readTreeRef() match { - case tree:Ident => tree - case other => - errorBadSignature("expected an Ident (" + other + ")") - } - protected def readTypeDefRef(): TypeDef = - readTreeRef() match { - case tree:TypeDef => tree - case other => - errorBadSignature("expected an TypeDef (" + other + ")") - } - - protected def errorBadSignature(msg: String) = - throw new RuntimeException("malformed Scala signature of " + classRoot.name + " at " + readIndex + "; " + msg) - - protected def errorMissingRequirement(msg: String): Nothing = - if (debug) errorBadSignature(msg) - else throw new IOException("class file needed by "+classRoot.name+" is missing.\n"+msg) - - protected def errorMissingRequirement(name: Name, owner: Symbol): Nothing = - errorMissingRequirement("reference " + NameTransformer.decode(name.toString) + " of " + owner.tpe + " refers to nonexisting symbol.") - - /** pre: `fun` points to a symbol with an overloaded type. - * Selects the overloaded alternative of `fun` which best matches given - * argument types `argtpes` and result type `restpe`. Stores this alternative as - * the symbol of `fun`. - */ - def inferMethodAlternative(fun: Tree, argtpes: List[Type], restpe: Type) - - /** Create a lazy type which when completed returns type at index `i`. */ - def newLazyTypeRef(i: Int): LazyType - - /** Create a lazy type which when completed returns type at index `i` and sets alias - * of completed symbol to symbol at index `j` - */ - def newLazyTypeRefAndAlias(i: Int, j: Int): LazyType - } -} diff --git a/src/library/scala/reflect/generic/Universe.scala b/src/library/scala/reflect/generic/Universe.scala deleted file mode 100755 index 4bc70044ae..0000000000 --- a/src/library/scala/reflect/generic/Universe.scala +++ /dev/null @@ -1,17 +0,0 @@ -package scala.reflect -package generic - -@deprecated("scala.reflect.generic will be removed", "2.9.1") -abstract class Universe extends Symbols - with Types - with Constants - with Scopes - with Names - with StdNames - with Trees - with AnnotationInfos - with StandardDefinitions { - type Position - val NoPosition: Position -} - -- cgit v1.2.3