Decompose 517-line mlirGen(ObjectLiteralExpression) into passes#206
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second §5 item (giant-method decomposition) from
docs/MLIRGen-refactoring-review.md, same treatment ascast()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:ObjectLiteralInfostruct holds the accumulated state (field infos, values, method refs, fields-to-set, receiver type,objThis, the literal node).mlirGenObjectLiteralFields→mlirGenObjectLiteralMethodPrototypes→mlirGenObjectLiteralCaptures→mlirGenObjectLiteralMethodBodies, withaddObjectFieldInfo/addObjectFuncFieldInfo/processObjectFunctionLike(Proto)replacing the closures.std::optional<ValueOrLogicalResult>so the early "success but no value" exits underallowPartialResolvepropagate to the caller exactly as before — a plainLogicalResultwould silently swallow them.receiverTypemid-pass now mutatesoli.receiverTypeexplicitly instead of a captured local.Test plan
tslangrebuilt cleanly (vs2026 debug)thisaccess, arrow function capturing an outer variable (exercises the accumulated-captures field), getter, and object spread — JIT output1 5 101 11 2 1 2as expectedMLIRGenTests.exe: 12/12 pass🤖 Generated with Claude Code