Skip to content

feat: expose canonical action layout - #103

Merged
Teakowa merged 2 commits into
mainfrom
feat/issue-102-action-layout
Aug 24, 2026
Merged

feat: expose canonical action layout#103
Teakowa merged 2 commits into
mainfrom
feat/issue-102-action-layout

Conversation

@Teakowa

@Teakowa Teakowa commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • expose workshop_rs::emitter::action_width for canonical WIR action sequences
  • derive layout from the emitter's existing recursive action expansion and central line path
  • return explicit WIR/emission errors and cover leaf, nested If/Else, While, ForGlobalVariable, and ForPlayerVariable layouts
  • index the public contract from the canonical docs/README.md

Scope

This PR does not add source-language control-flow semantics, Switch/Case/Default/DoWhile, labels, goto, CFG, fallthrough, break policy, or a relocation system. It does not modify opy-rs#61.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --locked -- -D warnings
  • cargo run --locked -p workshop-rs --bin workshop-catalog-gen -- check
  • cargo test --workspace --all-targets --locked (249 passed, 24 suites)
  • focused action-layout tests cover nested structured expansion, canonical-emission width consistency, and explicit invalid-WIR failure

Downstream contract

After this PR is merged and a release containing it is published, opy-rs#61 can replace its local normalized_action_width() model with workshop_rs::emitter::action_width(&program, &catalog, &locale, actions).map(|layout| layout.width), while retaining all OPY-specific switch/do-while semantics and diagnostics locally.

Closes #102

Use the emitter's recursive action expansion as the single source of truth for native action widths, with explicit WIR/emission errors and coverage for nested structured actions. Fixes #102
@Teakowa Teakowa linked an issue Aug 24, 2026 that may be closed by this pull request

@Teakowa Teakowa left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review verdict: merge-ready

I reviewed the complete PR #103 diff against the narrowed scope and acceptance criteria of #102. I found no correctness, ownership, architecture, validation, or regression blocker.

Verified

  • action_width() does not maintain a second manually synchronized width table. It invokes the same recursive Emitter::action() implementation used by canonical emission and counts at the shared line() sink.
  • Nested If/Else, While, ForGlobalVariable, and ForPlayerVariable expansion is therefore derived from the same implementation that emits native Workshop structure.
  • The API remains source-language-neutral. No Switch, Case, Default, DoWhile, label, goto, CFG, fallthrough, or source-language break semantics were added to WIR/workshop-rs.
  • Invalid programs fail explicitly through InvalidWIR; emission/layout failures remain explicit through Emission rather than producing guessed/partial widths.
  • The non-rule-final context is explicitly documented. This matches the relative-Skip use required by opy-rs#61 and preserves the existing rule-final If emission optimization instead of changing emitter semantics.
  • Tests cover leaf/native width, nested structured expansion, emitter/layout agreement, and explicit invalid-WIR failure.
  • The implementation is small and does not redesign WIR or introduce a generic target/relocation system.
  • CI run #220 is green on the reviewed head, including Rust 1.85/stable quality gates, catalog checks, and the five real-project scenarios.

Minor / metadata

  1. docs/action-layout.md is a durable public contract but is not linked from the canonical docs/README.md index. Add it under Architecture/ownership or a small compiler-consumer-contract section so the new public contract is discoverable.
  2. The PR body is empty. The commit contains Fixes #102, but PR-level scope/closure should still explicitly link #102 (for example Closes #102) so the PR remains self-describing independent of merge strategy.

Neither item changes the implementation verdict. After those metadata/documentation cleanups, this is ready to merge and release; opy-rs#61 can then replace its local normalized_action_width() with the released workshop-rs API.

@Teakowa
Teakowa merged commit 1bffc7d into main Aug 24, 2026
3 checks passed
@Teakowa
Teakowa deleted the feat/issue-102-action-layout branch August 24, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose canonical Workshop action layout for relative Skip lowering

1 participant