Wats is a compiler front-end and optimizer targeting Bril IR. It has nothing to do with Wat
Wats can be built to Web Assembly that allows running wats compiler directly on the web. Run your code online on Wats Playground
- Ensure you have make and a C++ compiler that supports at least C++20
- Clone the repo.
- From root directory run:
make
- Ensure you have make and the latest emsdk (for emscripten) installed.
- clone the repo
- From root directory run:
make wasm
function factorial (num: i32) -> i32{
let result = 1;
for i in 2 to num {
result = result * i;
}
return result;
}
function cube (num : i32) -> i32 {
return num * num * num;
}
function demo_match(num: i32) -> i32 {
let result = 1;
# syntactic sugar for if else
match once {
result < 30 => {result = 30;}
result < 50 => {result = 45;}
}
return result;
}
wats -p <pass-name> <file-path>