Examples of AbstractInsnNode


Examples of org.objectweb.asm.tree.AbstractInsnNode

        if (insns.size() == 0) {
          continue;
        }
        Iterator j = insns.iterator();
        while (j.hasNext()) {
          AbstractInsnNode in = (AbstractInsnNode) j.next();
          int op = in.getOpcode();
          if ((op >= IRETURN && op <= RETURN) || op == ATHROW) {
            InsnList il = new InsnList();
            il.add(new FieldInsnNode(GETSTATIC, cn.name, "timer", "J"));
            il.add(new MethodInsnNode(INVOKESTATIC, "java/lang/System",
                "currentTimeMillis", "()J"));
            il.add(new InsnNode(LADD));
            il.add(new FieldInsnNode(PUTSTATIC, cn.name, "timer", "J"));
            if (in.getPrevious() == null) {
              continue;
            }
            insns.insert(in.getPrevious(), il);
          }
        }
        InsnList il = new InsnList();
        il.add(new FieldInsnNode(GETSTATIC, cn.name, "timer", "J"));
        il.add(new MethodInsnNode(INVOKESTATIC, "java/lang/System",
View Full Code Here

Examples of org.objectweb.asm.tree.AbstractInsnNode

  public void transform(MethodNode mn) {
    InsnList insns = mn.instructions;
    Iterator i = insns.iterator();
    while (i.hasNext()) {
      AbstractInsnNode in = (AbstractInsnNode) i.next();
      if (in instanceof JumpInsnNode) {
        LabelNode label = ((JumpInsnNode) in).label;
        AbstractInsnNode target;
        // while target == goto l, replace label with l
        while (true) {
          target = label;
          while (target != null && target.getOpcode() < 0) {
            target = target.getNext();
          }
          if (target != null && target.getOpcode() == GOTO) {
            label = ((JumpInsnNode) target).label;
          } else {
            break;
          }
        }
        // update target
        ((JumpInsnNode) in).label = label;
        // if possible, replace jump with target instruction
        if (in.getOpcode() == GOTO && target != null) {
          int op = target.getOpcode();
          if ((op >= IRETURN && op <= RETURN) || op == ATHROW) {
            // replace 'in' with clone of 'target'
            insns.set(in, target.clone(null));
          }
        }
      }
    }
    super.transform(mn);
View Full Code Here

Examples of org.objectweb.asm.tree.AbstractInsnNode

  public void transform(MethodNode mn) {
    InsnList insns = mn.instructions;
    Iterator i = insns.iterator();
    while (i.hasNext()) {
      AbstractInsnNode i1 = (AbstractInsnNode) i.next();
      if (i1 instanceof VarInsnNode) {
        VarInsnNode v1 = (VarInsnNode) i1;
        int op1 = v1.getOpcode();
        if (op1 >= ILOAD && op1 <= ALOAD) {
          AbstractInsnNode i2 = getNext(i);
          if (i2 instanceof VarInsnNode) {
            VarInsnNode v2 = (VarInsnNode) i2;
            int op2 = v2.getOpcode();
            if (op2 - ISTORE == op1 - ILOAD && v2.var == v1.var) {
              insns.remove(i1);
View Full Code Here

Examples of org.objectweb.asm.tree.AbstractInsnNode

    super.transform(mn);
  }

  private static AbstractInsnNode getNext(Iterator i) {
    while (i.hasNext()) {
      AbstractInsnNode in = (AbstractInsnNode) i.next();
      if (!(in instanceof LineNumberNode)) {
        return in;
      }
    }
    return null;
View Full Code Here

Examples of org.objectweb.asm.tree.AbstractInsnNode

  public void transform(MethodNode mn) {
    InsnList insns = mn.instructions;
    Iterator i = insns.iterator();
    while (i.hasNext()) {
      AbstractInsnNode i1 = (AbstractInsnNode) i.next();
      if (isALOAD0(i1)) {
        AbstractInsnNode i2 = getNext(i1);
        if (i2 != null && isALOAD0(i2)) {
          AbstractInsnNode i3 = getNext(i2);
          if (i3 != null && i3.getOpcode() == GETFIELD) {
            AbstractInsnNode i4 = getNext(i3);
            if (i4 != null && i4.getOpcode() == PUTFIELD) {
              if (sameField(i3, i4)) {
                while (i.next() != i4) {
                }
                insns.remove(i1);
                insns.remove(i2);
View Full Code Here

Examples of org.objectweb.asm.tree.AbstractInsnNode

        Object o = m.instructions.get(insn);
       
        if (o instanceof Label) {
          merge(insn + 1, f, subroutine);
        } else {
          AbstractInsnNode insnNode = (AbstractInsnNode)o;
          int insnOpcode = insnNode.getOpcode();
         
          current.init(f).execute(insnNode, interpreter);
          subroutine = subroutine == null ? null : subroutine.copy();
         
          if (insnNode instanceof JumpInsnNode) {
View Full Code Here

Examples of org.objectweb.asm.tree.AbstractInsnNode

            }
            locals.addLast(local);
        }

        // now visit the instructions intercepting labels
        AbstractInsnNode insn = getFirst();
        while (insn != null) {
            insn.accept(mv);
            if (insn.getType() == AbstractInsnNode.LABEL) {
                LabelNode labelNode = (LabelNode) insn;
                Label label = labelNode.getLabel();
                List<LocalVariableNode> localStart = localStarts.get(label);
                List<LocalVariableNode> localEnd = localEnds.get(label);
                if (localStart != null) {
                    for (LocalVariableNode local : localStart) {
                        lsmv.visitLocalScopeStart(local.name, local.desc, local.signature, local.index, label.getOffset());
                    }
                }
                if (localEnd != null) {
                    for (LocalVariableNode local : localEnd) {
                        lsmv.visitLocalScopeEnd(local.name, local.desc, local.signature, local.index, label.getOffset());
                    }
                }
            }
            insn = insn.getNext();
        }
    }
View Full Code Here

Examples of org.objectweb.asm.tree.AbstractInsnNode

   
    ByteBufferHelper bufferHelper = new ByteBufferHelper(meta);
   
    boolean shouldDoSetter = true;
    for (int i = 0; instructions.size() > i; i++) {
      AbstractInsnNode node = instructions.get(i);
      switch(node.getType()) {
        case AbstractInsnNode.FIELD_INSN:
          FieldInsnNode f = (FieldInsnNode)node;
          if (shouldDoSetter && isSettingFieldWithPrimitive(f)) {
            if (LOG) System.out.println(">> SETTING FIELD index=" + i);
            i = on(instructions, f)
View Full Code Here

Examples of org.objectweb.asm.tree.AbstractInsnNode

  public boolean transform(MethodNode mn) {
    InsnList instructions = mn.instructions;
    boolean changed = false;
   
    for (int i = 0; instructions.size() > i; i++) {
      AbstractInsnNode node = instructions.get(i);
      if (AbstractInsnNode.FIELD_INSN != node.getType())
        continue;
     
      FieldInsnNode fn = (FieldInsnNode)node;
      if (className.equals(fn.owner))
        continue;
View Full Code Here

Examples of org.objectweb.asm.tree.AbstractInsnNode

  public int transform() {
    ArrayList<Integer> offsets = new ArrayList<Integer>(insertions.keySet());
    Collections.sort(offsets, new ReversedComparator());
    for (int offset : offsets) {
      int refIndex = instructions.indexOf(reference);
      AbstractInsnNode ref = instructions.get(refIndex - offset);
      for (AbstractInsnNode n :  insertions.get(offset)) {
        instructions.insertBefore(ref, n);
      }
    }
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.