Design safe method-body import with local and label remapping
Author: pardeikeCreated Sep 8, 2026Updated Sep 8, 2026
Labelsenhancementneeds more info/work
Design for the Harmony 3 backlog.
A transpiler author wants to replace a method's instructions with another method's body, apply a few edits, and avoid manually reconciling locals and branches. This concrete use case appears in the #586 discussion.
Design an explicit import/remapping operation for this case. Harmony allocates some of its own locals before transpilers run, so clearing the whole local table would not be a safe default.
Completion criteria:
- Map imported locals and labels into the destination and preserve pinned locals, branches, switch targets and exception regions.
- Define argument, receiver, return-type and generic compatibility, with explicit rejection of unsupported imports.
- Preserve Harmony-owned result/state/exception locals and specify composition with other transpilers and subsequent Infix processing.
- Keep rejected imports from publishing a broken replacement.
- Demonstrate the end-to-end scenario with focused tests and document the limits.
Compare this with existing instruction-reading and reverse-patching APIs. Coordinate local ownership with the transpiler-context design; do not require a complete emitter rewrite without evidence.
Follow-up to #586. Current method reading; Wrapper construction.
Source: pardeike/Harmony