Eager translation context shared by registered hooks. Hooks construct Docs, use explicit lexical scopes, and attach origins when emitting.
More...
|
| ffi::Optional< ExprDoc > | Translate (ffi::AnyView value, const ffi::Optional< Var > bind_var=std::nullopt) |
| | Translate a value with an optional pre-mapped binding variable.
|
| |
| void | Emit (const Doc &doc, ffi::Optional< ffi::ObjectRef > origin=std::nullopt) |
| | Append a completed Doc and record its optional origin.
|
| |
| IdDoc | VarGetOrAllocId (const Var &var, bool explicit_def) |
| | Reuse or allocate a variable's stable identifier.
|
| |
| IdDoc | AllocId (const ffi::String &hint) |
| | Reserve a fresh identifier without mapping a variable.
|
| |
| ffi::Dict< Var, IdDoc > | GetImplicitDefs () |
| | Get the current variable scope's pending definitions.
|
| |
| template<typename T > |
| T | GetExtraConfig (const ffi::String &name, T fallback) const |
| | Read a typed extension option.
|
| |
| template<typename T > |
| T | GetOrCreateExtraState (const ffi::String &name) |
| | Get or initialize typed extension state.
|
| |
| void | SetExtraState (const ffi::String &name, std::optional< ffi::Any > value) |
| | Replace or remove extension state.
|
| |
| void | BeginVarScope () |
| | Begin a lexical variable scope independent of Doc collection.
|
| |
| void | EndVarScope () |
| | End the latest naming region, retaining the root region. Explicit local bindings expire. Unresolved implicit references and their identifiers remain pending in the enclosing region, preserving captures shared by sibling functions.
|
| |
| template<typename Callback > |
| decltype(auto) | WithVarScope (Callback &&callback) |
| | Run a callback in a balanced lexical variable scope without collecting Docs.
|
| |
| template<typename T , typename Callback > |
| decltype(auto) | WithExtraStateScope (const ffi::String &name, T value, Callback &&callback) |
| | Run a callback with temporarily replaced typed extension state.
|
| |
| void | BeginDocScope () |
| | Push an empty Doc collection.
|
| |
| ffi::List< Doc > | EndDocScope () |
| | Pop the latest Doc collection.
|
| |
| ffi::List< Doc > | CurrentScopeDocs () const |
| | Get the current Doc collection without popping it.
|
| |
| template<typename Callback > |
| ffi::List< Doc > | WithDocScope (Callback &&callback) |
| | Run a callback in a balanced Doc collection scope.
|
| |
| ffi::Dict< Doc, ffi::ObjectRef > | GetDocOrigins () const |
| | Get the owned Doc-to-original-object associations.
|
| |
| void | RecordOrigin (const Doc &doc, const ffi::ObjectRef &origin) |
| | Set a Doc's original IR object, replacing any previous association.
|
| |
| ffi::Optional< ExprDoc > | DefaultTranslate (ffi::AnyView value, const ffi::Object *destination=nullptr) |
| | Dispatch to a registered hook, or reflect an unhandled Type constructor.
|
| |
| TVM_TIRX_DLL ExprDoc | DefaultTypeTranslate (const Type &type) |
| | Translate a Type constructor from its reflected fields and fixed defaults.
|
| |
| | TVM_FFI_DECLARE_OBJECT_INFO ("script.printer.DocTranslator", DocTranslatorObj, ffi::Object) |
| |
Eager translation context shared by registered hooks. Hooks construct Docs, use explicit lexical scopes, and attach origins when emitting.
const ffi::Object* destination) {
if (!destination) return rhs;
auto var = ffi::GetRef<Var>(
static_cast<const VarObj*
>(destination));
return std::nullopt;
}
A local variable in the IR.
Definition expr.h:552
Reference type of AssignDocObj.
Definition doc.h:843
Eager translation context shared by registered hooks. Hooks construct Docs, use explicit lexical scop...
Definition doc_translator.h:124
void Emit(const Doc &doc, ffi::Optional< ffi::ObjectRef > origin=std::nullopt)
Append a completed Doc and record its optional origin.
Definition doc_translator.h:152
IdDoc VarGetOrAllocId(const Var &var, bool explicit_def)
Reuse or allocate a variable's stable identifier.
Definition doc_translator.h:163
Reference type of ExprDocObj.
Definition doc.h:135
Reference type of IdDocObj.
Definition doc.h:387
static LiteralDoc Str(const ffi::String &v, const ffi::Optional< AccessPath > &p)
Create a LiteralDoc to represent string.
Definition doc.h:304