Define TVM_FFI_S_VISIT_MAYBE_EARLY_RETURN#
Defined in File structural_visit.h
Define Documentation#
-
TVM_FFI_S_VISIT_MAYBE_EARLY_RETURN(Result)#
Return from a visit hook if
Resultstops traversal.Propagates an
Erroror aVisitInterruptout of the enclosing function and otherwise falls through. The stopping result is moved directly into the enclosing Optional or Expected return type.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.Expected<Optional<VisitInterrupt>> FooVisit(StructuralVisitorObj* visitor, AnyView value) noexcept { const FooNode* self = detail::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 Optional<VisitInterrupt>(std::nullopt); } FStructuralVisit hook = FStructuralVisit::FromNative<&FooVisit>(); Expected<Optional<VisitInterrupt>> result = hook.CallExpected(visitor, value);
- Parameters:
Result – An expression yielding the descent result to inspect.