Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.bcel.generic
Class SWITCH  view SWITCH download SWITCH.java

java.lang.Object
  extended byorg.apache.bcel.generic.SWITCH
All Implemented Interfaces:
CompoundInstruction

public final class SWITCH
extends java.lang.Object
implements CompoundInstruction

SWITCH - Branch depending on int value, generates either LOOKUPSWITCH or TABLESWITCH instruction, depending on whether the match values (int[]) can be sorted with no gaps between the numbers.

Version:
$Id: SWITCH.java 386056 2006-03-15 11:31:56Z tcurdt $

Field Summary
private  Select instruction
           
private  int[] match
           
private  int match_length
           
private  InstructionHandle[] targets
           
 
Constructor Summary
SWITCH(int[] match, InstructionHandle[] targets, InstructionHandle target)
           
SWITCH(int[] match, InstructionHandle[] targets, InstructionHandle target, int max_gap)
          Template for switch() constructs.
 
Method Summary
private  void fillup(int max_gap, InstructionHandle target)
           
 Instruction getInstruction()
           
 InstructionList getInstructionList()
           
private  boolean matchIsOrdered(int max_gap)
           
private  void sort(int l, int r)
          Sort match and targets array with QuickSort.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

match

private int[] match

targets

private InstructionHandle[] targets

instruction

private Select instruction

match_length

private int match_length
Constructor Detail

SWITCH

public SWITCH(int[] match,
              InstructionHandle[] targets,
              InstructionHandle target,
              int max_gap)
Template for switch() constructs. If the match array can be sorted in ascending order with gaps no larger than max_gap between the numbers, a TABLESWITCH instruction is generated, and a LOOKUPSWITCH otherwise. The former may be more efficient, but needs more space. Note, that the key array always will be sorted, though we leave the original arrays unaltered.


SWITCH

public SWITCH(int[] match,
              InstructionHandle[] targets,
              InstructionHandle target)
Method Detail

fillup

private final void fillup(int max_gap,
                          InstructionHandle target)

sort

private final void sort(int l,
                        int r)
Sort match and targets array with QuickSort.


matchIsOrdered

private final boolean matchIsOrdered(int max_gap)

getInstructionList

public final InstructionList getInstructionList()
Specified by:
getInstructionList in interface CompoundInstruction

getInstruction

public final Instruction getInstruction()