MCPcopy Index your code
hub / github.com/apache/tvm / visit_with

Function visit_with

python/tvm/tirx/script/parser/parser.py:569–594  ·  view source on GitHub ↗

The with visiting method for tirx. Parameters ---------- self : Parser The visiting parser. node : doc.With The doc AST with node.

(self: Parser, node: doc.With)

Source from the content-addressed store, hash-verified

567
568@dispatch.register(token="tirx", type_name="With")
569def visit_with(self: Parser, node: doc.With) -> None:
570 """The with visiting method for tirx.
571
572 Parameters
573 ----------
574 self : Parser
575 The visiting parser.
576
577 node : doc.With
578 The doc AST with node.
579 """
580 with contextlib.ExitStack() as stack:
581 stack.enter_context(self.var_table.with_frame())
582 for item in node.items:
583 frame = self.eval_expr(item.context_expr)
584 if not isinstance(frame, Frame) and not (
585 hasattr(frame, "__enter__") and hasattr(frame, "__exit__")
586 ):
587 self.report_error(
588 item.context_expr,
589 "Invalid context expression in the with-statement.",
590 )
591 rhs = stack.enter_context(frame)
592 if item.optional_vars is not None:
593 self.eval_assign(target=item.optional_vars, source=rhs, bind_value=bind_with_value)
594 self.visit_body(node.body)
595
596
597@dispatch.register(token="tirx", type_name="FunctionDef")

Callers

nothing calls this directly

Calls 5

with_frameMethod · 0.80
eval_exprMethod · 0.80
report_errorMethod · 0.80
eval_assignMethod · 0.80
visit_bodyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…