gnu.bytecode

Class SwitchState


public class SwitchState
extends java.lang.Object

Maintains the state for generating a switch statement.

Constructor Summary

SwitchState(CodeAttr code)

Method Summary

boolean
addCase(int value, CodeAttr code)
Emit a new case, for the given value, whose label is here.
boolean
addCase(int value, Label label, CodeAttr code)
Add a new case.
void
addDefault(CodeAttr code)
void
addDefault(Label label, CodeAttr code)
void
finish(CodeAttr code)
Handle the end of the switch statement.
int
getMaxValue()

Constructor Details

SwitchState

public SwitchState(CodeAttr code)

Method Details

addCase

public boolean addCase(int value,
                       CodeAttr code)
Emit a new case, for the given value, whose label is here.

addCase

public boolean addCase(int value,
                       Label label,
                       CodeAttr code)
Add a new case.
Parameters:
value - the case value to match against at run-time
label - the location to go to if the value matches
code - the CodeAttr of the Method we are generating code for
Returns:
true on success; false if value duplicates an existing value

addDefault

public void addDefault(CodeAttr code)

addDefault

public void addDefault(Label label,
                       CodeAttr code)

finish

public void finish(CodeAttr code)
Handle the end of the switch statement. Assume the case value is on the stack; go to the matching case label.

getMaxValue

public int getMaxValue()