Problem
llvm-generator.ts, method-calls.ts, and member.ts are 3000-5000+ lines each. Every new feature adds more branches to these files. Reasoning about behavior, finding bugs, and avoiding regressions is increasingly hard.
CLAUDE.md acknowledges this: "there are several MASSIVE files."
Concrete decomposition plan
llvm-generator.ts (~4600 lines)
Already partially decomposed (function-generator, control-flow, etc.), but still has ~200 methods. Next moves:
- Extract top-level item processing into
top-level-generator.ts
- Extract HTTP/WebSocket server generation into
stdlib/http.ts
- Extract debug info generation into
infrastructure/debug-info.ts
method-calls.ts (~3500 lines)
Central dispatcher for all object.method() calls. Each method handler is 20-100 lines.
- Group by object type: already have string/array/map/set generators, but many methods are still inline
- Extract remaining inline handlers into their respective type generators
- Create
stdlib/date.ts, stdlib/json-methods.ts for built-in method dispatch
member.ts (~3300 lines)
Member access generator. Complex because it handles class fields, interface fields, array indexing, map access, etc.
- Extract class field access into
access/class-fields.ts
- Extract interface field access into
access/interface-fields.ts
- Extract collection indexing into
access/indexing.ts
Approach
One file at a time, one extraction per PR. Each PR must pass verify:quick. No behavior changes — pure mechanical extraction.
Success criteria
No file in src/codegen/ exceeds 1500 lines.
Problem
llvm-generator.ts,method-calls.ts, andmember.tsare 3000-5000+ lines each. Every new feature adds more branches to these files. Reasoning about behavior, finding bugs, and avoiding regressions is increasingly hard.CLAUDE.md acknowledges this: "there are several MASSIVE files."
Concrete decomposition plan
llvm-generator.ts (~4600 lines)
Already partially decomposed (function-generator, control-flow, etc.), but still has ~200 methods. Next moves:
top-level-generator.tsstdlib/http.tsinfrastructure/debug-info.tsmethod-calls.ts (~3500 lines)
Central dispatcher for all
object.method()calls. Each method handler is 20-100 lines.stdlib/date.ts,stdlib/json-methods.tsfor built-in method dispatchmember.ts (~3300 lines)
Member access generator. Complex because it handles class fields, interface fields, array indexing, map access, etc.
access/class-fields.tsaccess/interface-fields.tsaccess/indexing.tsApproach
One file at a time, one extraction per PR. Each PR must pass verify:quick. No behavior changes — pure mechanical extraction.
Success criteria
No file in
src/codegen/exceeds 1500 lines.