summaryrefslogtreecommitdiff
path: root/src/scalap/scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-02-15 20:00:36 +0000
committerPaul Phillips <paulp@improving.org>2010-02-15 20:00:36 +0000
commit821229741d41ab5a0087ddf289ee01b92e9c0685 (patch)
tree1306ddc619017d903c2bceb35ba37ba27cc27dbf /src/scalap/scala
parent369d3ca26f05ab848807c109e464f90f2e668c81 (diff)
downloadscala-821229741d41ab5a0087ddf289ee01b92e9c0685.tar.gz
scala-821229741d41ab5a0087ddf289ee01b92e9c0685.tar.bz2
scala-821229741d41ab5a0087ddf289ee01b92e9c0685.zip
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
Diffstat (limited to 'src/scalap/scala')
-rw-r--r--src/scalap/scala/tools/scalap/Classfile.scala1
-rw-r--r--src/scalap/scala/tools/scalap/Decode.scala12
2 files changed, 12 insertions, 1 deletions
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]] = {