[WIP] Review API design for reasonableness#65
Conversation
…ecode functions Agent-Logs-Url: https://github.com/ashyanSpada/expression_engine_rs/sessions/6c599b7f-b7f6-4f2e-a732-61b10b9c4971 Co-authored-by: ashyanSpada <22587148+ashyanSpada@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #65 +/- ##
==========================================
+ Coverage 90.96% 91.02% +0.06%
==========================================
Files 12 12
Lines 1394 1404 +10
==========================================
+ Hits 1268 1278 +10
Misses 126 126 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@codex[agent] review this mr |
Reviewed at ffb2dc5: stray |
There was a problem hiding this comment.
Pull request overview
This PR adds a higher-level API for compiling expressions directly into bytecode and executing pre-compiled bytecode programs, aiming to support bytecode caching/reuse across multiple executions.
Changes:
- Added
parse_expression_to_bytecodeto compile an input string directly intobytecode::Program. - Added
execute_programas a crate-level wrapper to run a pre-compiledbytecode::Programwith aContext. - Added tests covering compilation, execution, and bytecode reuse scenarios.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/lib.rs |
Introduces new public bytecode-oriented APIs plus tests and rustdoc examples. |
.DS_Store |
Adds a macOS Finder metadata file to the repo (should not be tracked). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| init(); | ||
| let ast = parser::Parser::new(expr)?.parse_stmt()?; |
There was a problem hiding this comment.
parse_expression_to_bytecode re-implements parsing (Parser::new(...).parse_stmt()) instead of delegating to the existing parse_expression helper. This duplicates logic and can drift if parsing behavior or initialization changes. Consider calling parse_expression(expr)? here and then compiling that AST.
| init(); | |
| let ast = parser::Parser::new(expr)?.parse_stmt()?; | |
| let ast = parse_expression(expr)?; |
| /// let result = execute_program(&program, &mut ctx).unwrap(); | ||
| /// assert_eq!(result, Value::from(13)); | ||
| /// ``` | ||
| pub fn execute_program(program: &bytecode::Program, ctx: &mut Context) -> Result<value::Value> { |
There was a problem hiding this comment.
The public API returns Result<value::Value>, while other public entrypoints in this module return Result<Value> (the crate alias). For a consistent and simpler public surface, prefer returning Result<Value> here as well.
| pub fn execute_program(program: &bytecode::Program, ctx: &mut Context) -> Result<value::Value> { | |
| pub fn execute_program(program: &bytecode::Program, ctx: &mut Context) -> Result<Value> { |
云智能体已开始处理 Review the api desig...,并将随工作推进更新此拉取请求。
Original prompt
创建自 VS Code。