1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//! Type definitions for data structures representing a WebAssembly module and its
//! components.
pub use CustomSection;
pub use ;
use *;
pub use Instruction;
use ;
pub type Expr = ;
/// The imports component of a module defines a set of imports that are required for
/// instantiation. Each import is labeled by a two-level name space, consisting of a module
/// name and a name for an entity within that module. Importable definitions are functions,
/// tables, memories, and globals. Each import is specified by a descriptor with a
/// respective type that a definition provided during instantiation is required to match.
/// Every import defines an index in the respective index space. In each index space, the
/// indices of imports go before the first index of any definition contained in the module
/// itself.
///
/// <https://www.w3.org/TR/wasm-core-2/#imports>
/// <https://www.w3.org/TR/wasm-core-2/#import-section>
/// The exports component of a module defines a set of exports that become accessible to the
/// host environment once the module has been instantiated. Each export is labeled by a
/// unique name. Exportable definitions are functions, tables, memories, and globals, which
/// are referenced through a respective descriptor.
///
/// <https://www.w3.org/TR/wasm-core-2/#exports>
/// <https://www.w3.org/TR/wasm-core-2/#export-section>
/// The funcs component of a module defines a vector of functions.
///
/// Functions are referenced through function indices, starting with the
/// smallest index not referencing a function import.
///
/// <https://www.w3.org/TR/wasm-core-2/#functions>
/// <https://www.w3.org/TR/wasm-core-2/#code-section>
/// The globals component of a module defines a vector of global variables (or globals for
/// short): Each global stores a single value of the given global type. Its type also
/// specifies whether a global is immutable or mutable. Moreover, each global is initialized
/// with an init value given by a constant initializer expression. Globals are referenced
/// through global indices, starting with the smallest index not referencing a global import.
///
/// <https://www.w3.org/TR/wasm-core-2/#globals>
/// <https://www.w3.org/TR/wasm-core-2/#global-section>
/// The initial contents of a memory are zero bytes. Data segments can be used to initialize
/// a range of memory from a static vector of bytes. The datas component of a module
/// defines a vector of data segments. Like element segments, data segments have a mode
/// that identifies them as either passive or active. A passive data segment's contents can
/// be copied into a memory using the memory.init instruction. An active data segment
/// copies its contents into a memory during instantiation, as specified by a memory index
/// and a constant expression defining an offset into that memory. Data segments are
/// referenced through data indices.
///
/// <https://www.w3.org/TR/wasm-core-2/#data-segments>
/// <https://www.w3.org/TR/wasm-core-2/#data-section>
/// The initial contents of a table is uninitialized. Element segments can be used to
/// initialize a subrange of a table from a static vector of elements. The elems component
/// of a module defines a vector of element segments. Each element segment defines a
/// reference type and a corresponding list of constant element expressions. Element
/// segments have a mode that identifies them as either passive, active, or declarative. A
/// passive element segment's elements can be copied to a table using the table.init
/// instruction. An active element segment copies its elements into a table during
/// instantiation, as specified by a table index and a constant expression defining an
/// offset into that table. A declarative element segment is not available at runtime but
/// merely serves to forward-declare references that are formed in code with instructions
/// like ref.func. The offset is given by a constant expression. Element segments are
/// referenced through element indices.
///
/// <https://www.w3.org/TR/wasm-core-2/#element-segments>
/// <https://www.w3.org/TR/wasm-core-2/#element-section>