/** * {@inheritDoc} */ public int getRequiredVariablePadding() { return StackSize.ZERO.getSize(); } }
/** * Creates a new method return manipulation. * * @param returnOpcode The opcode of this operation. * @param stackSize The operand stack size change that is implied by this operation. */ MethodReturn(int returnOpcode, StackSize stackSize) { this.returnOpcode = returnOpcode; size = stackSize.toDecreasingSize(); }
/** * Creates a null constant. * * @param size The size of the constant on the operand stack. */ NullConstant(StackSize size) { this.size = size.toIncreasingSize(); }
/** * {@inheritDoc} */ public int prepare(MethodVisitor methodVisitor) { StackSize stackSize; if (!instrumentedMethod.isStatic()) { methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); methodVisitor.visitVarInsn(Opcodes.ASTORE, instrumentedMethod.getStackSize() + exitType.getStackSize().getSize() + StackSize.of(namedTypes.values()) + enterType.getStackSize().getSize()); stackSize = StackSize.SINGLE; } else { stackSize = StackSize.ZERO; } for (ParameterDescription parameterDescription : instrumentedMethod.getParameters()) { Type type = Type.getType(parameterDescription.getType().asErasure().getDescriptor()); methodVisitor.visitVarInsn(type.getOpcode(Opcodes.ILOAD), parameterDescription.getOffset()); methodVisitor.visitVarInsn(type.getOpcode(Opcodes.ISTORE), instrumentedMethod.getStackSize() + exitType.getStackSize().getSize() + StackSize.of(namedTypes.values()) + enterType.getStackSize().getSize() + parameterDescription.getOffset()); stackSize = stackSize.maximum(parameterDescription.getType().getStackSize()); } return stackSize.getSize(); } }
/** * {@inheritDoc} */ public int getStackSize() { return StackSize.of(this); }
/** * {@inheritDoc} */ public StackSize getStackSize() { return StackSize.of(type); }
/** * {@inheritDoc} */ public int getRequiredVariablePadding() { return StackSize.ZERO.getSize(); } }
/** * Creates a new duplication. * * @param stackSize The size representing the impact of applying the duplication onto the operand stack. * @param opcode The opcode that represents the manipulation. */ Duplication(StackSize stackSize, int opcode) { size = stackSize.toIncreasingSize(); this.opcode = opcode; }
/** * Creates a new removal stack manipulation. * * @param stackSize The size impact of the removal onto the operand stack. * @param opcode The opcode to execute for the removal. */ Removal(StackSize stackSize, int opcode) { size = stackSize.toDecreasingSize(); this.opcode = opcode; }
/** * Creates a new field access. * * @param putterOpcode The opcode for setting a field value. * @param getterOpcode The opcode for getting a field value. * @param targetSizeChange The amount of operand slots this field access operation consumes when it is applied * before eventually adding new values onto the operand stack. */ FieldAccess(int putterOpcode, int getterOpcode, StackSize targetSizeChange) { this.putterOpcode = putterOpcode; this.getterOpcode = getterOpcode; this.targetSizeChange = targetSizeChange.getSize(); }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { return StackSize.ZERO.toIncreasingSize(); } }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { methodVisitor.visitInsn(opcode); return stackSize.toDecreasingSize(); } }