summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-01-27 01:26:41 +0000
committerPaul Phillips <paulp@improving.org>2011-01-27 01:26:41 +0000
commit4a194bf5384a217697e7106ab5aca42946bb74cd (patch)
tree3d2c71608c52f49d367f09235cdc001cfc11a803 /src/compiler
parentb6fb314419101bf4ca2959d949723de1af675ffb (diff)
downloadscala-4a194bf5384a217697e7106ab5aca42946bb74cd.tar.gz
scala-4a194bf5384a217697e7106ab5aca42946bb74cd.tar.bz2
scala-4a194bf5384a217697e7106ab5aca42946bb74cd.zip
Some minor cleanups in anyval source generation.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/cmd/gen/AnyVals.scala13
-rw-r--r--src/compiler/scala/tools/cmd/gen/Codegen.scala16
-rw-r--r--src/compiler/scala/tools/cmd/gen/CodegenSpec.scala1
3 files changed, 18 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala
index b8ed251062..23a31a56b4 100644
--- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala
+++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala
@@ -7,7 +7,7 @@ package scala.tools.cmd
package gen
trait AnyValTemplates {
- def now = "" + new java.util.Date
+ def timestampString = "// generated on " + new java.util.Date + "\n"
def template = """
/* __ *\
@@ -18,13 +18,12 @@ trait AnyValTemplates {
** |/ **
\* */
-// generated on %s
-
+%s
package scala
import java.{ lang => jl }
- """.trim.format(now) + "\n\n"
+ """.trim.format(timestampString) + "\n\n"
val booleanBody = """
final class Boolean extends AnyVal {
@@ -62,7 +61,7 @@ object Unit extends AnyValCompanion {
""".trim
}
-object AnyVals extends AnyValTemplates {
+class AnyVals extends AnyValTemplates {
val B = "Byte"
val S = "Short"
val C = "Char"
@@ -202,4 +201,6 @@ object AnyVals extends AnyValTemplates {
else floatingCompanion
) ++ commonCompanion
}
-} \ No newline at end of file
+}
+
+object AnyVals extends AnyVals { } \ No newline at end of file
diff --git a/src/compiler/scala/tools/cmd/gen/Codegen.scala b/src/compiler/scala/tools/cmd/gen/Codegen.scala
index 0beb7c986a..a96e53d4e2 100644
--- a/src/compiler/scala/tools/cmd/gen/Codegen.scala
+++ b/src/compiler/scala/tools/cmd/gen/Codegen.scala
@@ -20,17 +20,21 @@ object Codegen {
if (args0.isEmpty)
return println (CodegenSpec.helpMsg)
- val out = outDir getOrElse { return println("--outdir is required.") }
+ val out = outDir getOrElse { return println("--out is required.") }
val all = genall || (!anyvals && !products)
echo("Generating sources into " + out)
if (anyvals || all) {
- AnyVals.make() foreach {
- case (name, code ) =>
- val file = out / (name + ".scala") toFile;
- echo("Writing: " + file)
- file writeAll code
+ val av = new AnyVals {
+ override def timestampString =
+ if (stamp) super.timestampString
+ else ""
+ }
+ av.make() foreach { case (name, code ) =>
+ val file = out / (name + ".scala") toFile;
+ echo("Writing: " + file)
+ file writeAll code
}
}
if (products || all) {
diff --git a/src/compiler/scala/tools/cmd/gen/CodegenSpec.scala b/src/compiler/scala/tools/cmd/gen/CodegenSpec.scala
index e655334b1b..e99c49721f 100644
--- a/src/compiler/scala/tools/cmd/gen/CodegenSpec.scala
+++ b/src/compiler/scala/tools/cmd/gen/CodegenSpec.scala
@@ -22,6 +22,7 @@ trait CodegenSpec extends Spec with Meta.StdOpts with Interpolation {
val anyvals = "anyvals" / "generate sources for AnyVal types" --?
val products = "products" / "generate sources for ProductN, FunctionN, etc." --?
val genall = "all" / "generate sources for everything" --?
+ val stamp = "stamp" / "add a timestamp to the generated files" --?
}
object CodegenSpec extends CodegenSpec with Reference {