|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgnu.bytecode.SwitchState
public class SwitchState
Maintains the state for generating a switch statement or expression.
To translate:
switch (exps) {
case 1: exp1; break;
case 2: exp2; break;
default: expd;
}
you can do:
compile[exps] SwitchState sw = code.startSwitch(); sw.addCase(1, code); compile[exp1]; sw.exitSwitch(code); sw.addCase(2, code); compile[exp2]; sw.exitSwitch(code); sw.addDefault(code); compile[expd]; sw.finish(code);
| Constructor Summary | |
|---|---|
SwitchState(CodeAttr code)
|
|
| Method Summary | |
|---|---|
boolean |
addCase(int value,
CodeAttr code)
Add a new case. |
boolean |
addCaseGoto(int value,
CodeAttr code,
Label label)
Optimization of addCase(value, code); emitGoto(label). |
void |
addDefault(CodeAttr code)
|
void |
exitSwitch(CodeAttr code)
Break/exit from this switch. |
void |
finish(CodeAttr code)
Handle the end of the switch statement. |
int |
getMaxValue()
|
int |
getNumCases()
|
boolean |
insertCase(int value,
Label label,
CodeAttr code)
Internal routine to add a new case. |
void |
switchValuePushed(CodeAttr code)
Needs to be called after the switch value has been pushed. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SwitchState(CodeAttr code)
| Method Detail |
|---|
public int getMaxValue()
public int getNumCases()
public void switchValuePushed(CodeAttr code)
CodeAttr.startSwitch().
public boolean addCase(int value,
CodeAttr code)
value - the case value to match against at run-timecode - the CodeAttr of the Method we are generating code for
public boolean addCaseGoto(int value,
CodeAttr code,
Label label)
addCase(value, code); emitGoto(label).
public void addDefault(CodeAttr code)
public boolean insertCase(int value,
Label label,
CodeAttr code)
value - the case value to match against at run-timelabel - the location to go to if the value matchescode - the CodeAttr of the Method we are generating code for
public void exitSwitch(CodeAttr code)
ExitableBlock.
public void finish(CodeAttr code)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||