Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pmatos/racket-binaryen
Binaryen bindings for Racket
https://github.com/pmatos/racket-binaryen
binaryen racket webassembly
Last synced: 25 days ago
JSON representation
Binaryen bindings for Racket
- Host: GitHub
- URL: https://github.com/pmatos/racket-binaryen
- Owner: pmatos
- License: apache-2.0
- Created: 2021-02-24T16:10:14.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-20T07:51:13.000Z (over 3 years ago)
- Last Synced: 2024-11-11T14:56:30.367Z (3 months ago)
- Topics: binaryen, racket, webassembly
- Language: Racket
- Homepage:
- Size: 771 KB
- Stars: 11
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![](.github/badges/SponsoredbyIgalia.svg)](https://www.igalia.com)
[![CI](https://github.com/pmatos/racket-binaryen/workflows/Test/badge.svg?branch=main)](https://github.com/pmatos/racket-binaryen/actions)
[![Scribble](https://img.shields.io/badge/Docs-Scribble-blue.svg)](https://pmatos.github.io/racket-binaryen)# racket-binaryen
[Binaryen](https://github.com/WebAssembly/binaryen) bindings for [Racket](https://www.racket-lang.org).
Currently, this work is experimental. There is some [initial documentation](https://pmatos.github.io/racket-binaryen) evolving together with the implementation of safe bindings but it's highly incomplete.
Andy Wingo gave a ["Compiling to WebAssembly"](https://fosdem.org/2021/schedule/event/webassembly/) presentation at FOSDEM'21, and published his [artifacts](https://github.com/wingo/compiling-to-webassembly).
I implemented the same compiler in Racket using the binaryen bindings (see `tests/wingo-raw.rkt`). To run it on the same example Andy presented try:
```
$ racket test/wingo-raw.rkt test/wingo_fact.scm
"Compiled module:"
(module
(type $i32_=>_i32 (func (param i32) (result i32)))
(export "fac" (func $fac))
(func $fac (param $0 i32) (result i32)
(if (result i32)
(i32.eqz
(local.get $0)
)
(i32.const 1)
(i32.mul
(local.get $0)
(call $fac
(i32.sub
(local.get $0)
(i32.const 1)
)
)
)
)
)
)
"Optimized module:"
(module
(type $i32_=>_i32 (func (param i32) (result i32)))
(export "fac" (func $fac))
(func $fac (; has Stack IR ;) (param $0 i32) (result i32)
(if (result i32)
(local.get $0)
(i32.mul
(call $fac
(i32.sub
(local.get $0)
(i32.const 1)
)
)
(local.get $0)
)
(i32.const 1)
)
)
)
```