This repository has been archived on 2024-06-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coffee.pygments/tests/examplefiles/wat/fib.wat
Jendrik 06f2eba843
Fix #1416: add WebAssembly lexer (#1564)
* add WebAssembly lexer

* avoid test failure by using the default function instead of an empty regex

* address small issues

* fix WebAssembly string escapes

* change WebAssembly multiline comment parsing

* update copyright year

* set versionadded to 2.9

* change WebAssembly tests to use the new test system

* change WebAssembly unit test to use snippets
2021-04-04 17:50:00 +02:00

35 lines
No EOL
916 B
Text

(module
(func $fib (param $n i32) (result i32)
(local $a i32)
(local $b i32)
(local $result i32)
(if
(i32.eqz (local.get $n))
(then
(return (i32.const 1))
)
)
(local.set $b (i32.const 1))
(; nested (; comment ;) ;)
loop
(local.set $result (i32.add (local.get $a) (local.get $b)))
(local.set $a (local.get $b))
(local.set $b (local.get $result))
;; decrement $n
(local.tee $n (i32.sub (local.get $n) (i32.const 1)))
(; test if $n > 0 ;)
(i32.gt_u (i32.const 0))
;; if so, jump to the beginning of the loop
br_if 0
end
local.get $result
)
(func $test_memory_store_args
i32.const 1
f64.store align=8 offset=16
)
(export "fib" (func $fib))
)