MCPcopy Index your code
hub / github.com/bazelbuild/bazel / execFor

Method execFor

src/main/java/net/starlark/java/eval/Eval.java:129–160  ·  view source on GitHub ↗
(StarlarkThread.Frame fr, ForStatement node)

Source from the content-addressed store, hash-verified

127 }
128
129 private static TokenKind execFor(StarlarkThread.Frame fr, ForStatement node)
130 throws EvalException, InterruptedException {
131 Iterable<?> seq = evalAsIterable(fr, node.getCollection());
132 EvalUtils.addIterator(seq);
133 try {
134 for (Object it : seq) {
135 assign(fr, node.getVars(), it);
136
137 switch (execStatements(fr, node.getBody(), /* indented= */ true)) {
138 case PASS:
139 case CONTINUE:
140 // Stay in loop.
141 fr.thread.checkInterrupt();
142 continue;
143 case BREAK:
144 // Finish loop, execute next statement after loop.
145 return TokenKind.PASS;
146 case RETURN:
147 // Finish loop, return from function.
148 return TokenKind.RETURN;
149 default:
150 throw new IllegalStateException("unreachable");
151 }
152 }
153 } catch (EvalException ex) {
154 fr.setErrorLocation(node.getStartLocation());
155 throw ex;
156 } finally {
157 EvalUtils.removeIterator(seq);
158 }
159 return TokenKind.PASS;
160 }
161
162 private static StarlarkFunction newFunction(StarlarkThread.Frame fr, Resolver.Function rfn)
163 throws EvalException, InterruptedException {

Callers 1

execMethod · 0.95

Calls 11

evalAsIterableMethod · 0.95
addIteratorMethod · 0.95
assignMethod · 0.95
execStatementsMethod · 0.95
removeIteratorMethod · 0.95
getCollectionMethod · 0.80
checkInterruptMethod · 0.80
setErrorLocationMethod · 0.80
getVarsMethod · 0.45
getBodyMethod · 0.45
getStartLocationMethod · 0.45

Tested by

no test coverage detected