Skip to content

Decompose 517-line mlirGen(ObjectLiteralExpression) into passes#206

Merged
ASDAlexander77 merged 1 commit into
mainfrom
refactor/objectliteral-decomposition
Jul 12, 2026
Merged

Decompose 517-line mlirGen(ObjectLiteralExpression) into passes#206
ASDAlexander77 merged 1 commit into
mainfrom
refactor/objectliteral-decomposition

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

Second §5 item (giant-method decomposition) from docs/MLIRGen-refactoring-review.md, same treatment as cast() in #205.

mlirGen(ObjectLiteralExpression) interleaved three passes over the properties — data fields, method prototypes, method bodies — plus capture accumulation, glued together by five lambdas closing over shared accumulator vectors. Now:

  • ObjectLiteralInfo struct holds the accumulated state (field infos, values, method refs, fields-to-set, receiver type, objThis, the literal node).
  • Each pass is a named member function: mlirGenObjectLiteralFieldsmlirGenObjectLiteralMethodPrototypesmlirGenObjectLiteralCapturesmlirGenObjectLiteralMethodBodies, with addObjectFieldInfo / addObjectFuncFieldInfo / processObjectFunctionLike(Proto) replacing the closures.
  • The fields pass returns std::optional<ValueOrLogicalResult> so the early "success but no value" exits under allowPartialResolve propagate to the caller exactly as before — a plain LogicalResult would silently swallow them.
  • Bodies moved verbatim; the driver is now ~90 lines and reads as the pass sequence. The union-receiver detection that narrows receiverType mid-pass now mutates oli.receiverType explicitly instead of a captured local.

Test plan

🤖 Generated with Claude Code

The function interleaved three passes over the properties (data fields,
method prototypes, method bodies) plus capture accumulation, glued by
five lambdas closing over shared accumulator vectors. Now an
ObjectLiteralInfo struct holds the accumulated state and each pass is a
named member: mlirGenObjectLiteralFields (returns optional result to
preserve early no-value exits under partial resolve),
mlirGenObjectLiteralMethodPrototypes, mlirGenObjectLiteralCaptures,
mlirGenObjectLiteralMethodBodies, with add*/process* helpers replacing
the lambdas. Bodies moved verbatim; driver is ~90 lines.

Review doc item (section 5).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ASDAlexander77 ASDAlexander77 merged commit 7405dd6 into main Jul 12, 2026
2 checks passed
@ASDAlexander77 ASDAlexander77 deleted the refactor/objectliteral-decomposition branch July 12, 2026 12:00
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.

1 participant