Skip to content

Commit

Permalink
add process_core_asset to test passing and returning a struct
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat committed Nov 19, 2024
1 parent b710dc3 commit 55700bb
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 63 deletions.
28 changes: 21 additions & 7 deletions tests/integration/expected/rust_sdk/basic_wallet.hir
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

(func #__rust_alloc (param i32) (param i32) (result i32)
(block 0 (param v0 i32) (param v1 i32)
(let (v3 i32) (const.i32 1048624))
(let (v3 i32) (const.i32 1048632))
(let (v4 i32) (call #<miden_sdk_alloc::BumpAlloc as core::alloc::global::GlobalAlloc>::alloc v3 v1 v0))
(br (block 1 v4)))

Expand All @@ -56,7 +56,7 @@
(func #__rust_realloc
(param i32) (param i32) (param i32) (param i32) (result i32)
(block 0 (param v0 i32) (param v1 i32) (param v2 i32) (param v3 i32)
(let (v5 i32) (const.i32 1048624))
(let (v5 i32) (const.i32 1048632))
(let (v6 i32) (call #<miden_sdk_alloc::BumpAlloc as core::alloc::global::GlobalAlloc>::alloc v5 v2 v3))
(let (v7 i1) (eq v6 0))
(let (v8 i32) (zext v7))
Expand Down Expand Up @@ -87,7 +87,7 @@

(func #__rust_alloc_zeroed (param i32) (param i32) (result i32)
(block 0 (param v0 i32) (param v1 i32)
(let (v3 i32) (const.i32 1048624))
(let (v3 i32) (const.i32 1048632))
(let (v4 i32) (call #<miden_sdk_alloc::BumpAlloc as core::alloc::global::GlobalAlloc>::alloc v3 v1 v0))
(let (v5 i1) (eq v4 0))
(let (v6 i32) (zext v5))
Expand Down Expand Up @@ -506,6 +506,19 @@
(ret))
)

(func (export #miden:basic-wallet/aux@1.0.0#process-core-asset)
(param felt) (param felt) (param felt) (param felt) (result i32)
(block 0
(param v0 felt)
(param v1 felt)
(param v2 felt)
(param v3 felt)
(call #wit_bindgen_rt::run_ctors_once)
(unreachable))

(block 1 (param v4 i32))
)

(func (export #cabi_realloc_wit_bindgen_0_28_0)
(param i32) (param i32) (param i32) (param i32) (result i32)
(block 0 (param v0 i32) (param v1 i32) (param v2 i32) (param v3 i32)
Expand Down Expand Up @@ -545,7 +558,7 @@
(block 6
(let (v9 i32) (const.i32 0))
(let (v10 u32) (bitcast v9))
(let (v11 u32) (add.checked v10 1048628))
(let (v11 u32) (add.checked v10 1048636))
(let (v12 (ptr u8)) (inttoptr v11))
(let (v13 u8) (load v12))
(let (v14 i32) (zext v13))
Expand All @@ -560,7 +573,7 @@
(block 0
(let (v0 i32) (const.i32 0))
(let (v1 u32) (bitcast v0))
(let (v2 u32) (add.checked v1 1048629))
(let (v2 u32) (add.checked v1 1048637))
(let (v3 (ptr u8)) (inttoptr v2))
(let (v4 u8) (load v3))
(let (v5 i32) (zext v4))
Expand All @@ -580,7 +593,7 @@
(let (v9 u32) (bitcast v8))
(let (v10 u8) (trunc v9))
(let (v11 u32) (bitcast v7))
(let (v12 u32) (add.checked v11 1048629))
(let (v12 u32) (add.checked v11 1048637))
(let (v13 (ptr u8)) (inttoptr v12))
(store v13 v10)
(br (block 2)))
Expand Down Expand Up @@ -1172,7 +1185,7 @@
(block 5
(let (v8 i32) (const.i32 0))
(let (v9 u32) (bitcast v8))
(let (v10 u32) (add.checked v9 1048628))
(let (v10 u32) (add.checked v9 1048636))
(let (v11 (ptr u8)) (inttoptr v10))
(let (v12 u8) (load v11))
(let (v13 i32) (zext v12))
Expand Down Expand Up @@ -1311,6 +1324,7 @@


;; Component Exports
(lift (miden:basic-wallet/aux@1.0.0#process-core-asset) (#basic_wallet #miden:basic-wallet/aux@1.0.0#process-core-asset (func (abi wasm) (param (struct (struct (struct (struct felt) (struct felt) (struct felt) (struct felt))))) (result (struct (struct (struct (struct felt) (struct felt) (struct felt) (struct felt)))))) )
(lift (miden:basic-wallet/aux@1.0.0#process-list-felt) (#basic_wallet #miden:basic-wallet/aux@1.0.0#process-list-felt (func (abi wasm) (param (list (struct felt))) (result (list (struct felt)))) (realloc (#basic_wallet #cabi_realloc) (post-return (#basic_wallet #cabi_post_miden:basic-wallet/aux@1.0.0#process-list-felt) )
(lift (miden:basic-wallet/aux@1.0.0#test-felt-intrinsics) (#basic_wallet #miden:basic-wallet/aux@1.0.0#test-felt-intrinsics (func (abi wasm) (param (struct felt)) (param (struct felt)) (result (struct felt))) )
(lift (miden:basic-wallet/aux@1.0.0#test-stdlib) (#basic_wallet #miden:basic-wallet/aux@1.0.0#test-stdlib (func (abi wasm) (param (list u8)) (result (list u8))) (realloc (#basic_wallet #cabi_realloc) (post-return (#basic_wallet #cabi_post_miden:basic-wallet/aux@1.0.0#process-list-felt) )
Expand Down
15 changes: 10 additions & 5 deletions tests/integration/expected/rust_sdk/basic_wallet.masm
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ end

proc."wit_bindgen_rt::run_ctors_once"
push.0
add.1048629
add.1048637
u32assert
dup.0
u32mod.16
Expand All @@ -432,7 +432,7 @@ proc."wit_bindgen_rt::run_ctors_once"
push.128
u32and
push.0
add.1048629
add.1048637
u32assert
dup.0
u32mod.16
Expand Down Expand Up @@ -1902,15 +1902,15 @@ end


proc."__rust_alloc"
push.1048624
push.1048632
movup.2
swap.1
exec."<miden_sdk_alloc::BumpAlloc as core::alloc::global::GlobalAlloc>::alloc"
end


proc."__rust_alloc_zeroed"
push.1048624
push.1048632
dup.1
swap.2
swap.3
Expand Down Expand Up @@ -1972,7 +1972,7 @@ end


proc."__rust_realloc"
push.1048624
push.1048632
dup.4
swap.2
swap.4
Expand Down Expand Up @@ -2075,6 +2075,11 @@ export.cabi_realloc_wit_bindgen_0_28_0
end


export."miden:basic-wallet/aux@1.0.0#process-core-asset"
exec."wit_bindgen_rt::run_ctors_once" push.0 assert
end


export."miden:basic-wallet/aux@1.0.0#process-list-felt"
exec."wit_bindgen_rt::run_ctors_once" push.0 assert
end
Expand Down
Loading

0 comments on commit 55700bb

Please sign in to comment.