tvm
Loading...
Searching...
No Matches
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | List of all members
tvm::ObjectVisitor Class Reference

Native visiting with exact dispatch and structural fallback. More...

#include <object_functor.h>

Inheritance diagram for tvm::ObjectVisitor:
Collaboration diagram for tvm::ObjectVisitor:

Public Member Functions

 ObjectVisitor ()
 Construct a visitor using structural fallback for every value.
 
 ObjectVisitor (const ObjectVisitor &other)=delete
 
ObjectVisitor & operator= (const ObjectVisitor &other)=delete
 
virtual ffi::Optional< VisitInterrupt > Visit (ffi::AnyView value)
 Visit a borrowed object or inline value, throwing on failure.
 
Expected< ffi::Optional< VisitInterrupt > > VisitExpected (ffi::AnyView value) noexcept
 Adapt the virtual throwing entrypoint to the structural ABI.
 

Protected Types

using VTable = ObjectFunctor< ffi::Optional< VisitInterrupt >(const ffi::Object *, ObjectVisitor *)>
 Exact native dispatch table with owning interrupt results.
 

Protected Member Functions

 ObjectVisitor (const VTable *vtable)
 Construct a visitor with a finalized native dispatch table.
 

Static Protected Member Functions

static void InitVTable (VTable *vtable)
 Initialize the base registrations in a fresh mutable table.
 
template<typename Self , typename Node >
static void SetDispatch (VTable *vtable)
 Register an exact node type in a fresh table initialized by its parent. Derived node types require separate registrations.
 

Detailed Description

Native visiting with exact dispatch and structural fallback.

Allocate visitors with ffi::make_object<Derived>(). Inputs are borrowed; interrupts and errors own their values. A hook controls descent into its node. One visitor must not be shared by overlapping traversals.

Member Typedef Documentation

◆ VTable

using tvm::ObjectVisitor::VTable = ObjectFunctor<ffi::Optional<VisitInterrupt>(const ffi::Object*, ObjectVisitor*)>
protected

Exact native dispatch table with owning interrupt results.

Constructor & Destructor Documentation

◆ ObjectVisitor() [1/3]

tvm::ObjectVisitor::ObjectVisitor ( )
inline

Construct a visitor using structural fallback for every value.

◆ ObjectVisitor() [2/3]

tvm::ObjectVisitor::ObjectVisitor ( const ObjectVisitor &  other)
delete

◆ ObjectVisitor() [3/3]

tvm::ObjectVisitor::ObjectVisitor ( const VTable *  vtable)
inlineexplicitprotected

Construct a visitor with a finalized native dispatch table.

Parameters
vtableThe immutable table, which must outlive this visitor.

Member Function Documentation

◆ InitVTable()

static void tvm::ObjectVisitor::InitVTable ( VTable *  vtable)
inlinestaticprotected

Initialize the base registrations in a fresh mutable table.

Parameters
vtableThe table to initialize before adding derived registrations.

◆ operator=()

ObjectVisitor & tvm::ObjectVisitor::operator= ( const ObjectVisitor &  other)
delete

◆ SetDispatch()

template<typename Self , typename Node >
static void tvm::ObjectVisitor::SetDispatch ( VTable *  vtable)
inlinestaticprotected

Register an exact node type in a fresh table initialized by its parent. Derived node types require separate registrations.

Template Parameters
SelfThe visitor implementing the hook.
NodeThe exact node type handled by the hook.
Parameters
vtableThe mutable table to receive the registration.

◆ Visit()

virtual ffi::Optional< VisitInterrupt > tvm::ObjectVisitor::Visit ( ffi::AnyView  value)
inlinevirtual

Visit a borrowed object or inline value, throwing on failure.

Parameters
valueThe borrowed value to visit.
Returns
None on completion or an owning interrupt that halts traversal.
Note
A qualified Parent::Visit bypasses this entry override only; recursive child visits still use virtual dispatch.

Reimplemented in tvm::ExprVisitor, and tvm::tirx::SRefTreeCreator.

◆ VisitExpected()

Expected< ffi::Optional< VisitInterrupt > > tvm::ObjectVisitor::VisitExpected ( ffi::AnyView  value)
inlinenoexcept

Adapt the virtual throwing entrypoint to the structural ABI.

Parameters
valueThe borrowed value to visit.
Returns
Completion, interrupt, or the caught error.
Note
Follows the FFI safe-call exception contract: Error retains its identity, and other standard exceptions become InternalError.

The documentation for this class was generated from the following file: