by roman01la

roman01la / clj-wasm

Clojure-flavored WASM's text format

132 Stars 1 Forks Last release: Not found 5 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

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.