diff options
Diffstat (limited to 'src/scalap')
-rw-r--r-- | src/scalap/scala/tools/scalap/Decode.scala | 8 | ||||
-rw-r--r-- | src/scalap/scala/tools/scalap/Main.scala | 12 |
2 files changed, 11 insertions, 9 deletions
diff --git a/src/scalap/scala/tools/scalap/Decode.scala b/src/scalap/scala/tools/scalap/Decode.scala index 6e55558249..4b319da13a 100644 --- a/src/scalap/scala/tools/scalap/Decode.scala +++ b/src/scalap/scala/tools/scalap/Decode.scala @@ -10,7 +10,8 @@ package scala.tools.scalap import scala.tools.scalap.scalax.rules.scalasig._ -import scala.tools.nsc.util.ScalaClassLoader.{ getSystemLoader, findBytesForClassName } +import scala.tools.nsc.util.ScalaClassLoader +import scala.tools.nsc.util.ScalaClassLoader.getSystemLoader import Main.SCALA_SIG /** Temporary decoder. This would be better off in the scala.tools.nsc @@ -26,8 +27,9 @@ object Decode { /** Return the classfile bytes representing the scala sig attribute. */ - def scalaSigBytes(name: String): Option[Array[Byte]] = { - val bytes = findBytesForClassName(name) + def scalaSigBytes(name: String): Option[Array[Byte]] = scalaSigBytes(name, getSystemLoader()) + def scalaSigBytes(name: String, classLoader: ScalaClassLoader): Option[Array[Byte]] = { + val bytes = classLoader.findBytesForClassName(name) val reader = new ByteArrayReader(bytes) val cf = new Classfile(reader) cf.scalaSigAttribute map (_.data) diff --git a/src/scalap/scala/tools/scalap/Main.scala b/src/scalap/scala/tools/scalap/Main.scala index eee689c189..d386e7a08f 100644 --- a/src/scalap/scala/tools/scalap/Main.scala +++ b/src/scalap/scala/tools/scalap/Main.scala @@ -97,16 +97,16 @@ object Main { baos.toString } - - def decompileScala(bytes: Array[Byte], isPackageObject: Boolean) = { + def getDecompiledScala(bytes: Array[Byte], isPackageObject: Boolean) = { val byteCode = ByteCode(bytes) val classFile = ClassFileParser.parse(byteCode) - classFile.attribute(SCALA_SIG).map(_.byteCode).map(ScalaSigAttributeParsers.parse) match { - case Some(scalaSig) => Console.println(parseScalaSignature(scalaSig, isPackageObject)) - case None => //Do nothing - } + val sig = classFile.attribute(SCALA_SIG).map(_.byteCode).map(ScalaSigAttributeParsers.parse) + + sig map (x => parseScalaSignature(x, isPackageObject)) } + def decompileScala(bytes: Array[Byte], isPackageObject: Boolean) = + getDecompiledScala(bytes, isPackageObject) foreach (Console println _) /**Executes scalap with the given arguments and classpath for the * class denoted by <code>classname</code>. |