當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。