(self: Parser, node: doc.With)
| 349 | |
| 350 | @dispatch.register(token="relax", type_name="With") |
| 351 | def visit_with(self: Parser, node: doc.With) -> None: |
| 352 | # Currently only `with R.dataflow()` is supported |
| 353 | if len(node.items) != 1: |
| 354 | self.report_error(node, "Only one item is allowed.") |
| 355 | item = node.items[0] |
| 356 | if item.optional_vars is not None: |
| 357 | self.report_error( |
| 358 | item.context_expr, |
| 359 | "Relax syntax doesn't allow binding expressions in `with` to variables", |
| 360 | ) |
| 361 | frame = self.eval_expr(item.context_expr) |
| 362 | with self.var_table.with_frame(): |
| 363 | with frame: |
| 364 | self.visit(node.body) |
| 365 | if isinstance(frame, BindingBlockFrame) and frame.is_dataflow: |
| 366 | output_vars = frame.output_vars |
| 367 | for var in output_vars: |
| 368 | self.var_table.add(var.name_hint, var, allow_shadowing=True) |
| 369 | |
| 370 | |
| 371 | @dispatch.register(token="relax", type_name="Assign") |
nothing calls this directly
no test coverage detected
searching dependent graphs…