public final void visitTableSwitchInsn( int min, int max, Label dflt, Label[] labels) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "min", "min", "", Integer.toString(min)); attrs.addAttribute("", "max", "max", "", Integer.toString(max)); attrs.addAttribute("", "dflt", "dflt", "", getLabel(dflt)); String o = AbstractVisitor.OPCODES[Opcodes.TABLESWITCH]; addStart(o, attrs); for (int i = 0; i < labels.length; i++) { AttributesImpl att2 = new AttributesImpl(); att2.addAttribute("", "name", "name", "", getLabel(labels[i])); addElement("label", att2); } addEnd(o); }
public final void visitLookupSwitchInsn( Label dflt, int[] keys, Label[] labels) { AttributesImpl att = new AttributesImpl(); att.addAttribute("", "dflt", "dflt", "", getLabel(dflt)); String o = AbstractVisitor.OPCODES[Opcodes.LOOKUPSWITCH]; addStart(o, att); for (int i = 0; i < labels.length; i++) { AttributesImpl att2 = new AttributesImpl(); att2.addAttribute("", "name", "name", "", getLabel(labels[i])); att2.addAttribute("", "key", "key", "", Integer.toString(keys[i])); addElement("label", att2); } addEnd(o); }
@Override public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "name", "name", "", name); attrs.addAttribute("", "desc", "desc", "", desc); attrs.addAttribute("", "bsm", "bsm", "", SAXClassAdapter.encode(bsm.toString())); String o = AbstractVisitor.OPCODES[Opcodes.INVOKEDYNAMIC]; addStart(o, attrs); for (int i = 0; i < bsmArgs.length; i++) { AttributesImpl cattrs = new AttributesImpl(); cattrs.addAttribute("", "cst", "cst", "", SAXClassAdapter.encode(bsmArgs[i].toString())); cattrs.addAttribute("", "desc", "desc", "", Type.getDescriptor(bsmArgs[i].getClass())); addElement("bsmArg", cattrs); } addEnd(o); }
public final void visitFieldInsn( int opcode, String owner, String name, String desc) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "owner", "owner", "", owner); attrs.addAttribute("", "name", "name", "", name); attrs.addAttribute("", "desc", "desc", "", desc); addElement(AbstractVisitor.OPCODES[opcode], attrs); }
public final void visitMethodInsn( int opcode, String owner, String name, String desc) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "owner", "owner", "", owner); attrs.addAttribute("", "name", "name", "", name); attrs.addAttribute("", "desc", "desc", "", desc); addElement(AbstractVisitor.OPCODES[opcode], attrs); }
public final void visitLdcInsn(Object cst) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "cst", "cst", "", SAXClassAdapter.encode(cst.toString())); attrs.addAttribute("", "desc", "desc", "", Type.getDescriptor(cst.getClass())); addElement(AbstractVisitor.OPCODES[Opcodes.LDC], attrs); }
public void test() throws Exception { String n = "org.objectweb.asm.attrs.StackMapTableSample"; InputStream is = StackMapTableAttributeTest.class.getResourceAsStream(StackMapTableAttributeTest.TEST_CLASS); ClassReader cr = new ClassReader(is); StringWriter sw = new StringWriter(); ASMifierClassVisitor cv = new ASMifierClassVisitor(new PrintWriter(sw)); cr.accept(cv, AbstractVisitor.getDefaultAttributes(), false); String generated = sw.toString(); byte[] generatorClassData; try { generatorClassData = ASMifierTest.COMPILER.compile(n, generated); System.err.println(generated); } catch (Exception ex) { System.err.println(generated); System.err.println("------------------"); throw ex; } Class c = ASMifierTest.LOADER.defineClass("asm." + n + "Dump", generatorClassData); Method m = c.getMethod("dump", new Class[0]); byte[] b = (byte[]) m.invoke(null, new Object[0]); assertEquals(cr, new ClassReader(b)); }
public final void visitInsn(int opcode) { addElement(AbstractVisitor.OPCODES[opcode], new AttributesImpl()); }
public final void visitIntInsn(int opcode, int operand) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "value", "value", "", Integer.toString(operand)); addElement(AbstractVisitor.OPCODES[opcode], attrs); }
public final void visitVarInsn(int opcode, int var) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "var", "var", "", Integer.toString(var)); addElement(AbstractVisitor.OPCODES[opcode], attrs); }
public final void visitTypeInsn(int opcode, String desc) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "desc", "desc", "", desc); addElement(AbstractVisitor.OPCODES[opcode], attrs); }
public final void visitJumpInsn(int opcode, Label label) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "label", "label", "", getLabel(label)); addElement(AbstractVisitor.OPCODES[opcode], attrs); }
public final void visitIincInsn(int var, int increment) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "var", "var", "", Integer.toString(var)); attrs.addAttribute("", "inc", "inc", "", Integer.toString(increment)); addElement(AbstractVisitor.OPCODES[Opcodes.IINC], attrs); }
public final void visitMultiANewArrayInsn(String desc, int dims) { AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "desc", "desc", "", desc); attrs.addAttribute("", "dims", "dims", "", Integer.toString(dims)); addElement(AbstractVisitor.OPCODES[Opcodes.MULTIANEWARRAY], attrs); }