| 458 | } |
| 459 | |
| 460 | private ScopeNode jumpTo(ScopeNode toScope) { |
| 461 | ScopeNode cur = _scope.dup(); |
| 462 | ctrl(XCTRL); // Kill current scope |
| 463 | // Prune nested lexical scopes that have depth > than the loop head |
| 464 | // We use _breakScope as a proxy for the loop head scope to obtain the depth |
| 465 | while( cur._lexSize.size() > _breakScope._lexSize.size() ) |
| 466 | cur.pop(); |
| 467 | // If this is a continue then first time the target is null |
| 468 | // So we just use the pruned current scope as the base for the |
| 469 | // "continue" |
| 470 | if( toScope == null ) |
| 471 | return cur; |
| 472 | // toScope is either the break scope, or a scope that was created here |
| 473 | assert toScope._lexSize.size() <= _breakScope._lexSize.size(); |
| 474 | toScope.ctrl(toScope.mergeScopes(cur,loc()).peephole()); |
| 475 | return toScope; |
| 476 | } |
| 477 | |
| 478 | private void checkLoopActive() { if (_breakScope == null) throw error("No active loop for a break or continue"); } |
| 479 | |