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/fjbg/ch | |
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/fjbg/ch')
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java b/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java index 911acd18da..4fa048177c 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JConstantPool.java @@ -187,6 +187,10 @@ public class JConstantPool { return addEntry(new Utf8Entry(value)); } + public int addUtf8(byte[] value) { + return addEntry(new Utf8Entry(value)); + } + public String lookupUtf8(int index) { Utf8Entry entry = (Utf8Entry)lookupEntry(index); return entry.getValue(); @@ -344,22 +348,46 @@ public class JConstantPool { public class Utf8Entry extends ChildlessEntry implements Entry { private final String value; - public Utf8Entry(String value) { this.value = value.intern(); } + private final byte[] bytes; + public Utf8Entry(String value) { + this.value = value.intern(); + this.bytes = null; + } public Utf8Entry(DataInputStream stream) throws IOException { this(stream.readUTF()); } + public Utf8Entry(byte[] bytes) { + this.bytes = bytes; + this.value = null; + } - public int hashCode() { return value.hashCode(); } + public int hashCode() { + if (bytes != null) return bytes.hashCode(); + return value.hashCode(); + } public boolean equals(Object o) { - return o instanceof Utf8Entry && ((Utf8Entry)o).value == value; + boolean isEqual = o instanceof Utf8Entry; + if (bytes != null) { + isEqual = isEqual && ((Utf8Entry)o).bytes == bytes; + } + else { + isEqual = isEqual && ((Utf8Entry)o).value == value; + } + return isEqual; } public int getTag() { return CONSTANT_Utf8; } public String getValue() { return value; } + public byte[] getBytes() { return bytes; } public int getSize() { return 1; } public void writeContentsTo(DataOutputStream stream) throws IOException { - stream.writeUTF(value); + if (bytes != null) { + stream.writeShort(bytes.length); + stream.write(bytes); + } + else + stream.writeUTF(value); } } |