All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.zving.framework.thirdparty.asm.AnnotationWriter Maven / Gradle / Ivy
package com.zving.framework.thirdparty.asm;
// fix
final class AnnotationWriter extends AnnotationVisitor {
AnnotationWriter(ClassWriter cw, boolean named, ByteVector bv, ByteVector parent, int offset) {
super(0x40000);
this.cw = cw;
this.named = named;
this.bv = bv;
this.parent = parent;
this.offset = offset;
}
public void visit(String name, Object value) {
size++;
if (named)
bv.putShort(cw.newUTF8(name));
if (value instanceof String)
bv.put12(115, cw.newUTF8((String) value));
else if (value instanceof Byte)
bv.put12(66, cw.newInteger(((Byte) value).byteValue()).index);
else if (value instanceof Boolean) {
int v = ((Boolean) value).booleanValue() ? 1 : 0;
bv.put12(90, cw.newInteger(v).index);
} else if (value instanceof Character)
bv.put12(67, cw.newInteger(((Character) value).charValue()).index);
else if (value instanceof Short)
bv.put12(83, cw.newInteger(((Short) value).shortValue()).index);
else if (value instanceof Type)
bv.put12(99, cw.newUTF8(((Type) value).getDescriptor()));
else if (value instanceof byte[]) {
byte v[] = (byte[]) value;
bv.put12(91, v.length);
byte abyte0[];
int l1 = (abyte0 = v).length;
for (int j = 0; j < l1; j++) {
byte element = abyte0[j];
bv.put12(66, cw.newInteger(element).index);
}
} else if (value instanceof boolean[]) {
boolean v[] = (boolean[]) value;
bv.put12(91, v.length);
boolean aflag[];
int i2 = (aflag = v).length;
for (int k = 0; k < i2; k++) {
boolean element = aflag[k];
bv.put12(90, cw.newInteger(element ? 1 : 0).index);
}
} else if (value instanceof short[]) {
short v[] = (short[]) value;
bv.put12(91, v.length);
short aword0[];
int j2 = (aword0 = v).length;
for (int l = 0; l < j2; l++) {
short element = aword0[l];
bv.put12(83, cw.newInteger(element).index);
}
} else if (value instanceof char[]) {
char v[] = (char[]) value;
bv.put12(91, v.length);
char ac[];
int k2 = (ac = v).length;
for (int i1 = 0; i1 < k2; i1++) {
char element = ac[i1];
bv.put12(67, cw.newInteger(element).index);
}
} else if (value instanceof int[]) {
int v[] = (int[]) value;
bv.put12(91, v.length);
int ai[];
int l2 = (ai = v).length;
for (int j1 = 0; j1 < l2; j1++) {
int element = ai[j1];
bv.put12(73, cw.newInteger(element).index);
}
} else if (value instanceof long[]) {
long v[] = (long[]) value;
bv.put12(91, v.length);
long al[];
int l3 = (al = v).length;
for (int i3 = 0; i3 < l3; i3++) {
long element = al[i3];
bv.put12(74, cw.newLong(element).index);
}
} else if (value instanceof float[]) {
float v[] = (float[]) value;
bv.put12(91, v.length);
float af[];
int j3 = (af = v).length;
for (int k1 = 0; k1 < j3; k1++) {
float element = af[k1];
bv.put12(70, cw.newFloat(element).index);
}
} else if (value instanceof double[]) {
double v[] = (double[]) value;
bv.put12(91, v.length);
double ad[];
int i4 = (ad = v).length;
for (int k3 = 0; k3 < i4; k3++) {
double element = ad[k3];
bv.put12(68, cw.newDouble(element).index);
}
} else {
Item i = cw.newConstItem(value);
bv.put12(".s.IFJDCS".charAt(i.type), i.index);
}
}
public void visitEnum(String name, String desc, String value) {
size++;
if (named)
bv.putShort(cw.newUTF8(name));
bv.put12(101, cw.newUTF8(desc)).putShort(cw.newUTF8(value));
}
public AnnotationVisitor visitAnnotation(String name, String desc) {
size++;
if (named)
bv.putShort(cw.newUTF8(name));
bv.put12(64, cw.newUTF8(desc)).putShort(0);
return new AnnotationWriter(cw, true, bv, bv, bv.length - 2);
}
public AnnotationVisitor visitArray(String name) {
size++;
if (named)
bv.putShort(cw.newUTF8(name));
bv.put12(91, 0);
return new AnnotationWriter(cw, false, bv, bv, bv.length - 2);
}
public void visitEnd() {
if (parent != null) {
byte data[] = parent.data;
data[offset] = (byte) (size >>> 8);
data[offset + 1] = (byte) size;
}
}
int getSize() {
int size = 0;
for (AnnotationWriter aw = this; aw != null; aw = aw.next)
size += aw.bv.length;
return size;
}
void put(ByteVector out) {
int n = 0;
int size = 2;
AnnotationWriter aw = this;
AnnotationWriter last = null;
for (; aw != null; aw = aw.next) {
n++;
size += aw.bv.length;
aw.visitEnd();
aw.prev = last;
last = aw;
}
out.putInt(size);
out.putShort(n);
for (aw = last; aw != null; aw = aw.prev)
out.putByteArray(aw.bv.data, 0, aw.bv.length);
}
static void put(AnnotationWriter panns[], int off, ByteVector out) {
int size = 1 + 2 * (panns.length - off);
for (int i = off; i < panns.length; i++)
size += panns[i] != null ? panns[i].getSize() : 0;
out.putInt(size).putByte(panns.length - off);
for (int i = off; i < panns.length; i++) {
AnnotationWriter aw = panns[i];
AnnotationWriter last = null;
int n = 0;
for (; aw != null; aw = aw.next) {
n++;
aw.visitEnd();
aw.prev = last;
last = aw;
}
out.putShort(n);
for (aw = last; aw != null; aw = aw.prev)
out.putByteArray(aw.bv.data, 0, aw.bv.length);
}
}
private final int offset;
private final ClassWriter cw;
private int size;
private final boolean named;
private final ByteVector bv;
private final ByteVector parent;
AnnotationWriter next;
AnnotationWriter prev;
}