Skip to content

refactor(compiler): group native constructor operations into descriptors - #952

Closed
ramonzx6 wants to merge 1 commit into
bendlang:mainfrom
ramonzx6:refactor/native-constructor-descriptors
Closed

ramonzx6 wants to merge 1 commit into
bendlang:mainfrom
ramonzx6:refactor/native-constructor-descriptors

Conversation

@ramonzx6

Copy link
Copy Markdown
Contributor

Why the change

The JavaScript emitter stores native constructor builders, field readers, and match conditions in separate maps. This repeats constructor names and makes additions or renames easy to apply inconsistently. Keeping these related operations together makes each constructor's encoding easier to review and maintain.

What changed

Replace the parallel maps in bend2/comp.ts with one descriptor per native constructor and update the lookups for construction, field access, and matching. Each descriptor requires a builder, with optional readers and conditions; satisfies checks the registry literal before Object.setPrototypeOf. Generated expressions, the outer null prototype, existing diagnostics, and field-count checks remain unchanged.

Validation

  • 1,413 checker/interpreter tests and 639 JavaScript tests pass.
  • 1,294 emitted C/JS files are byte-for-byte identical; 258 rejection diagnostics match.
  • Repository gate: 46/46. Standalone CLI build passes.

Keep each native constructor's builder, field readers, and condition together. Check the registry literal with satisfies before Object.setPrototypeOf and adapt the three JS emitter lookups while preserving templates and diagnostics.
@ramonzx6
ramonzx6 force-pushed the refactor/native-constructor-descriptors branch from 3d2a22f to 822ee1f Compare September 21, 2026 08:06
@ramonzx6
ramonzx6 marked this pull request as ready for review September 21, 2026 08:06
@ramonzx6 ramonzx6 changed the title Use one descriptor per native constructor refactor(compiler): group native constructor operations into descriptors Sep 21, 2026
VictorTaelin pushed a commit that referenced this pull request Sep 21, 2026
The builder, the field readers and the match conditions of a native constructor sit in one record instead of three parallel maps. Emission is byte-identical. (PR #952)
@VictorTaelin

Copy link
Copy Markdown
Contributor

Merged into 2.0.25 under your authorship, thank you: one record per native constructor, byte-identical emission, −48 ttok.

Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.

Phylliida pushed a commit to Phylliida/bend that referenced this pull request Sep 27, 2026
The builder, the field readers and the match conditions of a native constructor sit in one record instead of three parallel maps. Emission is byte-identical. (PR bendlang#952)
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.

2 participants