Skip to content

Commit 1044da7

Browse files
authored
Update README.md.
1 parent 45c30af commit 1044da7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
11
# Binaryen.NET
22
C# Bindings for the Binaryen WebAssembly toolchain.
3+
4+
## Samples
5+
6+
### Generating IR -> WAT
7+
```CSharp
8+
using (var module = new BinaryenModule())
9+
{
10+
// Create a simple function body with a single NOP instruction
11+
var body = BinaryenExpression.Nop(module);
12+
13+
// Add a function with no parameters, no return type, and no locals
14+
module.AddFunction(
15+
name: "TestMethod",
16+
paramTypes: Array.Empty<BinaryenType>(),
17+
resultType: BinaryenType.None,
18+
localTypes: Array.Empty<BinaryenType>(),
19+
body: body);
20+
21+
// Emit WAT
22+
Console.WriteLine(module.ToText());
23+
}
24+
```
25+
26+
Web Assembly Text (WAT) Output:
27+
```WAT
28+
(module
29+
(type $0 (func))
30+
(func $TestMethod
31+
(nop)
32+
)
33+
)
34+
```
35+

0 commit comments

Comments
 (0)