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

Method jumpTo

chapter08/src/main/java/com/seaofnodes/simple/Parser.java:236–252  ·  view source on GitHub ↗
(ScopeNode toScope)

Source from the content-addressed store, hash-verified

234 _continueScope = savedContinueScope;
235 _breakScope = savedBreakScope;
236
237 // At exit the false control is the current control, and
238 // the scope is the exit scope after the exit test.
239 return _scope = exit;
240 }
241
242 private ScopeNode jumpTo(ScopeNode toScope) {
243 ScopeNode cur = _scope.dup();
244 ctrl(new ConstantNode(Type.XCONTROL).peephole()); // Kill current scope
245 // Prune nested lexical scopes that have depth > than the loop head
246 // We use _breakScope as a proxy for the loop head scope to obtain the depth
247 while( cur._scopes.size() > _breakScope._scopes.size() )
248 cur.pop();
249 // If this is a continue then first time the target is null
250 // So we just use the pruned current scope as the base for the
251 // continue
252 if (toScope == null)
253 return cur;
254 // toScope is either the break scope, or a scope that was created here
255 assert toScope._scopes.size() <= _breakScope._scopes.size();

Callers 3

parseWhileMethod · 0.95
parseBreakMethod · 0.95
parseContinueMethod · 0.95

Calls 6

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

Tested by

no test coverage detected