Need help with clj-wasm?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

149 Stars 2 Forks 5 Commits 0 Opened issues


Clojure-flavored WASM's text format

Services available


Need anything else?

Contributors list

# 26,412
5 commits

Clojure-flavored WASM's text format

Turns this

  (defn add [^i32 a ^i32 b]
    (let [x 1]
      (if (= a x)
        (+ a x)
        (+ a b))))

(defn main [] (add 9 8)))

into this

  (type $return_add (func (param $a i32) (param $b i32) (result i32)))

(func $add (param $a i32) (param $b i32) (result i32) (local $x i32) (block (result i32) (local.set $x (i32.const 1)) (if (result i32) (i32.eq (local.get $x) (local.get $a)) (then (i32.add (local.get $x) (local.get $a))) (else (i32.add (local.get $b) (local.get $a))))))

(export "add" (func $add))

(type $return_main (func (result i32)))

(func $main (result i32) (call $add (i32.const 9) (i32.const 8)))

(export "main" (func $main)))

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.