-
-
Save gtrsh/eccb3f3765e9d941474ca89bbc8b856d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 hidden or 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