• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MethodVisitor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.bytebuddy.jar.asm.MethodVisitor的典型用法代码示例。如果您正苦于以下问题:Java MethodVisitor类的具体用法?Java MethodVisitor怎么用?Java MethodVisitor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MethodVisitor类属于net.bytebuddy.jar.asm包,在下文中一共展示了MethodVisitor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Context implementationContext) {
  final int opcode;
  Size size = new Size(-StackSize.of(variableType).getSize() * 2, 0);
  if (variableType == int.class || variableType == boolean.class) {
    opcode = Opcodes.IF_ICMPEQ;
  } else if (variableType == long.class) {
    methodVisitor.visitInsn(Opcodes.LCMP);
    opcode = Opcodes.IFEQ;
  } else if (variableType == float.class) {
    methodVisitor.visitInsn(Opcodes.FCMPG);
    opcode = Opcodes.IFEQ;
  } else if (variableType == double.class) {
    methodVisitor.visitInsn(Opcodes.DCMPG);
    opcode = Opcodes.IFEQ;
  } else {
    // Reference type comparison assumes the result of Object.equals is already on the stack.
    opcode = Opcodes.IFNE;
    // There is only a boolean on the stack, so we only consume one item, unlike the others that
    // consume both.
    size = new Size(-1, 0);
  }
  methodVisitor.visitJumpInsn(opcode, destination);
  return size;
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:26,代码来源:IfEqual.java


示例2: visitFrame

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
private void visitFrame(
    MethodVisitor mv, boolean localsIncludeReturn, @Nullable String stackTop) {
  boolean hasReturnLocal = (returnVarIndex != null) && localsIncludeReturn;

  Type[] localTypes = Type.getArgumentTypes(instrumentedMethod.getDescriptor());
  Object[] locals = new Object[1 + localTypes.length + (hasReturnLocal ? 1 : 0)];
  locals[0] = instrumentedMethod.getReceiverType().asErasure().getInternalName();
  for (int i = 0; i < localTypes.length; i++) {
    locals[i + 1] = describeType(localTypes[i]);
  }
  if (hasReturnLocal) {
    locals[locals.length - 1] = returnType.getInternalName();
  }

  Object[] stack = stackTop == null ? new Object[] {} : new Object[] {stackTop};

  mv.visitFrame(Opcodes.F_NEW, locals.length, locals, stack.length, stack);
}
 
开发者ID:apache,项目名称:beam,代码行数:19,代码来源:ByteBuddyDoFnInvokerFactory.java


示例3: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext) {
  switch (variableIndex) {
    case 0:
      methodVisitor.visitInsn(storeOpcode + storeOpcodeShortcutOffset);
      break;
    case 1:
      methodVisitor.visitInsn(storeOpcode + storeOpcodeShortcutOffset + 1);
      break;
    case 2:
      methodVisitor.visitInsn(storeOpcode + storeOpcodeShortcutOffset + 2);
      break;
    case 3:
      methodVisitor.visitInsn(storeOpcode + storeOpcodeShortcutOffset + 3);
      break;
    default:
      methodVisitor.visitVarInsn(storeOpcode, variableIndex);
      break;
  }
  return size;
}
 
开发者ID:bramp,项目名称:unsafe,代码行数:21,代码来源:MethodVariableStore.java


示例4: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
    MethodDescription instrumentedMethod) {

  checkMethodSignature(instrumentedMethod);

  try {
    StackManipulation stack = buildStack();
    StackManipulation.Size finalStackSize = stack.apply(methodVisitor, implementationContext);

    return new Size(finalStackSize.getMaximalSize(),
        instrumentedMethod.getStackSize() + 2); // 2 stack slots for a single local variable

  } catch (NoSuchMethodException | NoSuchFieldException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:bramp,项目名称:unsafe,代码行数:17,代码来源:CopierImplementation.java


示例5: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
                MethodDescription instrumentedMethod) {
    switch (returnType) {
        case REFERENCE:
            return new Size(MethodReturn.REFERENCE.apply(methodVisitor, implementationContext).getMaximalSize(),
                            instrumentedMethod.getStackSize());
        case VOID:
            return new Size(MethodReturn.VOID.apply(methodVisitor, implementationContext).getMaximalSize(),
                            instrumentedMethod.getStackSize());
        case INT:
            return new Size(MethodReturn.INTEGER.apply(methodVisitor, implementationContext).getMaximalSize(),
                            instrumentedMethod.getStackSize());
        default:
            throw new IllegalStateException("Illegal opType");
    }

}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:19,代码来源:ReturnAppender.java


示例6: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
                MethodDescription instrumentedMethod) {
    int numArgs = instrumentedMethod.getParameters().asTypeList().getStackSize();
    /**
     * Load the desired id
     * relative to the method arguments.
     * The idea here would be to load references
     * to declared variables
     */
    //references start with zero if its an instance or zero if its static
    //think of it like an implicit self in python without actually being defined
    int start = instrumentedMethod.isStatic() ? 1 : 0;
    StackManipulation arg0 = MethodVariableAccess.REFERENCE
                    .loadOffset(numArgs + start + OpCodeUtil.getAloadInstructionForReference(refId));
    StackManipulation.Size size = arg0.apply(methodVisitor, implementationContext);
    return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize());
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:19,代码来源:LoadDeclaredInternalReference.java


示例7: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public ByteCodeAppender.Size apply(MethodVisitor mv, Implementation.Context p2, MethodDescription p3) {
	mv.visitVarInsn(ALOAD, 0);
	mv.visitMethodInsn(INVOKESPECIAL, "br/com/brjdevs/highhacks/eventbus/ASMEventHandler", "<init>", "()V", false);
	if (!isStatic) {
		mv.visitVarInsn(ALOAD, 0);
		mv.visitVarInsn(ALOAD, 1);
		mv.visitFieldInsn(PUTFIELD, thisClass, "instance", "Ljava/lang/Object;");
	}
	mv.visitInsn(RETURN);
	mv.visitMaxs(2, 2);
	return new ByteCodeAppender.Size(2, 2);
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:14,代码来源:ASMEventHandlerConstructor.java


示例8: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public ByteCodeAppender.Size apply(MethodVisitor mv, Implementation.Context implementationContext, MethodDescription instrumentedMethod) {
	mv.visitVarInsn(ALOAD, 0);
	if (!isStatic) {
		mv.visitFieldInsn(GETFIELD, thisClass, "instance", "Ljava/lang/Object;");
		mv.visitTypeInsn(CHECKCAST, listenerClass);
	}
	mv.visitVarInsn(ALOAD, 1);
	mv.visitTypeInsn(CHECKCAST, eventClass);
	mv.visitMethodInsn(isStatic ? INVOKESTATIC : INVOKEVIRTUAL, listenerClass, callback.getName(), Type.getMethodDescriptor(callback), false);
	mv.visitInsn(RETURN);
	mv.visitMaxs(2, 2);
	return new Size(2, 2);
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:15,代码来源:ASMEventHandlerHandle.java


示例9: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(
    MethodVisitor methodVisitor,
    Context implementationContext,
    MethodDescription instrumentedMethod) {
  Map<String, FieldDescription> fieldsByName = CodeGenUtil.fieldsByName(implementationContext);
  StackManipulation.Size operandStackSize =
      new StackManipulation.Compound(
              new TextConstant(unserializedFieldValue),
              SerializeSupport_serializeString,
              FieldAccess.forField(fieldsByName.get(fieldName)).write())
          .apply(methodVisitor, implementationContext);
  return new Size(operandStackSize.getMaximalSize(), instrumentedMethod.getStackSize());
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:15,代码来源:SetSerializedFieldName.java


示例10: appender

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public ByteCodeAppender appender(final Target implementationTarget) {
  return new ByteCodeAppender() {
    @Override
    public Size apply(
        MethodVisitor methodVisitor,
        Context implementationContext,
        MethodDescription instrumentedMethod) {
      StackManipulation.Size size =
          new StackManipulation.Compound(
                  // Load the this reference
                  MethodVariableAccess.REFERENCE.loadFrom(0),
                  // Load the delegate argument
                  MethodVariableAccess.REFERENCE.loadFrom(1),
                  // Invoke the super constructor (default constructor of Object)
                  MethodInvocation.invoke(
                      new TypeDescription.ForLoadedType(DoFnInvokerBase.class)
                          .getDeclaredMethods()
                          .filter(
                              ElementMatchers.isConstructor()
                                  .and(ElementMatchers.takesArguments(DoFn.class)))
                          .getOnly()),
                  // Return void.
                  MethodReturn.VOID)
              .apply(methodVisitor, implementationContext);
      return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize());
    }
  };
}
 
开发者ID:apache,项目名称:beam,代码行数:30,代码来源:ByteBuddyDoFnInvokerFactory.java


示例11: appender

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public ByteCodeAppender appender(final Target implementationTarget) {
  return new ByteCodeAppender() {
    @Override
    public Size apply(
        MethodVisitor methodVisitor,
        Context implementationContext,
        MethodDescription instrumentedMethod) {
      StackManipulation.Size size =
          new StackManipulation.Compound(
                  // Load the this reference
                  MethodVariableAccess.REFERENCE.loadFrom(0),
                  // Invoke the super constructor (default constructor of Object)
                  MethodInvocation.invoke(
                      new TypeDescription.ForLoadedType(Object.class)
                          .getDeclaredMethods()
                          .filter(
                              ElementMatchers.isConstructor()
                                  .and(ElementMatchers.takesArguments(0)))
                          .getOnly()),
                  // Load the this reference
                  MethodVariableAccess.REFERENCE.loadFrom(0),
                  // Load the delegate argument
                  MethodVariableAccess.REFERENCE.loadFrom(1),
                  // Assign the delegate argument to the delegate field
                  FieldAccess.forField(
                          implementationTarget
                              .getInstrumentedType()
                              .getDeclaredFields()
                              .filter(ElementMatchers.named(FN_DELEGATE_FIELD_NAME))
                              .getOnly())
                      .write(),
                  // Return void.
                  MethodReturn.VOID)
              .apply(methodVisitor, implementationContext);
      return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize());
    }
  };
}
 
开发者ID:apache,项目名称:beam,代码行数:40,代码来源:ByteBuddyOnTimerInvokerFactory.java


示例12: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
                MethodDescription instrumentedMethod) {
    //initialize the stack with the array access with this as reference 0 and the array (first argument) as reference 1
    StackManipulation compound = assignOperation();
    StackManipulation.Size size = compound.apply(methodVisitor, implementationContext);
    //resolve the opType to store in the array and retrieve the load command
    StackManipulation store = ArrayAccess.of(typePool.describe("int").resolve()).load();
    size = size.aggregate(store.apply(methodVisitor, implementationContext));
    return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize());
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:12,代码来源:RelativeRetrieveArrayValueAppender.java


示例13: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
                MethodDescription instrumentedMethod) {
    //resolve the opType to store in the array and retrieve the store command
    StackManipulation store = ArrayAccess.of(typePool.describe("int").resolve()).load();
    StackManipulation.Size size = store.apply(methodVisitor, implementationContext);
    return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize());
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:9,代码来源:ArrayRetrieve.java


示例14: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
                MethodDescription instrumentedMethod) {
    //resolve the opType to store in the array and retrieve the store command
    StackManipulation store = ArrayAccess.of(typePool.describe("int").resolve()).store();
    StackManipulation.Size size = store.apply(methodVisitor, implementationContext);
    return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize());
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:9,代码来源:AssignOpAppender.java


示例15: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
                MethodDescription instrumentedMethod) {
    //initialize the stack with the array access with this as reference 0 and the array (first argument) as reference 1
    StackManipulation compound = assignOperation();
    StackManipulation.Size size = compound.apply(methodVisitor, implementationContext);
    //resolve the opType to store in the array and retrieve the store command
    StackManipulation store = ArrayAccess.of(typePool.describe("int").resolve()).store();
    size = size.aggregate(store.apply(methodVisitor, implementationContext));
    return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize());
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:12,代码来源:RelativeAssignNoValueArrayValueAppender.java


示例16: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
                MethodDescription instrumentedMethod) {
    //initialize the stack with the array access with this as reference 0 and the array (first argument) as reference 1
    StackManipulation compound = assignOperation();
    StackManipulation.Size size = compound.apply(methodVisitor, implementationContext);
    //resolve the opType to store in the array and retrieve the store command
    StackManipulation store = ArrayAccess.of(typePool.describe("int").resolve()).store();
    size = size.aggregate(store.apply(methodVisitor, implementationContext));
    //set the return opType (ALWAYS REMEMBER TO DO THIS)
    StackManipulation returnOp = MethodReturn.VOID;
    size = size.aggregate(returnOp.apply(methodVisitor, implementationContext));
    return new Size(size.getMaximalSize(), instrumentedMethod.getStackSize());
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:15,代码来源:AssignArrayValueAppender.java


示例17: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
                MethodDescription instrumentedMethod) {
    StackManipulation createArray = RelativeIntArrayCreation.intCreationOfLength(length);
    StackManipulation.Compound size = new StackManipulation.Compound(createArray);

    StackManipulation.Size size1 = size.apply(methodVisitor, implementationContext);
    return new Size(size1.getMaximalSize(), instrumentedMethod.getStackSize());

}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:11,代码来源:RelativeCreateArrayByteCodeAppender.java


示例18: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
                MethodDescription instrumentedMethod) {
    StackManipulation createArray = IntArrayCreation.intCreationOfLength(length);
    StackManipulation.Compound size = new StackManipulation.Compound(createArray);

    StackManipulation.Size size1 = size.apply(methodVisitor, implementationContext);
    return new Size(size1.getMaximalSize(), instrumentedMethod.getStackSize());

}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:11,代码来源:CreateArrayByteCodeAppender.java


示例19: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
                MethodDescription instrumentedMethod) {
    StackManipulation createArray = IntArrayCreation.intCreationOfLength(length);
    StackManipulation.Compound size = new StackManipulation.Compound(createArray, MethodReturn.REFERENCE);

    StackManipulation.Size size1 = size.apply(methodVisitor, implementationContext);
    return new Size(size1.getMaximalSize(), instrumentedMethod.getStackSize());

}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:11,代码来源:CreateArrayByteCodeAppender.java


示例20: apply

import net.bytebuddy.jar.asm.MethodVisitor; //导入依赖的package包/类
@Override
public Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext,
                MethodDescription instrumentedMethod) {
    StackManipulation.Size size = IntegerConstant.forValue(length).apply(methodVisitor, implementationContext);
    methodVisitor.visitIntInsn(Opcodes.NEWARRAY, Opcodes.T_INT);
    return new Size(size.getMaximalSize(), size.getSizeImpact());
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:8,代码来源:SimpleCreateArrayByteCodeAppender.java



注:本文中的net.bytebuddy.jar.asm.MethodVisitor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DOM2Helper类代码示例发布时间:2022-05-23
下一篇:
Java ProviderWithDependencies类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap