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


Java Opcodes类代码示例

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


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

示例1: visitFieldInsn

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public void visitFieldInsn(final int opcode, final String owner,
        final String name, final String desc) {
    switch (opcode) {
    case Opcodes.GETSTATIC:
        getstatic(owner, name, desc);
        break;
    case Opcodes.PUTSTATIC:
        putstatic(owner, name, desc);
        break;
    case Opcodes.GETFIELD:
        getfield(owner, name, desc);
        break;
    case Opcodes.PUTFIELD:
        putfield(owner, name, desc);
        break;
    default:
        throw new IllegalArgumentException();
    }
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:21,代码来源:InstructionAdapter.java

示例2: visitVarInsn

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public void visitVarInsn(final int opcode, final int var) {
  ReplacingBasicValue v;
  if (opcode == Opcodes.ASTORE && (v = peekFromTop(0)) != null) {
    final ValueHolderSub from = oldToNew.get(v.getIndex());

    final ReplacingBasicValue current = getLocal(var);
    // if local var is set, then transfer to it to the existing holders in the local position.
    if (current != null) {
      final ValueHolderSub newSub = oldToNew.get(current.getIndex());
      if (newSub.iden() == from.iden()) {
        final int targetFirst = newSub.first();
        from.transfer(this, targetFirst);
        return;
      }
    }

    // if local var is not set, then check map to see if existing holders are mapped to local var.
    if (oldLocalToFirst.containsKey(var)) {
      final ValueHolderSub sub = oldToNew.get(oldLocalToFirst.lget());
      if (sub.iden() == from.iden()) {
        // if they are, then transfer to that.
        from.transfer(this, sub.first());
        return;
      }
    }

    // map from variables to global space for future use.
    oldLocalToFirst.put(var, v.getIndex());
    return;
  } else if (opcode == Opcodes.ALOAD && (v = getLocal(var)) != null) {
    /*
     * Not forwarding this removes a now unnecessary ALOAD for a holder. The required LOAD/STORE
     * sequences will be generated by the ASTORE code above.
     */
    return;
  }

  super.visitVarInsn(opcode, var);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:41,代码来源:InstructionModifier.java

示例3: throw_compilation

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
private void throw_compilation(ASTJumpExpr node) throws CompileException {
  TContextFunc func_context = getClosestFunContext();
  MethodVisitor mv = func_context.getMethodVisitor();

  switch (node.jjtGetNumChildren()) {
  case 1:
    Reduction reduce = this.popReduction();
    Debug.assertion(reduce != null, "Invalid Popped Reduction");
    Debug.assertion(reduce.isContainer(), "Invalid Popped Reduction " + reduce);
    Container throw_cont = (Container) reduce;
    Debug.assertion(throw_cont.isTypeInitialized(), "Throw Type is not initialized in the function signature");

    LOG.debug("CONT TYPE:" + throw_cont.getType());
    Debug.assertion(!throw_cont.isForm(Container.FORM_TYPE), "throw_cont should not be type container");

    LOG.debug("ATHROW");
    mv.visitInsn(Opcodes.ATHROW);
    break;

  default:
    throw new CompileException("Invalid Throw Expression child");
  }

  pushReduction(new Control(Control.FORM_THROW));
}
 
开发者ID:Samsung,项目名称:MeziLang,代码行数:26,代码来源:ASTCompileVisitor.java

示例4: smaller

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public Container smaller(Container lval, Container rvalue, OpInfo opinfo) throws CompileException {

  Label greater_equal_label = new Label();
  Label end_label = new Label();

  opinfo.mv.visitJumpInsn(Opcodes.IF_ICMPGE, greater_equal_label);
  opinfo.mv.visitInsn(Opcodes.ICONST_1);
  opinfo.mv.visitJumpInsn(Opcodes.GOTO, end_label);
  opinfo.mv.visitLabel(greater_equal_label);
  opinfo.mv.visitInsn(Opcodes.ICONST_0);
  opinfo.mv.visitLabel(end_label);

  Container anony_bool = new Container("anonymous", Container.FORM_OPSTACK_VAR, true, false);
  anony_bool.initializeType((AbsType) cpLoader.findClassFull(TPrimitiveClass.NAME_BOOL));
  anony_bool.setAssigned(true);

  return anony_bool;
}
 
开发者ID:Samsung,项目名称:MeziLang,代码行数:20,代码来源:OpInt.java

示例5: remap

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
protected void remap() {
    findNode(getObfType().getJvmStandard()).ifPresent((classNode -> classNode.methods.forEach((methodNode -> {
        if (methodNode.name.equals("<init>")) {
            methodNode.instructions.iterator().forEachRemaining((insnNode) -> {
                if (insnNode.getOpcode() == Opcodes.ANEWARRAY) {
                    if (insnNode instanceof TypeInsnNode) {
                        TypeInsnNode typeInsnNode = (TypeInsnNode) insnNode;
                        Type type = Type.getType(typeInsnNode.desc);
                        getMappings().putClass(type.getInternalName(), "net.minecraft.world" +
                                ".IWorldEventListener");
                    }
                }
            });
        }
    }))));
}
 
开发者ID:PizzaCrust,项目名称:GraphiteMappings,代码行数:18,代码来源:WorldMappings.java

示例6: visitFieldInsn

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
/**
 * Imports field instructions (put and get), both for static and instance
 * fields.
 *
 * @param opcode Opcode.
 * @param owner  Class containing the field.
 * @param name   Name of field.
 * @param desc   Type descriptor of field.
 */
@Override
public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc) {
  Field f = ClassNode.getClass(owner).getField(name, desc);

  if(((opcode == Opcodes.GETSTATIC) || (opcode == Opcodes.PUTSTATIC)) !=
          f.getModifiers().contains(Modifier.STATIC)) {
    throw new RuntimeException("Field staticness conflicts with instruction");
  }

  switch(opcode) {
    // Loads
    case Opcodes.GETSTATIC:
    case Opcodes.GETFIELD:  createFieldRead(f);  break;
    // Stores
    case Opcodes.PUTSTATIC:
    case Opcodes.PUTFIELD:  createFieldWrite(f); break;
  }
}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:28,代码来源:MethodImporter.java

示例7: visitMethod

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public MethodVisitor visitMethod(int access, String name, String desc,
                                 String signature, String[] exceptions) {
    if (attemptToVisitR) return null;
    return new MethodVisitor(Opcodes.ASM5, null) {

        @Override
        public void visitFieldInsn(int opcode, String owner, String fieldName,
                                   String fieldDesc) {

            if (attemptToVisitR
                    || opcode != Opcodes.GETSTATIC
                    || owner.startsWith("java/lang/")) {
                return;
            }

            attemptToVisitR = isRClass(owner);
        }
    };
}
 
开发者ID:yrom,项目名称:shrinker,代码行数:21,代码来源:PredicateClassVisitor.java

示例8: accept

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
/**
 * Makes the given visitor visit this stack map frame.
 * 
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
开发者ID:ItzSomebody,项目名称:Simple-JAR-Watermark,代码行数:29,代码来源:FrameNode.java

示例9: minus_assign

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public Container minus_assign(Container lval, Container rvalue, OpInfo opinfo) throws CompileException {
  Container anonyInt = lval.getOpStackClone("anonymous");
  //// Compiled Instruction
  LOG.info("FSUB");
  opinfo.mv.visitInsn(Opcodes.FSUB);

  do_assign_common(lval, anonyInt, opinfo);

  //// End
  return anonyInt;
}
 
开发者ID:Samsung,项目名称:MeziLang,代码行数:13,代码来源:OpFloat.java

示例10: visitMethodInsn

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public void visitMethodInsn(final int opcode, final String owner,
        final String name, final String desc, final boolean itf) {
    if (api < Opcodes.ASM5) {
        super.visitMethodInsn(opcode, owner, name, desc, itf);
        return;
    }
    doVisitMethodInsn(opcode, owner, name, desc, itf);
}
 
开发者ID:ItzSomebody,项目名称:Spigot-Attribute-Remover,代码行数:10,代码来源:AnalyzerAdapter.java

示例11: visit

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
/**
 * Output instructions for allocating arrays, both for primitive and
 * reference types.
 *
 * @param instruction Array allocation instruction.
 * @return            <code>null</code>
 */
@Override
public Void visit(NewArray instruction) {
  if(instruction.getElementType().getSort() == Type.Sort.REF) {
    mv.visitTypeInsn(
      Opcodes.ANEWARRAY,
      instruction.getElementType().getInternalName()
    );
  } else {
    int type;

    switch(instruction.getElementType().getSort()) {
      case BOOL:   type = Opcodes.T_BOOLEAN; break;
      case CHAR:   type = Opcodes.T_CHAR;    break;
      case FLOAT:  type = Opcodes.T_FLOAT;   break;
      case DOUBLE: type = Opcodes.T_DOUBLE;  break;
      case BYTE:   type = Opcodes.T_BYTE;    break;
      case SHORT:  type = Opcodes.T_SHORT;   break;
      case INT:    type = Opcodes.T_INT;     break;
      case LONG:   type = Opcodes.T_LONG;    break;
      default: throw new RuntimeException("Unknown array element type");
    }

    mv.visitIntInsn(Opcodes.NEWARRAY, type);
  }

  return null;
}
 
开发者ID:adnanmitf09,项目名称:Rubus,代码行数:35,代码来源:InstructionExporter.java

示例12: transform

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public void transform(ClassNode clazz, MethodNode method, InsnMatcher matcher) {
	method.instructions.clear();
	method.localVariables.clear();
	method.tryCatchBlocks.clear();

	method.instructions.add(new InsnNode(Opcodes.ICONST_0));
	method.instructions.add(new InsnNode(Opcodes.IRETURN));

	// TODO adjust maxLocals and maxStack?
}
 
开发者ID:jonathanedgecombe,项目名称:anvil,代码行数:12,代码来源:XmasCalendarTransformer.java

示例13: invokevirtual

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Deprecated
public void invokevirtual(final String owner, final String name,
        final String desc) {
    if (api >= Opcodes.ASM5) {
        invokevirtual(owner, name, desc, false);
        return;
    }
    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, desc);
}
 
开发者ID:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:10,代码来源:InstructionAdapter.java

示例14: hookMethod

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
protected MethodVisitor hookMethod(int access, String name, String desc, String signature, String[] exceptions, MethodVisitor mv) {
    if ("extractParameters".equals(name) || "extractContentParameters".equals(name)) {
        return new AdviceAdapter(Opcodes.ASM5, mv, access, name, desc) {
            @Override
            protected void onMethodEnter() {
                invokeStatic(Type.getType(HookHandler.class),
                        new Method("onParseParameters", "()V"));
            }

        };
    }
    return mv;
}
 
开发者ID:baidu,项目名称:openrasp,代码行数:15,代码来源:JettyRequestHook.java

示例15: minus

import org.objectweb.asm.Opcodes; //导入依赖的package包/类
@Override
public Container minus(Container lval, Container rvalue, OpInfo opinfo) throws CompileException {

  Container anonyInt = lval.getOpStackClone("anonymous");

  //// Compiled Instruction
  opinfo.mv.visitInsn(Opcodes.ISUB);
  LOG.info("ISUB");
  // subed result will be on the operand stack
  //// End

  return anonyInt;
}
 
开发者ID:Samsung,项目名称:MeziLang,代码行数:14,代码来源:OpInt.java


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