MCPcopy Create free account
hub / github.com/SeaOfNodes/Simple / jumpTo

Method jumpTo

chapter20/src/main/java/com/seaofnodes/simple/Parser.java:431–447  ·  view source on GitHub ↗
(ScopeNode toScope)

Source from the content-addressed store, hash-verified

429 }
430
431 private ScopeNode jumpTo(ScopeNode toScope) {
432 ScopeNode cur = _scope.dup();
433 ctrl(XCTRL); // Kill current scope
434 // Prune nested lexical scopes that have depth > than the loop head
435 // We use _breakScope as a proxy for the loop head scope to obtain the depth
436 while( cur._lexSize.size() > _breakScope._lexSize.size() )
437 cur.pop();
438 // If this is a continue then first time the target is null
439 // So we just use the pruned current scope as the base for the
440 // "continue"
441 if( toScope == null )
442 return cur;
443 // toScope is either the break scope, or a scope that was created here
444 assert toScope._lexSize.size() <= _breakScope._lexSize.size();
445 toScope.ctrl(toScope.mergeScopes(cur,loc()).peephole());
446 return toScope;
447 }
448
449 private void checkLoopActive() { if (_breakScope == null) throw error("No active loop for a break or continue"); }
450

Callers 3

parseLoopingMethod · 0.95
parseContinueMethod · 0.95
parseBreakMethod · 0.95

Calls 7

ctrlMethod · 0.95
popMethod · 0.95
locMethod · 0.95
dupMethod · 0.45
sizeMethod · 0.45
peepholeMethod · 0.45
mergeScopesMethod · 0.45

Tested by

no test coverage detected