当前位置: 首页>>代码示例>>Java>>正文


Java MethodVisitor.visitJumpInsn方法代码示例

本文整理汇总了Java中org.objectweb.asm.MethodVisitor.visitJumpInsn方法的典型用法代码示例。如果您正苦于以下问题:Java MethodVisitor.visitJumpInsn方法的具体用法?Java MethodVisitor.visitJumpInsn怎么用?Java MethodVisitor.visitJumpInsn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.objectweb.asm.MethodVisitor的用法示例。


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

示例1: insertCollectionStart

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void insertCollectionStart(MethodVisitor mv) {
    // collection.iterator()
    mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Collection", "iterator", "()Ljava/util/Iterator;", true);
    mv.visitVarInsn(ASTORE, varArray);

    mv.visitLabel(loopStart);

    // Append a new frame preserving the same locals from the last one
    mv.visitFrame(F_APPEND, 2, new Object[]{BUILDER.getInternalName(), "java/util/Iterator"}, 0, null);

    // if(iterator.hasNext()) break;
    mv.visitVarInsn(ALOAD, varArray);
    mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true);
    mv.visitJumpInsn(IFEQ, loopEnd);

    // (String)iterator.next()
    mv.visitVarInsn(ALOAD, varArray);
    mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true);
    mv.visitTypeInsn(CHECKCAST, Type.getInternalName(member.component));
    mv.visitVarInsn(ASTORE, varObject);
}
 
开发者ID:Guichaguri,项目名称:FastMustache,代码行数:22,代码来源:LoopSection.java

示例2: unboxType

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void unboxType(MethodVisitor methodVisitor, Class<?> primitiveClass) {
    // Float f = (Float) tmp
    // f==null?0:f.floatValue()
    Class<?> boxedType = BOXED_TYPES.get(primitiveClass);
    Type primitiveType = Type.getType(primitiveClass);
    methodVisitor.visitTypeInsn(CHECKCAST, Type.getInternalName(boxedType));
    methodVisitor.visitInsn(DUP);
    Label exit = new Label();
    Label elseValue = new Label();
    methodVisitor.visitJumpInsn(IFNONNULL, elseValue);
    methodVisitor.visitInsn(POP);
    pushDefaultValue(methodVisitor, primitiveClass);
    methodVisitor.visitJumpInsn(GOTO, exit);
    methodVisitor.visitLabel(elseValue);
    methodVisitor.visitMethodInsn(INVOKEVIRTUAL, Type.getInternalName(boxedType), primitiveClass.getSimpleName() + "Value", Type.getMethodDescriptor(primitiveType), false);
    methodVisitor.visitLabel(exit);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:ManagedProxyClassGenerator.java

示例3: visit

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public Object visit(ASTStreamBlock node, Object data) throws CompileException {

  TContextFunc func_ctx = (TContextFunc) getTopContext().getClosestAncestor(AbsType.FORM_FUNC);
  if (func_ctx != null) {
    MethodVisitor mv = func_ctx.getMethodVisitor();
    Label streamblock_end_label = new Label();
    mv.visitLabel(streamblock_end_label);
    node.setStreamBlockEndLabel(streamblock_end_label);

    LangUnitNode stream_node = (LangUnitNode) node.jjtGetParent();
    Debug.assertion(stream_node != null, "stream_node should be valid");

    if (stream_node.isNodeId(JJTSTREAM)) {
      int catchnode_child_idx = stream_node.getChildIdxWithId(JJTCATCH, 0);
      if (catchnode_child_idx != -1) {
        Label stream_end_label = stream_node.getStreamEndLabel();
        Debug.assertion(stream_end_label != null, "stream_end_label should be valid");

        LOG.info("GOTO stream_end_label({}) in stream block end", stream_end_label);
        mv.visitJumpInsn(GOTO, stream_end_label);
      }
    }

  }

  return null;
}
 
开发者ID:Samsung,项目名称:MeziLang,代码行数:29,代码来源:ASTCompileVisitor.java

示例4: addGetMetaClass

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void addGetMetaClass() {
    Label lookup = new Label();

    MethodVisitor methodVisitor = cv.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, "getMetaClass", RETURN_META_CLASS, null, null);
    methodVisitor.visitCode();

    // if (this.metaClass != null) { return this.metaClass; }
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitFieldInsn(Opcodes.GETFIELD, className, META_CLASS_FIELD, META_CLASS_TYPE.getDescriptor());
    methodVisitor.visitInsn(Opcodes.DUP);
    methodVisitor.visitJumpInsn(Opcodes.IFNULL, lookup);
    methodVisitor.visitInsn(Opcodes.ARETURN);

    methodVisitor.visitLabel(lookup);
    methodVisitor.visitFrame(Opcodes.F_NEW, 1, new Object[]{className}, 1, new Object[]{META_CLASS_TYPE.getInternalName()});
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); // for storing to field

    // GroovySystem.getMetaClassRegistry()
    methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, GROOVY_SYSTEM_TYPE.getInternalName(), "getMetaClassRegistry", RETURN_META_CLASS_REGISTRY, false);

    // this.getClass()
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, OBJECT_TYPE.getInternalName(), "getClass", RETURN_CLASS, false);

    // getMetaClass(..)
    methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, META_CLASS_REGISTRY_TYPE.getInternalName(), "getMetaClass", RETURN_META_CLASS_FROM_CLASS, true);

    // this.metaClass = <value>
    methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, className, META_CLASS_FIELD, META_CLASS_TYPE.getDescriptor());

    // return this.metaClass
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitFieldInsn(Opcodes.GETFIELD, className, META_CLASS_FIELD, META_CLASS_TYPE.getDescriptor());

    methodVisitor.visitInsn(Opcodes.ARETURN);
    methodVisitor.visitMaxs(4, 1);
    methodVisitor.visitEnd();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:39,代码来源:MixInLegacyTypesClassLoader.java

示例5: insertArrayStart

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void insertArrayStart(MethodVisitor mv, BytecodeGenerator generator) {
    // Store the array in a local variable
    mv.visitVarInsn(ASTORE, varArray);

    // array.length
    mv.visitVarInsn(ALOAD, varArray);
    mv.visitInsn(ARRAYLENGTH);
    mv.visitVarInsn(ISTORE, varLength);

    // i = 0
    mv.visitInsn(ICONST_0);
    mv.visitVarInsn(ISTORE, varIndex);

    mv.visitLabel(loopStart);

    // Create a compressed frame
    mv.visitFrame(F_FULL, 6, new Object[]{generator.className,
            generator.data.getDataType().getInternalName(), BUILDER.getInternalName(),
            member.clazzType.getInternalName(), INTEGER, INTEGER}, 0, new Object[0]);

    // if(index >= length) break;
    mv.visitVarInsn(ILOAD, varIndex);
    mv.visitVarInsn(ILOAD, varLength);
    mv.visitJumpInsn(IF_ICMPGE, loopEnd);

    // array[i]
    mv.visitVarInsn(ALOAD, varArray);
    mv.visitVarInsn(ILOAD, varIndex);
    mv.visitInsn(AALOAD);
    mv.visitVarInsn(ASTORE, varObject);
}
 
开发者ID:Guichaguri,项目名称:FastMustache,代码行数:32,代码来源:LoopSection.java

示例6: insertArrayEnd

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void insertArrayEnd(MethodVisitor mv) {
    mv.visitInsn(POP);
    mv.visitIincInsn(varIndex, 1);
    mv.visitJumpInsn(GOTO, loopStart);
    mv.visitLabel(loopEnd);
    mv.visitFrame(F_CHOP, 3, null, 0, null);
}
 
开发者ID:Guichaguri,项目名称:FastMustache,代码行数:8,代码来源:LoopSection.java

示例7: accept

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void accept(final MethodVisitor mv) {
    mv.visitJumpInsn(opcode, label.getLabel());
    acceptAnnotations(mv);
}
 
开发者ID:ItzSomebody,项目名称:Spigot-Attribute-Remover,代码行数:6,代码来源:JumpInsnNode.java

示例8: jumpToLabelIfStackEvaluatesToTrue

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void jumpToLabelIfStackEvaluatesToTrue(MethodVisitor methodVisitor, Label label) {
    methodVisitor.visitJumpInsn(IFNE, label);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:4,代码来源:ManagedProxyClassGenerator.java

示例9: applyConventionMappingToGetter

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
public void applyConventionMappingToGetter(PropertyMetaData property, Method getter) throws Exception {
    // GENERATE public <type> <getter>() { return (<type>)getConventionMapping().getConventionValue(super.<getter>(), '<prop>', __<prop>__); }
    String flagName = propFieldName(property);
    String getterName = getter.getName();

    Type returnType = Type.getType(getter.getReturnType());
    String methodDescriptor = Type.getMethodDescriptor(returnType);
    MethodVisitor methodVisitor = visitor.visitMethod(Opcodes.ACC_PUBLIC, getterName, methodDescriptor, null, EMPTY_STRINGS);
    methodVisitor.visitCode();

    if (hasMappingField) {
        // if (conventionMapping == null) { return super.<getter>; }
        methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
        methodVisitor.visitFieldInsn(Opcodes.GETFIELD, generatedType.getInternalName(), MAPPING_FIELD, CONVENTION_MAPPING_FIELD_DESCRIPTOR);
        Label useConvention = new Label();
        methodVisitor.visitJumpInsn(Opcodes.IFNONNULL, useConvention);
        methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
        methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, superclassType.getInternalName(), getterName, methodDescriptor, false);
        methodVisitor.visitInsn(returnType.getOpcode(Opcodes.IRETURN));

        methodVisitor.visitLabel(useConvention);
    }
    // else { return (<type>)getConventionMapping().getConventionValue(super.<getter>(), '<prop>', __<prop>__);  }
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, CONVENTION_AWARE_TYPE.getInternalName(), "getConventionMapping", Type.getMethodDescriptor(CONVENTION_MAPPING_TYPE), true);

    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, superclassType.getInternalName(), getterName, methodDescriptor, false);

    Type boxedType = null;
    if (getter.getReturnType().isPrimitive()) {
        // Box value
        boxedType = Type.getType(JavaReflectionUtil.getWrapperTypeForPrimitiveType(getter.getReturnType()));
        String valueOfMethodDescriptor = Type.getMethodDescriptor(boxedType, returnType);
        methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, boxedType.getInternalName(), "valueOf", valueOfMethodDescriptor, false);
    }

    methodVisitor.visitLdcInsn(property.getName());

    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitFieldInsn(Opcodes.GETFIELD, generatedType.getInternalName(), flagName,
            Type.BOOLEAN_TYPE.getDescriptor());

    String getConventionValueDesc = Type.getMethodDescriptor(ConventionMapping.class.getMethod(
            "getConventionValue", Object.class, String.class, Boolean.TYPE));
    methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, CONVENTION_MAPPING_TYPE.getInternalName(), "getConventionValue", getConventionValueDesc, true);

    if (getter.getReturnType().isPrimitive()) {
        // Unbox value
        methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, boxedType.getInternalName());
        String valueMethodDescriptor = Type.getMethodDescriptor(returnType);
        methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, boxedType.getInternalName(), getter.getReturnType().getName() + "Value", valueMethodDescriptor, false);
    } else {
        // Cast to return type
        methodVisitor.visitTypeInsn(Opcodes.CHECKCAST,
                getter.getReturnType().isArray() ? "[" + returnType.getElementType().getDescriptor()
                        : returnType.getInternalName());
    }

    methodVisitor.visitInsn(returnType.getOpcode(Opcodes.IRETURN));
    methodVisitor.visitMaxs(0, 0);
    methodVisitor.visitEnd();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:64,代码来源:AsmBackedClassGenerator.java

示例10: makeClazz

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private static byte[] makeClazz() {
    // Code generated the class below using asm.
    String clazzName = DeoptimizeOnExceptionTest.class.getName().replace('.', '/');
    final ClassWriter w = new ClassWriter(0);
    w.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC,
                    "t/TestJSR", null, "java/lang/Object",
                    new String[]{"java/lang/Runnable"});
    MethodVisitor mv = w.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, new String[]{});
    mv.visitCode();
    mv.visitVarInsn(Opcodes.ALOAD, 0);
    mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
    mv.visitInsn(Opcodes.RETURN);
    mv.visitMaxs(10, 10);
    mv.visitEnd();

    mv = w.visitMethod(Opcodes.ACC_PUBLIC, "run", "()V", null, null);
    mv.visitCode();
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazzName, "getM", "()Ljava/lang/Object;", false);
    Label l1 = new Label();
    mv.visitJumpInsn(Opcodes.JSR, l1);
    mv.visitInsn(Opcodes.RETURN);

    mv.visitLabel(l1);
    mv.visitVarInsn(Opcodes.ASTORE, 1);

    Label lElse = new Label();
    Label lEnd = new Label();
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/System", "currentTimeMillis", "()J", false);
    mv.visitInsn(Opcodes.POP2);
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazzName, "getM", "()Ljava/lang/Object;", false);
    mv.visitInsn(Opcodes.DUP);
    mv.visitJumpInsn(Opcodes.IFNULL, lElse);
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazzName, "methodA", "()V", false);
    mv.visitJumpInsn(Opcodes.GOTO, lEnd);
    mv.visitLabel(lElse);
    mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazzName, "methodB", "()V", false);
    mv.visitLabel(lEnd);

    mv.visitVarInsn(Opcodes.RET, 1);
    mv.visitMaxs(10, 10);
    mv.visitEnd();
    return w.toByteArray();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:DeoptimizeOnExceptionTest.java

示例11: insertSectionStart

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void insertSectionStart(MethodVisitor mv, BytecodeGenerator generator) {
    mv.visitJumpInsn(inverted ? IFNULL : IFNONNULL, ifEnd);
}
 
开发者ID:Guichaguri,项目名称:FastMustache,代码行数:5,代码来源:ObjectConditionSection.java

示例12: insertSectionStart

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void insertSectionStart(MethodVisitor mv, BytecodeGenerator generator) {
    mv.visitJumpInsn(inverted ? IFNE : IFEQ, ifEnd);
}
 
开发者ID:Guichaguri,项目名称:FastMustache,代码行数:5,代码来源:ConditionSection.java


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