/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { return StackSize.ZERO.toIncreasingSize(); } }
/** * 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 null constant. * * @param size The size of the constant on the operand stack. */ NullConstant(StackSize size) { this.size = size.toIncreasingSize(); }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { methodVisitor.visitLdcInsn(text); return StackSize.SINGLE.toIncreasingSize(); } }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { methodVisitor.visitVarInsn(loadOpcode, offset); return size.toIncreasingSize(); } }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { methodVisitor.visitInsn(opcode); return stackSize.toIncreasingSize(); } }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, typeDescription.getInternalName()); return StackSize.ZERO.toIncreasingSize(); } }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { methodVisitor.visitLdcInsn(javaConstant.asConstantPoolValue()); return StackSize.SINGLE.toIncreasingSize(); } }
/** * Creates a new primitive unboxing delegate. * * @param wrapperType The wrapper type of the represented primitive type. * @param primitiveType The represented primitive type. * @param sizeDifference The size difference between the wrapper type and its primitive value. * @param unboxingMethodName The name of the method for unboxing a wrapper value to its primitive value. * @param unboxingMethodDescriptor The descriptor of the method for unboxing a wrapper value to its primitive value. */ PrimitiveUnboxingDelegate(Class<?> wrapperType, Class<?> primitiveType, StackSize sizeDifference, String unboxingMethodName, String unboxingMethodDescriptor) { this.size = sizeDifference.toIncreasingSize(); this.wrapperType = TypeDescription.ForLoadedType.of(wrapperType); this.primitiveType = TypeDescription.ForLoadedType.of(primitiveType); this.unboxingMethodName = unboxingMethodName; this.unboxingMethodDescriptor = unboxingMethodDescriptor; }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { methodVisitor.visitInsn(loadOpcode); return stackSize.toIncreasingSize().aggregate(new Size(-2, 0)); } }
/** * {@inheritDoc} */ public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) { Size size = IntegerConstant.forValue(stackManipulations.size()).apply(methodVisitor, implementationContext); // The array's construction does not alter the stack's size. size = size.aggregate(arrayCreator.apply(methodVisitor, implementationContext)); int index = 0; for (StackManipulation stackManipulation : stackManipulations) { methodVisitor.visitInsn(Opcodes.DUP); size = size.aggregate(StackSize.SINGLE.toIncreasingSize()); size = size.aggregate(IntegerConstant.forValue(index++).apply(methodVisitor, implementationContext)); size = size.aggregate(stackManipulation.apply(methodVisitor, implementationContext)); methodVisitor.visitInsn(arrayCreator.getStorageOpcode()); size = size.aggregate(sizeDecrease); } return size; } }
/** * Creates a new method variable access for a given JVM type. * * @param storeOpcode The opcode for loading this variable. * @param storeOpcodeShortcutOffset The offset for any shortcut opcode that allows to load a variable from a low * range index, such as {@code ASTORE_0}, {@code ISTORE_0} etc. * @param stackSize The size of the JVM type. */ MethodVariableStore(int storeOpcode, int storeOpcodeShortcutOffset, StackSize stackSize) { this.storeOpcode = storeOpcode; this.storeOpcodeShortcutOffset = storeOpcodeShortcutOffset; this.size = stackSize.toIncreasingSize(); }
/** * Creates a new method variable access for a given JVM type. * * @param storeOpcode The opcode for loading this variable. * @param storeOpcodeShortcutOffset The offset for any shortcut opcode that allows to load a * variable from a low range index, such as {@code ASTORE_0}, * {@code ISTORE_0} etc. * @param stackSize The size of the JVM type. */ MethodVariableStore(int storeOpcode, int storeOpcodeShortcutOffset, StackSize stackSize) { this.storeOpcode = storeOpcode; this.storeOpcodeShortcutOffset = storeOpcodeShortcutOffset; this.size = stackSize.toIncreasingSize(); }