Debian Codegraph @

tests/cli/component-model/virtualize.wast

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots %
2
3 (component
4 (core module $libc
5 (memory (export "mem") 0)
6 (func (export "realloc") (param i32 i32 i32 i32) (result i32)
7 unreachable
8 )
9 )
10 (core instance $libc (instantiate $libc))
11
12 (component $child
13 (import "wasi-file" (instance $wasi-file
14 (export "read" (func (param "count" u32) (result (list u8))))
15 (export "write" (func (param "bytes" (list u8)) (result u32)))
16 ))
17
18 (core instance $libc (instantiate $libc))
19
20 (core module $m
21 (import "wasi-file" "read" (func $read (param i32 i32)))
22 (func $play (export "play")
23 unreachable
24 )
25 )
26
27 (core func $wasi_file_read
28 (canon lower (func $wasi-file "read")
29 (memory $libc "mem")
30 (realloc (func $libc "realloc"))
31 )
32 )
33
34 (core instance $i (instantiate $m
35 (with "wasi-file" (instance
36 (export "read" (func $wasi_file_read))
37 ))
38 ))
39
40 (func (export "play")
41 (canon lift (core func $i "play"))
42 )
43 )
44
45 (component $virtualize
46 (import "wasi-file" (instance $wasi-file
47 (export "read" (func (param "len" u32) (result (list u8))))
48 (export "write" (func (param "buf" (list u8)) (result u32)))
49 ))
50 (export "read" (func $wasi-file "read"))
51 (export "write" (func $wasi-file "write"))
52 )
53
54 (component
55 (type $WasiFile (instance
56 (export "read" (func (param "len" u32) (result (list u8))))
57 (export "write" (func (param "buf" (list u8)) (result u32)))
58 ))
59 (import "wasi-file" (instance $real-wasi (type $WasiFile)))
60 (import "virtualize" (component $VIRTUALIZE
61 (import "wasi-file" (instance (type $WasiFile)))
62 (export "read" (func (param "len" u32) (result (list u8))))
63 (export "write" (func (param "buf" (list u8)) (result u32)))
64 ))
65 (import "child" (component $CHILD
66 (import "wasi-file" (instance (type $WasiFile)))
67 (export "play" (func))
68 )
69 )
70
71 (instance $virt-wasi (instantiate $VIRTUALIZE (with "wasi-file" (instance $real-wasi))))
72 (instance $child (instantiate $CHILD (with "wasi-file" (instance $virt-wasi))))
73
74 (export "work" (func $child "play"))
75 )
76
77 (component
78 (type $WasiFile (instance
79 (export "read" (func (param "len" u32) (result (list u8))))
80 (export "write" (func (param "buf" (list u8)) (result u32)))
81 ))
82 (import "wasi-file" (instance $real-wasi (type $WasiFile)))
83
84 (core instance $libc (instantiate $libc))
85
86 (core module $CHILD
87 (import "wasi-file" "read" (func $wasi-file (param i32 i32)))
88 (func $play (export "play")
89 unreachable
90 )
91 )
92
93 (core module $VIRTUALIZE
94 (import "wasi-file" "read" (func (param i32 i32)))
95 (func (export "read") (param i32 i32)
96 unreachable
97 )
98 (func (export "write") (param i32 i32 i32)
99 unreachable
100 )
101 )
102
103 (core func $real-wasi-read
104 (canon lower (func $real-wasi "read")
105 (memory $libc "mem")
106 (realloc (func $libc "realloc"))
107 )
108 )
109
110 (core instance $virt-wasi (instantiate $VIRTUALIZE (with "wasi-file" (instance (export "read" (func $real-wasi-read))))))
111 (core instance $child (instantiate $CHILD (with "wasi-file" (instance $virt-wasi))))
112 (func (export "work")
113 (canon lift (core func $child "play")
114 (memory $libc "mem")
115 (realloc (func $libc "realloc"))
116 )
117 )
118 )
119 )