List of usage examples for org.objectweb.asm.tree InsnList InsnList
InsnList
From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java
License:Open Source License
/** * Generates instructions for a label./* www . ja va 2 s .c om*/ * @param labelNode label to insert * @throws NullPointerException if any argument is {@code null} * @return instructions for a label */ public static InsnList addLabel(LabelNode labelNode) { Validate.notNull(labelNode); InsnList ret = new InsnList(); ret.add(labelNode); return ret; }
From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java
License:Open Source License
/** * Generates instructions for line numbers. This is useful for debugging. For example, you can put a line number of 99999 or some other * special number to denote that the code being executed is instrumented code. Then if a stacktrace happens, you'll know that if * instrumented code was immediately involved. * @param num line number/* w w w. j a v a 2s.co m*/ * @return instructions for a line number * @throws IllegalArgumentException if {@code num < 0} */ public static InsnList lineNumber(int num) { Validate.isTrue(num >= 0); InsnList ret = new InsnList(); LabelNode labelNode = new LabelNode(); ret.add(labelNode); ret.add(new LineNumberNode(num, labelNode)); return ret; }
From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java
License:Open Source License
/** * Generates instructions for printing out a string constant using {@link System#out}. This is useful for debugging. For example, you * can print out lines around your instrumented code to make sure that what you think is being run is actually being run. * @param text text to print out/*from w w w . j av a 2s . co m*/ * @return instructions to call System.out.println with a string constant * @throws NullPointerException if any argument is {@code null} */ public static InsnList debugPrint(String text) { Validate.notNull(text); InsnList ret = new InsnList(); ret.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;")); ret.add(new LdcInsnNode(text)); ret.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false)); return ret; }
From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java
License:Open Source License
/** * Generates instructions to pop an item off the stack. * @return instructions for a pop/*from ww w. ja v a2 s .c om*/ */ public static InsnList pop() { InsnList ret = new InsnList(); ret.add(new InsnNode(Opcodes.POP)); return ret; }
From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java
License:Open Source License
/** * Generates instructions to pop {@code count} items off the stack. * @param count number of items to pop// ww w. ja v a2s .co m * @return instructions for a pop * @throws IllegalArgumentException if any numeric argument is negative */ public static InsnList pop(int count) { Validate.isTrue(count >= 0); InsnList ret = new InsnList(); for (int i = 0; i < count; i++) { ret.add(new InsnNode(Opcodes.POP)); } return ret; }
From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java
License:Open Source License
/** * Generates a MONITORENTER instruction, which consumes an Object from the top of the stack. * @return instructions for a pop// ww w. j a v a 2s .c o m */ public static InsnList monitorEnter() { InsnList ret = new InsnList(); ret.add(new InsnNode(Opcodes.MONITORENTER)); return ret; }
From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java
License:Open Source License
/** * Generates a MONITOREXIT instruction, which consumes an Object from the top of the stack. * @return instructions for a pop/*from w ww . j ava 2s .c o m*/ */ public static InsnList monitorExit() { InsnList ret = new InsnList(); ret.add(new InsnNode(Opcodes.MONITOREXIT)); return ret; }
From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java
License:Open Source License
/** * Generates instructions to push an integer constant on to the stack. * @param i integer constant to push/*www . j av a 2s . c om*/ * @return instructions to push an integer constant */ public static InsnList loadIntConst(int i) { InsnList ret = new InsnList(); ret.add(new LdcInsnNode(i)); return ret; }
From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java
License:Open Source License
/** * Generates instruction to push a string constant on to the stack. * @param s string constant to push/*from w w w . java 2 s . com*/ * @return instructions to push a string constant * @throws NullPointerException if any argument is {@code null} */ public static InsnList loadStringConst(String s) { Validate.notNull(s); InsnList ret = new InsnList(); ret.add(new LdcInsnNode(s)); return ret; }
From source file:com.offbynull.coroutines.instrumenter.asm.InstructionUtils.java
License:Open Source License
/** * Generates instruction to push a null on to the stack. * @return instructions to push a null//from w ww . ja v a 2 s .c o m */ public static InsnList loadNull() { InsnList ret = new InsnList(); ret.add(new InsnNode(Opcodes.ACONST_NULL)); return ret; }