Skip to content

Close out review-doc section 5; add const_cast<GenContext&> removal plan#208

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

Close out review-doc section 5; add const_cast<GenContext&> removal plan#208
ASDAlexander77 merged 1 commit into
mainfrom
refactor/class-method-decomposition

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

Closes §5 (giant-method decomposition) of docs/MLIRGen-refactoring-review.md and tees up §3.

  • Code: the duplicated 5-parameter cast-callback lambda in mlirGenPropertyAccessExpressionBaseLogic is hoisted to a single castFn local shared by the ConstArrayType/ArrayType cases — the last real duplication in that function.
  • Doc — §5 closed: investigating the remaining table entries showed the original measurements were stale: mlirGenClassVirtualTableDefinition was already reduced to ~96 lines by Make class vtable slot resolution O(1), deterministic, and kind-safe #200, and detectAccessLevel was always ~30 lines (the old survey mislabeled multi-line signatures). A fresh survey confirms nothing over 250 lines remains after Decompose 590-line cast() into named pipeline stages #205Decompose 304-line inferType into per-template-kind helpers #207; further splitting is diminishing returns.
  • Doc — A6 added: a phased plan for removing the 31 const_cast<GenContext &> mutations (§3), with a census by mutated field (9× funcOp, 4× typeParamsWithArgs, 3 loop-flag sites, 3× generatedStatements, 2× thisType, 2× stop(), 1× inferTypes, 2 in MLIRCodeLogic.h) and four independently shippable phases: legalize stop() via mutable; copy-on-override for downstream-only overrides (flagging unrestored mutations as the latent bugs §3 predicted); honest GenContext&/out-params for the inference family; parameterize the MLIRCodeLogic.h pokes.

Test plan

  • tslang rebuilt cleanly (vs2026 debug)
  • All seven JIT smoke tests (statics/gctors, generics, utility types, closures/inference, casts, object literals, type inference) produce identical output
  • MLIRGenTests.exe: 12/12 pass

🤖 Generated with Claude Code

@ASDAlexander77 ASDAlexander77 merged commit 9a7f152 into main Jul 12, 2026
2 checks passed
@ASDAlexander77 ASDAlexander77 deleted the refactor/class-method-decomposition branch July 12, 2026 12:46
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