diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2010-03-23 14:38:11 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2010-03-23 14:38:11 +0000 |
commit | ef1577a9c5a9f2905e9b89b1508f97127d941bd7 (patch) | |
tree | 009b8393710f33c0c4f8d6560a36d270a3c0cab7 /src/library | |
parent | fb8c14ea43d273466b7d01bb00ce4185d9a91091 (diff) | |
download | scala-ef1577a9c5a9f2905e9b89b1508f97127d941bd7.tar.gz scala-ef1577a9c5a9f2905e9b89b1508f97127d941bd7.tar.bz2 scala-ef1577a9c5a9f2905e9b89b1508f97127d941bd7.zip |
Scala signature is generated as an annotation (...
Scala signature is generated as an annotation (that is accessible
through Java reflection).
- compiler generates all pickled Scala signatures as annotations to class files.
- compiler can read class files with signature as annotations or old-style signatures as attributes.
- Scalap has also been updated to new signatures (contributed by Ilya Sergey: thanks a lot).
- FJBG updated to allow entering constant pool strings as byte arrays.
- ByteCodecs decode method returns the length of the decoded array.
Review by ilyas. Already mostly reviewed by odersky.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/reflect/ScalaSignature.java | 13 | ||||
-rwxr-xr-x | src/library/scala/reflect/generic/AnnotationInfos.scala | 8 | ||||
-rw-r--r-- | src/library/scala/reflect/generic/ByteCodecs.scala | 7 |
3 files changed, 25 insertions, 3 deletions
diff --git a/src/library/scala/reflect/ScalaSignature.java b/src/library/scala/reflect/ScalaSignature.java new file mode 100644 index 0000000000..d1cdbc0589 --- /dev/null +++ b/src/library/scala/reflect/ScalaSignature.java @@ -0,0 +1,13 @@ +package scala.reflect; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface ScalaSignature { + public String bytes(); +} diff --git a/src/library/scala/reflect/generic/AnnotationInfos.scala b/src/library/scala/reflect/generic/AnnotationInfos.scala index 6239ca189c..cc6c909a45 100755 --- a/src/library/scala/reflect/generic/AnnotationInfos.scala +++ b/src/library/scala/reflect/generic/AnnotationInfos.scala @@ -20,6 +20,9 @@ trait AnnotationInfos { self: Universe => type ArrayAnnotArg <: ClassfileAnnotArg val ArrayAnnotArg: ArrayAnnotArgExtractor + type ScalaSigBytes <: ClassfileAnnotArg + val ScalaSigBytes: ScalaSigBytesExtractor + type NestedAnnotArg <: ClassfileAnnotArg val NestedAnnotArg: NestedAnnotArgExtractor @@ -33,6 +36,11 @@ trait AnnotationInfos { self: Universe => def unapply(arg: ArrayAnnotArg): Option[Array[ClassfileAnnotArg]] } + abstract class ScalaSigBytesExtractor { + def apply(bytes: Array[Byte]): ScalaSigBytes + def unapply(arg: ScalaSigBytes): Option[Array[Byte]] + } + abstract class NestedAnnotArgExtractor { def apply(anninfo: AnnotationInfo): NestedAnnotArg def unapply(arg: NestedAnnotArg): Option[AnnotationInfo] diff --git a/src/library/scala/reflect/generic/ByteCodecs.scala b/src/library/scala/reflect/generic/ByteCodecs.scala index 1f42008837..fd2e326e19 100644 --- a/src/library/scala/reflect/generic/ByteCodecs.scala +++ b/src/library/scala/reflect/generic/ByteCodecs.scala @@ -122,7 +122,7 @@ object ByteCodecs { @deprecated("use 2-argument version instead") def decode7to8(src: Array[Byte], srclen: Int, dstlen: Int) { decode7to8(src, srclen) } - def decode7to8(src: Array[Byte], srclen: Int) { + def decode7to8(src: Array[Byte], srclen: Int): Int = { var i = 0 var j = 0 val dstlen = (srclen * 7 + 7) / 8 @@ -185,6 +185,7 @@ object ByteCodecs { } if (j < dstlen) src(j) = out.toByte } + dstlen } def encode(xs: Array[Byte]): Array[Byte] = avoidZero(encode8to7(xs)) @@ -192,8 +193,8 @@ object ByteCodecs { @deprecated("use 1-argument version instead") def decode(xs: Array[Byte], dstlen: Int) { decode(xs) } - /** Destructively decode array xs */ - def decode(xs: Array[Byte]) { + /** Destructively decode array xs and returns the length of the decoded array */ + def decode(xs: Array[Byte]): Int = { val len = regenerateZero(xs) decode7to8(xs, len) } |