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

Method jumpTo

chapter15/src/main/java/com/seaofnodes/simple/Parser.java:334–350  ·  view source on GitHub ↗
(ScopeNode toScope)

Source from the content-addressed store, hash-verified

332 }
333
334 private ScopeNode jumpTo(ScopeNode toScope) {
335 ScopeNode cur = _scope.dup();
336 ctrl(XCTRL); // Kill current scope
337 // Prune nested lexical scopes that have depth > than the loop head
338 // We use _breakScope as a proxy for the loop head scope to obtain the depth
339 while( cur._idxs.size() > _breakScope._idxs.size() )
340 cur.pop();
341 // If this is a continue then first time the target is null
342 // So we just use the pruned current scope as the base for the
343 // "continue"
344 if (toScope == null)
345 return cur;
346 // toScope is either the break scope, or a scope that was created here
347 assert toScope._idxs.size() <= _breakScope._idxs.size();
348 toScope.ctrl(toScope.mergeScopes(cur));
349 return toScope;
350 }
351
352 private void checkLoopActive() { if (_breakScope == null) throw Parser.error("No active loop for a break or continue"); }
353

Callers 3

parseWhileMethod · 0.95
parseBreakMethod · 0.95
parseContinueMethod · 0.95

Calls 5

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

Tested by

no test coverage detected