From 579538647a084dcf2ceba5abb2c16874aab014d2 Mon Sep 17 00:00:00 2001 From: ForAeons <w.xy020203@gmail.com> Date: Wed, 17 Apr 2024 09:36:11 +0800 Subject: [PATCH 1/3] Fix assign micro_code --- vm/ignite/src/micro_code/call.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vm/ignite/src/micro_code/call.rs b/vm/ignite/src/micro_code/call.rs index 368ad4e..2835953 100644 --- a/vm/ignite/src/micro_code/call.rs +++ b/vm/ignite/src/micro_code/call.rs @@ -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. @@ -38,6 +40,8 @@ pub fn call(mut rt: Runtime, arity: usize) -> Result<Runtime> { ); } + args.reverse(); + let value = rt .current_thread .operand_stack From 93c8d5703bec054bd0a366cfdab02ec50e0bfc90 Mon Sep 17 00:00:00 2001 From: ForAeons <w.xy020203@gmail.com> Date: Wed, 17 Apr 2024 09:41:38 +0800 Subject: [PATCH 2/3] Add small optimization --- vm/ignite/src/micro_code/call.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/vm/ignite/src/micro_code/call.rs b/vm/ignite/src/micro_code/call.rs index 2835953..aaea02e 100644 --- a/vm/ignite/src/micro_code/call.rs +++ b/vm/ignite/src/micro_code/call.rs @@ -30,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( From 215526262ee374c8a9d7f7b393df587bb5a42d94 Mon Sep 17 00:00:00 2001 From: ForAeons <w.xy020203@gmail.com> Date: Wed, 17 Apr 2024 09:58:38 +0800 Subject: [PATCH 3/3] Update ci cd to run build script --- .github/workflows/test.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73f802c..4e1f149 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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