Expand description
Source-text rewriting engine: applies IR-node span substitutions to a source string for a given target backend.
Functions§
- apply_
replacements - Apply the span replacements for
targetagainstunit.source, returning the rewritten text. Replacements are applied in source order, tracking the cumulative byte shift so each edit lands at its original semantic position regardless of earlier edits’ length differences. - effective_
end - Effective end-byte of a node for the given target. For HIP, the
trailing
.x/.y/.zfield access is preserved (HIP’s builtins are dim3-typed and the field access is still valid). For every other target the field access must be consumed because the replacement is a scalar function call. - emit
- Emit
unittotarget. Returns the rewritten source plus a list of warnings produced during the rewrite (structurally the rewriter also has the option of mutating the IR withWarningnodes up-front). - replacement_
for - Decide what (if anything) to replace for a given node and target. Returns
Noneif the node needs no rewrite for the given target.