diff options
author | ilyas <ilyas@epfl.ch> | 2010-02-05 16:53:41 +0000 |
---|---|---|
committer | ilyas <ilyas@epfl.ch> | 2010-02-05 16:53:41 +0000 |
commit | f203f3adfd63936ccfa71d61608e95f05ae800b0 (patch) | |
tree | 25d258ba2fd35fec7bb53fdbe5ca98698983cda7 | |
parent | 96dc0e44e8f1610463e38c05f647987c336b5093 (diff) | |
download | scala-f203f3adfd63936ccfa71d61608e95f05ae800b0.tar.gz scala-f203f3adfd63936ccfa71d61608e95f05ae800b0.tar.bz2 scala-f203f3adfd63936ccfa71d61608e95f05ae800b0.zip |
some scalap tweaks
4 files changed, 34 insertions, 25 deletions
diff --git a/src/scalap/scala/tools/scalap/Main.scala b/src/scalap/scala/tools/scalap/Main.scala index 338143f671..28e48a34d0 100644 --- a/src/scalap/scala/tools/scalap/Main.scala +++ b/src/scalap/scala/tools/scalap/Main.scala @@ -33,7 +33,8 @@ object Main { */ def usage { Console.println("usage: scalap {<option>} <name>") - Console.println("where <option> is") + Console.println("where <name> is fully-qualified class name or <package_name>.package for package objects") + Console.println("and <option> is") Console.println(" -private print private definitions") Console.println(" -verbose print out additional information") Console.println(" -version print out the version number of scalap") diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala index da268f4e44..76c59d837f 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala +++ b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala @@ -16,6 +16,7 @@ import java.io.{PrintStream, ByteArrayOutputStream} import java.util.regex.Pattern import scala.tools.scalap.scalax.util.StringUtil +import reflect.NameTransformer class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { import stream._ @@ -98,25 +99,29 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { private def refinementClass(c: ClassSymbol) = c.name == "<refinement>" def printClass(level: Int, c: ClassSymbol) { - printModifiers(c) - val defaultConstructor = if (c.isCase) getPrinterByConstructor(c) else "" - if (c.isTrait) print("trait ") else print("class ") - print(processName(c.name)) - val it = c.infoType - val classType = it match { - case PolyType(typeRef, symbols) => PolyTypeWithCons(typeRef, symbols, defaultConstructor) - case _ => it - } - printType(classType) - print(" {") - //Print class selftype - c.selfType match { - case Some(t: Type) => print("\n"); print(" this : " + toString(t) + " =>") - case None => + if (c.name != "<local child>"/*scala.tools.nsc.symtab.StdNames.LOCALCHILD.toString()*/) { + print("\n") + } else { + printModifiers(c) + val defaultConstructor = if (c.isCase) getPrinterByConstructor(c) else "" + if (c.isTrait) print("trait ") else print("class ") + print(processName(c.name)) + val it = c.infoType + val classType = it match { + case PolyType(typeRef, symbols) => PolyTypeWithCons(typeRef, symbols, defaultConstructor) + case _ => it + } + printType(classType) + print(" {") + //Print class selftype + c.selfType match { + case Some(t: Type) => print("\n"); print(" this : " + toString(t) + " =>") + case None => + } + print("\n") + printChildren(level, c) + printWithIndent(level, "}\n") } - print("\n") - printChildren(level, c) - printWithIndent(level, "}\n") } def getPrinterByConstructor(c: ClassSymbol) = { @@ -347,9 +352,11 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { if (typeArgs.isEmpty) "" else typeArgs.map(toString).map(StringUtil.trimStart(_, "=> ")).mkString("[", ", ", "]") - def typeParamString(params: Seq[Symbol]): String = - if (params.isEmpty) "" + def typeParamString(params: Seq[Symbol]): String = { + val res = if (params.isEmpty) "" else params.map(toString).mkString("[", ", ", "]") + res.replace(" >: scala.Nothing", "").replace(" <: scala.Any", "") + } val _syms = Map("\\$bar" -> "|", "\\$tilde" -> "~", "\\$bang" -> "!", "\\$up" -> "^", "\\$plus" -> "+", @@ -368,7 +375,8 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { val re = "\\" + key temp = temp.replaceAll(re, _syms(re)) } - temp.replaceAll(placeholderPattern, "_") + val result = temp.replaceAll(placeholderPattern, "_") + NameTransformer.decode(result) } } diff --git a/test/files/scalap/classWithExistential/result.test b/test/files/scalap/classWithExistential/result.test index 243f51e2ad..37767c0904 100644 --- a/test/files/scalap/classWithExistential/result.test +++ b/test/files/scalap/classWithExistential/result.test @@ -1,4 +1,4 @@ class ClassWithExistential extends java.lang.Object with scala.ScalaObject { def this() = { /* compiled code */ } - def foo[A >: scala.Nothing <: scala.Any, B >: scala.Nothing <: scala.Any] : scala.Function1[A, B forSome {type A >: scala.Nothing <: scala.Seq[scala.Int]; type B >: scala.Predef.String <: scala.Any}] = { /* compiled code */ } + def foo[A, B] : scala.Function1[A, B forSome {type A >: scala.Nothing <: scala.Seq[scala.Int]; type B >: scala.Predef.String <: scala.Any}] = { /* compiled code */ } } diff --git a/test/files/scalap/covariantParam/result.test b/test/files/scalap/covariantParam/result.test index ce480ee0cd..8acd9b497a 100644 --- a/test/files/scalap/covariantParam/result.test +++ b/test/files/scalap/covariantParam/result.test @@ -1,4 +1,4 @@ -class CovariantParam[+A >: scala.Nothing <: scala.Any] extends java.lang.Object with scala.ScalaObject { +class CovariantParam[+A] extends java.lang.Object with scala.ScalaObject { def this() = { /* compiled code */ } - def foo[A >: scala.Nothing <: scala.Any](a : A) : scala.Int = { /* compiled code */ } + def foo[A](a : A) : scala.Int = { /* compiled code */ } } |