FileDocCategorySizeDatePackage
InsnLookupSwitch.javaAPI DocGlassfish v2 API5823Fri May 04 22:34:28 BST 2007com.sun.jdo.api.persistence.enhancer.classfile

InsnLookupSwitch

public class InsnLookupSwitch extends Insn
Special instruction form for the opc_lookupswitch instruction

Fields Summary
private InsnTarget
defaultOp
private int[]
matchesOp
private InsnTarget[]
targetsOp
Constructors Summary
public InsnLookupSwitch(InsnTarget defaultOp, int[] matchesOp, InsnTarget[] targetsOp)
Constructor for opc_lookupswitch

    this(defaultOp, matchesOp, targetsOp, NO_OFFSET);
  
InsnLookupSwitch(InsnTarget defaultOp, int[] matchesOp, InsnTarget[] targetsOp, int offset)

    super(opc_lookupswitch, offset);

    this.defaultOp = defaultOp; 
    this.matchesOp = matchesOp;
    this.targetsOp = targetsOp;

    if (defaultOp == null || targetsOp == null || matchesOp == null ||
	targetsOp.length != matchesOp.length)
        throw new InsnError ("attempt to create an opc_lookupswitch" +//NOI18N
                             " with invalid operands");//NOI18N
  
Methods Summary
public java.lang.StringargTypes()
What are the types of the stack operands ?

      return "I";//NOI18N
  
public booleanbranches()

    return true;
  
public InsnTargetdefaultTarget()
Return the defaultTarget for the switch

    return defaultOp;
  
public voidmarkTargets()
Mark possible branch targets

    defaultOp.setBranchTarget();
    for (int i=0; i<targetsOp.length; i++)
      targetsOp[i].setBranchTarget();
  
public intnStackArgs()

    return 1;
  
public intnStackResults()

    return 0;
  
voidprint(java.io.PrintStream out, int indent)

    ClassPrint.spaces(out, indent);
    out.println(offset() + "  opc_lookupswitch  ");//NOI18N
    for (int i=0; i<matchesOp.length; i++) {
      ClassPrint.spaces(out, indent+2);
      out.println(matchesOp[i] + " -> " + targetsOp[i].offset());//NOI18N
    }
    ClassPrint.spaces(out, indent+2);
    out.println("default -> " + defaultOp.offset());//NOI18N
  
static com.sun.jdo.api.persistence.enhancer.classfile.InsnLookupSwitchread(InsnReadEnv insnEnv, int myPC)

    /* eat up any padding */
    int thisPC = myPC +1;
    for (int pads = ((thisPC + 3) & ~3) - thisPC; pads > 0; pads--)
      insnEnv.getByte();
    InsnTarget defaultTarget = insnEnv.getTarget(insnEnv.getInt() + myPC);
    int npairs = insnEnv.getInt();
    int matches[] = new int[npairs];
    InsnTarget[] offsets = new InsnTarget[npairs];
    for (int i=0; i<npairs; i++) {
      matches[i] = insnEnv.getInt();
      offsets[i] = insnEnv.getTarget(insnEnv.getInt() + myPC);
    }
    return new InsnLookupSwitch(defaultTarget, matches, offsets, myPC);
  
public java.lang.StringresultTypes()
What are the types of the stack results?

      return "";//NOI18N
  
intsize()

    /* account for the instruction, 0-3 bytes of pad, 2 ints */
    int basic = ((offset() + 4) & ~3) - offset() + 8;
    /* Add 8*number of offsets */
    return basic + targetsOp.length*8;
  
intstore(byte[] buf, int index)

    buf[index++] = (byte) opcode();
    index = (index + 3) & ~3;
    index = storeInt(buf, index, defaultOp.offset() - offset());
    index = storeInt(buf, index, targetsOp.length);
    for (int i=0; i<targetsOp.length; i++) {
      index = storeInt(buf, index, matchesOp[i]);
      index = storeInt(buf, index, targetsOp[i].offset() - offset());
    }
    return index;
  
public int[]switchCases()
Return the case values of the switch.

    return matchesOp;
  
public InsnTarget[]switchTargets()
Return the targets for the cases of the switch.

    return targetsOp;