| 1 |
;; RUN: dump % |
| 2 |
|
| 3 |
(component |
| 4 |
(type $WasiFile (instance |
| 5 |
(export "read" (func (param "len" u32) (result (list u8)))) |
| 6 |
(export "write" (func (param "buf" (list u8)) (result u32))) |
| 7 |
)) |
| 8 |
(import "wasi-file" (instance $real-wasi (type $WasiFile))) |
| 9 |
|
| 10 |
(core module $libc |
| 11 |
(memory (export "mem") 0) |
| 12 |
(func (export "realloc") (param i32 i32 i32 i32) (result i32) |
| 13 |
unreachable |
| 14 |
) |
| 15 |
) |
| 16 |
|
| 17 |
(core instance $libc (instantiate $libc)) |
| 18 |
|
| 19 |
(core module $CHILD |
| 20 |
(import "wasi-file" "read" (func $wasi-file (param i32 i32))) |
| 21 |
(func $play (export "play") |
| 22 |
unreachable |
| 23 |
) |
| 24 |
) |
| 25 |
|
| 26 |
(core module $VIRTUALIZE |
| 27 |
(import "wasi-file" "read" (func (param i32 i32))) |
| 28 |
(func (export "read") (param i32 i32) |
| 29 |
unreachable |
| 30 |
) |
| 31 |
(func (export "write") (param i32 i32 i32) |
| 32 |
unreachable |
| 33 |
) |
| 34 |
) |
| 35 |
|
| 36 |
(core func $real-wasi-read |
| 37 |
(canon lower (func $real-wasi "read") |
| 38 |
(memory $libc "mem") |
| 39 |
(realloc (func $libc "realloc")) |
| 40 |
) |
| 41 |
) |
| 42 |
|
| 43 |
(core instance $virt-wasi (instantiate $VIRTUALIZE (with "wasi-file" (instance (export "read" (func $real-wasi-read)))))) |
| 44 |
(core instance $child (instantiate $CHILD (with "wasi-file" (instance $virt-wasi)))) |
| 45 |
(func (export "work") |
| 46 |
(canon lift (core func $child "play") |
| 47 |
(memory $libc "mem") |
| 48 |
(realloc (func $libc "realloc")) |
| 49 |
) |
| 50 |
) |
| 51 |
) |