File tree Expand file tree Collapse file tree 9 files changed +372
-0
lines changed
examples/tutorial/moonbit Expand file tree Collapse file tree 9 files changed +372
-0
lines changed Original file line number Diff line number Diff line change 1+ // Generated by `wit-bindgen` 0.45.0.
2+
3+ ///|
4+ fn init {
5+ let _ = @add .add (1 , 2 ).unwrap_or_error () catch { Overflow => ... }
6+
7+ }
Original file line number Diff line number Diff line change 1+ // Generated by `wit-bindgen` 0.45.0. DO NOT EDIT!
2+
3+ ///|
4+ pub (all ) suberror ComputationError {
5+ Overflow
6+ } derive (Show , Eq )
7+
8+ ///|
9+ pub fn add (x : UInt , y : UInt ) -> Result [UInt , ComputationError ] {
10+ let return_area = @ffi .malloc (8 )
11+ wasmImportAdd (x .reinterpret_as_int (), y .reinterpret_as_int (), return_area )
12+ let lifted4 = match @ffi .load8_u (return_area + 0 ) {
13+ 0 => Result ::Ok (@ffi .load32 (return_area + 4 ).reinterpret_as_uint ())
14+ 1 => {
15+ let lifted = match @ffi .load8_u (return_area + 4 ) {
16+ 0 => ComputationError ::Overflow
17+ _ => panic ()
18+ }
19+ Result ::Err (lifted )
20+ }
21+ _ => panic ()
22+ }
23+ @ffi .free (return_area )
24+ return lifted4
25+ }
Original file line number Diff line number Diff line change 1+ package docs : adder @ 0.1.0;
2+
3+ interface add {
4+ variant computation-error {
5+ overflow
6+ }
7+ add : func (x : u32 , y : u32 ) -> result <u32 , computation-error >;
8+ }
9+
10+ world adder {
11+ import add ;
12+ }
Original file line number Diff line number Diff line change 1+ {
2+ // link configuration for Wasm backend
3+ "link" : {
4+ "wasm" : {
5+ "exports" : [
6+ // Export for cabi_realloc
7+ " cabi_realloc:cabi_realloc" ,
8+ // Export per the interface definition
9+ " wasmExportAdd:docs:adder/add@0.1.0#add"
10+ ],
11+ "export-memory-name" : " memory" ,
12+ "heap-start-address" : 16
13+ }
14+ },
15+ "import" : [
16+ {
17+ "path" : " docs/adder/ffi" ,
18+ "alias" : " ffi"
19+ },
20+ {
21+ "path" : " docs/adder/gen/interface/docs/adder/add" ,
22+ "alias" : " add"
23+ }
24+ ]
25+ }
Original file line number Diff line number Diff line change 1+ // Generated by `wit-bindgen` 0.45.0.
2+
3+ ///|
4+ pub fn add (x : UInt , y : UInt ) -> UInt {
5+ x + y
6+ }
Original file line number Diff line number Diff line change 2323 - [ JavaScript] ( ./language-support/javascript.md )
2424 - [ Python] ( ./language-support/python.md )
2525 - [ Rust] ( ./language-support/rust.md )
26+ - [ MoonBit] ( ./language-support/moonbit.md )
2627 - [ WebAssembly Text Format (WAT)] ( ./language-support/wat.md )
2728 - [ Other Languages] ( ./language-support/other-languages.md )
2829- [ Running Components] ( ./running-components.md )
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ This documentation is aimed at _users_ of the component model: developers of lib
1919| [ Worlds] | [ JavaScript] | |
2020| | [ Python] | |
2121| | [ Rust] | |
22+ | | [ MoonBit] | |
2223
2324[ Why Components? ] : ./design/why-component-model.md
2425[ Components ] : ./design/components.md
@@ -31,6 +32,7 @@ This documentation is aimed at _users_ of the component model: developers of lib
3132[ JavaScript ] : ./language-support/javascript.md
3233[ Python ] : ./language-support/python.md
3334[ Rust ] : ./language-support/rust.md
35+ [ MoonBit ] : ./language-support/moonbit.md
3436
3537[ Composing ] : ./composing-and-distributing/composing.md
3638[ Running ] : ./running-components.md
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ without using a higher-level language front-end.
3737 - [ Rust Tooling] ( ./language-support/rust.md )
3838 - [ Building a Component with ` cargo component ` ] ( ./language-support/rust.md#building-a-component-with-cargo-component )
3939 - [ Running a Component from Rust Applications] ( ./language-support/rust.md#running-a-component-from-rust-appliacations )
40+ - [ MoonBit Tooling] ( ./language-support/moonbit.md )
4041 - [ WebAssembly Text Format (WAT)] ( ./language-support/wat.md#wat-webassembly-text-format )
4142 - [ Building a Component from WAT with ` wasm-tools ` ] ( ./language-support/wat.md#building-a-component-with-wasm-tools )
4243 - [ Running a Component with Wasmtime] ( ./language-support/wat.md#running-a-component-with-wasmtime )
You can’t perform that action at this time.
0 commit comments