Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/brandonbloom/waet

The WebAssembly Edn Toolkit
https://github.com/brandonbloom/waet

clojure wasm webassembly

Last synced: 2 months ago
JSON representation

The WebAssembly Edn Toolkit

Awesome Lists containing this project

README

        

# WAET: The WebAssembly Edn Toolkit

WAET (prounced "weight") is the Clojure-equivilent of [WABT, the WebAssembly
Binary Toolkit](https://github.com/WebAssembly/wabt).

The WebAssembly Edn Toolkit provides a collection of Babashka scripts in the
style of WABT's C++ programs for manipulating various WebAssembly file formats.

**Provided Tools:**

- `wat2wie` -- Converts WebAssembly Text into WebAssembly In Edn.
- `wie2wasm` -- Converts WebAssembly In Edn to binary WebAssembly. Accepts the
same options as `wat2wasm`.
- `wat2wie2wasm` -- Behaves as `wat2wasm`, but detours through WIE for testing
purposes.

Additionally -- and perhaps most importantly -- WAET provides the above
functionality as a Clojure library for the purpose of being a pleasant
compilation toolkit for compilers targeting WebAssembly.

## Status

Feature incomplete, barely tested, incompletely documented, and completely
unstable. The Waet syntax and command line tools are alpha status. The
Clojure API is expected to undergo significant breaking changes.

Primarily tested in terms of a subset of wabt's own test suite.

## WIE: WebAssembly In Edn

WAT (WebAssembly Text) is already an sexpression language and so has a great
deal of common syntax with EDN (Clojure's Extensible Data Notation).

Where possible, WAT syntax is used directly. Where not possible, WAT is translated to WAET
as described here.

### Strings and Data

Clojure on the JVM uses UTF-16 strings, but WAT data strings specify UTF-8 data.
This means that binary data can not safely be encoded into strings. Instead,
strings are treated abstractly and encoded into UTF-8 when written into Wasm binary.
To exactly encode binary data, use `#waet/data[ ... ]` tagged literals. Each element of the
vector is a data "chunk" which may be a string or number. Big integers are encoded big-endian,
other integers are treated as individual bytes.

### Attributes

WAT attributes are encoded with the `#waet/attribute(NAME & DATA...)` tagged literal.

### Other Differences

- TODO: Document more differences.

## Usage

See `waet.core`. There will be two modes: Compile an entire module, or
compile modulefield-by-modulefield.

## Testing

Use `./test.sh`, which delegates to `$WABT_HOME/run-tests.sh` and injects Waet's toolchain.

## License

Copyright © 2024 Brandon Bloom

Distributed under the Eclipse Public License 1.0.