Skip to content

refactor: decompose generateGlobalVariableDeclarations (794 → 423 lines)#282

Merged
cs01 merged 3 commits intomainfrom
refactor/decompose-global-var-decls
Mar 12, 2026
Merged

refactor: decompose generateGlobalVariableDeclarations (794 → 423 lines)#282
cs01 merged 3 commits intomainfrom
refactor/decompose-global-var-decls

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 12, 2026

Summary

Breaks down the 794-line generateGlobalVariableDeclarations method into 5 focused helper methods, reducing the main method to ~423 lines. This makes the codegen easier to extend and reduces native compiler miscompilation risk (smaller functions = safer self-hosting).

Extracted methods:

  • tryHandleGlobalCallReturn — function call return type classification (150 lines)
  • tryHandleGlobalJSONParse — JSON.parse interface detection (55 lines)
  • tryHandleGlobalDeclaredType — declared type annotation (interface/class/alias) (65 lines)
  • tryHandleGlobalExpressionType — expression-based interface detection (55 lines)
  • classifyGlobalCatchAll — final type inference from expression node type (45 lines)

Test plan

  • npm run verify:quick passes (all tests + Stage 1 self-hosting)
  • No behavior change — pure refactor, same control flow
  • Prettier formatted

🤖 Generated with Claude Code

@cs01 cs01 merged commit 69b8b97 into main Mar 12, 2026
12 checks passed
@cs01 cs01 deleted the refactor/decompose-global-var-decls branch March 12, 2026 07:57
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