linked_list.html (original) (raw)

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

[ Show hidden characters]({{ revealButtonHref }})

;; To compile this wat to wasm, you can use Binaryen:
;;
;; wasm-as -all linked_list.wat -o linked_list.wasm
;;
(module
(type Node(struct(fieldNode (struct (field Node(struct(fieldnext (ref null $Node))))
(global global(mut(refnullglobal (mut (ref null global(mut(refnullNode)) (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)
)
)
)
)
)