A scratchpad of stuff in WebAssembly. All examples are written for simplicity, not good code style nor performance. Please do not use anything here in important stuff.
Much of the toolchain is based on yurydelendik's "Using WebAssembly in LLVM" gist.
Run make build
and make install
in tools
. This builds LLVM, clang, binaryen and WABT with correct stuff for WebAssembly compiling.
Build by running make
in each directory. Test using python3 by running make serve
and browsing to localhost:8000.
To build intermediate results from the C -> WASM compilation, try make main.s
and make main.wat
Simple function export example. Adds two numbers together and prints to console
Same as Add, now with an added step of delegating the addition back to JavaScript.
Poking an exported linear memory from JS and C.
Manipulating JS strings in C.
Implementing a simple toy dynamic memory allocation scheme.
Some canvas functions imported to WASM, shows bouncing particles.
Wraps a portion of WebGL API for importing to WASM, draws a moving triangle.
Wraps a little more of WebGL API for importing to WASM, plays Pong.