org.apache.bcel.generic

Class SWITCH

public final class SWITCH extends 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 $

Author: M. Dahm

Field Summary
Selectinstruction
int[]match
intmatch_length
InstructionHandle[]targets
Constructor Summary
SWITCH(int[] match, InstructionHandle[] targets, InstructionHandle target, int max_gap)
Template for switch() constructs.
SWITCH(int[] match, InstructionHandle[] targets, InstructionHandle target)
Method Summary
voidfillup(int max_gap, InstructionHandle target)
InstructiongetInstruction()
InstructionListgetInstructionList()
booleanmatchIsOrdered(int max_gap)
voidsort(int l, int r)
Sort match and targets array with QuickSort.

Field Detail

instruction

private Select instruction

match

private int[] match

match_length

private int match_length

targets

private InstructionHandle[] targets

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.

Parameters: match array of match values (case 2: ... case 7: ..., etc.) targets the instructions to be branched to for each case target the default target max_gap maximum gap that may between case branches

SWITCH

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

Method Detail

fillup

private final void fillup(int max_gap, InstructionHandle target)

getInstruction

public final Instruction getInstruction()

getInstructionList

public final InstructionList getInstructionList()

matchIsOrdered

private final boolean matchIsOrdered(int max_gap)

Returns: match is sorted in ascending order with no gap bigger than max_gap?

sort

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