Package org.objectweb.asm.tree

Examples of org.objectweb.asm.tree.InsnList


        // 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,
View Full Code Here


    return cloneInsnList(cloneLabels(insns), insns);
  }

  public static InsnList cloneInsnList(Map<LabelNode, LabelNode> labelMap, InsnList insns)
  {
    InsnList clone = new InsnList();
    for (AbstractInsnNode insn = insns.getFirst(); insn != null; insn = insn.getNext())
      clone.add(insn.clone(labelMap));

    return clone;
  }
View Full Code Here

    {
      if (insn instanceof LabelNode)
        labels.put((LabelNode) insn, (LabelNode) insn);
    }

    InsnList importantNodeList = new InsnList();
    for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext())
    {
      if (insn instanceof LabelNode || insn instanceof LineNumberNode)
        continue;

      importantNodeList.add(insn.clone(labels));
    }
    return importantNodeList;
  }
View Full Code Here

            }
           
            AbstractInsnNode next = insn.getNext();
            if (toNull.cardinality() > 0) {
                // Construct the nulling instructions.
                InsnList nullingInsns = new InsnList();
                for (int i = 0; i < toNull.length(); i++) {
                    if (toNull.get(i)) {
                        AbstractInsnNode pushNull = new InsnNode(Opcodes.ACONST_NULL);
                        AbstractInsnNode store = new VarInsnNode(Opcodes.ASTORE, i);
                        nullingInsns.add(pushNull);
                        nullingInsns.add(store);
                    }
                }
               
                if (AbstractInsnNode.LABEL == insn.getType()) {
                    instructions.insert(insn, nullingInsns);
View Full Code Here

    @Nullable
    private static MethodInsnNode findConstructorInvocation(
            @NonNull MethodNode method,
            @NonNull String className) {
        InsnList nodes = ((MethodNode) method).instructions;
        for (int i = 0, n = nodes.size(); i < n; i++) {
            AbstractInsnNode instruction = nodes.get(i);
            if (instruction.getOpcode() == Opcodes.INVOKESPECIAL) {
                MethodInsnNode call = (MethodInsnNode) instruction;
                if (className.equals(call.owner)) {
                    return call;
                }
View Full Code Here

    @Nullable
    private static MethodInsnNode findConstructorInvocation(
            @NonNull MethodNode method,
            @NonNull String className) {
        InsnList nodes = ((MethodNode) method).instructions;
        for (int i = 0, n = nodes.size(); i < n; i++) {
            AbstractInsnNode instruction = nodes.get(i);
            if (instruction.getOpcode() == Opcodes.INVOKESPECIAL) {
                MethodInsnNode call = (MethodInsnNode) instruction;
                if (className.equals(call.owner)) {
                    return call;
                }
View Full Code Here

        // 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,
View Full Code Here

    cr.accept(cn, ClassReader.SKIP_FRAMES);

    cn.superName = "net/minecraft/world/WorldServer";
    for (MethodNode m : cn.methods) {
      if ("<init>".equals(m.name)) {
        InsnList l = m.instructions;
        for (int i = 0, e = l.size(); i < e; i++) {
          AbstractInsnNode n = l.get(i);
          if (n instanceof MethodInsnNode) {
            MethodInsnNode mn = (MethodInsnNode) n;
            if (mn.getOpcode() == INVOKESPECIAL) {
              mn.owner = cn.superName;
              break;
View Full Code Here

        // main routine
        worklist.add(new Instantiation(null, mainSubroutine));

        // Emit instantiations of each subroutine we encounter, including the
        // main subroutine
        InsnList newInstructions = new InsnList();
        List newTryCatchBlocks = new ArrayList();
        List newLocalVariables = new ArrayList();
        while (!worklist.isEmpty()) {
            Instantiation inst = (Instantiation) worklist.removeFirst();
            emitSubroutine(inst,
View Full Code Here

        };
        m.accept(mv);
        node.methods.set(node.methods.indexOf(m), mv);
      }
      if(m.name.equals("updateSignalStateForColor")) {
        InsnList list = m.instructions;
        AbstractInsnNode current = list.getLast();
        while(!(current instanceof InsnNode && ((InsnNode)current).getOpcode() == Opcodes.RETURN)) {
          current = current.getPrevious();
        }
        current = current.getPrevious();
        InsnList toAdd = new InsnList();
        toAdd.add(new VarInsnNode(Opcodes.ALOAD, 0));
        toAdd.add(new VarInsnNode(Opcodes.ALOAD, 1));
        toAdd.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "logisticspipes/proxy/buildcraft/BCPipeWireHooks", "updateSignalStateForColor", "(Lbuildcraft/transport/Pipe;Lbuildcraft/api/transport/PipeWire;)V"));
        toAdd.add(getLabelNode(new Label()));
        m.instructions.insert(current, toAdd);
      }
      if(m.name.equals("readNearbyPipesSignal")) {
        MethodNode mv = new MethodNode(Opcodes.ASM4, m.access, m.name, m.desc, m.signature, m.exceptions.toArray(new String[0])) {
          boolean handled = false;
          @Override
          public void visitInsn(int opcode) {
            if(!handled) {
              handled = true;
              super.visitVarInsn(Opcodes.ALOAD, 0);
              super.visitVarInsn(Opcodes.ALOAD, 1);
              super.visitMethodInsn(Opcodes.INVOKESTATIC, "logisticspipes/proxy/buildcraft/BCPipeWireHooks", "readNearbyPipesSignal_Pre", "(Lbuildcraft/transport/Pipe;Lbuildcraft/api/transport/PipeWire;)Z");
            } else {
              super.visitInsn(opcode);
            }
          }
        };

        m.accept(mv);
       
        InsnList list = mv.instructions;
        AbstractInsnNode current = list.getLast();
        while(!(current instanceof InsnNode && ((InsnNode)current).getOpcode() == Opcodes.RETURN)) {
          current = current.getPrevious();
        }
        current = current.getPrevious();
        InsnList toAdd = new InsnList();
        toAdd.add(new VarInsnNode(Opcodes.ALOAD, 0));
        toAdd.add(new VarInsnNode(Opcodes.ALOAD, 1));
        toAdd.add(new VarInsnNode(Opcodes.ILOAD, 2));
        toAdd.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "logisticspipes/proxy/buildcraft/BCPipeWireHooks", "readNearbyPipesSignal_Post", "(Lbuildcraft/transport/Pipe;Lbuildcraft/api/transport/PipeWire;Z)V"));
        toAdd.add(getLabelNode(new Label()));
        mv.instructions.insert(current, toAdd);
       
        node.methods.set(node.methods.indexOf(m), mv);
      }
      if(m.name.equals("receiveSignal")) {
View Full Code Here

TOP

Related Classes of org.objectweb.asm.tree.InsnList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.