/** * Create an ASM attribute from an Soot attribute * @param attr Soot attribute * @return ASM attribute */ public static org.objectweb.asm.Attribute createASMAttribute(Attribute attr) { final Attribute a = attr; return new org.objectweb.asm.Attribute( attr.getName()) { @Override protected ByteVector write(final ClassWriter cw, final byte[] code, final int len, final int maxStack, final int maxLocals) { ByteVector result = new ByteVector(); result.putByteArray(a.getValue(), 0, a.getValue().length); return result; } }; }
private void writeTypeInfos( ByteVector bv, ClassWriter cw, List info, int start, int end) { for (int j = start; j < end; j++) { StackMapType typeInfo = (StackMapType) info.get(j); bv.putByte(typeInfo.getType()); switch (typeInfo.getType()) { case StackMapType.ITEM_Object: // bv.putShort(cw.newClass(typeInfo.getObject())); break; case StackMapType.ITEM_Uninitialized: // bv.putShort(typeInfo.getLabel().getOffset()); break; } } }
private void writeTypeInfo(ByteVector bv, ClassWriter cw, List info, int max) { if (max > StackMapAttribute.MAX_SIZE) { bv.putInt(info.size()); } else { bv.putShort(info.size()); } for (int j = 0; j < info.size(); j++) { StackMapType typeInfo = (StackMapType) info.get(j); bv.putByte(typeInfo.getType()); switch (typeInfo.getType()) { case StackMapType.ITEM_Object: // bv.putShort(cw.newClass(typeInfo.getObject())); break; case StackMapType.ITEM_Uninitialized: // bv.putShort(typeInfo.getLabel().getOffset()); break; } } }
protected ByteVector write( ClassWriter cw, byte[] code, int len, int maxStack, int maxLocals) { ByteVector bv = new ByteVector(); if (code != null && code.length > MAX_SIZE) { // TODO verify value bv.putInt(frames.size()); } else { bv.putShort(frames.size()); } for (int i = 0; i < frames.size(); i++) { writeFrame((StackMapFrame) frames.get(i), cw, maxStack, maxLocals, bv); } return bv; }
private void writeSize(int delta, ByteVector bv, boolean isExt) { if (isExt) { bv.putInt(delta); } else { bv.putShort(delta); } }
private void writeFrame( StackMapFrame frame, ClassWriter cw, int maxStack, int maxLocals, ByteVector bv) { bv.putShort(frame.label.getOffset()); writeTypeInfo(bv, cw, frame.locals, maxLocals); writeTypeInfo(bv, cw, frame.stack, maxStack); }
protected ByteVector write(ClassWriter arg0, byte[] arg1, int arg2, int arg3, int arg4) { return new ByteVector(); }
protected ByteVector write( final ClassWriter cw, final byte[] code, final int len, final int maxStack, final int maxLocals) { ByteVector bv = new ByteVector(); bv.putInt(retroweaverBuildNumber); bv.putInt(originalClassVersion); bv.putLong(timestamp); return bv; }
@Override protected ByteVector write( final ClassWriter cw, final byte[] code, final int len, final int maxStack, final int maxLocals) { return new ByteVector(); }
@Override protected ByteVector write( final ClassWriter cw, final byte[] code, final int len, final int maxStack, final int maxLocals) { return new ByteVector().putShort(cw.newUTF8(comment)); }
@Override protected ByteVector write(ClassWriter cw, byte[] code, int len, int maxStack, int maxLocals) { return new ByteVector( 0 ); }
@Override protected ByteVector write(final ClassWriter cw, final byte[] code, final int len, final int maxStack, final int maxLocals) { return new ByteVector(); }
@Override protected ByteVector write(final ClassWriter cw, final byte[] code, final int len, final int maxStack, final int maxLocals) { return new ByteVector().putShort(cw.newUTF8(comment)); }