Skip to content
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

bug: call micro_code pop order #52

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@ jobs:
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo build --verbose
- run: cargo test --verbose

build_script:
name: Rust project - build script
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: chmod +x build.sh
- run: ./build.sh
5 changes: 5 additions & 0 deletions vm/ignite/src/micro_code/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use super::apply_builtin;

/// Call a function with the given number of arguments.
/// First it pops n values from the operand stack where n is the arity of the function.
/// The values will be the arguments to the function and they are pushed to a vector and reversed.
/// i.e. the last argument is the top value of the operand stack.
/// Then it pops the closure from the operand stack.
/// It checks that the closure is a closure and that the arity of the closure matches the number of arguments.
/// If the closure is a builtin function it applies the builtin function and returns.
Expand All @@ -28,6 +30,7 @@ use super::apply_builtin;
/// If the closure is not of type closure or the arity of the closure does not match the number of arguments.
pub fn call(mut rt: Runtime, arity: usize) -> Result<Runtime> {
let mut args = Vec::new();
args.reserve_exact(arity);

for _ in 0..arity {
args.push(
Expand All @@ -38,6 +41,8 @@ pub fn call(mut rt: Runtime, arity: usize) -> Result<Runtime> {
);
}

args.reverse();

let value = rt
.current_thread
.operand_stack
Expand Down
Loading