Skip to content

[architecture] decompose god files: llvm-generator, method-calls, member #727

@cs01

Description

@cs01

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions