Expand description
Workshop IR → OPY reconstruction (issue #124).
Consumes a validated workshop_rs::wir::Program and emits deterministic,
byte-stable canonical OPY source that the native opy-rs parser accepts
and that re-lowers to a structurally equivalent WIR
program under workshop_rs::roundtrip::equivalent.
Scope and ownership:
- Builtin action/value/member/enum identities resolve only through the
OPY semantic compatibility manifest (
Manifest) and the Workshop catalog (Catalog) — no new content/signature tables and no invented OPY syntax. - Reconstructed OPY is simple low-level valid OPY: it does not recover
comments, macros, functions, or source abstractions. Names must be valid
OPY identifiers; calls must use the OPY source names the manifest
declares (
len,wait,playEffect, …), because the frontend’s own lowering stamps those names into the recompiled WIR and the equivalence contract compares them exactly. - Every WIR construct the frontend cannot recompile identically is
rejected with a structured
ReconstructIssuenaming the construct — never partial or misleading OPY. This includes the per-player loop form, disabled rules, arbitrary-player variable targets, negative and non-finite number literals (the OPY lexer has no negative-literal token), Workshop-spelled call names with no manifest source form (add,countOf,createBeamEffect, …), enums outside the manifest’s declared domains,Remove From Arraymodifies, calls the frontend lowers to dedicated nodes (debug,print,append,vect), and any rule layout the frontend’s deterministic re-lowering cannot reproduce (non-leading initializer rules, out-of-table-order subroutine rules, unsorted global slots, non-canonical subroutine indices). debug/printactions, arrays, vectors, andformatare emitted in their OPY source forms (debug(x),print(x),[...],vect(x, y, z),"text".format(...)) from the dedicated WIR nodes; they are reachable from OPY-derived WIR and are covered by direct unit tests (no Workshop text spells them).
Pipeline: reconstruct validates the table layout, then emits the
declarations (variables, subroutines), the def bodies, and the rules in
deterministic arena order. Any issue collected anywhere fails the whole
reconstruction with all collected diagnostics.
Structs§
- Reconstruct
Error - All reconstruction failures for one program, in deterministic arena order. The emitter never returns partial output: a non-empty issue list means no OPY was produced.
- Reconstruct
Issue - A structured reconstruction diagnostic naming one non-representable WIR
construct. Stable
code, a human-readablemessage, and the offending source span when the WIR carries one.
Functions§
- reconstruct
- Reconstruct a validated WIR program into deterministic OPY source.
- reconstruct_
with - The context-sensitive form of
reconstruct: resolves identities through the supplied manifest and catalog. The locale selects the catalog spellings used for cross-checks (reconstruction emits OPY, which is locale-independent;en-USis the catalog’s declared surface).