Permalink
Browse files

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.
  • Loading branch information...
1 parent 1cbe06c commit 4253124eecba6bed38f1dc961c5c4ee39a29f730 @paulp paulp committed Jan 24, 2011
Showing with 1,411 additions and 377 deletions.
  1. +1 −1 lib/scala-compiler.jar.desired.sha1
  2. +1 −1 lib/scala-library-src.jar.desired.sha1
  3. +1 −1 lib/scala-library.jar.desired.sha1
  4. +0 −1 src/compiler/scala/tools/cmd/gen/AnyVals.scala
  5. +50 −20 src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
  6. +2 −2 src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
  7. +0 −4 src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala
  8. +2 −1 src/compiler/scala/tools/nsc/matching/Matrix.scala
  9. +155 −249 src/compiler/scala/tools/nsc/symtab/Definitions.scala
  10. +3 −0 src/compiler/scala/tools/nsc/symtab/StdNames.scala
  11. +1 −1 src/compiler/scala/tools/nsc/transform/Constructors.scala
  12. +1 −1 src/compiler/scala/tools/nsc/transform/Erasure.scala
  13. +8 −4 src/compiler/scala/tools/nsc/transform/Mixin.scala
  14. +2 −1 src/compiler/scala/tools/nsc/transform/TailCalls.scala
  15. +12 −2 src/compiler/scala/tools/nsc/typechecker/Namers.scala
  16. +8 −4 src/compiler/scala/tools/nsc/typechecker/Typers.scala
  17. +6 −0 src/compiler/scala/tools/nsc/util/Exceptional.scala
  18. +11 −0 src/library/scala/AnyVal.scala
  19. +21 −0 src/library/scala/AnyValCompanion.scala
  20. +34 −0 src/library/scala/Boolean.scala
  21. +154 −0 src/library/scala/Byte.scala
  22. +154 −0 src/library/scala/Char.scala
  23. +137 −0 src/library/scala/Double.scala
  24. +137 −0 src/library/scala/Float.scala
  25. +154 −0 src/library/scala/Int.scala
  26. +154 −0 src/library/scala/Long.scala
  27. +154 −0 src/library/scala/Short.scala
  28. +23 −0 src/library/scala/Unit.scala
  29. +3 −75 src/library/scala/runtime/AnyValCompanion.scala
  30. +13 −0 src/library/scala/runtime/package.scala
  31. +1 −1 src/library/scala/specialized.scala
  32. +8 −8 test/files/neg/overload-msg.check
@@ -1 +1 @@
-91d31d91a1dcebb045af5e171974751fef282a84 ?scala-compiler.jar
+4b2f54712dab89071f1909f07367673635beffda ?scala-compiler.jar
@@ -1 +1 @@
-63be019508818165998eaa2be955eaa28ef4ad8c ?scala-library-src.jar
+f015b1389419b997796a3a9814bedac6343f108e ?scala-library-src.jar
@@ -1 +1 @@
-acc4baf73128ac1b66d611a86d8234744998659c ?scala-library.jar
+af0438e6911f357a2af0d068482baa1f526dbac0 ?scala-library.jar
@@ -22,7 +22,6 @@ trait AnyValTemplates {
package scala
-import scala.runtime.AnyValCompanion
import java.{ lang => jl }
""".trim.format(now) + "\n\n"
@@ -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 =>
@@ -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) = {
@@ -42,10 +42,6 @@ trait GenJVMUtil {
NullClass -> RuntimeNullClass.fullName('/'),
RuntimeNullClass -> RuntimeNullClass.fullName('/')
)
- primitiveCompanions foreach { sym =>
- map(sym) = "scala/runtime/" + sym.name + "$"
- }
-
map
}
@@ -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 = {
Oops, something went wrong.

0 comments on commit 4253124

Please sign in to comment.