refactor: decompose statement generation into modules #261
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.
Following the modularization of expression handling, this PR decomposes the massive
statement.rsfile into specialized submodules withinllvm_temporary/src/llvm_temporary/statement/. This structural refactor significantly improves code readability, reduces cognitive load when navigating the backend, and provides a cleaner foundation for future language features.Key Changes
1. Module Reorganization
The monolithic
generate_statement_irfunction has been broken down into the following logical components:mod.rs: Serves as the main entry point and orchestrator for statement generation.variable.rs: Handles variable declarations and complex initializations (including arrays and structs).assign.rs: Manages variable assignments and dereference-based stores.control.rs: Consolidates logic for control flow structures, includingifchains,whileloops, and jump statements (break,continue,return).io.rs: Encapsulates standard I/O logic forprint,println, and the recently addedinputstatement.asm.rs: Dedicated logic for processing and emitting inline assembly blocks.expr_stmt.rs: Handles statements that consist of a single expression.2. Logic Migration & Cleanup
gen_variable_ir,gen_if_ir, andgen_io_ir.truthy_to_i1(for boolean coercion) andmake_global_cstr(for string literal management), are now managed within their relevant modules or shared viamod.rs.3. Behavioral Consistency
generate_statement_irsignature remains stable to ensure zero impact on the rest of the compiler's pipeline.