Skip to content

Instantly share code, notes, and snippets.

@weebs
Forked from kripken/linked_list.html
Created February 22, 2024 03:42
Show Gist options
  • Save weebs/e748fdd426f62fa79dcd72c4d27b84f5 to your computer and use it in GitHub Desktop.
Save weebs/e748fdd426f62fa79dcd72c4d27b84f5 to your computer and use it in GitHub Desktop.
<script>
var module = WebAssembly.instantiateStreaming(fetch("linked_list.wasm"), {});
</script>
;; 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