(StarlarkThread.Frame fr, ForStatement node)
| 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 { |
no test coverage detected