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

Method jumpTo

chapter12/src/main/java/com/seaofnodes/simple/Parser.java:298–314  ·  view source on GitHub ↗
(ScopeNode toScope)

Source from the content-addressed store, hash-verified

296 }
297
298 private ScopeNode jumpTo(ScopeNode toScope) {
299 ScopeNode cur = _scope.dup();
300 ctrl(XCTRL); // Kill current scope
301 // Prune nested lexical scopes that have depth > than the loop head
302 // We use _breakScope as a proxy for the loop head scope to obtain the depth
303 while( cur._scopes.size() > _breakScope._scopes.size() )
304 cur.pop();
305 // If this is a continue then first time the target is null
306 // So we just use the pruned current scope as the base for the
307 // "continue"
308 if (toScope == null)
309 return cur;
310 // toScope is either the break scope, or a scope that was created here
311 assert toScope._scopes.size() <= _breakScope._scopes.size();
312 toScope.ctrl(toScope.mergeScopes(cur));
313 return toScope;
314 }
315
316 private void checkLoopActive() { if (_breakScope == null) throw Parser.error("No active loop for a break or continue"); }
317

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