diff options
author | Paul Phillips <paulp@improving.org> | 2011-01-24 06:18:01 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-01-24 06:18:01 +0000 |
commit | 4253124eecba6bed38f1dc961c5c4ee39a29f730 (patch) | |
tree | 797f007d753da349feb718f802c476557c47249e /src | |
parent | 1cbe06c2dcde9606c3d3f6fe86e89fbba3a404e3 (diff) | |
download | scala-4253124eecba6bed38f1dc961c5c4ee39a29f730.tar.gz scala-4253124eecba6bed38f1dc961c5c4ee39a29f730.tar.bz2 scala-4253124eecba6bed38f1dc961c5c4ee39a29f730.zip |
The AnyVal types become source files instead of...
The AnyVal types become source files instead of polite compiler
fictions.
!! You'll need a serious "ant all.clean" now. !!
As of this commit the system is fully bootstrapped and the
synthetic code eliminated: only the source files remain. The
sort-of-AnyVal-companions in scala.runtime.* have all been eliminated
because the actual companions can do everything; deprecated vals in
the scala.runtime package object point to the companions. This left
AnyValCompanion as the only AnyVal related thing in the runtime package:
that made little sense, so I deprecated and moved it as well.
Starr is based on r24066 plus this commit. Closes #4121. Review by rytz,
odersky.
Diffstat (limited to 'src')
28 files changed, 1400 insertions, 366 deletions
diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala index f1eb6fab5e..b8ed251062 100644 --- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala +++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala @@ -22,7 +22,6 @@ trait AnyValTemplates { package scala -import scala.runtime.AnyValCompanion import java.{ lang => jl } """.trim.format(now) + "\n\n" diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 49e1485437..21628f9864 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -283,6 +283,16 @@ self => /** Are we inside the Scala package? Set for files that start with package scala */ private var inScalaPackage = false + private var currentPackage = "" + def resetPackage() { + inScalaPackage = false + currentPackage = "" + } + private lazy val anyValNames: Set[Name] = tpnme.ScalaValueNames.toSet + tpnme.AnyVal + + private def inScalaRootPackage = inScalaPackage && currentPackage == "scala" + private def isScalaArray(name: Name) = inScalaRootPackage && name == tpnme.Array + private def isAnyValType(name: Name) = inScalaRootPackage && anyValNames(name) def parseStartRule: () => Tree @@ -600,7 +610,6 @@ self => def isUnaryOp = isIdent && raw.isUnary(in.name) def isRawStar = isIdent && in.name == raw.STAR def isRawBar = isIdent && in.name == raw.BAR - def isScalaArray(name: Name) = inScalaPackage && name == tpnme.Array def isIdent = in.token == IDENTIFIER || in.token == BACKQUOTED_IDENT @@ -1049,6 +1058,20 @@ self => if (in.token == DOT) { selectors(id, false, in.skipToken()) } else id } + /** Calls qualId() and manages some package state. + */ + private def pkgQualId() = { + if (in.token == IDENTIFIER && in.name.encode == nme.scala_) + inScalaPackage = true + + val pkg = qualId() + newLineOptWhenFollowedBy(LBRACE) + + if (currentPackage == "") currentPackage = pkg.toString + else currentPackage = currentPackage + "." + pkg + + pkg + } /** SimpleExpr ::= literal * | symbol @@ -2515,27 +2538,36 @@ self => * TraitExtends ::= 'extends' | `<:' */ def templateOpt(mods: Modifiers, name: Name, constrMods: Modifiers, vparamss: List[List[ValDef]], tstart: Int): Template = { - val (parents0, argss, self, body) = - if (in.token == EXTENDS || settings.YvirtClasses && mods.hasTraitFlag && in.token == SUBTYPE) { + val (parents0, argss, self, body) = ( + if (in.token == EXTENDS || in.token == SUBTYPE && mods.hasTraitFlag) { in.nextToken() template(mods.hasTraitFlag) - } else if ((in.token == SUBTYPE) && mods.hasTraitFlag) { - in.nextToken() - template(true) - } else { + } + else { newLineOptWhenFollowedBy(LBRACE) val (self, body) = templateBodyOpt(false) (List(), List(List()), self, body) } - var parents = parents0 - if (!isInterface(mods, body) && !isScalaArray(name)) - parents = parents :+ scalaScalaObjectConstr - if (parents.isEmpty) - parents = List(scalaAnyRefConstr) - if (mods.isCase) parents ++= List(productConstr, serializableConstr) + ) + val tstart0 = if (body.isEmpty && in.lastOffset < tstart) in.lastOffset else tstart atPos(tstart0) { - Template(parents, self, constrMods, vparamss, argss, body, o2p(tstart)) + if (isAnyValType(name)) { + val parent = if (name == tpnme.AnyVal) tpnme.Any else tpnme.AnyVal + Template(List(scalaDot(parent)), self, body) + } + else { + val parents = ( + if (!isInterface(mods, body) && !isScalaArray(name)) parents0 :+ scalaScalaObjectConstr + else if (parents0.isEmpty) List(scalaAnyRefConstr) + else parents0 + ) ++ ( + if (mods.isCase) List(productConstr, serializableConstr) + else Nil + ) + + Template(parents, self, constrMods, vparamss, argss, body, o2p(tstart)) + } } } @@ -2596,8 +2628,7 @@ self => /** Packaging ::= package QualId [nl] `{' TopStatSeq `}' */ def packaging(start: Int): Tree = { - val pkg = qualId() - newLineOptWhenFollowedBy(LBRACE) + val pkg = pkgQualId() val stats = inBracesOrNil(topStatSeq()) makePackaging(start, pkg, stats) } @@ -2790,10 +2821,7 @@ self => } } else { in.flushDoc - if (in.token == IDENTIFIER && in.name.encode == nme.scala_) - inScalaPackage = true - val pkg = qualId() - newLineOptWhenFollowedBy(LBRACE) + val pkg = pkgQualId() if (in.token == EOF) { ts += makePackaging(start, pkg, List()) } else if (isStatSep) { @@ -2810,6 +2838,8 @@ self => } ts.toList } + + resetPackage() topstats() match { case List(stat @ PackageDef(_, _)) => stat case stats => diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 6e30da1f88..2d71a00f61 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -29,7 +29,7 @@ abstract class GenICode extends SubComponent { ArrayClass, ObjectClass, ThrowableClass, StringClass, StringModule, NothingClass, NullClass, AnyRefClass, Object_equals, Object_isInstanceOf, Object_asInstanceOf, ScalaRunTimeModule, BoxedNumberClass, BoxedCharacterClass, - getMember, runtimeCompanions + getMember } import scalaPrimitives.{ isArrayOp, isComparisonOp, isLogicalOp, @@ -1221,7 +1221,7 @@ abstract class GenICode extends SubComponent { } private def genLoadModule(ctx: Context, sym: Symbol, pos: Position) { - ctx.bb.emit(LOAD_MODULE(runtimeCompanions.getOrElse(sym, sym)), pos) + ctx.bb.emit(LOAD_MODULE(sym), pos) } def genConversion(from: TypeKind, to: TypeKind, ctx: Context, cast: Boolean) = { diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala index 6a6489b4c9..6ff5d42e55 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala @@ -42,10 +42,6 @@ trait GenJVMUtil { NullClass -> RuntimeNullClass.fullName('/'), RuntimeNullClass -> RuntimeNullClass.fullName('/') ) - primitiveCompanions foreach { sym => - map(sym) = "scala/runtime/" + sym.name + "$" - } - map } diff --git a/src/compiler/scala/tools/nsc/matching/Matrix.scala b/src/compiler/scala/tools/nsc/matching/Matrix.scala index ee20bf0870..2532801d83 100644 --- a/src/compiler/scala/tools/nsc/matching/Matrix.scala +++ b/src/compiler/scala/tools/nsc/matching/Matrix.scala @@ -125,7 +125,8 @@ trait Matrix extends MatrixAdditions { private val _syntheticSyms = mutable.HashSet[Symbol]() def clearSyntheticSyms() = { _syntheticSyms foreach (_ resetFlag (NO_EXHAUSTIVE|MUTABLE)) - log("Cleared NO_EXHAUSTIVE/MUTABLE on " + _syntheticSyms.size + " synthetic symbols.") + if (settings.debug.value) + log("Cleared NO_EXHAUSTIVE/MUTABLE on " + _syntheticSyms.size + " synthetic symbols.") _syntheticSyms.clear() } def recordSyntheticSym(sym: Symbol): Symbol = { diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 6c3d579e30..1757048036 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -16,7 +16,107 @@ import classfile.ClassfileConstants trait Definitions extends reflect.generic.StandardDefinitions { self: SymbolTable => - object definitions extends AbsDefinitions { + // the scala value classes + trait ValueClassDefinitions { + self: definitions.type => + + private[Definitions] def valueCache(name: Name) = { + if (name.isTypeName) ScalaPackageClass.info member name + else ScalaPackageClass.info member name suchThat (_ hasFlag MODULE) + } + private[Definitions] def valueModuleMethod(className: Name, methodName: Name): Symbol = { + valueCache(className.toTermName).moduleClass.tpe member methodName + } + + import ClassfileConstants._ + + private val nameToWeight = Map[Name, Int]( + tpnme.Byte -> 2, + tpnme.Char -> 3, + tpnme.Short -> 4, + tpnme.Int -> 12, + tpnme.Long -> 24, + tpnme.Float -> 48, + tpnme.Double -> 96 + ) + + private val nameToTag = Map[Name, Char]( + tpnme.Byte -> BYTE_TAG, + tpnme.Char -> CHAR_TAG, + tpnme.Short -> SHORT_TAG, + tpnme.Int -> INT_TAG, + tpnme.Long -> LONG_TAG, + tpnme.Float -> FLOAT_TAG, + tpnme.Double -> DOUBLE_TAG, + tpnme.Boolean -> BOOL_TAG, + tpnme.Unit -> VOID_TAG + ) + + private def classesMap[T](f: Name => T) = symbolsMap(ScalaValueClassesNoUnit, f) + private def symbolsMap[T](syms: List[Symbol], f: Name => T): Map[Symbol, T] = syms zip (syms map (x => f(x.name))) toMap + private def symbolsMapFilt[T](syms: List[Symbol], p: Name => Boolean, f: Name => T) = symbolsMap(syms filter (x => p(x.name)), f) + + private def boxedName(name: Name) = sn.Boxed(name.toTypeName) + + lazy val abbrvTag = symbolsMap(ScalaValueClasses, nameToTag) + lazy val numericWeight = symbolsMapFilt(ScalaValueClasses, nameToWeight.keySet, nameToWeight) + lazy val boxedModule = classesMap(x => getModule(boxedName(x))) + lazy val boxedClass = classesMap(x => getClass(boxedName(x))) + lazy val refClass = classesMap(x => getClass("scala.runtime." + x + "Ref")) + lazy val volatileRefClass = classesMap(x => getClass("scala.runtime.Volatile" + x + "Ref")) + lazy val boxMethod = classesMap(x => valueModuleMethod(x, nme.box)) + lazy val unboxMethod = classesMap(x => valueModuleMethod(x, nme.unbox)) + + private def newClass(owner: Symbol, name: TypeName, parents: List[Type]): Symbol = { + val clazz = owner.newClass(NoPosition, name) + clazz.setInfo(ClassInfoType(parents, new Scope, clazz)) + owner.info.decls.enter(clazz) + clazz + } + + def isNumericSubClass(sub: Symbol, sup: Symbol) = { + val cmp = for (w1 <- numericWeight get sub ; w2 <- numericWeight get sup) yield w2 % w1 + cmp exists (_ == 0) + } + + /** Is symbol a numeric value class? */ + def isNumericValueClass(sym: Symbol): Boolean = + numericWeight contains sym + + private[Definitions] def fullNameStrings: List[String] = nme.ScalaValueNames map ("scala." + _) + private[Definitions] lazy val fullValueName: Set[Name] = { + val values = nme.ScalaValueNames flatMap (x => List(newTypeName("scala." + x), newTermName("scala." + x))) + values.toSet + newTypeName("scala.AnyVal") + } + + lazy val AnyValClass = valueCache(tpnme.AnyVal) + lazy val UnitClass = valueCache(tpnme.Unit) + lazy val ByteClass = valueCache(tpnme.Byte) + lazy val ShortClass = valueCache(tpnme.Short) + lazy val CharClass = valueCache(tpnme.Char) + lazy val IntClass = valueCache(tpnme.Int) + lazy val LongClass = valueCache(tpnme.Long) + lazy val FloatClass = valueCache(tpnme.Float) + lazy val DoubleClass = valueCache(tpnme.Double) + lazy val BooleanClass = valueCache(tpnme.Boolean) + def Boolean_and = getMember(BooleanClass, nme.ZAND) + def Boolean_or = getMember(BooleanClass, nme.ZOR) + + def ScalaValueClassesNoUnit = ScalaValueClasses filterNot (_ eq UnitClass) + def ScalaValueClasses: List[Symbol] = List( + UnitClass, + BooleanClass, + ByteClass, + ShortClass, + CharClass, + IntClass, + LongClass, + FloatClass, + DoubleClass + ) + } + + object definitions extends AbsDefinitions with ValueClassDefinitions { private var isInitialized = false def isDefinitionsInitialized = isInitialized @@ -53,63 +153,35 @@ trait Definitions extends reflect.generic.StandardDefinitions { lazy val anyrefparam = List(AnyRefClass.typeConstructor) // private parameter conveniences - private def booltype = BooleanClass.typeConstructor - private def boolparam = List(booltype) - private def bytetype = ByteClass.typeConstructor - private def byteparam = List(bytetype) - private def shorttype = ShortClass.typeConstructor - private def shortparam = List(shorttype) - private def inttype = IntClass.typeConstructor - private def intparam = List(inttype) - private def longtype = LongClass.typeConstructor - private def longparam = List(longtype) - private def floattype = FloatClass.typeConstructor - private def floatparam = List(floattype) - private def doubletype = DoubleClass.typeConstructor + private def booltype = BooleanClass.typeConstructor + private def boolparam = List(booltype) + private def bytetype = ByteClass.typeConstructor + private def byteparam = List(bytetype) + private def shorttype = ShortClass.typeConstructor + private def shortparam = List(shorttype) + private def inttype = IntClass.typeConstructor + private def intparam = List(inttype) + private def longtype = LongClass.typeConstructor + private def longparam = List(longtype) + private def floattype = FloatClass.typeConstructor + private def floatparam = List(floattype) + private def doubletype = DoubleClass.typeConstructor private def doubleparam = List(doubletype) - private def chartype = CharClass.typeConstructor - private def charparam = List(chartype) - private def stringtype = StringClass.typeConstructor + private def chartype = CharClass.typeConstructor + private def charparam = List(chartype) + private def stringtype = StringClass.typeConstructor // top types - lazy val AnyClass = newClass(ScalaPackageClass, tpnme.Any, Nil) setFlag (ABSTRACT) - lazy val AnyValClass = newClass(ScalaPackageClass, tpnme.AnyVal, anyparam) setFlag (ABSTRACT | SEALED) - lazy val AnyRefClass = newAlias(ScalaPackageClass, tpnme.AnyRef, ObjectClass.typeConstructor) - lazy val ObjectClass = getClass(sn.Object) + lazy val AnyClass = newClass(ScalaPackageClass, tpnme.Any, Nil) setFlag (ABSTRACT) + lazy val AnyRefClass = newAlias(ScalaPackageClass, tpnme.AnyRef, ObjectClass.typeConstructor) + lazy val ObjectClass = getClass(sn.Object) + lazy val AnyValCompanionClass = getClass("scala.AnyValCompanion") setFlag (SEALED | ABSTRACT | TRAIT) // bottom types lazy val NullClass = newClass(ScalaPackageClass, tpnme.Null, anyrefparam) setFlag (ABSTRACT | TRAIT | FINAL) lazy val NothingClass = newClass(ScalaPackageClass, tpnme.Nothing, anyparam) setFlag (ABSTRACT | TRAIT | FINAL) lazy val RuntimeNothingClass = getClass(ClassfileConstants.SCALA_NOTHING) lazy val RuntimeNullClass = getClass(ClassfileConstants.SCALA_NULL) - lazy val AnyValCompanionClass = getClass("scala.runtime.AnyValCompanion").setFlag(SEALED | ABSTRACT | TRAIT) - - // the scala value classes - import ClassfileConstants._ - - lazy val UnitClass = newClass(ScalaPackageClass, tpnme.Unit, anyvalparam).setFlag(ABSTRACT | FINAL) - lazy val ByteClass = newValueClass(nme.Byte, BYTE_TAG, 2) - lazy val ShortClass = newValueClass(nme.Short, SHORT_TAG, 4) - lazy val CharClass = newValueClass(nme.Char, CHAR_TAG, 3) - lazy val IntClass = newValueClass(nme.Int, INT_TAG, 12) - lazy val LongClass = newValueClass(nme.Long, LONG_TAG, 24) - lazy val FloatClass = newValueClass(nme.Float, FLOAT_TAG, 48) - lazy val DoubleClass = newValueClass(nme.Double, DOUBLE_TAG, 96) - lazy val BooleanClass = newValueClass(nme.Boolean, BOOL_TAG, 0) - def Boolean_and = getMember(BooleanClass, nme.ZAND) - def Boolean_or = getMember(BooleanClass, nme.ZOR) - - def ScalaValueClasses = List( - UnitClass, - BooleanClass, - ByteClass, - ShortClass, - CharClass, - IntClass, - LongClass, - FloatClass, - DoubleClass - ) // exceptions and other throwables lazy val ClassCastExceptionClass = getClass("java.lang.ClassCastException") @@ -565,7 +637,6 @@ trait Definitions extends reflect.generic.StandardDefinitions { { log(sym.info); log(sym.info.members) }//debug throw new MissingRequirementError((if (module) "object " else "class ") + fullname) } - result } @@ -605,7 +676,7 @@ trait Definitions extends reflect.generic.StandardDefinitions { msym } - private def newMethod(owner: Symbol, name: TermName, formals: List[Type], restpe: Type): Symbol = { + private[Definitions] def newMethod(owner: Symbol, name: TermName, formals: List[Type], restpe: Type): Symbol = { val msym = newMethod(owner, name) val params = msym.newSyntheticValueParams(formals) msym.setInfo(MethodType(params, restpe)) @@ -628,198 +699,30 @@ trait Definitions extends reflect.generic.StandardDefinitions { private def newTypeParam(owner: Symbol, index: Int): Symbol = owner.newTypeParameter(NoPosition, newTypeName("T" + index)) setInfo TypeBounds.empty - val boxedClass = new HashMap[Symbol, Symbol] - val boxedModule = new HashMap[Symbol, Symbol] - val unboxMethod = new HashMap[Symbol, Symbol] // Type -> Method - val boxMethod = new HashMap[Symbol, Symbol] // Type -> Method - val primitiveCompanions = new mutable.HashSet[Symbol] // AnyVal -> Companion - lazy val boxedClassValues = boxedClass.values.toSet - - /** Maps a companion object like scala.Int to scala.runtime.Int. */ - lazy val runtimeCompanions = (primitiveCompanions map { sym => - sym -> getModule("scala.runtime." + sym.name) - }).toMap - - def isUnbox(m: Symbol) = unboxMethod.valuesIterator contains m - def isBox(m: Symbol) = boxMethod.valuesIterator contains m - - val refClass = new HashMap[Symbol, Symbol] - val volatileRefClass = new HashMap[Symbol, Symbol] - val abbrvTag = new HashMap[Symbol, Char] - private val numericWeight = new HashMap[Symbol, Int] - - def isNumericSubClass(sub: Symbol, sup: Symbol) = { - val cmp = for (w1 <- numericWeight get sub ; w2 <- numericWeight get sup) yield w2 % w1 - cmp exists (_ == 0) - } - - /** Create a companion object for scala.Unit. - */ - private def initUnitCompanionObject() { - val module = ScalaPackageClass.newModule(NoPosition, "Unit") - ScalaPackageClass.info.decls.enter(module) - val mclass = module.moduleClass - mclass.setInfo(ClassInfoType(List(AnyRefClass.tpe, AnyValCompanionClass.tpe), new Scope, mclass)) - module.setInfo(mclass.tpe) - primitiveCompanions += module - } - - private[symtab] def newValueClass(name: TermName, tag: Char, weight: Int): Symbol = { - val tpName = name.toTypeName - val boxedName = sn.Boxed(tpName).toTermName - - val clazz = newClass(ScalaPackageClass, tpName, anyvalparam) setFlag (ABSTRACT | FINAL) - boxedClass(clazz) = getClass(boxedName) - boxedModule(clazz) = getModule(boxedName) - refClass(clazz) = getClass("scala.runtime." + name + "Ref") - volatileRefClass(clazz) = getClass("scala.runtime.Volatile" + name + "Ref") - abbrvTag(clazz) = tag - if (weight > 0) numericWeight(clazz) = weight - - val module = ScalaPackageClass.newModule(NoPosition, name) - ScalaPackageClass.info.decls.enter(module) - val mclass = module.moduleClass - mclass.setInfo(ClassInfoType(List(AnyRefClass.tpe, AnyValCompanionClass.tpe), new Scope, mclass)) - module.setInfo(mclass.tpe) - primitiveCompanions += module - - boxMethod(clazz) = newMethod(mclass, nme.box, List(clazz.typeConstructor), boxedClass(clazz).tpe) - unboxMethod(clazz) = newMethod(mclass, nme.unbox, List(ObjectClass.typeConstructor), clazz.typeConstructor) - - clazz - } - - /** Sets-up symbols etc. for value classes, and their boxed versions. This - * method is called once from within the body of init. */ - private def initValueClasses() { - // init scala.Boolean - newParameterlessMethod(BooleanClass, nme.UNARY_!, booltype) - List(nme.EQ, nme.NE, nme.ZOR, nme.ZAND, nme.OR, nme.AND, nme.XOR) foreach { - newMethod(BooleanClass, _, boolparam, booltype) - } - - def initValueClass(clazz: Symbol, isCardinal: Boolean) { - assert (clazz ne null) - val boolBinOps = List(nme.EQ, nme.NE, nme.LT, nme.LE, nme.GT, nme.GE) - val otherBinOps = List(nme.ADD, nme.SUB, nme.MUL, nme.DIV, nme.MOD) - val cardBinOps = List(nme.OR, nme.AND, nme.XOR) - val shiftOps = List(nme.LSL, nme.LSR, nme.ASR) - - def addBinops(params: List[Type], restype: Type, isCardinal: Boolean) = { - boolBinOps foreach (x => newMethod(clazz, x, params, booltype)) - otherBinOps foreach (x => newMethod(clazz, x, params, restype)) - - if (isCardinal) - cardBinOps foreach (x => newMethod(clazz, x, params, restype)) - } - - // conversion methods - newParameterlessMethod(clazz, nme.toByte, bytetype) - newParameterlessMethod(clazz, nme.toShort, shorttype) - newParameterlessMethod(clazz, nme.toChar, chartype) - newParameterlessMethod(clazz, nme.toInt, inttype) - newParameterlessMethod(clazz, nme.toLong, longtype) - newParameterlessMethod(clazz, nme.toFloat, floattype) - newParameterlessMethod(clazz, nme.toDouble, doubletype) - - // def +(s: String): String - newMethod(clazz, nme.ADD, List(stringtype), stringtype) - - def isLongFloatOrDouble = clazz match { - case LongClass | FloatClass | DoubleClass => true - case _ => false - } - val restype = if (isLongFloatOrDouble) clazz.typeConstructor else inttype - - // shift operations - if (isCardinal) - for (op <- shiftOps ; param <- List(intparam, longparam)) - newMethod(clazz, op, param, restype) - - // unary operations - newParameterlessMethod(clazz, nme.UNARY_+, restype) - newParameterlessMethod(clazz, nme.UNARY_-, restype) - - if (isCardinal) { - newParameterlessMethod(clazz, nme.UNARY_~, restype) - } - - // binary operations - List(byteparam, shortparam, charparam, intparam) . - foreach (x => addBinops(x, restype, isCardinal)) - - addBinops(longparam, (if (isCardinal) longtype else restype), isCardinal) - addBinops(floatparam, (if (clazz eq DoubleClass) doubletype else floattype), false ) - addBinops(doubleparam, doubletype, false ) - } - - List(ByteClass, ShortClass, CharClass, IntClass, LongClass) foreach (x => initValueClass(x, true)) - List(FloatClass, DoubleClass) foreach (x => initValueClass(x, false)) - - def addModuleMethod(clazz: Symbol, name: TermName, value: Any) = { - val owner = clazz.linkedClassOfClass - newParameterlessMethod(owner, name, ConstantType(Constant(value))) - } - def addDeprecatedModuleMethod(clazz: Symbol, name: TermName, value: Any, msg: String) = { - val m = addModuleMethod(clazz, name, value) - val arg = Literal(Constant(msg)) - m.addAnnotation(AnnotationInfo(DeprecatedAttr.tpe, List(arg), List())) - } - addModuleMethod(ByteClass, "MinValue", java.lang.Byte.MIN_VALUE) - addModuleMethod(ByteClass, "MaxValue", java.lang.Byte.MAX_VALUE) - addModuleMethod(ShortClass, "MinValue", java.lang.Short.MIN_VALUE) - addModuleMethod(ShortClass, "MaxValue", java.lang.Short.MAX_VALUE) - addModuleMethod(CharClass, "MinValue", java.lang.Character.MIN_VALUE) - addModuleMethod(CharClass, "MaxValue", java.lang.Character.MAX_VALUE) - addModuleMethod(IntClass, "MinValue", java.lang.Integer.MIN_VALUE) - addModuleMethod(IntClass, "MaxValue", java.lang.Integer.MAX_VALUE) - addModuleMethod(LongClass, "MinValue", java.lang.Long.MIN_VALUE) - addModuleMethod(LongClass, "MaxValue", java.lang.Long.MAX_VALUE) - - addDeprecatedModuleMethod(FloatClass, "MinValue", -java.lang.Float.MAX_VALUE, "use Float.MinNegativeValue instead") - addModuleMethod(FloatClass, "MinNegativeValue", -java.lang.Float.MAX_VALUE) - addModuleMethod(FloatClass, "MaxValue", java.lang.Float.MAX_VALUE) - addDeprecatedModuleMethod(FloatClass, "Epsilon", java.lang.Float.MIN_VALUE, "use Float.MinPositiveValue instead") - addModuleMethod(FloatClass, "MinPositiveValue", java.lang.Float.MIN_VALUE) - addModuleMethod(FloatClass, "NaN", java.lang.Float.NaN) - addModuleMethod(FloatClass, "PositiveInfinity", java.lang.Float.POSITIVE_INFINITY) - addModuleMethod(FloatClass, "NegativeInfinity", java.lang.Float.NEGATIVE_INFINITY) - - addDeprecatedModuleMethod(DoubleClass, "MinValue", -java.lang.Double.MAX_VALUE, "use Double.MinNegativeValue instead") - addModuleMethod(DoubleClass, "MinNegativeValue", -java.lang.Double.MAX_VALUE) - addModuleMethod(DoubleClass, "MaxValue", java.lang.Double.MAX_VALUE) - // see #3791. change cycle for `Epsilon`: 1. deprecate, 2. remove, 3. re-introduce as - // org.apache.commons.math.util.MathUtils.EPSILON (0x1.0p-53). not sure what to do for float. - addDeprecatedModuleMethod(DoubleClass, "Epsilon", java.lang.Double.MIN_VALUE, "use Double.MinPositiveValue instead") - addModuleMethod(DoubleClass, "MinPositiveValue", java.lang.Double.MIN_VALUE) - addModuleMethod(DoubleClass, "NaN", java.lang.Double.NaN) - addModuleMethod(DoubleClass, "PositiveInfinity", java.lang.Double.POSITIVE_INFINITY) - addModuleMethod(DoubleClass, "NegativeInfinity", java.lang.Double.NEGATIVE_INFINITY) - } + lazy val isUnbox = unboxMethod.values.toSet + lazy val isBox = boxMethod.values.toSet /** Is symbol a phantom class for which no runtime representation exists? */ - def isPhantomClass(sym: Symbol) = - sym == AnyClass || sym == AnyValClass || sym == NullClass || sym == NothingClass + lazy val isPhantomClass = Set[Symbol](AnyClass, AnyValClass, NullClass, NothingClass) + + private lazy val scalaValueClassesSet = ScalaValueClasses.toSet + private lazy val boxedValueClassesSet = boxedClass.values.toSet + BoxedUnitClass /** Is symbol a value class? */ - def isValueClass(sym: Symbol): Boolean = - (sym eq UnitClass) || (boxedClass contains sym) + def isValueClass(sym: Symbol) = scalaValueClassesSet(sym) /** Is symbol a boxed value class, e.g. java.lang.Integer? */ - def isBoxedValueClass(sym: Symbol): Boolean = - (sym eq BoxedUnitClass) || boxedClassValues(sym) + def isBoxedValueClass(sym: Symbol) = boxedValueClassesSet(sym) - /** If symbol is a value class or a boxed value class, return the value class: otherwise NoSymbol. */ + /** If symbol is a value class, return the value class, with the exception + * that BoxedUnit remains BoxedUnit. If not a value class, NoSymbol. + */ def unboxedValueClass(sym: Symbol): Symbol = if (isValueClass(sym)) sym else if (sym == BoxedUnitClass) sym else boxedClass.map(_.swap).getOrElse(sym, NoSymbol) - /** Is symbol a numeric value class? */ - def isNumericValueClass(sym: Symbol): Boolean = - numericWeight contains sym - /** Is type's symbol a numeric value class? */ def isNumericValueType(tp: Type): Boolean = tp match { case TypeRef(_, sym, _) => isNumericValueClass(sym) @@ -867,18 +770,25 @@ trait Definitions extends reflect.generic.StandardDefinitions { // } // } + /** Surgery on the value classes. Without this, AnyVals defined in source + * files end up with an AnyRef parent. It is likely there is a better way + * to evade that AnyRef. + */ + private def setParents(sym: Symbol, parents: List[Type]): Symbol = sym.rawInfo match { + case ClassInfoType(_, scope, clazz) => + sym setInfo ClassInfoType(parents, scope, clazz) + case _ => + sym + } + def init { if (isInitialized) return - EmptyPackageClass.setInfo(ClassInfoType(Nil, new Scope, EmptyPackageClass)) - EmptyPackage.setInfo(EmptyPackageClass.tpe) - RootClass.info.decls.enter(EmptyPackage) - RootClass.info.decls.enter(RootPackage) + EmptyPackageClass setInfo ClassInfoType(Nil, new Scope, EmptyPackageClass) + EmptyPackage setInfo EmptyPackageClass.tpe - abbrvTag(UnitClass) = 'V' - - initValueClasses() - initUnitCompanionObject() + RootClass.info.decls enter EmptyPackage + RootClass.info.decls enter RootPackage // members of class scala.Any Any_== = newMethod(AnyClass, nme.EQ, anyparam, booltype) setFlag FINAL @@ -911,15 +821,6 @@ trait Definitions extends reflect.generic.StandardDefinitions { RepeatedParamClass, JavaRepeatedParamClass, ByNameParamClass, - UnitClass, - ByteClass, - ShortClass, - CharClass, - IntClass, - LongClass, - FloatClass, - DoubleClass, - BooleanClass, AnyClass, AnyRefClass, AnyValClass, @@ -930,8 +831,13 @@ trait Definitions extends reflect.generic.StandardDefinitions { Object_isInstanceOf, Object_asInstanceOf ) - // AnyVal is sealed but needs to be made aware of its children - ScalaValueClasses foreach (AnyValClass addChild _) + + /** Removing the anyref parent they acquire from having a source file. + */ + setParents(AnyValClass, anyparam) + ScalaValueClasses foreach { sym => + setParents(sym, anyvalparam) + } if (forMSIL) { val intType = IntClass.typeConstructor diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index a10f196331..fdc828a96f 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -23,6 +23,9 @@ trait StdNames extends reflect.generic.StdNames with NameManglers { final val Short: NameType = "Short" final val Unit: NameType = "Unit" + final val ScalaValueNames: scala.List[NameType] = + scala.List(Byte, Char, Short, Int, Long, Float, Double, Boolean, Unit) + // types whose companions we utilize final val Array: NameType = "Array" final val List: NameType = "List" diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 952244d904..e7325c4f18 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -523,7 +523,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { override def transform(tree: Tree): Tree = tree match { - case ClassDef(mods, name, tparams, impl) if !tree.symbol.isInterface => + case ClassDef(mods, name, tparams, impl) if !tree.symbol.isInterface && !isValueClass(tree.symbol) => treeCopy.ClassDef(tree, mods, name, tparams, transformClassTemplate(impl)) case _ => super.transform(tree) diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index c311875820..a46fe0683d 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -174,7 +174,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast. apply(atp) case ClassInfoType(parents, decls, clazz) => ClassInfoType( - if ((clazz == ObjectClass) || (isValueClass(clazz))) List() + if (clazz == ObjectClass || isValueClass(clazz)) Nil else if (clazz == ArrayClass) List(erasedTypeRef(ObjectClass)) else removeDoubleObject(parents map this), decls, clazz) diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index 97c7e47f31..b66810ba01 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -241,10 +241,10 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { treatedClassInfos(clazz) = clazz.info assert(!clazz.isTrait, clazz) - assert(!clazz.info.parents.isEmpty, clazz) + assert(clazz.info.parents.nonEmpty, clazz) // first complete the superclass with mixed in members - addMixedinMembers(clazz.superClass,unit) + addMixedinMembers(clazz.superClass, unit) //Console.println("adding members of " + clazz.info.baseClasses.tail.takeWhile(superclazz !=) + " to " + clazz);//DEBUG @@ -490,8 +490,12 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL { case Template(parents, self, body) => localTyper = erasure.newTyper(rootContext.make(tree, currentOwner)) atPhase(phase.next)(currentOwner.owner.info)//todo: needed? - if (!currentOwner.isTrait) addMixedinMembers(currentOwner,unit) - else if (currentOwner hasFlag lateINTERFACE) addLateInterfaceMembers(currentOwner) + + if (!currentOwner.isTrait && !isValueClass(currentOwner)) + addMixedinMembers(currentOwner, unit) + else if (currentOwner hasFlag lateINTERFACE) + addLateInterfaceMembers(currentOwner) + tree case DefDef(mods, name, tparams, List(vparams), tpt, rhs) => if (currentOwner.isImplClass) { diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index a46c16f3a0..5745cccb12 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -192,7 +192,8 @@ abstract class TailCalls extends Transform { * Position is unchanged (by default, the method definition.) */ def fail(reason: String) = { - log("Cannot rewrite recursive call at: " + fun.pos + " because: " + reason) + if (settings.debug.value) + log("Cannot rewrite recursive call at: " + fun.pos + " because: " + reason) ctx.failReason = reason treeCopy.Apply(tree, target, transformArgs) diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 781df7a88f..1f750dd727 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -790,6 +790,14 @@ trait Namers { self: Analyzer => classAndNamerOfModule(module) = (cdef, templateNamer) } + if (opt.verbose) { + log( + "ClassInfoType(\n%s,\n%s,\n%s)".format( + " " + (parents map (_.typeSymbol) mkString ", "), + if (global.opt.debug) decls.toList map (">> " + _) mkString("\n", "\n", "") else " <decls>", + " " + clazz) + ) + } ClassInfoType(parents, decls, clazz) } @@ -1376,7 +1384,7 @@ trait Namers { self: Analyzer => * Finds the companion module of a class symbol. Calling .companionModule * does not work for classes defined inside methods. */ - def companionModuleOf(clazz: Symbol, context: Context) = + def companionModuleOf(clazz: Symbol, context: Context): Symbol = { try { var res = clazz.companionModule if (res == NoSymbol) @@ -1388,8 +1396,9 @@ trait Namers { self: Analyzer => context.error(clazz.pos, e.getMessage) NoSymbol } + } - def companionClassOf(module: Symbol, context: Context) = + def companionClassOf(module: Symbol, context: Context): Symbol = { try { var res = module.companionClass if (res == NoSymbol) @@ -1400,6 +1409,7 @@ trait Namers { self: Analyzer => context.error(module.pos, e.getMessage) NoSymbol } + } def companionSymbolOf(sym: Symbol, context: Context) = if (sym.isTerm) companionClassOf(sym, context) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index ef135271b8..ecb99b7f5b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1148,10 +1148,11 @@ trait Typers extends Modes { error(parent.pos, "illegal inheritance from final "+psym) } if (psym.isSealed && !phase.erasedTypes) { - if (context.unit.source.file != psym.sourceFile) - error(parent.pos, "illegal inheritance from sealed "+psym) - else + // AnyVal is sealed, but we have to let the value classes through manually + if (context.unit.source.file == psym.sourceFile || isValueClass(context.owner)) psym addChild context.owner + else + error(parent.pos, "illegal inheritance from sealed "+psym) } if (!(selfType <:< parent.tpe.typeOfThis) && !phase.erasedTypes && @@ -1296,6 +1297,7 @@ trait Typers extends Modes { assert(getter != NoSymbol, stat) if (getter.isOverloaded) error(getter.pos, getter+" is defined twice") + getter.setAnnotations(memberAnnots(allAnnots, GetterTargetClass)) if (value.isLazy) List(stat) @@ -2074,7 +2076,7 @@ trait Typers extends Modes { // error for this is issued in RefChecks.checkDefaultsInOverloaded if (!e.sym.isErroneous && !e1.sym.isErroneous && !e.sym.hasDefaultFlag) { error(e.sym.pos, e1.sym+" is defined twice"+ - {if(!settings.debug.value) "" else " in "+unit.toString}) + {if(!settings.debug.value) "" else " in "+unit.toString}) scope.unlink(e1) // need to unlink to avoid later problems with lub; see #2779 } e1 = scope.lookupNextEntry(e1) @@ -3432,6 +3434,8 @@ trait Typers extends Modes { * @return ... */ def typedSelect(qual: Tree, name: Name): Tree = { + + val sym = if (tree.symbol != NoSymbol) { if (phase.erasedTypes && qual.isInstanceOf[Super]) diff --git a/src/compiler/scala/tools/nsc/util/Exceptional.scala b/src/compiler/scala/tools/nsc/util/Exceptional.scala index 54ef3606f1..4230f29eb5 100644 --- a/src/compiler/scala/tools/nsc/util/Exceptional.scala +++ b/src/compiler/scala/tools/nsc/util/Exceptional.scala @@ -48,6 +48,11 @@ class Exceptional(val ex: Throwable)(implicit prefs: ScalaPrefs) { def causes = Exceptional.causes(ex) def summary = unwrapped.toString + "\n at " + apply(0).shortNameString + private def println(msg: Any) = { + Console println msg + Console.flush() + } + def show(): Unit = println(context()) def show(num: Int): Unit = println(context(num)) def showCauses() = println((ex :: causes).mkString("", "\n caused by -> ", "")) @@ -66,6 +71,7 @@ object Exceptional { /** Some handy functions. */ def stack() = JavaStackFrame frames ((new Throwable).getStackTrace dropWhile isLocal) def showme() = apply(new Throwable).show() + def showstack() = apply(new Throwable).showTable() /** A frame formatter with more refined aesthetics than the default. * Come, let us be civilized. diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala new file mode 100755 index 0000000000..4b4b6038d1 --- /dev/null +++ b/src/library/scala/AnyVal.scala @@ -0,0 +1,11 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2010, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala + +sealed trait AnyVal diff --git a/src/library/scala/AnyValCompanion.scala b/src/library/scala/AnyValCompanion.scala new file mode 100644 index 0000000000..854a63e865 --- /dev/null +++ b/src/library/scala/AnyValCompanion.scala @@ -0,0 +1,21 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala + +/** A common supertype for companion classes of primitive types. + * + * A common trait for /companion/ objects of primitive types comes handy + * when parameterizing code on types. For instance, the specialized + * annotation is passed a sequence of types on which to specialize: + * {{{ + * class Tuple1[@specialized(Unit, Int, Double) T] + * }}} + * + */ +private[scala] trait AnyValCompanion { } diff --git a/src/library/scala/Boolean.scala b/src/library/scala/Boolean.scala new file mode 100755 index 0000000000..d5e9eb950e --- /dev/null +++ b/src/library/scala/Boolean.scala @@ -0,0 +1,34 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// generated on Sun Jan 23 21:13:38 PST 2011 + +package scala + +import java.{ lang => jl } + +final class Boolean extends AnyVal { + def unary_! : Boolean = sys.error("stub") + + def ==(x: Boolean): Boolean = sys.error("stub") + def !=(x: Boolean): Boolean = sys.error("stub") + def ||(x: Boolean): Boolean = sys.error("stub") + def &&(x: Boolean): Boolean = sys.error("stub") + // Compiler won't build with these seemingly more accurate signatures + // def ||(x: => Boolean): Boolean = sys.error("stub") + // def &&(x: => Boolean): Boolean = sys.error("stub") + def |(x: Boolean): Boolean = sys.error("stub") + def &(x: Boolean): Boolean = sys.error("stub") + def ^(x: Boolean): Boolean = sys.error("stub") +} + +object Boolean extends AnyValCompanion { + override def toString = "object scala.Boolean" + def box(x: Boolean): jl.Boolean = jl.Boolean.valueOf(x) + def unbox(x: jl.Object): Boolean = x.asInstanceOf[jl.Boolean].booleanValue() +}
\ No newline at end of file diff --git a/src/library/scala/Byte.scala b/src/library/scala/Byte.scala new file mode 100644 index 0000000000..e3f4a82003 --- /dev/null +++ b/src/library/scala/Byte.scala @@ -0,0 +1,154 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// generated on Sun Jan 23 21:13:38 PST 2011 + +package scala + +import java.{ lang => jl } + + +final class Byte extends AnyVal { + def toByte: Byte = sys.error("stub") + def toShort: Short = sys.error("stub") + def toChar: Char = sys.error("stub") + def toInt: Int = sys.error("stub") + def toLong: Long = sys.error("stub") + def toFloat: Float = sys.error("stub") + def toDouble: Double = sys.error("stub") + + def unary_+ : Int = sys.error("stub") + def unary_- : Int = sys.error("stub") + def unary_~ : Int = sys.error("stub") + + def +(x: String): String = sys.error("stub") + + def <<(x: Int): Int = sys.error("stub") + def <<(x: Long): Int = sys.error("stub") + def >>>(x: Int): Int = sys.error("stub") + def >>>(x: Long): Int = sys.error("stub") + def >>(x: Int): Int = sys.error("stub") + def >>(x: Long): Int = sys.error("stub") + + def ==(x: Byte): Boolean = sys.error("stub") + def ==(x: Short): Boolean = sys.error("stub") + def ==(x: Char): Boolean = sys.error("stub") + def ==(x: Int): Boolean = sys.error("stub") + def ==(x: Long): Boolean = sys.error("stub") + def ==(x: Float): Boolean = sys.error("stub") + def ==(x: Double): Boolean = sys.error("stub") + + def !=(x: Byte): Boolean = sys.error("stub") + def !=(x: Short): Boolean = sys.error("stub") + def !=(x: Char): Boolean = sys.error("stub") + def !=(x: Int): Boolean = sys.error("stub") + def !=(x: Long): Boolean = sys.error("stub") + def !=(x: Float): Boolean = sys.error("stub") + def !=(x: Double): Boolean = sys.error("stub") + + def <(x: Byte): Boolean = sys.error("stub") + def <(x: Short): Boolean = sys.error("stub") + def <(x: Char): Boolean = sys.error("stub") + def <(x: Int): Boolean = sys.error("stub") + def <(x: Long): Boolean = sys.error("stub") + def <(x: Float): Boolean = sys.error("stub") + def <(x: Double): Boolean = sys.error("stub") + + def <=(x: Byte): Boolean = sys.error("stub") + def <=(x: Short): Boolean = sys.error("stub") + def <=(x: Char): Boolean = sys.error("stub") + def <=(x: Int): Boolean = sys.error("stub") + def <=(x: Long): Boolean = sys.error("stub") + def <=(x: Float): Boolean = sys.error("stub") + def <=(x: Double): Boolean = sys.error("stub") + + def >(x: Byte): Boolean = sys.error("stub") + def >(x: Short): Boolean = sys.error("stub") + def >(x: Char): Boolean = sys.error("stub") + def >(x: Int): Boolean = sys.error("stub") + def >(x: Long): Boolean = sys.error("stub") + def >(x: Float): Boolean = sys.error("stub") + def >(x: Double): Boolean = sys.error("stub") + + def >=(x: Byte): Boolean = sys.error("stub") + def >=(x: Short): Boolean = sys.error("stub") + def >=(x: Char): Boolean = sys.error("stub") + def >=(x: Int): Boolean = sys.error("stub") + def >=(x: Long): Boolean = sys.error("stub") + def >=(x: Float): Boolean = sys.error("stub") + def >=(x: Double): Boolean = sys.error("stub") + + def |(x: Byte): Int = sys.error("stub") + def |(x: Short): Int = sys.error("stub") + def |(x: Char): Int = sys.error("stub") + def |(x: Int): Int = sys.error("stub") + def |(x: Long): Long = sys.error("stub") + + def &(x: Byte): Int = sys.error("stub") + def &(x: Short): Int = sys.error("stub") + def &(x: Char): Int = sys.error("stub") + def &(x: Int): Int = sys.error("stub") + def &(x: Long): Long = sys.error("stub") + + def ^(x: Byte): Int = sys.error("stub") + def ^(x: Short): Int = sys.error("stub") + def ^(x: Char): Int = sys.error("stub") + def ^(x: Int): Int = sys.error("stub") + def ^(x: Long): Long = sys.error("stub") + + def +(x: Byte): Int = sys.error("stub") + def +(x: Short): Int = sys.error("stub") + def +(x: Char): Int = sys.error("stub") + def +(x: Int): Int = sys.error("stub") + def +(x: Long): Long = sys.error("stub") + def +(x: Float): Float = sys.error("stub") + def +(x: Double): Double = sys.error("stub") + + def -(x: Byte): Int = sys.error("stub") + def -(x: Short): Int = sys.error("stub") + def -(x: Char): Int = sys.error("stub") + def -(x: Int): Int = sys.error("stub") + def -(x: Long): Long = sys.error("stub") + def -(x: Float): Float = sys.error("stub") + def -(x: Double): Double = sys.error("stub") + + def *(x: Byte): Int = sys.error("stub") + def *(x: Short): Int = sys.error("stub") + def *(x: Char): Int = sys.error("stub") + def *(x: Int): Int = sys.error("stub") + def *(x: Long): Long = sys.error("stub") + def *(x: Float): Float = sys.error("stub") + def *(x: Double): Double = sys.error("stub") + + def /(x: Byte): Int = sys.error("stub") + def /(x: Short): Int = sys.error("stub") + def /(x: Char): Int = sys.error("stub") + def /(x: Int): Int = sys.error("stub") + def /(x: Long): Long = sys.error("stub") + def /(x: Float): Float = sys.error("stub") + def /(x: Double): Double = sys.error("stub") + + def %(x: Byte): Int = sys.error("stub") + def %(x: Short): Int = sys.error("stub") + def %(x: Char): Int = sys.error("stub") + def %(x: Int): Int = sys.error("stub") + def %(x: Long): Long = sys.error("stub") + def %(x: Float): Float = sys.error("stub") + def %(x: Double): Double = sys.error("stub") + +} + + +object Byte extends AnyValCompanion { + final val MinValue = jl.Byte.MIN_VALUE + final val MaxValue = jl.Byte.MAX_VALUE + + def box(x: Byte): jl.Byte = jl.Byte.valueOf(x) + def unbox(x: jl.Object): Byte = x.asInstanceOf[jl.Byte].byteValue() + override def toString = "object scala.Byte" +} diff --git a/src/library/scala/Char.scala b/src/library/scala/Char.scala new file mode 100644 index 0000000000..3c3f292fd2 --- /dev/null +++ b/src/library/scala/Char.scala @@ -0,0 +1,154 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// generated on Sun Jan 23 21:13:38 PST 2011 + +package scala + +import java.{ lang => jl } + + +final class Char extends AnyVal { + def toByte: Byte = sys.error("stub") + def toShort: Short = sys.error("stub") + def toChar: Char = sys.error("stub") + def toInt: Int = sys.error("stub") + def toLong: Long = sys.error("stub") + def toFloat: Float = sys.error("stub") + def toDouble: Double = sys.error("stub") + + def unary_+ : Int = sys.error("stub") + def unary_- : Int = sys.error("stub") + def unary_~ : Int = sys.error("stub") + + def +(x: String): String = sys.error("stub") + + def <<(x: Int): Int = sys.error("stub") + def <<(x: Long): Int = sys.error("stub") + def >>>(x: Int): Int = sys.error("stub") + def >>>(x: Long): Int = sys.error("stub") + def >>(x: Int): Int = sys.error("stub") + def >>(x: Long): Int = sys.error("stub") + + def ==(x: Byte): Boolean = sys.error("stub") + def ==(x: Short): Boolean = sys.error("stub") + def ==(x: Char): Boolean = sys.error("stub") + def ==(x: Int): Boolean = sys.error("stub") + def ==(x: Long): Boolean = sys.error("stub") + def ==(x: Float): Boolean = sys.error("stub") + def ==(x: Double): Boolean = sys.error("stub") + + def !=(x: Byte): Boolean = sys.error("stub") + def !=(x: Short): Boolean = sys.error("stub") + def !=(x: Char): Boolean = sys.error("stub") + def !=(x: Int): Boolean = sys.error("stub") + def !=(x: Long): Boolean = sys.error("stub") + def !=(x: Float): Boolean = sys.error("stub") + def !=(x: Double): Boolean = sys.error("stub") + + def <(x: Byte): Boolean = sys.error("stub") + def <(x: Short): Boolean = sys.error("stub") + def <(x: Char): Boolean = sys.error("stub") + def <(x: Int): Boolean = sys.error("stub") + def <(x: Long): Boolean = sys.error("stub") + def <(x: Float): Boolean = sys.error("stub") + def <(x: Double): Boolean = sys.error("stub") + + def <=(x: Byte): Boolean = sys.error("stub") + def <=(x: Short): Boolean = sys.error("stub") + def <=(x: Char): Boolean = sys.error("stub") + def <=(x: Int): Boolean = sys.error("stub") + def <=(x: Long): Boolean = sys.error("stub") + def <=(x: Float): Boolean = sys.error("stub") + def <=(x: Double): Boolean = sys.error("stub") + + def >(x: Byte): Boolean = sys.error("stub") + def >(x: Short): Boolean = sys.error("stub") + def >(x: Char): Boolean = sys.error("stub") + def >(x: Int): Boolean = sys.error("stub") + def >(x: Long): Boolean = sys.error("stub") + def >(x: Float): Boolean = sys.error("stub") + def >(x: Double): Boolean = sys.error("stub") + + def >=(x: Byte): Boolean = sys.error("stub") + def >=(x: Short): Boolean = sys.error("stub") + def >=(x: Char): Boolean = sys.error("stub") + def >=(x: Int): Boolean = sys.error("stub") + def >=(x: Long): Boolean = sys.error("stub") + def >=(x: Float): Boolean = sys.error("stub") + def >=(x: Double): Boolean = sys.error("stub") + + def |(x: Byte): Int = sys.error("stub") + def |(x: Short): Int = sys.error("stub") + def |(x: Char): Int = sys.error("stub") + def |(x: Int): Int = sys.error("stub") + def |(x: Long): Long = sys.error("stub") + + def &(x: Byte): Int = sys.error("stub") + def &(x: Short): Int = sys.error("stub") + def &(x: Char): Int = sys.error("stub") + def &(x: Int): Int = sys.error("stub") + def &(x: Long): Long = sys.error("stub") + + def ^(x: Byte): Int = sys.error("stub") + def ^(x: Short): Int = sys.error("stub") + def ^(x: Char): Int = sys.error("stub") + def ^(x: Int): Int = sys.error("stub") + def ^(x: Long): Long = sys.error("stub") + + def +(x: Byte): Int = sys.error("stub") + def +(x: Short): Int = sys.error("stub") + def +(x: Char): Int = sys.error("stub") + def +(x: Int): Int = sys.error("stub") + def +(x: Long): Long = sys.error("stub") + def +(x: Float): Float = sys.error("stub") + def +(x: Double): Double = sys.error("stub") + + def -(x: Byte): Int = sys.error("stub") + def -(x: Short): Int = sys.error("stub") + def -(x: Char): Int = sys.error("stub") + def -(x: Int): Int = sys.error("stub") + def -(x: Long): Long = sys.error("stub") + def -(x: Float): Float = sys.error("stub") + def -(x: Double): Double = sys.error("stub") + + def *(x: Byte): Int = sys.error("stub") + def *(x: Short): Int = sys.error("stub") + def *(x: Char): Int = sys.error("stub") + def *(x: Int): Int = sys.error("stub") + def *(x: Long): Long = sys.error("stub") + def *(x: Float): Float = sys.error("stub") + def *(x: Double): Double = sys.error("stub") + + def /(x: Byte): Int = sys.error("stub") + def /(x: Short): Int = sys.error("stub") + def /(x: Char): Int = sys.error("stub") + def /(x: Int): Int = sys.error("stub") + def /(x: Long): Long = sys.error("stub") + def /(x: Float): Float = sys.error("stub") + def /(x: Double): Double = sys.error("stub") + + def %(x: Byte): Int = sys.error("stub") + def %(x: Short): Int = sys.error("stub") + def %(x: Char): Int = sys.error("stub") + def %(x: Int): Int = sys.error("stub") + def %(x: Long): Long = sys.error("stub") + def %(x: Float): Float = sys.error("stub") + def %(x: Double): Double = sys.error("stub") + +} + + +object Char extends AnyValCompanion { + final val MinValue = jl.Character.MIN_VALUE + final val MaxValue = jl.Character.MAX_VALUE + + def box(x: Char): jl.Character = jl.Character.valueOf(x) + def unbox(x: jl.Object): Char = x.asInstanceOf[jl.Character].charValue() + override def toString = "object scala.Char" +} diff --git a/src/library/scala/Double.scala b/src/library/scala/Double.scala new file mode 100644 index 0000000000..cc4f597bda --- /dev/null +++ b/src/library/scala/Double.scala @@ -0,0 +1,137 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// generated on Sun Jan 23 21:13:38 PST 2011 + +package scala + +import java.{ lang => jl } + + +final class Double extends AnyVal { + def toByte: Byte = sys.error("stub") + def toShort: Short = sys.error("stub") + def toChar: Char = sys.error("stub") + def toInt: Int = sys.error("stub") + def toLong: Long = sys.error("stub") + def toFloat: Float = sys.error("stub") + def toDouble: Double = sys.error("stub") + + def unary_+ : Double = sys.error("stub") + def unary_- : Double = sys.error("stub") + + def +(x: String): String = sys.error("stub") + + def ==(x: Byte): Boolean = sys.error("stub") + def ==(x: Short): Boolean = sys.error("stub") + def ==(x: Char): Boolean = sys.error("stub") + def ==(x: Int): Boolean = sys.error("stub") + def ==(x: Long): Boolean = sys.error("stub") + def ==(x: Float): Boolean = sys.error("stub") + def ==(x: Double): Boolean = sys.error("stub") + + def !=(x: Byte): Boolean = sys.error("stub") + def !=(x: Short): Boolean = sys.error("stub") + def !=(x: Char): Boolean = sys.error("stub") + def !=(x: Int): Boolean = sys.error("stub") + def !=(x: Long): Boolean = sys.error("stub") + def !=(x: Float): Boolean = sys.error("stub") + def !=(x: Double): Boolean = sys.error("stub") + + def <(x: Byte): Boolean = sys.error("stub") + def <(x: Short): Boolean = sys.error("stub") + def <(x: Char): Boolean = sys.error("stub") + def <(x: Int): Boolean = sys.error("stub") + def <(x: Long): Boolean = sys.error("stub") + def <(x: Float): Boolean = sys.error("stub") + def <(x: Double): Boolean = sys.error("stub") + + def <=(x: Byte): Boolean = sys.error("stub") + def <=(x: Short): Boolean = sys.error("stub") + def <=(x: Char): Boolean = sys.error("stub") + def <=(x: Int): Boolean = sys.error("stub") + def <=(x: Long): Boolean = sys.error("stub") + def <=(x: Float): Boolean = sys.error("stub") + def <=(x: Double): Boolean = sys.error("stub") + + def >(x: Byte): Boolean = sys.error("stub") + def >(x: Short): Boolean = sys.error("stub") + def >(x: Char): Boolean = sys.error("stub") + def >(x: Int): Boolean = sys.error("stub") + def >(x: Long): Boolean = sys.error("stub") + def >(x: Float): Boolean = sys.error("stub") + def >(x: Double): Boolean = sys.error("stub") + + def >=(x: Byte): Boolean = sys.error("stub") + def >=(x: Short): Boolean = sys.error("stub") + def >=(x: Char): Boolean = sys.error("stub") + def >=(x: Int): Boolean = sys.error("stub") + def >=(x: Long): Boolean = sys.error("stub") + def >=(x: Float): Boolean = sys.error("stub") + def >=(x: Double): Boolean = sys.error("stub") + + def +(x: Byte): Double = sys.error("stub") + def +(x: Short): Double = sys.error("stub") + def +(x: Char): Double = sys.error("stub") + def +(x: Int): Double = sys.error("stub") + def +(x: Long): Double = sys.error("stub") + def +(x: Float): Double = sys.error("stub") + def +(x: Double): Double = sys.error("stub") + + def -(x: Byte): Double = sys.error("stub") + def -(x: Short): Double = sys.error("stub") + def -(x: Char): Double = sys.error("stub") + def -(x: Int): Double = sys.error("stub") + def -(x: Long): Double = sys.error("stub") + def -(x: Float): Double = sys.error("stub") + def -(x: Double): Double = sys.error("stub") + + def *(x: Byte): Double = sys.error("stub") + def *(x: Short): Double = sys.error("stub") + def *(x: Char): Double = sys.error("stub") + def *(x: Int): Double = sys.error("stub") + def *(x: Long): Double = sys.error("stub") + def *(x: Float): Double = sys.error("stub") + def *(x: Double): Double = sys.error("stub") + + def /(x: Byte): Double = sys.error("stub") + def /(x: Short): Double = sys.error("stub") + def /(x: Char): Double = sys.error("stub") + def /(x: Int): Double = sys.error("stub") + def /(x: Long): Double = sys.error("stub") + def /(x: Float): Double = sys.error("stub") + def /(x: Double): Double = sys.error("stub") + + def %(x: Byte): Double = sys.error("stub") + def %(x: Short): Double = sys.error("stub") + def %(x: Char): Double = sys.error("stub") + def %(x: Int): Double = sys.error("stub") + def %(x: Long): Double = sys.error("stub") + def %(x: Float): Double = sys.error("stub") + def %(x: Double): Double = sys.error("stub") + +} + + +object Double extends AnyValCompanion { + final val MinPositiveValue = jl.Double.MIN_VALUE + final val MinNegativeValue = -jl.Double.MAX_VALUE + final val NaN = jl.Double.NaN + final val PositiveInfinity = jl.Double.POSITIVE_INFINITY + final val NegativeInfinity = jl.Double.NEGATIVE_INFINITY + + @deprecated("use Double.MinPositiveValue instead") + final val Epsilon = MinPositiveValue + @deprecated("use Double.MinNegativeValue instead") + final val MinValue = MinNegativeValue + final val MaxValue = jl.Double.MAX_VALUE + + def box(x: Double): jl.Double = jl.Double.valueOf(x) + def unbox(x: jl.Object): Double = x.asInstanceOf[jl.Double].doubleValue() + override def toString = "object scala.Double" +} diff --git a/src/library/scala/Float.scala b/src/library/scala/Float.scala new file mode 100644 index 0000000000..81b464078d --- /dev/null +++ b/src/library/scala/Float.scala @@ -0,0 +1,137 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// generated on Sun Jan 23 21:13:38 PST 2011 + +package scala + +import java.{ lang => jl } + + +final class Float extends AnyVal { + def toByte: Byte = sys.error("stub") + def toShort: Short = sys.error("stub") + def toChar: Char = sys.error("stub") + def toInt: Int = sys.error("stub") + def toLong: Long = sys.error("stub") + def toFloat: Float = sys.error("stub") + def toDouble: Double = sys.error("stub") + + def unary_+ : Float = sys.error("stub") + def unary_- : Float = sys.error("stub") + + def +(x: String): String = sys.error("stub") + + def ==(x: Byte): Boolean = sys.error("stub") + def ==(x: Short): Boolean = sys.error("stub") + def ==(x: Char): Boolean = sys.error("stub") + def ==(x: Int): Boolean = sys.error("stub") + def ==(x: Long): Boolean = sys.error("stub") + def ==(x: Float): Boolean = sys.error("stub") + def ==(x: Double): Boolean = sys.error("stub") + + def !=(x: Byte): Boolean = sys.error("stub") + def !=(x: Short): Boolean = sys.error("stub") + def !=(x: Char): Boolean = sys.error("stub") + def !=(x: Int): Boolean = sys.error("stub") + def !=(x: Long): Boolean = sys.error("stub") + def !=(x: Float): Boolean = sys.error("stub") + def !=(x: Double): Boolean = sys.error("stub") + + def <(x: Byte): Boolean = sys.error("stub") + def <(x: Short): Boolean = sys.error("stub") + def <(x: Char): Boolean = sys.error("stub") + def <(x: Int): Boolean = sys.error("stub") + def <(x: Long): Boolean = sys.error("stub") + def <(x: Float): Boolean = sys.error("stub") + def <(x: Double): Boolean = sys.error("stub") + + def <=(x: Byte): Boolean = sys.error("stub") + def <=(x: Short): Boolean = sys.error("stub") + def <=(x: Char): Boolean = sys.error("stub") + def <=(x: Int): Boolean = sys.error("stub") + def <=(x: Long): Boolean = sys.error("stub") + def <=(x: Float): Boolean = sys.error("stub") + def <=(x: Double): Boolean = sys.error("stub") + + def >(x: Byte): Boolean = sys.error("stub") + def >(x: Short): Boolean = sys.error("stub") + def >(x: Char): Boolean = sys.error("stub") + def >(x: Int): Boolean = sys.error("stub") + def >(x: Long): Boolean = sys.error("stub") + def >(x: Float): Boolean = sys.error("stub") + def >(x: Double): Boolean = sys.error("stub") + + def >=(x: Byte): Boolean = sys.error("stub") + def >=(x: Short): Boolean = sys.error("stub") + def >=(x: Char): Boolean = sys.error("stub") + def >=(x: Int): Boolean = sys.error("stub") + def >=(x: Long): Boolean = sys.error("stub") + def >=(x: Float): Boolean = sys.error("stub") + def >=(x: Double): Boolean = sys.error("stub") + + def +(x: Byte): Float = sys.error("stub") + def +(x: Short): Float = sys.error("stub") + def +(x: Char): Float = sys.error("stub") + def +(x: Int): Float = sys.error("stub") + def +(x: Long): Float = sys.error("stub") + def +(x: Float): Float = sys.error("stub") + def +(x: Double): Double = sys.error("stub") + + def -(x: Byte): Float = sys.error("stub") + def -(x: Short): Float = sys.error("stub") + def -(x: Char): Float = sys.error("stub") + def -(x: Int): Float = sys.error("stub") + def -(x: Long): Float = sys.error("stub") + def -(x: Float): Float = sys.error("stub") + def -(x: Double): Double = sys.error("stub") + + def *(x: Byte): Float = sys.error("stub") + def *(x: Short): Float = sys.error("stub") + def *(x: Char): Float = sys.error("stub") + def *(x: Int): Float = sys.error("stub") + def *(x: Long): Float = sys.error("stub") + def *(x: Float): Float = sys.error("stub") + def *(x: Double): Double = sys.error("stub") + + def /(x: Byte): Float = sys.error("stub") + def /(x: Short): Float = sys.error("stub") + def /(x: Char): Float = sys.error("stub") + def /(x: Int): Float = sys.error("stub") + def /(x: Long): Float = sys.error("stub") + def /(x: Float): Float = sys.error("stub") + def /(x: Double): Double = sys.error("stub") + + def %(x: Byte): Float = sys.error("stub") + def %(x: Short): Float = sys.error("stub") + def %(x: Char): Float = sys.error("stub") + def %(x: Int): Float = sys.error("stub") + def %(x: Long): Float = sys.error("stub") + def %(x: Float): Float = sys.error("stub") + def %(x: Double): Double = sys.error("stub") + +} + + +object Float extends AnyValCompanion { + final val MinPositiveValue = jl.Float.MIN_VALUE + final val MinNegativeValue = -jl.Float.MAX_VALUE + final val NaN = jl.Float.NaN + final val PositiveInfinity = jl.Float.POSITIVE_INFINITY + final val NegativeInfinity = jl.Float.NEGATIVE_INFINITY + + @deprecated("use Float.MinPositiveValue instead") + final val Epsilon = MinPositiveValue + @deprecated("use Float.MinNegativeValue instead") + final val MinValue = MinNegativeValue + final val MaxValue = jl.Float.MAX_VALUE + + def box(x: Float): jl.Float = jl.Float.valueOf(x) + def unbox(x: jl.Object): Float = x.asInstanceOf[jl.Float].floatValue() + override def toString = "object scala.Float" +} diff --git a/src/library/scala/Int.scala b/src/library/scala/Int.scala new file mode 100644 index 0000000000..416512d43b --- /dev/null +++ b/src/library/scala/Int.scala @@ -0,0 +1,154 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// generated on Sun Jan 23 21:13:38 PST 2011 + +package scala + +import java.{ lang => jl } + + +final class Int extends AnyVal { + def toByte: Byte = sys.error("stub") + def toShort: Short = sys.error("stub") + def toChar: Char = sys.error("stub") + def toInt: Int = sys.error("stub") + def toLong: Long = sys.error("stub") + def toFloat: Float = sys.error("stub") + def toDouble: Double = sys.error("stub") + + def unary_+ : Int = sys.error("stub") + def unary_- : Int = sys.error("stub") + def unary_~ : Int = sys.error("stub") + + def +(x: String): String = sys.error("stub") + + def <<(x: Int): Int = sys.error("stub") + def <<(x: Long): Int = sys.error("stub") + def >>>(x: Int): Int = sys.error("stub") + def >>>(x: Long): Int = sys.error("stub") + def >>(x: Int): Int = sys.error("stub") + def >>(x: Long): Int = sys.error("stub") + + def ==(x: Byte): Boolean = sys.error("stub") + def ==(x: Short): Boolean = sys.error("stub") + def ==(x: Char): Boolean = sys.error("stub") + def ==(x: Int): Boolean = sys.error("stub") + def ==(x: Long): Boolean = sys.error("stub") + def ==(x: Float): Boolean = sys.error("stub") + def ==(x: Double): Boolean = sys.error("stub") + + def !=(x: Byte): Boolean = sys.error("stub") + def !=(x: Short): Boolean = sys.error("stub") + def !=(x: Char): Boolean = sys.error("stub") + def !=(x: Int): Boolean = sys.error("stub") + def !=(x: Long): Boolean = sys.error("stub") + def !=(x: Float): Boolean = sys.error("stub") + def !=(x: Double): Boolean = sys.error("stub") + + def <(x: Byte): Boolean = sys.error("stub") + def <(x: Short): Boolean = sys.error("stub") + def <(x: Char): Boolean = sys.error("stub") + def <(x: Int): Boolean = sys.error("stub") + def <(x: Long): Boolean = sys.error("stub") + def <(x: Float): Boolean = sys.error("stub") + def <(x: Double): Boolean = sys.error("stub") + + def <=(x: Byte): Boolean = sys.error("stub") + def <=(x: Short): Boolean = sys.error("stub") + def <=(x: Char): Boolean = sys.error("stub") + def <=(x: Int): Boolean = sys.error("stub") + def <=(x: Long): Boolean = sys.error("stub") + def <=(x: Float): Boolean = sys.error("stub") + def <=(x: Double): Boolean = sys.error("stub") + + def >(x: Byte): Boolean = sys.error("stub") + def >(x: Short): Boolean = sys.error("stub") + def >(x: Char): Boolean = sys.error("stub") + def >(x: Int): Boolean = sys.error("stub") + def >(x: Long): Boolean = sys.error("stub") + def >(x: Float): Boolean = sys.error("stub") + def >(x: Double): Boolean = sys.error("stub") + + def >=(x: Byte): Boolean = sys.error("stub") + def >=(x: Short): Boolean = sys.error("stub") + def >=(x: Char): Boolean = sys.error("stub") + def >=(x: Int): Boolean = sys.error("stub") + def >=(x: Long): Boolean = sys.error("stub") + def >=(x: Float): Boolean = sys.error("stub") + def >=(x: Double): Boolean = sys.error("stub") + + def |(x: Byte): Int = sys.error("stub") + def |(x: Short): Int = sys.error("stub") + def |(x: Char): Int = sys.error("stub") + def |(x: Int): Int = sys.error("stub") + def |(x: Long): Long = sys.error("stub") + + def &(x: Byte): Int = sys.error("stub") + def &(x: Short): Int = sys.error("stub") + def &(x: Char): Int = sys.error("stub") + def &(x: Int): Int = sys.error("stub") + def &(x: Long): Long = sys.error("stub") + + def ^(x: Byte): Int = sys.error("stub") + def ^(x: Short): Int = sys.error("stub") + def ^(x: Char): Int = sys.error("stub") + def ^(x: Int): Int = sys.error("stub") + def ^(x: Long): Long = sys.error("stub") + + def +(x: Byte): Int = sys.error("stub") + def +(x: Short): Int = sys.error("stub") + def +(x: Char): Int = sys.error("stub") + def +(x: Int): Int = sys.error("stub") + def +(x: Long): Long = sys.error("stub") + def +(x: Float): Float = sys.error("stub") + def +(x: Double): Double = sys.error("stub") + + def -(x: Byte): Int = sys.error("stub") + def -(x: Short): Int = sys.error("stub") + def -(x: Char): Int = sys.error("stub") + def -(x: Int): Int = sys.error("stub") + def -(x: Long): Long = sys.error("stub") + def -(x: Float): Float = sys.error("stub") + def -(x: Double): Double = sys.error("stub") + + def *(x: Byte): Int = sys.error("stub") + def *(x: Short): Int = sys.error("stub") + def *(x: Char): Int = sys.error("stub") + def *(x: Int): Int = sys.error("stub") + def *(x: Long): Long = sys.error("stub") + def *(x: Float): Float = sys.error("stub") + def *(x: Double): Double = sys.error("stub") + + def /(x: Byte): Int = sys.error("stub") + def /(x: Short): Int = sys.error("stub") + def /(x: Char): Int = sys.error("stub") + def /(x: Int): Int = sys.error("stub") + def /(x: Long): Long = sys.error("stub") + def /(x: Float): Float = sys.error("stub") + def /(x: Double): Double = sys.error("stub") + + def %(x: Byte): Int = sys.error("stub") + def %(x: Short): Int = sys.error("stub") + def %(x: Char): Int = sys.error("stub") + def %(x: Int): Int = sys.error("stub") + def %(x: Long): Long = sys.error("stub") + def %(x: Float): Float = sys.error("stub") + def %(x: Double): Double = sys.error("stub") + +} + + +object Int extends AnyValCompanion { + final val MinValue = jl.Integer.MIN_VALUE + final val MaxValue = jl.Integer.MAX_VALUE + + def box(x: Int): jl.Integer = jl.Integer.valueOf(x) + def unbox(x: jl.Object): Int = x.asInstanceOf[jl.Integer].intValue() + override def toString = "object scala.Int" +} diff --git a/src/library/scala/Long.scala b/src/library/scala/Long.scala new file mode 100644 index 0000000000..25b6873e72 --- /dev/null +++ b/src/library/scala/Long.scala @@ -0,0 +1,154 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// generated on Sun Jan 23 21:13:38 PST 2011 + +package scala + +import java.{ lang => jl } + + +final class Long extends AnyVal { + def toByte: Byte = sys.error("stub") + def toShort: Short = sys.error("stub") + def toChar: Char = sys.error("stub") + def toInt: Int = sys.error("stub") + def toLong: Long = sys.error("stub") + def toFloat: Float = sys.error("stub") + def toDouble: Double = sys.error("stub") + + def unary_+ : Long = sys.error("stub") + def unary_- : Long = sys.error("stub") + def unary_~ : Long = sys.error("stub") + + def +(x: String): String = sys.error("stub") + + def <<(x: Int): Long = sys.error("stub") + def <<(x: Long): Long = sys.error("stub") + def >>>(x: Int): Long = sys.error("stub") + def >>>(x: Long): Long = sys.error("stub") + def >>(x: Int): Long = sys.error("stub") + def >>(x: Long): Long = sys.error("stub") + + def ==(x: Byte): Boolean = sys.error("stub") + def ==(x: Short): Boolean = sys.error("stub") + def ==(x: Char): Boolean = sys.error("stub") + def ==(x: Int): Boolean = sys.error("stub") + def ==(x: Long): Boolean = sys.error("stub") + def ==(x: Float): Boolean = sys.error("stub") + def ==(x: Double): Boolean = sys.error("stub") + + def !=(x: Byte): Boolean = sys.error("stub") + def !=(x: Short): Boolean = sys.error("stub") + def !=(x: Char): Boolean = sys.error("stub") + def !=(x: Int): Boolean = sys.error("stub") + def !=(x: Long): Boolean = sys.error("stub") + def !=(x: Float): Boolean = sys.error("stub") + def !=(x: Double): Boolean = sys.error("stub") + + def <(x: Byte): Boolean = sys.error("stub") + def <(x: Short): Boolean = sys.error("stub") + def <(x: Char): Boolean = sys.error("stub") + def <(x: Int): Boolean = sys.error("stub") + def <(x: Long): Boolean = sys.error("stub") + def <(x: Float): Boolean = sys.error("stub") + def <(x: Double): Boolean = sys.error("stub") + + def <=(x: Byte): Boolean = sys.error("stub") + def <=(x: Short): Boolean = sys.error("stub") + def <=(x: Char): Boolean = sys.error("stub") + def <=(x: Int): Boolean = sys.error("stub") + def <=(x: Long): Boolean = sys.error("stub") + def <=(x: Float): Boolean = sys.error("stub") + def <=(x: Double): Boolean = sys.error("stub") + + def >(x: Byte): Boolean = sys.error("stub") + def >(x: Short): Boolean = sys.error("stub") + def >(x: Char): Boolean = sys.error("stub") + def >(x: Int): Boolean = sys.error("stub") + def >(x: Long): Boolean = sys.error("stub") + def >(x: Float): Boolean = sys.error("stub") + def >(x: Double): Boolean = sys.error("stub") + + def >=(x: Byte): Boolean = sys.error("stub") + def >=(x: Short): Boolean = sys.error("stub") + def >=(x: Char): Boolean = sys.error("stub") + def >=(x: Int): Boolean = sys.error("stub") + def >=(x: Long): Boolean = sys.error("stub") + def >=(x: Float): Boolean = sys.error("stub") + def >=(x: Double): Boolean = sys.error("stub") + + def |(x: Byte): Long = sys.error("stub") + def |(x: Short): Long = sys.error("stub") + def |(x: Char): Long = sys.error("stub") + def |(x: Int): Long = sys.error("stub") + def |(x: Long): Long = sys.error("stub") + + def &(x: Byte): Long = sys.error("stub") + def &(x: Short): Long = sys.error("stub") + def &(x: Char): Long = sys.error("stub") + def &(x: Int): Long = sys.error("stub") + def &(x: Long): Long = sys.error("stub") + + def ^(x: Byte): Long = sys.error("stub") + def ^(x: Short): Long = sys.error("stub") + def ^(x: Char): Long = sys.error("stub") + def ^(x: Int): Long = sys.error("stub") + def ^(x: Long): Long = sys.error("stub") + + def +(x: Byte): Long = sys.error("stub") + def +(x: Short): Long = sys.error("stub") + def +(x: Char): Long = sys.error("stub") + def +(x: Int): Long = sys.error("stub") + def +(x: Long): Long = sys.error("stub") + def +(x: Float): Float = sys.error("stub") + def +(x: Double): Double = sys.error("stub") + + def -(x: Byte): Long = sys.error("stub") + def -(x: Short): Long = sys.error("stub") + def -(x: Char): Long = sys.error("stub") + def -(x: Int): Long = sys.error("stub") + def -(x: Long): Long = sys.error("stub") + def -(x: Float): Float = sys.error("stub") + def -(x: Double): Double = sys.error("stub") + + def *(x: Byte): Long = sys.error("stub") + def *(x: Short): Long = sys.error("stub") + def *(x: Char): Long = sys.error("stub") + def *(x: Int): Long = sys.error("stub") + def *(x: Long): Long = sys.error("stub") + def *(x: Float): Float = sys.error("stub") + def *(x: Double): Double = sys.error("stub") + + def /(x: Byte): Long = sys.error("stub") + def /(x: Short): Long = sys.error("stub") + def /(x: Char): Long = sys.error("stub") + def /(x: Int): Long = sys.error("stub") + def /(x: Long): Long = sys.error("stub") + def /(x: Float): Float = sys.error("stub") + def /(x: Double): Double = sys.error("stub") + + def %(x: Byte): Long = sys.error("stub") + def %(x: Short): Long = sys.error("stub") + def %(x: Char): Long = sys.error("stub") + def %(x: Int): Long = sys.error("stub") + def %(x: Long): Long = sys.error("stub") + def %(x: Float): Float = sys.error("stub") + def %(x: Double): Double = sys.error("stub") + +} + + +object Long extends AnyValCompanion { + final val MinValue = jl.Long.MIN_VALUE + final val MaxValue = jl.Long.MAX_VALUE + + def box(x: Long): jl.Long = jl.Long.valueOf(x) + def unbox(x: jl.Object): Long = x.asInstanceOf[jl.Long].longValue() + override def toString = "object scala.Long" +} diff --git a/src/library/scala/Short.scala b/src/library/scala/Short.scala new file mode 100644 index 0000000000..abbb939c4c --- /dev/null +++ b/src/library/scala/Short.scala @@ -0,0 +1,154 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// generated on Sun Jan 23 21:13:38 PST 2011 + +package scala + +import java.{ lang => jl } + + +final class Short extends AnyVal { + def toByte: Byte = sys.error("stub") + def toShort: Short = sys.error("stub") + def toChar: Char = sys.error("stub") + def toInt: Int = sys.error("stub") + def toLong: Long = sys.error("stub") + def toFloat: Float = sys.error("stub") + def toDouble: Double = sys.error("stub") + + def unary_+ : Int = sys.error("stub") + def unary_- : Int = sys.error("stub") + def unary_~ : Int = sys.error("stub") + + def +(x: String): String = sys.error("stub") + + def <<(x: Int): Int = sys.error("stub") + def <<(x: Long): Int = sys.error("stub") + def >>>(x: Int): Int = sys.error("stub") + def >>>(x: Long): Int = sys.error("stub") + def >>(x: Int): Int = sys.error("stub") + def >>(x: Long): Int = sys.error("stub") + + def ==(x: Byte): Boolean = sys.error("stub") + def ==(x: Short): Boolean = sys.error("stub") + def ==(x: Char): Boolean = sys.error("stub") + def ==(x: Int): Boolean = sys.error("stub") + def ==(x: Long): Boolean = sys.error("stub") + def ==(x: Float): Boolean = sys.error("stub") + def ==(x: Double): Boolean = sys.error("stub") + + def !=(x: Byte): Boolean = sys.error("stub") + def !=(x: Short): Boolean = sys.error("stub") + def !=(x: Char): Boolean = sys.error("stub") + def !=(x: Int): Boolean = sys.error("stub") + def !=(x: Long): Boolean = sys.error("stub") + def !=(x: Float): Boolean = sys.error("stub") + def !=(x: Double): Boolean = sys.error("stub") + + def <(x: Byte): Boolean = sys.error("stub") + def <(x: Short): Boolean = sys.error("stub") + def <(x: Char): Boolean = sys.error("stub") + def <(x: Int): Boolean = sys.error("stub") + def <(x: Long): Boolean = sys.error("stub") + def <(x: Float): Boolean = sys.error("stub") + def <(x: Double): Boolean = sys.error("stub") + + def <=(x: Byte): Boolean = sys.error("stub") + def <=(x: Short): Boolean = sys.error("stub") + def <=(x: Char): Boolean = sys.error("stub") + def <=(x: Int): Boolean = sys.error("stub") + def <=(x: Long): Boolean = sys.error("stub") + def <=(x: Float): Boolean = sys.error("stub") + def <=(x: Double): Boolean = sys.error("stub") + + def >(x: Byte): Boolean = sys.error("stub") + def >(x: Short): Boolean = sys.error("stub") + def >(x: Char): Boolean = sys.error("stub") + def >(x: Int): Boolean = sys.error("stub") + def >(x: Long): Boolean = sys.error("stub") + def >(x: Float): Boolean = sys.error("stub") + def >(x: Double): Boolean = sys.error("stub") + + def >=(x: Byte): Boolean = sys.error("stub") + def >=(x: Short): Boolean = sys.error("stub") + def >=(x: Char): Boolean = sys.error("stub") + def >=(x: Int): Boolean = sys.error("stub") + def >=(x: Long): Boolean = sys.error("stub") + def >=(x: Float): Boolean = sys.error("stub") + def >=(x: Double): Boolean = sys.error("stub") + + def |(x: Byte): Int = sys.error("stub") + def |(x: Short): Int = sys.error("stub") + def |(x: Char): Int = sys.error("stub") + def |(x: Int): Int = sys.error("stub") + def |(x: Long): Long = sys.error("stub") + + def &(x: Byte): Int = sys.error("stub") + def &(x: Short): Int = sys.error("stub") + def &(x: Char): Int = sys.error("stub") + def &(x: Int): Int = sys.error("stub") + def &(x: Long): Long = sys.error("stub") + + def ^(x: Byte): Int = sys.error("stub") + def ^(x: Short): Int = sys.error("stub") + def ^(x: Char): Int = sys.error("stub") + def ^(x: Int): Int = sys.error("stub") + def ^(x: Long): Long = sys.error("stub") + + def +(x: Byte): Int = sys.error("stub") + def +(x: Short): Int = sys.error("stub") + def +(x: Char): Int = sys.error("stub") + def +(x: Int): Int = sys.error("stub") + def +(x: Long): Long = sys.error("stub") + def +(x: Float): Float = sys.error("stub") + def +(x: Double): Double = sys.error("stub") + + def -(x: Byte): Int = sys.error("stub") + def -(x: Short): Int = sys.error("stub") + def -(x: Char): Int = sys.error("stub") + def -(x: Int): Int = sys.error("stub") + def -(x: Long): Long = sys.error("stub") + def -(x: Float): Float = sys.error("stub") + def -(x: Double): Double = sys.error("stub") + + def *(x: Byte): Int = sys.error("stub") + def *(x: Short): Int = sys.error("stub") + def *(x: Char): Int = sys.error("stub") + def *(x: Int): Int = sys.error("stub") + def *(x: Long): Long = sys.error("stub") + def *(x: Float): Float = sys.error("stub") + def *(x: Double): Double = sys.error("stub") + + def /(x: Byte): Int = sys.error("stub") + def /(x: Short): Int = sys.error("stub") + def /(x: Char): Int = sys.error("stub") + def /(x: Int): Int = sys.error("stub") + def /(x: Long): Long = sys.error("stub") + def /(x: Float): Float = sys.error("stub") + def /(x: Double): Double = sys.error("stub") + + def %(x: Byte): Int = sys.error("stub") + def %(x: Short): Int = sys.error("stub") + def %(x: Char): Int = sys.error("stub") + def %(x: Int): Int = sys.error("stub") + def %(x: Long): Long = sys.error("stub") + def %(x: Float): Float = sys.error("stub") + def %(x: Double): Double = sys.error("stub") + +} + + +object Short extends AnyValCompanion { + final val MinValue = jl.Short.MIN_VALUE + final val MaxValue = jl.Short.MAX_VALUE + + def box(x: Short): jl.Short = jl.Short.valueOf(x) + def unbox(x: jl.Object): Short = x.asInstanceOf[jl.Short].shortValue() + override def toString = "object scala.Short" +} diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala new file mode 100755 index 0000000000..7ef282a9ad --- /dev/null +++ b/src/library/scala/Unit.scala @@ -0,0 +1,23 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// generated on Sun Jan 23 21:13:38 PST 2011 + +package scala + +import java.{ lang => jl } + +import runtime.BoxedUnit + +final class Unit extends AnyVal { } + +object Unit extends AnyValCompanion { + override def toString = "object scala.Unit" + def box(x: Unit): BoxedUnit = BoxedUnit.UNIT + def unbox(x: jl.Object): Unit = () +}
\ No newline at end of file diff --git a/src/library/scala/runtime/AnyValCompanion.scala b/src/library/scala/runtime/AnyValCompanion.scala index 34d6069cc8..5f6f581f50 100644 --- a/src/library/scala/runtime/AnyValCompanion.scala +++ b/src/library/scala/runtime/AnyValCompanion.scala @@ -6,81 +6,9 @@ ** |/ ** \* */ - - package scala.runtime -/** A common supertype for companion classes of primitive types. - * - * A common trait for /companion/ objects of primitive types comes handy - * when parameterizing code on types. For instance, the specialized - * annotation is passed a sequence of types on which to specialize: - * {{{ - * class Tuple1[@specialized(Unit, Int, Double) T] - * }}} - * - */ -sealed trait AnyValCompanion - -/** A object representing `object scala.Unit`. It should never be used - * directly. - */ -object Unit extends AnyValCompanion { - override def toString = "object scala.Unit" -} - -/** A object representing `object scala.Boolean`. It should never be used - * directly. - */ -object Boolean extends AnyValCompanion { - override def toString = "object scala.Boolean" -} - -/** A object representing `object scala.Byte`. It should never be used - * directly. - */ -object Byte extends AnyValCompanion { - override def toString = "object scala.Byte" -} - -/** A object representing `object scala.Short`. It should never be used - * directly. - */ -object Short extends AnyValCompanion { - override def toString = "object scala.Short" -} - -/** A object representing `object scala.Char`. It should never be used - * directly. - */ -object Char extends AnyValCompanion { - override def toString = "object scala.Char" -} - -/** A object representing `object scala.Int`. It should never be used - * directly. - */ -object Int extends AnyValCompanion { - override def toString = "object scala.Int" -} - -/** A object representing `object scala.Long`. It should never be used - * directly. - */ -object Long extends AnyValCompanion { - override def toString = "object scala.Long" -} - -/** A object representing `object scala.Float`. It should never be used - * directly. - */ -object Float extends AnyValCompanion { - override def toString = "object scala.Float" -} - -/** A object representing `object scala.Double`. It should never be used - * directly. +/** See scala.AnyValCompanion. */ -object Double extends AnyValCompanion { - override def toString = "object scala.Double" -} +@deprecated("Use scala.AnyValCompanion instead") +private[scala] trait AnyValCompanion extends scala.AnyValCompanion { }
\ No newline at end of file diff --git a/src/library/scala/runtime/package.scala b/src/library/scala/runtime/package.scala new file mode 100644 index 0000000000..83947cce9f --- /dev/null +++ b/src/library/scala/runtime/package.scala @@ -0,0 +1,13 @@ +package scala + +package object runtime { + @deprecated("Use `scala.Unit` instead.") val Unit = scala.Unit + @deprecated("Use `scala.Boolean` instead.") val Boolean = scala.Boolean + @deprecated("Use `scala.Byte` instead.") val Byte = scala.Byte + @deprecated("Use `scala.Short` instead.") val Short = scala.Short + @deprecated("Use `scala.Char` instead.") val Char = scala.Char + @deprecated("Use `scala.Int` instead.") val Int = scala.Int + @deprecated("Use `scala.Long` instead.") val Long = scala.Long + @deprecated("Use `scala.Float` instead.") val Float = scala.Float + @deprecated("Use `scala.Double` instead.") val Double = scala.Double +} diff --git a/src/library/scala/specialized.scala b/src/library/scala/specialized.scala index 6f2e44f10f..656508c9d9 100644 --- a/src/library/scala/specialized.scala +++ b/src/library/scala/specialized.scala @@ -25,7 +25,7 @@ package scala * * @since 2.8 */ -class specialized(types: runtime.AnyValCompanion*) extends annotation.StaticAnnotation { +class specialized(types: AnyValCompanion*) extends annotation.StaticAnnotation { def this() { this(Unit, Boolean, Byte, Short, Char, Int, Long, Float, Double) } |