org.objectweb.asm.Opcodes# F_NEW 源码实例Demo

下面列出了org.objectweb.asm.Opcodes# F_NEW 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Cafebabe   文件: FrameNode.java

/**
 * Constructs a new {@link FrameNode}.
 *
 * @param type
 *          the type of this frame. Must be {@link Opcodes#F_NEW} for expanded frames, or {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND}, {@link Opcodes#F_CHOP}, {@link Opcodes#F_SAME} or {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for compressed frames.
 * @param numLocal
 *          number of local variables of this stack map frame.
 * @param local
 *          the types of the local variables of this stack map frame. Elements of this list can be Integer, String or LabelNode objects (for primitive, reference and uninitialized types respectively - see {@link MethodVisitor}).
 * @param numStack
 *          number of operand stack elements of this stack map frame.
 * @param stack
 *          the types of the operand stack elements of this stack map frame. Elements of this list can be Integer, String or LabelNode objects (for primitive, reference and uninitialized types respectively - see {@link MethodVisitor}).
 */
public FrameNode(final int type, final int numLocal, final Object[] local, final int numStack, final Object[] stack) {
	super(-1);
	this.type = type;
	switch (type) {
	case Opcodes.F_NEW:
	case Opcodes.F_FULL:
		this.local = Util.asArrayList(numLocal, local);
		this.stack = Util.asArrayList(numStack, stack);
		break;
	case Opcodes.F_APPEND:
		this.local = Util.asArrayList(numLocal, local);
		break;
	case Opcodes.F_CHOP:
		this.local = Util.asArrayList(numLocal);
		break;
	case Opcodes.F_SAME:
		break;
	case Opcodes.F_SAME1:
		this.stack = Util.asArrayList(1, stack);
		break;
	default:
		throw new IllegalArgumentException();
	}
}
 
源代码2 项目: JReFrameworker   文件: AnalyzerAdapter.java

@Override
public void visitFrame(
    final int type,
    final int numLocal,
    final Object[] local,
    final int numStack,
    final Object[] stack) {
  if (type != Opcodes.F_NEW) { // Uncompressed frame.
    throw new IllegalArgumentException(
        "AnalyzerAdapter only accepts expanded frames (see ClassReader.EXPAND_FRAMES)");
  }

  super.visitFrame(type, numLocal, local, numStack, stack);

  if (this.locals != null) {
    this.locals.clear();
    this.stack.clear();
  } else {
    this.locals = new ArrayList<Object>();
    this.stack = new ArrayList<Object>();
  }
  visitFrameTypes(numLocal, local, this.locals);
  visitFrameTypes(numStack, stack, this.stack);
  maxLocals = Math.max(maxLocals, this.locals.size());
  maxStack = Math.max(maxStack, this.stack.size());
}
 
源代码3 项目: Mixin   文件: Locals.java

/**
 * Compute a new frame size based on the supplied frame type and the size of
 * locals contained in the frame (this may differ from the number of actual
 * frame slots if the frame contains doubles or longs)
 * 
 * @param currentSize current frame size
 * @param type frame entry type
 * @param size frame entry size
 * @return new frame size
 */
private static int getAdjustedFrameSize(int currentSize, int type, int size) {
    switch (type) {
        case Opcodes.F_NEW:
        case Opcodes.F_FULL:
            return size;
        case Opcodes.F_APPEND:
            return currentSize + size;
        case Opcodes.F_CHOP:
            return currentSize - size;
        case Opcodes.F_SAME:
        case Opcodes.F_SAME1:
            return currentSize;
        default:
            return currentSize;
    }
 }
 
源代码4 项目: JByteMod-Beta   文件: AnalyzerAdapter.java

@Override
public void visitFrame(
    final int type,
    final int nLocal,
    final Object[] local,
    final int nStack,
    final Object[] stack) {
  if (type != Opcodes.F_NEW) { // Uncompressed frame.
    throw new IllegalArgumentException(
        "AnalyzerAdapter only accepts expanded frames (see ClassReader.EXPAND_FRAMES)");
  }

  super.visitFrame(type, nLocal, local, nStack, stack);

  if (this.locals != null) {
    this.locals.clear();
    this.stack.clear();
  } else {
    this.locals = new ArrayList<Object>();
    this.stack = new ArrayList<Object>();
  }
  visitFrameTypes(nLocal, local, this.locals);
  visitFrameTypes(nStack, stack, this.stack);
  maxLocals = Math.max(maxLocals, this.locals.size());
  maxStack = Math.max(maxStack, this.stack.size());
}
 
源代码5 项目: JByteMod-Beta   文件: FrameNode.java

/**
 * 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;
  }
}
 
源代码6 项目: JReFrameworker   文件: FrameNode.java

@Override
public void accept(final MethodVisitor methodVisitor) {
  switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
      methodVisitor.visitFrame(type, local.size(), asArray(local), stack.size(), asArray(stack));
      break;
    case Opcodes.F_APPEND:
      methodVisitor.visitFrame(type, local.size(), asArray(local), 0, null);
      break;
    case Opcodes.F_CHOP:
      methodVisitor.visitFrame(type, local.size(), null, 0, null);
      break;
    case Opcodes.F_SAME:
      methodVisitor.visitFrame(type, 0, null, 0, null);
      break;
    case Opcodes.F_SAME1:
      methodVisitor.visitFrame(type, 0, null, 1, asArray(stack));
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
源代码7 项目: JReFrameworker   文件: FrameNode.java

@Override
public void accept(final MethodVisitor methodVisitor) {
  switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
      methodVisitor.visitFrame(type, local.size(), asArray(local), stack.size(), asArray(stack));
      break;
    case Opcodes.F_APPEND:
      methodVisitor.visitFrame(type, local.size(), asArray(local), 0, null);
      break;
    case Opcodes.F_CHOP:
      methodVisitor.visitFrame(type, local.size(), null, 0, null);
      break;
    case Opcodes.F_SAME:
      methodVisitor.visitFrame(type, 0, null, 0, null);
      break;
    case Opcodes.F_SAME1:
      methodVisitor.visitFrame(type, 0, null, 1, asArray(stack));
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
源代码8 项目: Concurnas   文件: FrameNode.java

/**
 * Constructs a new {@link FrameNode}.
 *
 * @param type the type of this frame. Must be {@link Opcodes#F_NEW} for expanded frames, or
 *     {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND}, {@link Opcodes#F_CHOP}, {@link
 *     Opcodes#F_SAME} or {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for compressed frames.
 * @param numLocal number of local variables of this stack map frame.
 * @param local the types of the local variables of this stack map frame. Elements of this list
 *     can be Integer, String or LabelNode objects (for primitive, reference and uninitialized
 *     types respectively - see {@link MethodVisitor}).
 * @param numStack number of operand stack elements of this stack map frame.
 * @param stack the types of the operand stack elements of this stack map frame. Elements of this
 *     list can be Integer, String or LabelNode objects (for primitive, reference and
 *     uninitialized types respectively - see {@link MethodVisitor}).
 */
public FrameNode(
    final int type,
    final int numLocal,
    final Object[] local,
    final int numStack,
    final Object[] stack) {
  super(-1);
  this.type = type;
  switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
      this.local = Util.asArrayList(numLocal, local);
      this.stack = Util.asArrayList(numStack, stack);
      break;
    case Opcodes.F_APPEND:
      this.local = Util.asArrayList(numLocal, local);
      break;
    case Opcodes.F_CHOP:
      this.local = Util.asArrayList(numLocal);
      break;
    case Opcodes.F_SAME:
      break;
    case Opcodes.F_SAME1:
      this.stack = Util.asArrayList(1, stack);
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
源代码9 项目: Concurnas   文件: Textifier.java

@Override
public void visitFrame(
    final int type,
    final int numLocal,
    final Object[] local,
    final int numStack,
    final Object[] stack) {
  stringBuilder.setLength(0);
  stringBuilder.append(ltab);
  stringBuilder.append("FRAME ");
  switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
      stringBuilder.append("FULL [");
      appendFrameTypes(numLocal, local);
      stringBuilder.append("] [");
      appendFrameTypes(numStack, stack);
      stringBuilder.append(']');
      break;
    case Opcodes.F_APPEND:
      stringBuilder.append("APPEND [");
      appendFrameTypes(numLocal, local);
      stringBuilder.append(']');
      break;
    case Opcodes.F_CHOP:
      stringBuilder.append("CHOP ").append(numLocal);
      break;
    case Opcodes.F_SAME:
      stringBuilder.append("SAME");
      break;
    case Opcodes.F_SAME1:
      stringBuilder.append("SAME1 ");
      appendFrameTypes(1, stack);
      break;
    default:
      throw new IllegalArgumentException();
  }
  stringBuilder.append('\n');
  text.add(stringBuilder.toString());
}
 
源代码10 项目: JByteMod-Beta   文件: SAXCodeAdapter.java

@Override
public void visitFrame(final int type, final int nLocal, final Object[] local, final int nStack, final Object[] stack) {
  AttributesImpl attrs = new AttributesImpl();
  switch (type) {
  case Opcodes.F_NEW:
  case Opcodes.F_FULL:
    if (type == Opcodes.F_NEW) {
      attrs.addAttribute("", "type", "type", "", "NEW");
    } else {
      attrs.addAttribute("", "type", "type", "", "FULL");
    }
    sa.addStart("frame", attrs);
    appendFrameTypes(true, nLocal, local);
    appendFrameTypes(false, nStack, stack);
    break;
  case Opcodes.F_APPEND:
    attrs.addAttribute("", "type", "type", "", "APPEND");
    sa.addStart("frame", attrs);
    appendFrameTypes(true, nLocal, local);
    break;
  case Opcodes.F_CHOP:
    attrs.addAttribute("", "type", "type", "", "CHOP");
    attrs.addAttribute("", "count", "count", "", Integer.toString(nLocal));
    sa.addStart("frame", attrs);
    break;
  case Opcodes.F_SAME:
    attrs.addAttribute("", "type", "type", "", "SAME");
    sa.addStart("frame", attrs);
    break;
  case Opcodes.F_SAME1:
    attrs.addAttribute("", "type", "type", "", "SAME1");
    sa.addStart("frame", attrs);
    appendFrameTypes(false, 1, stack);
    break;
  }
  sa.addEnd("frame");
}
 
源代码11 项目: JByteMod-Beta   文件: Textifier.java

@Override
public void visitFrame(final int type, final int nLocal, final Object[] local, final int nStack, final Object[] stack) {
  buf.setLength(0);
  buf.append(ltab);
  buf.append("FRAME ");
  switch (type) {
  case Opcodes.F_NEW:
  case Opcodes.F_FULL:
    buf.append("FULL [");
    appendFrameTypes(nLocal, local);
    buf.append("] [");
    appendFrameTypes(nStack, stack);
    buf.append(']');
    break;
  case Opcodes.F_APPEND:
    buf.append("APPEND [");
    appendFrameTypes(nLocal, local);
    buf.append(']');
    break;
  case Opcodes.F_CHOP:
    buf.append("CHOP ").append(nLocal);
    break;
  case Opcodes.F_SAME:
    buf.append("SAME");
    break;
  case Opcodes.F_SAME1:
    buf.append("SAME1 ");
    appendFrameTypes(1, stack);
    break;
  }
  buf.append('\n');
  text.add(buf.toString());
}
 
源代码12 项目: JReFrameworker   文件: Textifier.java

@Override
public void visitFrame(
    final int type,
    final int numLocal,
    final Object[] local,
    final int numStack,
    final Object[] stack) {
  stringBuilder.setLength(0);
  stringBuilder.append(ltab);
  stringBuilder.append("FRAME ");
  switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
      stringBuilder.append("FULL [");
      appendFrameTypes(numLocal, local);
      stringBuilder.append("] [");
      appendFrameTypes(numStack, stack);
      stringBuilder.append(']');
      break;
    case Opcodes.F_APPEND:
      stringBuilder.append("APPEND [");
      appendFrameTypes(numLocal, local);
      stringBuilder.append(']');
      break;
    case Opcodes.F_CHOP:
      stringBuilder.append("CHOP ").append(numLocal);
      break;
    case Opcodes.F_SAME:
      stringBuilder.append("SAME");
      break;
    case Opcodes.F_SAME1:
      stringBuilder.append("SAME1 ");
      appendFrameTypes(1, stack);
      break;
    default:
      throw new IllegalArgumentException();
  }
  stringBuilder.append('\n');
  text.add(stringBuilder.toString());
}
 
源代码13 项目: JReFrameworker   文件: FrameNode.java

/**
 * Constructs a new {@link FrameNode}.
 *
 * @param type the type of this frame. Must be {@link Opcodes#F_NEW} for expanded frames, or
 *     {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND}, {@link Opcodes#F_CHOP}, {@link
 *     Opcodes#F_SAME} or {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for compressed frames.
 * @param numLocal number of local variables of this stack map frame.
 * @param local the types of the local variables of this stack map frame. Elements of this list
 *     can be Integer, String or LabelNode objects (for primitive, reference and uninitialized
 *     types respectively - see {@link MethodVisitor}).
 * @param numStack number of operand stack elements of this stack map frame.
 * @param stack the types of the operand stack elements of this stack map frame. Elements of this
 *     list can be Integer, String or LabelNode objects (for primitive, reference and
 *     uninitialized types respectively - see {@link MethodVisitor}).
 */
public FrameNode(
    final int type,
    final int numLocal,
    final Object[] local,
    final int numStack,
    final Object[] stack) {
  super(-1);
  this.type = type;
  switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
      this.local = Util.asArrayList(numLocal, local);
      this.stack = Util.asArrayList(numStack, stack);
      break;
    case Opcodes.F_APPEND:
      this.local = Util.asArrayList(numLocal, local);
      break;
    case Opcodes.F_CHOP:
      this.local = Util.asArrayList(numLocal);
      break;
    case Opcodes.F_SAME:
      break;
    case Opcodes.F_SAME1:
      this.stack = Util.asArrayList(1, stack);
      break;
    default:
      throw new IllegalArgumentException();
  }
}
 
源代码14 项目: JReFrameworker   文件: Textifier.java

@Override
public void visitFrame(
    final int type,
    final int numLocal,
    final Object[] local,
    final int numStack,
    final Object[] stack) {
  stringBuilder.setLength(0);
  stringBuilder.append(ltab);
  stringBuilder.append("FRAME ");
  switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
      stringBuilder.append("FULL [");
      appendFrameTypes(numLocal, local);
      stringBuilder.append("] [");
      appendFrameTypes(numStack, stack);
      stringBuilder.append(']');
      break;
    case Opcodes.F_APPEND:
      stringBuilder.append("APPEND [");
      appendFrameTypes(numLocal, local);
      stringBuilder.append(']');
      break;
    case Opcodes.F_CHOP:
      stringBuilder.append("CHOP ").append(numLocal);
      break;
    case Opcodes.F_SAME:
      stringBuilder.append("SAME");
      break;
    case Opcodes.F_SAME1:
      stringBuilder.append("SAME1 ");
      appendFrameTypes(1, stack);
      break;
    default:
      throw new IllegalArgumentException();
  }
  stringBuilder.append('\n');
  text.add(stringBuilder.toString());
}
 
源代码15 项目: bazel   文件: BytecodeTypeInference.java

@Override
public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {
  switch (type) {
    case Opcodes.F_NEW:
      // Expanded form.
      previousFrame =
          FrameInfo.create(
              convertTypesInStackMapFrame(nLocal, local),
              convertTypesInStackMapFrame(nStack, stack));
      break;
    case Opcodes.F_SAME:
      // This frame type indicates that the frame has exactly the same local variables as the
      // previous frame and that the operand stack is empty.
      previousFrame = FrameInfo.create(previousFrame.locals(), ImmutableList.of());
      break;
    case Opcodes.F_SAME1:
      // This frame type indicates that the frame has exactly the same local variables as the
      // previous frame and that the operand stack has one entry.
      previousFrame =
          FrameInfo.create(previousFrame.locals(), convertTypesInStackMapFrame(nStack, stack));
      break;
    case Opcodes.F_APPEND:
      // This frame type indicates that the frame has the same locals as the previous frame except
      // that k additional locals are defined, and that the operand stack is empty.
      previousFrame =
          FrameInfo.create(
              appendArrayToList(previousFrame.locals(), nLocal, local), ImmutableList.of());
      break;
    case Opcodes.F_CHOP:
      // This frame type indicates that the frame has the same local variables as the previous
      // frame except that the last k local variables are absent, and that the operand stack is
      // empty.
      previousFrame =
          FrameInfo.create(
              removeBackFromList(previousFrame.locals(), nLocal), ImmutableList.of());
      break;
    case Opcodes.F_FULL:
      previousFrame =
          FrameInfo.create(
              convertTypesInStackMapFrame(nLocal, local),
              convertTypesInStackMapFrame(nStack, stack));
      break;
    default:
      // continue below
  }
  // Update types for operand stack and local variables.
  operandStack.clear();
  operandStack.addAll(previousFrame.stack());
  localVariableSlots.clear();
  localVariableSlots.addAll(previousFrame.locals());
  super.visitFrame(type, nLocal, local, nStack, stack);
}
 
源代码16 项目: Concurnas   文件: ASMifier.java

@Override
public void visitFrame(
    final int type,
    final int numLocal,
    final Object[] local,
    final int numStack,
    final Object[] stack) {
  stringBuilder.setLength(0);
  switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
      declareFrameTypes(numLocal, local);
      declareFrameTypes(numStack, stack);
      if (type == Opcodes.F_NEW) {
        stringBuilder.append(name).append(".visitFrame(Opcodes.F_NEW, ");
      } else {
        stringBuilder.append(name).append(".visitFrame(Opcodes.F_FULL, ");
      }
      stringBuilder.append(numLocal).append(NEW_OBJECT_ARRAY);
      appendFrameTypes(numLocal, local);
      stringBuilder.append("}, ").append(numStack).append(NEW_OBJECT_ARRAY);
      appendFrameTypes(numStack, stack);
      stringBuilder.append('}');
      break;
    case Opcodes.F_APPEND:
      declareFrameTypes(numLocal, local);
      stringBuilder
          .append(name)
          .append(".visitFrame(Opcodes.F_APPEND,")
          .append(numLocal)
          .append(NEW_OBJECT_ARRAY);
      appendFrameTypes(numLocal, local);
      stringBuilder.append("}, 0, null");
      break;
    case Opcodes.F_CHOP:
      stringBuilder
          .append(name)
          .append(".visitFrame(Opcodes.F_CHOP,")
          .append(numLocal)
          .append(", null, 0, null");
      break;
    case Opcodes.F_SAME:
      stringBuilder.append(name).append(".visitFrame(Opcodes.F_SAME, 0, null, 0, null");
      break;
    case Opcodes.F_SAME1:
      declareFrameTypes(1, stack);
      stringBuilder
          .append(name)
          .append(".visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] {");
      appendFrameTypes(1, stack);
      stringBuilder.append('}');
      break;
    default:
      throw new IllegalArgumentException();
  }
  stringBuilder.append(");\n");
  text.add(stringBuilder.toString());
}
 

@Override
public void visitFrame(int arg0, int arg1, Object[] arg2, int arg3,
        Object[] arg4) {
    savePreviousFrame();
    if (logger.isDebugEnabled())
        logger.debug("stackBefore: " + currentFrame.stack);
    if (logger.isDebugEnabled())
        logger.debug("localBefore: " + currentFrame.localsToString());
    currentFrame = new StackInfo(lastDeclaredFrame);
    switch (arg0) {
        case F_SAME:
            // representing frame with exactly the same locals as the previous frame and with the empty stack.
            currentFrame.stack.clear();
            break;
        case F_SAME1:
            // representing frame with exactly the same locals as the previous frame and with single value
            // on the stack (nStack is 1 and stack[0] contains value for the type of the stack item).
            Type t = StackInfo.deferLocalDesc(arg4[0]);
            currentFrame.stack.clear();
            currentFrame.stack.push(t);
            break;
        case F_APPEND:
            // representing frame with current locals are the same as the locals in the previous frame,
            // except that additional locals are defined (nLocal is 1, 2 or 3 and local elements contains
            // values representing added types).
            currentFrame.appendLocals(arg1, arg2);
            break;
        case F_CHOP:
            // Opcodes.F_CHOP representing frame with current locals are the same as the locals in the
            // previous frame, except that the last 1-3 locals are absent and with the empty stack (nLocals
            // is 1, 2 or 3).
            currentFrame.removeLocals(arg1);
            currentFrame.stack.clear();
            break;
        case Opcodes.F_FULL: // representing complete frame data.
        case Opcodes.F_NEW:
            currentFrame.clearFrame();
            currentFrame.appendLocals(arg1, arg2);
            currentFrame.appendStack(arg3, arg4);
            break;
        default:
            throw new BuildStackFrameException("Unkwnon frame type " + arg0);

    }
    lastDeclaredFrame = new StackInfo(currentFrame);
    if (logger.isDebugEnabled())
        logger.debug("stack: " + currentFrame.stack);
    if (logger.isDebugEnabled())
        logger.debug("local: " + currentFrame.localsToString());
    if (logger.isDebugEnabled())
        logger.debug("frame " + getFrameType(arg0) + " '" + arg1 + "' '" + Arrays.asList(arg2) + "' '" + arg3 + "' '" + Arrays.asList(arg4) + "'");
    delegate.visitFrame(arg0, arg1, arg2, arg3, arg4);
}
 
源代码18 项目: JByteMod-Beta   文件: FrameNode.java

/**
 * Constructs a new {@link FrameNode}.
 * 
 * @param type
 *          the type of this frame. Must be {@link Opcodes#F_NEW} for expanded
 *          frames, or {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND},
 *          {@link Opcodes#F_CHOP}, {@link Opcodes#F_SAME} or
 *          {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for compressed
 *          frames.
 * @param nLocal
 *          number of local variables of this stack map frame.
 * @param local
 *          the types of the local variables of this stack map frame. Elements
 *          of this list can be Integer, String or LabelNode objects (for
 *          primitive, reference and uninitialized types respectively - see
 *          {@link MethodVisitor}).
 * @param nStack
 *          number of operand stack elements of this stack map frame.
 * @param stack
 *          the types of the operand stack elements of this stack map frame.
 *          Elements of this list can be Integer, String or LabelNode objects
 *          (for primitive, reference and uninitialized types respectively -
 *          see {@link MethodVisitor}).
 */
public FrameNode(final int type, final int nLocal, final Object[] local, final int nStack, final Object[] stack) {
  super(-1);
  this.type = type;
  switch (type) {
  case Opcodes.F_NEW:
  case Opcodes.F_FULL:
    this.local = asList(nLocal, local);
    this.stack = asList(nStack, stack);
    break;
  case Opcodes.F_APPEND:
    this.local = asList(nLocal, local);
    break;
  case Opcodes.F_CHOP:
    this.local = new ArrayList<Object>(Arrays.asList(new Object[nLocal]));
    break;
  case Opcodes.F_SAME:
    break;
  case Opcodes.F_SAME1:
    this.stack = asList(1, stack);
    break;
  }
}
 
源代码19 项目: JReFrameworker   文件: CheckMethodAdapter.java

@Override
public void visitFrame(
    final int type,
    final int numLocal,
    final Object[] local,
    final int numStack,
    final Object[] stack) {
  if (insnCount == lastFrameInsnIndex) {
    throw new IllegalStateException("At most one frame can be visited at a given code location.");
  }
  lastFrameInsnIndex = insnCount;
  int maxNumLocal;
  int maxNumStack;
  switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
      maxNumLocal = Integer.MAX_VALUE;
      maxNumStack = Integer.MAX_VALUE;
      break;

    case Opcodes.F_SAME:
      maxNumLocal = 0;
      maxNumStack = 0;
      break;

    case Opcodes.F_SAME1:
      maxNumLocal = 0;
      maxNumStack = 1;
      break;

    case Opcodes.F_APPEND:
    case Opcodes.F_CHOP:
      maxNumLocal = 3;
      maxNumStack = 0;
      break;

    default:
      throw new IllegalArgumentException("Invalid frame type " + type);
  }

  if (numLocal > maxNumLocal) {
    throw new IllegalArgumentException(
        "Invalid numLocal=" + numLocal + " for frame type " + type);
  }
  if (numStack > maxNumStack) {
    throw new IllegalArgumentException(
        "Invalid numStack=" + numStack + " for frame type " + type);
  }

  if (type != Opcodes.F_CHOP) {
    if (numLocal > 0 && (local == null || local.length < numLocal)) {
      throw new IllegalArgumentException("Array local[] is shorter than numLocal");
    }
    for (int i = 0; i < numLocal; ++i) {
      checkFrameValue(local[i]);
    }
  }
  if (numStack > 0 && (stack == null || stack.length < numStack)) {
    throw new IllegalArgumentException("Array stack[] is shorter than numStack");
  }
  for (int i = 0; i < numStack; ++i) {
    checkFrameValue(stack[i]);
  }
  if (type == Opcodes.F_NEW) {
    ++numExpandedFrames;
  } else {
    ++numCompressedFrames;
  }
  if (numExpandedFrames > 0 && numCompressedFrames > 0) {
    throw new IllegalArgumentException("Expanded and compressed frames must not be mixed.");
  }
  super.visitFrame(type, numLocal, local, numStack, stack);
}
 
源代码20 项目: JReFrameworker   文件: ASMifier.java

@Override
public void visitFrame(
    final int type,
    final int numLocal,
    final Object[] local,
    final int numStack,
    final Object[] stack) {
  stringBuilder.setLength(0);
  switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
      declareFrameTypes(numLocal, local);
      declareFrameTypes(numStack, stack);
      if (type == Opcodes.F_NEW) {
        stringBuilder.append(name).append(".visitFrame(Opcodes.F_NEW, ");
      } else {
        stringBuilder.append(name).append(".visitFrame(Opcodes.F_FULL, ");
      }
      stringBuilder.append(numLocal).append(NEW_OBJECT_ARRAY);
      appendFrameTypes(numLocal, local);
      stringBuilder.append("}, ").append(numStack).append(NEW_OBJECT_ARRAY);
      appendFrameTypes(numStack, stack);
      stringBuilder.append('}');
      break;
    case Opcodes.F_APPEND:
      declareFrameTypes(numLocal, local);
      stringBuilder
          .append(name)
          .append(".visitFrame(Opcodes.F_APPEND,")
          .append(numLocal)
          .append(NEW_OBJECT_ARRAY);
      appendFrameTypes(numLocal, local);
      stringBuilder.append("}, 0, null");
      break;
    case Opcodes.F_CHOP:
      stringBuilder
          .append(name)
          .append(".visitFrame(Opcodes.F_CHOP,")
          .append(numLocal)
          .append(", null, 0, null");
      break;
    case Opcodes.F_SAME:
      stringBuilder.append(name).append(".visitFrame(Opcodes.F_SAME, 0, null, 0, null");
      break;
    case Opcodes.F_SAME1:
      declareFrameTypes(1, stack);
      stringBuilder
          .append(name)
          .append(".visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] {");
      appendFrameTypes(1, stack);
      stringBuilder.append('}');
      break;
    default:
      throw new IllegalArgumentException();
  }
  stringBuilder.append(");\n");
  text.add(stringBuilder.toString());
}
 
 方法所在类
 同类方法