Skip to content

Abhilekhgautam/wats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

234 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wats

Wats is a compiler front-end and optimizer targeting Bril IR. It has nothing to do with Wat

Try Online

Wats can be built to Web Assembly that allows running wats compiler directly on the web. Run your code online on Wats Playground

Build Instruction [Native]

  • Ensure you have make and a C++ compiler that supports at least C++20
  • Clone the repo.
  • From root directory run: make

Build Instruction [WASM]

  • Ensure you have make and the latest emsdk (for emscripten) installed.
  • clone the repo
  • From root directory run: make wasm

Demo Program

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;
}

Compiling a Wats Program

wats -p <pass-name> <file-path>

About

Front End generator and optmizer for Bril IR.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors