| 363 | } |
| 364 | |
| 365 | private ScopeNode jumpTo(ScopeNode toScope) { |
| 366 | ScopeNode cur = _scope.dup(); |
| 367 | ctrl(XCTRL); // Kill current scope |
| 368 | // Prune nested lexical scopes that have depth > than the loop head |
| 369 | // We use _breakScope as a proxy for the loop head scope to obtain the depth |
| 370 | while( cur._lexSize.size() > _breakScope._lexSize.size() ) |
| 371 | cur.pop(); |
| 372 | // If this is a continue then first time the target is null |
| 373 | // So we just use the pruned current scope as the base for the |
| 374 | // "continue" |
| 375 | if( toScope == null ) |
| 376 | return cur; |
| 377 | // toScope is either the break scope, or a scope that was created here |
| 378 | assert toScope._lexSize.size() <= _breakScope._lexSize.size(); |
| 379 | toScope.ctrl(toScope.mergeScopes(cur).peephole()); |
| 380 | return toScope; |
| 381 | } |
| 382 | |
| 383 | private void checkLoopActive() { if (_breakScope == null) throw Parser.error("No active loop for a break or continue"); } |
| 384 | |