Last active
April 9, 2024 13:25
-
-
Save kripken/5cd3e18b6de41c559d590e44252eafff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var module = WebAssembly.instantiateStreaming(fetch("linked_list.wasm"), {}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; To compile this wat to wasm, you can use Binaryen: | |
;; | |
;; wasm-as -all linked_list.wat -o linked_list.wasm | |
;; | |
(module | |
(type $Node (struct (field $next (ref null $Node)))) | |
(global $global (mut (ref null $Node)) (ref.null $Node)) | |
(export "global" (global $global)) | |
(start $main) | |
(func $main | |
(local $i i32) | |
(loop $loop | |
(global.set $global | |
(struct.new $Node | |
(global.get $global) | |
) | |
) | |
(local.set $i | |
(i32.add | |
(local.get $i) | |
(i32.const 1) | |
) | |
) | |
(br_if $loop | |
(i32.le_u | |
(local.get $i) | |
(i32.const 1000) | |
) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See discussion in WebAssembly/binaryen#6253 (comment)