(state: State, data: ReadBuffer)
| 1187 | |
| 1188 | |
| 1189 | def read_block(state: State, data: ReadBuffer) -> Block: |
| 1190 | expect_tag(data, nodes.BLOCK) |
| 1191 | expect_tag(data, LIST_GEN) |
| 1192 | n = read_int_bare(data) |
| 1193 | is_unreachable = read_bool(data) |
| 1194 | if n == 0: |
| 1195 | # Empty block - read explicit location |
| 1196 | b = Block([], is_unreachable=is_unreachable) |
| 1197 | read_loc(data, b) |
| 1198 | expect_end_tag(data) |
| 1199 | return b |
| 1200 | else: |
| 1201 | # Non-empty block - read statements and set location from them |
| 1202 | a = read_statements(state, data, n) |
| 1203 | expect_end_tag(data) |
| 1204 | b = Block(a, is_unreachable=is_unreachable) |
| 1205 | b.line = a[0].line |
| 1206 | b.column = a[0].column |
| 1207 | b.end_line = a[-1].end_line |
| 1208 | b.end_column = a[-1].end_column |
| 1209 | return b |
| 1210 | |
| 1211 | |
| 1212 | def read_optional_block(state: State, data: ReadBuffer) -> Block | None: |
no test coverage detected
searching dependent graphs…