Class StructuralMapEngineBase#

Inheritance Relationships#

Base Type#

Class Documentation#

class StructuralMapEngineBase : public tvm::ffi::StructuralMutatorObj#

Shared state and variable-remap dispatch for both structural-map engines.

This base owns the identity-substitution environment used for FreeVar and DAG identities. Its variable-remap vtable thunks downcast to this common subobject, allowing the typed and dynamic engines to share the environment even when a Parent layer sits above this base.

Public Types

using StateTupleType = std::tuple<>#

Empty callback-state protocol used when no custom Parent layer is present.

Public Functions

inline explicit StructuralMapEngineBase(const StructuralMutatorVTable *vtable)#

Construct the shared engine base with the concrete engine’s vtable.

inline ~StructuralMapEngineBase()#

Protected Functions

inline StateTupleType StateTuple() const noexcept#

Return the empty state tuple exposed to typed map callbacks.

inline Expected<Any> VarRemapGetImpl(AnyView var) noexcept#

Look up a replacement in the identity-substitution environment.

Parameters:

var – The borrowed variable identity to look up.

Returns:

The owning replacement, FFI None on a miss, or an Error.

inline Expected<void> VarRemapSetImpl(AnyView var, AnyView mapped_value) noexcept#

Record a replacement in the identity-substitution environment.

Parameters:
  • var – The borrowed variable identity to bind.

  • mapped_value – The borrowed replacement value.

Returns:

Successful completion, or an Error if the binding cannot be stored.

Protected Attributes

std::unordered_map<const Object*, Any> var_remap_#

Identity-substitution environment keyed by object identity.

Protected Static Functions

static inline TVMFFIAny DispatchVarRemapGet(StructuralMutatorObj *mutator, AnyView var) noexcept#

Dispatch variable-remap lookup through the mutator vtable.

Parameters:
  • mutator – The erased callback-aware mutator.

  • var – The borrowed variable identity to look up.

Returns:

Raw TVMFFIAny containing the owning replacement, FFI None, or Error.

static inline TVMFFIAny DispatchVarRemapSet(StructuralMutatorObj *mutator, AnyView var, AnyView mapped_value) noexcept#

Dispatch variable-remap insertion through the mutator vtable.

Parameters:
  • mutator – The erased callback-aware mutator.

  • var – The borrowed variable identity to bind.

  • mapped_value – The borrowed replacement value.

Returns:

Raw TVMFFIAny containing FFI None or Error.

static inline void UpdateVisitErrorContext(const Expected<Any> &result, AnyView node) noexcept#

Append node to a failed result’s mutate error context.

Parameters:
  • result – The failed result whose Error is annotated.

  • node – The borrowed node to name in the context.

Friends

friend class StructuralMapEngine
friend class StructuralMapDynEngine
friend class StructuralMutateEngine