- /**
- * Utility wrapper to force ASM to compute frames.
- */
- private enum ComputeFrames implements AsmVisitorWrapper {
- INSTANCE;
-
- @Override
- public int mergeWriter(final int flags) {
- return flags | ClassWriter.COMPUTE_FRAMES;
- }
-
- @Override
- public int mergeReader(final int flags) {
- return flags | ClassWriter.COMPUTE_FRAMES;
- }
-
- @Override
- public ClassVisitor wrap(final TypeDescription td, final ClassVisitor cv, final Implementation.Context ctx,
- final TypePool tp, final FieldList<FieldDescription.InDefinedShape> fields, final MethodList<?> methods,
- final int wflags, final int rflags) {
- return cv;
- }
- }
-
- /**
- * IFEQ opcode invocation, jumping to a particular label.
- */
- private static final class IfEq implements StackManipulation {
- private static final StackManipulation.Size SIZE = new StackManipulation.Size(-1, 0);
-
- private final Label label;
-
- IfEq(final Label label) {
- this.label = requireNonNull(label);
- }
-
- @Override
- public boolean isValid() {
- return true;
- }
-
- @Override
- public StackManipulation.Size apply(final MethodVisitor mv, final Implementation.Context ctx) {
- mv.visitJumpInsn(Opcodes.IFEQ, label);
- return SIZE;
- }
- }
-
- /**
- * A label definition, marking the spot where IfEq should jump.
- */
- private static final class Mark implements StackManipulation {
- private static final StackManipulation.Size SIZE = new StackManipulation.Size(0, 0);
-
- private final Label label;
-
- Mark(final Label label) {
- this.label = requireNonNull(label);
- }
-
- @Override
- public boolean isValid() {
- return true;
- }
-
- @Override
- public StackManipulation.Size apply(final MethodVisitor mv, final Implementation.Context ctx) {
- mv.visitLabel(label);
- return SIZE;
- }
- }
-