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

Method jumpTo

chapter17/src/main/java/com/seaofnodes/simple/Parser.java:365–381  ·  view source on GitHub ↗
(ScopeNode toScope)

Source from the content-addressed store, hash-verified

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

Callers 3

parseLoopingMethod · 0.95
parseContinueMethod · 0.95
parseBreakMethod · 0.95

Calls 6

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

Tested by

no test coverage detected