-
Notifications
You must be signed in to change notification settings - Fork 235
[WIP] map constructors for the VM #2153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ba11b0y
wants to merge
55
commits into
canary
Choose a base branch
from
rahul/map-constructors
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Add support for storing string constants in the VM's object pool during compilation and update tests and documentation accordingly. > > - **Compiler Changes**: > - Add `objects` field to `Compiler` struct in `lib.rs` to store heap-allocated objects like string constants. > - Modify `compile_expression()` in `lib.rs` to handle `Expression::StringValue` by storing strings in the `objects` pool and emitting `LoadConst` instructions. > - **Testing**: > - Add `function_returning_string` and `multiple_strings` tests in `vm.rs` to verify string handling in the VM. > - **Documentation**: > - Add `CLAUDE.md` to provide guidance for working with the BAML compiler and related components. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for e1a7267. You can [customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Add source line number tracking to bytecode generation and display for improved debugging context. > > - **Behavior**: > - Track source line numbers in `Compiler` in `lib.rs` using `current_source_line` and `set_source_line_from_span()`. > - Update `emit()` in `lib.rs` to push `current_source_line` to `source_lines` in `Bytecode`. > - Modify `display_bytecode()` in `debug.rs` to include source line numbers in output. > - **Data Structures**: > - Add `source_lines: Vec<usize>` to `Bytecode` in `bytecode.rs` to map instructions to source lines. > - **Misc**: > - Remove unused span variables in `compile_expression()` in `lib.rs`. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for d0aa17a. You can [customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
100% vibe coded to pretty print instructions based on their type. <img width="443" height="223" alt="image" src="https://github.com/user-attachments/assets/4630630d-6b2a-478e-abde-ed2d356658c5" /> <img width="443" height="223" alt="image" src="https://github.com/user-attachments/assets/679fa3cb-e6c8-4414-ab97-35a5000185c7" /> <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Add color-coded pretty printing for bytecode instructions in BAML VM using the `colored` crate. > > - **Behavior**: > - `display_bytecode()` in `debug.rs` now pretty prints bytecode with colors based on instruction type. > - Uses `colored` crate to apply colors if output is to a TTY. > - **Functions**: > - Adds `get_instruction_color()` in `debug.rs` to map instructions to colors. > - **Dependencies**: > - Adds `colored = "2.1.0"` to `Cargo.toml`. > - **Versioning**: > - Updates `baml-vm` and `baml-compiler` versions in `Cargo.lock`. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for ef0124e. You can [customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
TODO: nested for loops don't work right now. <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Implement for loop support in Baml compiler and VM, adding iterator instructions and tests. > > - **Behavior**: > - Implement for loop compilation in `lib.rs`, handling iterator creation and loop execution. > - Add `CreateIterator` and `IterNext` instructions in `bytecode.rs` for iterator operations. > - Update VM execution in `vm.rs` to handle new instructions and manage iterators. > - **Testing**: > - Add tests for for loops and iterator instructions in `vm.rs` and `tests/vm.rs`. > - Ensure correct execution of simple and nested for loops, and iterator operations. > - **Misc**: > - Update `debug.rs` to display new instructions. > - Add comments and TODOs for future improvements and nested loop support. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for e5bd0bb. You can [customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN --> --------- Co-authored-by: Antonio Sarosi <sarosiantonio@gmail.com>
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.