@Override
protected void compileBody() throws CompilerException
{
final ExpressionNodeForSwitch switchNode = (ExpressionNodeForSwitch) node();
numericCompiler().compileInt( switchNode.selector() );
int nCases = switchNode.numberOfCases();
if (nCases > 0) {
final int[] switchValues = new int[ nCases ];
final ExpressionNodeForSwitchCase[] switchValueCases = new ExpressionNodeForSwitchCase[ nCases ];
int iSwitchValue = 0;
for (ExpressionNodeForSwitchCase caze : switchNode.cases()) {
switchValueCases[ iSwitchValue ] = caze;
switchValues[ iSwitchValue ] = caze.caseValue();
iSwitchValue++;
}
compileTableSwitch( switchValues, new TableSwitchGenerator()
{
private final int valReturn = expressionCompiler().typeCompiler().returnOpcode();
private int switchIndex = 0;
@Override
protected void generateCase( int _key, Label _end ) throws CompilerException
{
final ExpressionNodeForSwitchCase caze = switchValueCases[ this.switchIndex++ ];
if (null != caze) {
compileExpression( caze.value() );
mv().visitInsn( this.valReturn );
}
}
} );
}
compileExpression( switchNode.defaultValue() );
}