gnu.bytecode
Class SwitchState

java.lang.Object
  extended by gnu.bytecode.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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwitchState

public SwitchState(CodeAttr code)
Method Detail

getMaxValue

public int getMaxValue()

addCase

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


addDefault

public void addDefault(CodeAttr code)

addDefault

public void addDefault(Label label,
                       CodeAttr code)

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

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.