From 821229741d41ab5a0087ddf289ee01b92e9c0685 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 15 Feb 2010 20:00:36 +0000 Subject: Some new tools for the tools directory. amounts to a yak shaving expedition to enable this, which now works: tools/diffPickled scala.Either and since stability is presently broken you will see the following. (When it's not broken you will see nothing.) 541,544c541,544 < 538,4090: EXTref 3: 539(Left) 2 < 539,4095: TYPEname 4: Left < 540,4101: EXTref 3: 541(Right) 2 < 541,4106: TYPEname 5: Right --- > 538,4090: EXTref 3: 539(Right) 2 > 539,4095: TYPEname 5: Right > 540,4102: EXTref 3: 541(Left) 2 > 541,4107: TYPEname 4: Left --- src/scalap/scala/tools/scalap/Classfile.scala | 1 + src/scalap/scala/tools/scalap/Decode.scala | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/scalap') diff --git a/src/scalap/scala/tools/scalap/Classfile.scala b/src/scalap/scala/tools/scalap/Classfile.scala index 44f687bd85..c4f273c5aa 100644 --- a/src/scalap/scala/tools/scalap/Classfile.scala +++ b/src/scalap/scala/tools/scalap/Classfile.scala @@ -26,6 +26,7 @@ class Classfile(in: ByteArrayReader) { val fields = readMembers(true) val methods = readMembers(false) val attribs = readAttribs + def scalaSigAttribute = attribs find (_.toString == Main.SCALA_SIG) def readAttribs = { val n = in.nextChar diff --git a/src/scalap/scala/tools/scalap/Decode.scala b/src/scalap/scala/tools/scalap/Decode.scala index 04d72c015b..6e55558249 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 +import scala.tools.nsc.util.ScalaClassLoader.{ getSystemLoader, findBytesForClassName } +import Main.SCALA_SIG /** Temporary decoder. This would be better off in the scala.tools.nsc * but right now the compiler won't acknowledge scala.tools.scalap @@ -23,6 +24,15 @@ object Decode { case _ => NoSymbol } + /** Return the classfile bytes representing the scala sig attribute. + */ + def scalaSigBytes(name: String): Option[Array[Byte]] = { + val bytes = findBytesForClassName(name) + val reader = new ByteArrayReader(bytes) + val cf = new Classfile(reader) + cf.scalaSigAttribute map (_.data) + } + /** private[scala] so nobody gets the idea this is a supported interface. */ private[scala] def caseParamNames(path: String): Option[List[String]] = { -- cgit v1.2.3