private void addSwitchCase ( Node switchBlock , Node caseExpression , Node statements ) { if ( switchBlock . getType ( ) != Token . BLOCK ) throw Kit . codeBug ( ) ; Jump switchNode = ( Jump ) switchBlock . getFirstChild ( ) ; if ( switchNode . getType ( ) != Token . SWITCH ) throw Kit . codeBug ( ) ; Node gotoTarget = Node . newTarget ( ) ; if ( caseExpression != null ) { Jump caseNode = new Jump ( Token . CASE , caseExpression ) ; caseNode . target = gotoTarget ; switchNode . addChildToBack ( caseNode ) ; } else { switchNode . setDefault ( gotoTarget ) ; } switchBlock . addChildToBack ( gotoTarget ) ; switchBlock . addChildToBack ( statements ) ; }
If caseExpression argument is null it indicates a default label .