FileDocCategorySizeDatePackage
IINC.javaAPI DocJava SE 6 API5687Tue Jun 10 00:22:20 BST 2008com.sun.org.apache.bcel.internal.generic

IINC

public class IINC extends LocalVariableInstruction
IINC - Increment local variable by constant
version
$Id: IINC.java,v 1.1.2.1 2005/07/31 23:45:40 jeffsuttor Exp $
author
M. Dahm

Fields Summary
private boolean
wide
private int
c
Constructors Summary
IINC()
Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction(). Not to be used otherwise.

public IINC(int n, int c)

param
n index of local variable
param
c increment factor

    super(); // Default behaviour of LocalVariableInstruction causes error

    this.opcode = com.sun.org.apache.bcel.internal.Constants.IINC;
    this.length = (short)3;

    setIndex(n);    // May set wide as side effect
    setIncrement(c);
  
Methods Summary
public voidaccept(com.sun.org.apache.bcel.internal.generic.Visitor v)
Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.

param
v Visitor object

    v.visitLocalVariableInstruction(this);
    v.visitIINC(this);
  
public voiddump(java.io.DataOutputStream out)
Dump instruction as byte code to stream out.

param
out Output stream

    if(wide) // Need WIDE prefix ?
      out.writeByte(com.sun.org.apache.bcel.internal.Constants.WIDE);

    out.writeByte(opcode);

    if(wide) {
      out.writeShort(n);
      out.writeShort(c);
    } else {
      out.writeByte(n);
      out.writeByte(c);
    }
  
public final intgetIncrement()

return
increment factor

 return c; 
public com.sun.org.apache.bcel.internal.generic.TypegetType(com.sun.org.apache.bcel.internal.generic.ConstantPoolGen cp)

return
int type

    return Type.INT;
  
protected voidinitFromFile(com.sun.org.apache.bcel.internal.util.ByteSequence bytes, boolean wide)
Read needed data (e.g. index) from file.

    this.wide = wide;

    if(wide) {
      length = 6;
      n = bytes.readUnsignedShort();
      c = bytes.readShort();
    } else {
      length = 3;
      n = bytes.readUnsignedByte();
      c = bytes.readByte();
    }
  
public final voidsetIncrement(int c)
Set increment factor.

    this.c = c;
    setWide();
  
public final voidsetIndex(int n)
Set index of local variable.

 
    if(n < 0)
      throw new ClassGenException("Negative index value: " + n);

    this.n = n;
    setWide();
  
private final voidsetWide()

    if(wide = ((n > com.sun.org.apache.bcel.internal.Constants.MAX_SHORT) ||
	       (Math.abs(c) > Byte.MAX_VALUE)))
      length = 6; // wide byte included  
    else
      length = 3;
  
public java.lang.StringtoString(boolean verbose)

return
mnemonic for instruction

    return super.toString(verbose) + " " + c;