| 1 |
;; RUN: wast --assert default --snapshot tests/snapshots % -f cm-values |
| 2 |
|
| 3 |
;; With this, we can define a component that imports a string and computes a new exported string, all at instantiation time: |
| 4 |
|
| 5 |
(component |
| 6 |
(import "name" (value $name string)) |
| 7 |
(import "libc" (core module $Libc |
| 8 |
(export "memory" (memory 1)) |
| 9 |
(export "realloc" (func (param i32 i32 i32 i32) (result i32))) |
| 10 |
(export "free" (func (param i32 i32 i32))) |
| 11 |
(export "canonical_abi_realloc" (func (param i32 i32 i32 i32) (result i32))) |
| 12 |
)) |
| 13 |
(core instance $libc (instantiate $Libc)) |
| 14 |
(core module $Main |
| 15 |
(import "libc" "memory" (memory 1)) |
| 16 |
(func (export "start") (param i32 i32) (result i32) |
| 17 |
;;... general-purpose compute |
| 18 |
unreachable |
| 19 |
) |
| 20 |
(func (export "start-post-return") (param i32)) |
| 21 |
) |
| 22 |
(core instance $main (instantiate $Main (with "libc" (instance $libc)))) |
| 23 |
(alias core export $main "start" (core func $main_func)) |
| 24 |
(func $start (param "p1" string) (result string) |
| 25 |
(canon lift (core func $main_func) |
| 26 |
(memory $libc "memory") |
| 27 |
(realloc (func $libc "canonical_abi_realloc")) |
| 28 |
(post-return (func $main "start-post-return")) |
| 29 |
) |
| 30 |
) |
| 31 |
(start $start (value $name) (result (value $greeting))) |
| 32 |
(export "greeting" (value $greeting)) |
| 33 |
) |