feat: Basic IR codegen - #11
Conversation
Add comprehensive_test.rs and test.rs files with extensive test coverage. Declare test modules in codegen.rs to organize test structure.
Add modulo operator implementation for both integer and floating-point types. Support mixed int/float operations through automatic type conversion. Improve return type handling for boolean values.
This commit standardizes error handling in by refactoring long, chained error maps into more readable blocks. It also removes internal test modules to simplify the build structure. * **IR Generation:** Refactors complex LLVM builder calls and conversions (like float/int/bool promotions, bitwise operations) to use dedicated code blocks, improving readability and maintainability of error messages. * **Code Structure:** Removes and modules from , aligning with the typical Rust practice of placing tests directly within the module being tested or in a dedicated directory. * **Minor Cleanup:** Removes unused variable assignment in .
…setup # Conflicts: # src/codegen.rs # src/main.rs
There was a problem hiding this comment.
Pull Request Overview
This PR implements basic IR code generation functionality for the GML compiler, adding LLVM IR generation and JIT execution capabilities. The main purpose is to enable compilation and execution of GML code through LLVM infrastructure.
Key Changes:
- Implements complete LLVM IR generation for GML language constructs including expressions, statements, functions, and control flow
- Adds JIT execution engine for runtime code execution
- Refactors project structure to separate compilation phases into dedicated handler modules
Reviewed Changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/main.rs | Complete refactor to use modular handlers for parsing, symbol table building, and code generation |
| src/codegen/ | New module containing IR generator and JIT executor for LLVM-based compilation |
| src/handler/ | New modular handler system separating concerns for file operations, parsing, output, symbol tables, and code generation |
| src/tests/ | Comprehensive test suite with helper utilities and extensive codegen tests |
| src/utils/colorize.rs | Remove unnecessary parentheses around function call |
| src/parser/ | Module visibility changes and test reorganization |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Add early termination checks in statement processing to skip remaining statements when a block already has a terminator. Improve control flow handling in if statements and blocks by checking for existing terminators before adding branches.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
The 'windows-latest' runner pre-installs a newer LLVM version (e.g., v20), causing the 'choco install llvm --version=18.1.8' step to fail. Added '--allow-downgrade' to the Chocolatey command to force the installation of the required LLVM v18.1.8.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 34 out of 35 changed files in this pull request and generated no new comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
PR Type
Please check the type of this PR (you can select multiple)
Related Issue
What does this PR do?
The PR primarily focuses on introducing Just-In-Time (JIT) execution capabilities and updating the project dependency to LLVM 18.
JITExecutormodule was added to implement Just-In-Time compilation and execution, built on top of LLVM.ci.yml) was updated to install and use LLVM 18, and related dependencies were updated inCargo.toml.compile_and_execute_mainandcompile_and_execute_functionwere created to streamline the entire process of parsing, IR generation, module verification, and JIT execution for testing and library use.How to test?
Screenshots or Videos
N/A
Additional Information
N/A