 
      
    | You are here | blog.scottlogic.com | ||
| | | | | surma.dev | |
| | | | | What follows is a brain dump of everything I know about compiling Rust to WebAssembly. Enjoy. | |
| | | | | 21-lessons.com | |
| | | | | Learn how you can embed WebAssembly in your Rust program with wasmtime | |
| | | | | dusty.phillips.codes | |
| | | | | In earlier articles, we have implemented a tokenizer, parser, and transformer to convert WAT syntax to a Wasm AST and got started on the code generation. This part will continue with code generation. We'll start with the import section because it has a couple interesting complications that we need to take into account. The Import Section Consider this wat import statement: (module (import "wasi_snapshot_preview1" "fd_write" ( func $fd_write (param i32 i32 i32 i32) (result i32)) ) ) If we look at the bytes in the binary representation of this section, it's surprisingly long: | |
| | | | | blog.oddbit.com | |
| | | Overview I was recently working with someone else's C source and I wanted to add some basic error checking without mucking up the code with a bunch of if statements and calls to perror. I ended up implementing a simple must function that checks the return value of an expression, and exits with an error if the return value is less than 0. You use it like this: must(fd = open("textfile.txt", O_RDONLY)); Or: | ||