Define TVM_FFI_S_VISIT_MAYBE_EARLY_RETURN

Define TVM_FFI_S_VISIT_MAYBE_EARLY_RETURN#

Define Documentation#

TVM_FFI_S_VISIT_MAYBE_EARLY_RETURN(Result)#

Return from a visit hook if Result stops traversal.

Propagates an Error or a VisitInterrupt out of the enclosing function and otherwise falls through. An Optional<VisitInterrupt> result is returned directly. An Expected result uses an rvalue-only proxy to select the return representation for raw TVMFFIAny hooks or typed Expected helpers.

A registered __s_visit__ hook is one line per traversed field followed by the terminal return. A field skipped on purpose is guarded by a condition and carries a // skips: note saying why.

TVMFFIAny FooVisit(StructuralVisitorObj* visitor, AnyView value) noexcept {
  const FooNode* self =
      details::AnyUnsafe::RawObjectPtrFromAnyViewAfterCheck<const FooNode>(value);
  TVM_FFI_S_VISIT_MAYBE_EARLY_RETURN(visitor->VisitExpected(self->a));
  TVM_FFI_S_VISIT_MAYBE_EARLY_RETURN(visitor->VisitExpected(self->b));
  return AnyView(nullptr).CopyToTVMFFIAny();
}
Parameters:
  • Result – An expression yielding the descent result to inspect.