internal FieldWriter(ClassWriter cw, int access, String name, String desc, String signature, Object value) : base(Opcodes.ASM5) { if (cw.firstField == null) { cw.firstField = this; } else { cw.lastField.fv = this; } cw.lastField = this; this.cw = cw; this.access = access; this.name = cw.newUTF8(name); this.desc = cw.newUTF8(desc); if (ClassReader.SIGNATURES && signature != null) { this.signature = cw.newUTF8(signature); } if (value != null) { this.value = cw.newConstItem(value).index; } }
public override void visit(String name, Object value) { ++size; if (named) { bv.putShort(cw.newUTF8(name)); } if (value is String) { bv.put12('s', cw.newUTF8((String)value)); } else if (value is byte) { bv.put12('B', cw.newInteger((byte)value).index); } else if (value is bool) { int v = (bool)value ? 1 : 0; bv.put12('Z', cw.newInteger(v).index); } else if (value is char) { bv.put12('C', cw.newInteger((char)value).index); } else if (value is short) { bv.put12('S', cw.newInteger((short)value).index); } else if (value is Type) { bv.put12('c', cw.newUTF8(((Type)value).getDescriptor())); } else if (value is byte[]) { byte[] v = (byte[])value; bv.put12('[', v.Length); for (int i = 0; i < v.Length; i++) { bv.put12('B', cw.newInteger(v[i]).index); } } else if (value is bool[]) { bool[] v = (bool[])value; bv.put12('[', v.Length); for (int i = 0; i < v.Length; i++) { bv.put12('Z', cw.newInteger(v[i] ? 1 : 0).index); } } else if (value is short[]) { short[] v = (short[])value; bv.put12('[', v.Length); for (int i = 0; i < v.Length; i++) { bv.put12('S', cw.newInteger(v[i]).index); } } else if (value is char[]) { char[] v = (char[])value; bv.put12('[', v.Length); for (int i = 0; i < v.Length; i++) { bv.put12('C', cw.newInteger(v[i]).index); } } else if (value is int[]) { int[] v = (int[])value; bv.put12('[', v.Length); for (int i = 0; i < v.Length; i++) { bv.put12('I', cw.newInteger(v[i]).index); } } else if (value is long[]) { long[] v = (long[])value; bv.put12('[', v.Length); for (int i = 0; i < v.Length; i++) { bv.put12('J', cw.newLong(v[i]).index); } } else if (value is float[]) { float[] v = (float[])value; bv.put12('[', v.Length); for (int i = 0; i < v.Length; i++) { bv.put12('F', cw.newFloat(v[i]).index); } } else if (value is double[]) { double[] v = (double[])value; bv.put12('[', v.Length); for (int i = 0; i < v.Length; i++) { bv.put12('D', cw.newDouble(v[i]).index); } } else { Item i = cw.newConstItem(value); bv.put12(".s.IFJDCS".charAt(i.type), i.index); } }