當前位置: 首頁>>代碼示例>>Java>>正文


Java InsnList類代碼示例

本文整理匯總了Java中org.objectweb.asm.tree.InsnList的典型用法代碼示例。如果您正苦於以下問題:Java InsnList類的具體用法?Java InsnList怎麽用?Java InsnList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


InsnList類屬於org.objectweb.asm.tree包,在下文中一共展示了InsnList類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: emitCode

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
/**
 * Creates the new instructions, inlining each instantiation of each
 * subroutine until the code is fully elaborated.
 */
private void emitCode() {
    LinkedList<Instantiation> worklist = new LinkedList<Instantiation>();
    // Create an instantiation of the "root" subroutine, which is just the
    // main routine
    worklist.add(new Instantiation(null, mainSubroutine));

    // Emit instantiations of each subroutine we encounter, including the
    // main subroutine
    InsnList newInstructions = new InsnList();
    List<TryCatchBlockNode> newTryCatchBlocks = new ArrayList<TryCatchBlockNode>();
    List<LocalVariableNode> newLocalVariables = new ArrayList<LocalVariableNode>();
    while (!worklist.isEmpty()) {
        Instantiation inst = worklist.removeFirst();
        emitSubroutine(inst, worklist, newInstructions, newTryCatchBlocks,
                newLocalVariables);
    }
    instructions = newInstructions;
    tryCatchBlocks = newTryCatchBlocks;
    localVariables = newLocalVariables;
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:25,代碼來源:JSRInlinerAdapter.java

示例2: stringEncryptionTransformer

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
private static void stringEncryptionTransformer(ClassNode classNode) {
    if (classNode.superName.equals("org/bukkit/plugin/java/JavaPlugin") || classNode.superName.equals("net/md_5/bungee/api/plugin/Plugin")) {
        for (MethodNode methodNode : classNode.methods) {
            InsnList nodes = methodNode.instructions;
            for (int i = 0; i < nodes.size(); i++) {
                AbstractInsnNode instruction = nodes.get(i);
                if (instruction instanceof LdcInsnNode) {
                    if (instruction.getNext() instanceof MethodInsnNode) {
                        LdcInsnNode ldc = (LdcInsnNode) instruction;
                        MethodInsnNode methodinsnnode = (MethodInsnNode) ldc.getNext();
                        if (ldc.cst instanceof String) {
                            if (methodinsnnode.name.equalsIgnoreCase("\u0972") && methodinsnnode.desc.equalsIgnoreCase("(Ljava/lang/String;)Ljava/lang/String;")) {
                                methodNode.instructions.remove(methodinsnnode);
                                ldc.cst = decryptionArray((String)ldc.cst);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:ItzSomebody,項目名稱:DirectLeaks-AntiReleak-Remover,代碼行數:23,代碼來源:InjectorRemover.java

示例3: toNumericalValue

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
public static InsnList toNumericalValue(String what) {
  Objects.requireNonNull(what);
  InsnList il = new InsnList();

  il.add(new LdcInsnNode(what));
  il.add(new MethodInsnNode(
      INVOKESTATIC,
      Type.getInternalName(Conversions.class),
      "toNumericalValue",
      Type.getMethodDescriptor(
          Type.getType(Number.class),
          Type.getType(Object.class),
          Type.getType(String.class)),
      false));

  return il;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:18,代碼來源:ConversionMethods.java

示例4: getEntryPoints

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
private static BitSet getEntryPoints(MethodNode asmNode, Map<AbstractInsnNode, int[]> exitPoints) {
	InsnList il = asmNode.instructions;
	BitSet entryPoints = new BitSet(il.size());

	for (int[] eps : exitPoints.values()) {
		if (eps != null) {
			for (int ep : eps) entryPoints.set(ep);
		}
	}

	for (TryCatchBlockNode n : asmNode.tryCatchBlocks) {
		entryPoints.set(il.indexOf(n.handler));
	}

	return entryPoints;
}
 
開發者ID:sfPlayer1,項目名稱:Matcher,代碼行數:17,代碼來源:Analysis.java

示例5: addDirectExits

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
private static void addDirectExits(InsnList il, BitSet entryPoints, Map<AbstractInsnNode, int[]> exitPoints) {
	int idx = 0; // ignore 0 since it has no preceding instruction

	while ((idx = entryPoints.nextSetBit(idx + 1)) != -1) {
		AbstractInsnNode prev = il.get(idx - 1);
		if (exitPoints.containsKey(prev)) continue;
		int type = prev.getType();

		if (prev.getOpcode() != Opcodes.ATHROW
				&& (prev.getOpcode() < Opcodes.IRETURN || prev.getOpcode() > Opcodes.RETURN)
				&& type != AbstractInsnNode.JUMP_INSN
				&& type != AbstractInsnNode.TABLESWITCH_INSN
				&& type != AbstractInsnNode.LOOKUPSWITCH_INSN) {
			exitPoints.put(prev, new int[] { idx });
		}
	}
}
 
開發者ID:sfPlayer1,項目名稱:Matcher,代碼行數:18,代碼來源:Analysis.java

示例6: getMethodTransformers

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
@Override
public MethodTransformer[] getMethodTransformers() {
	MethodTransformer loadWorldTransformer = new MethodTransformer() {
		public String getMethodName() {return CoreLoader.isObfuscated ? "a" : "loadWorld";}
		public String getDescName() {return "(L" + (CoreLoader.isObfuscated ? "bnq" : Type.getInternalName(WorldClient.class)) + ";Ljava/lang/String;)V";}
		
		public void transform(ClassNode classNode, MethodNode method, boolean obfuscated) {
			CLTLog.info("Found method: " + method.name + " " + method.desc);
			CLTLog.info("begining at start of method " + getMethodName());
			
			//TransformerUtil.onWorldLoad(WorldClient worldClientIn)
			InsnList toInsert = new InsnList();
			toInsert.add(new VarInsnNode(ALOAD, 1)); //worldClientIn
			toInsert.add(new MethodInsnNode(INVOKESTATIC, Type.getInternalName(TransformerUtil.class),
					"onWorldLoad", "(L" + Type.getInternalName(WorldClient.class) + ";)V", false));
			method.instructions.insertBefore(method.instructions.getFirst(), toInsert);
		}
	};
	
	return new MethodTransformer[] {loadWorldTransformer};
}
 
開發者ID:18107,項目名稱:MC-Ray-Tracer,代碼行數:22,代碼來源:MinecraftTransformer.java

示例7: newTable

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
public static InsnList newTable(int array, int hash) {
  InsnList il = new InsnList();

  il.add(ASMUtils.loadInt(array));
  il.add(ASMUtils.loadInt(hash));

  il.add(new MethodInsnNode(
      INVOKEINTERFACE,
      selfTpe().getInternalName(),
      "newTable",
      Type.getMethodType(
          Type.getType(Table.class),
          Type.INT_TYPE,
          Type.INT_TYPE).getDescriptor(),
      true));

  return il;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:19,代碼來源:ExecutionContextMethods.java

示例8: get

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
public static InsnList get(int index) {
  Check.nonNegative(index);

  InsnList il = new InsnList();

  if (index <= 4) {
    String methodName = "get" + index;
    il.add(new MethodInsnNode(
        INVOKEINTERFACE,
        selfTpe().getInternalName(),
        methodName,
        Type.getMethodType(
            Type.getType(Object.class)).getDescriptor(),
        true));
  } else {
    il.add(ASMUtils.loadInt(index));
    il.add(get());
  }

  return il;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:22,代碼來源:ReturnBufferMethods.java

示例9: toClosureFieldInstance

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
public RunMethod.ClosureFieldInstance toClosureFieldInstance() {
  assert (this.isClosed());

  FieldNode fieldNode = instanceFieldNode();

  InsnList il = new InsnList();
  il.add(new VarInsnNode(ALOAD, 0));
  il.add(instantiationInsns());
  il.add(new FieldInsnNode(
      PUTFIELD,
      context.thisClassType().getInternalName(),
      instanceFieldName(),
      instanceType().getDescriptor()));

  return new RunMethod.ClosureFieldInstance(instanceFieldNode(), il);
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:17,代碼來源:BytecodeEmitVisitor.java

示例10: fetchInstanceInsns

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
private InsnList fetchInstanceInsns() {
  InsnList il = new InsnList();

  if (this.isClosed()) {
    if (this.isPure()) {
      il.add(new FieldInsnNode(
          GETSTATIC,
          instanceType().getInternalName(),
          ASMBytecodeEmitter.instanceFieldName(),
          instanceType().getDescriptor()));
    } else {
      il.add(new VarInsnNode(ALOAD, 0));
      il.add(new FieldInsnNode(
          GETFIELD,
          context.thisClassType().getInternalName(),
          instanceFieldName(),
          instanceType().getDescriptor()));
    }
  } else {
    il.add(instantiationInsns());
  }

  return il;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:25,代碼來源:BytecodeEmitVisitor.java

示例11: dispatchTable

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
private InsnList dispatchTable(List<LabelNode> extLabels, List<LabelNode> resumptionLabels,
    LabelNode errorStateLabel) {
  InsnList il = new InsnList();

  assert (!extLabels.isEmpty());

  ArrayList<LabelNode> labels = new ArrayList<>();
  labels.addAll(extLabels);
  labels.addAll(resumptionLabels);
  LabelNode[] labelArray = labels.toArray(new LabelNode[labels.size()]);

  int min = 1 - extLabels.size();
  int max = resumptionLabels.size();

  il.add(new VarInsnNode(ILOAD, LV_RESUME));
  il.add(new TableSwitchInsnNode(min, max, errorStateLabel, labelArray));
  return il;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:19,代碼來源:RunMethod.java

示例12: createSnapshot

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
InsnList createSnapshot() {
  InsnList il = new InsnList();

  il.add(new VarInsnNode(ALOAD, 0));  // this
  il.add(new VarInsnNode(ALOAD, 0));
  il.add(new VarInsnNode(ILOAD, LV_RESUME));
  if (context.isVararg()) {
    il.add(new VarInsnNode(ALOAD, LV_VARARGS));
  }
  for (int i = 0; i < numOfRegisters(); i++) {
    il.add(new VarInsnNode(ALOAD, slotOffset() + i));
  }
  il.add(snapshotMethodInvokeInsn());

  return il;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:17,代碼來源:RunMethod.java

示例13: resumptionHandler

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
protected InsnList resumptionHandler(LabelNode label) {
  InsnList il = new InsnList();

  il.add(label);
  il.add(ASMUtils.frameSame1(UnresolvedControlThrowable.class));

  il.add(createSnapshot());

  // register snapshot with the control exception
  il.add(new MethodInsnNode(
      INVOKEVIRTUAL,
      Type.getInternalName(UnresolvedControlThrowable.class),
      "resolve",
      Type.getMethodType(
          Type.getType(ResolvedControlThrowable.class),
          Type.getType(Resumable.class),
          Type.getType(Object.class)).getDescriptor(),
      false));

  // rethrow
  il.add(new InsnNode(ATHROW));

  return il;
}
 
開發者ID:kroepke,項目名稱:luna,代碼行數:25,代碼來源:RunMethod.java

示例14: transformCode

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
public byte[] transformCode(byte[] b1, String className) throws IOException {
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
    ClassReader cr = new ClassReader(b1);
    ClassNode classNode = new ClassNode();
    Map<String, Boolean> methodInstructionTypeMap = new HashMap<>();
    cr.accept(classNode, 0);
    final List<MethodNode> methods = classNode.methods;
    for (MethodNode m : methods) {
        InsnList inList = m.instructions;
        boolean isMethodInvoke = false;
        for (int i = 0; i < inList.size(); i++) {
            if (inList.get(i).getType() == AbstractInsnNode.METHOD_INSN) {
                isMethodInvoke = true;
            }
        }
        methodInstructionTypeMap.put(m.name + m.desc, isMethodInvoke);
    }
    InsertMethodBodyAdapter insertMethodBodyAdapter = new InsertMethodBodyAdapter(cw, className, methodInstructionTypeMap);
    cr.accept(insertMethodBodyAdapter, ClassReader.EXPAND_FRAMES);
    return cw.toByteArray();
}
 
開發者ID:Meituan-Dianping,項目名稱:Robust,代碼行數:22,代碼來源:AsmInsertImpl.java

示例15: populateClassGraph

import org.objectweb.asm.tree.InsnList; //導入依賴的package包/類
public void populateClassGraph() {
  String className = Type.getObjectType(classNode.name).getClassName();
  logger.debug("Creating graph for class {}" , className);
  for (MethodNode methodNode : classNode.methods) {
    String methodName = methodNode.name;
    MethodGraph caller = new MethodGraph(className, methodName);
    InsnList instructions = methodNode.instructions;
    for (int i = 0; i < instructions.size(); i++) {
      AbstractInsnNode insnNode = instructions.get(i);
      if (insnNode.getType() == AbstractInsnNode.METHOD_INSN) {
        MethodInsnNode methodInsnNode = (MethodInsnNode)insnNode;
        String calledOwner = Type.getObjectType(methodInsnNode.owner).getClassName();
        String calledName = methodInsnNode.name;
        MethodGraph called = new MethodGraph(calledOwner, calledName);
        Call call = new Call(caller, called);
        if (!called.getOwner().equals("java.lang.Object") && !called.getName().equals("<init>")) {
          logger.trace("Adding call graph: {}", call.toString());
          GraphHolder.addCallGraph(call);
        }
      }
    }
  }
}
 
開發者ID:fergarrui,項目名稱:custom-bytecode-analyzer,代碼行數:24,代碼來源:ClassCallGraph.java


注:本文中的org.objectweb.asm.tree.InsnList類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。