A tool that makes writing WebAssembly Text files easier.

Overview

Silly WAT Linker

SWL is a tool that makes writing WebAssembly Text files easier.

It is future-proof and simple because it doesn’t actually understand WAT. Instead, it is a simplistic S-Expression parser and uses surface-level pattern matching to implement its features. This way, future iterations of WAT with new syntax are unlikely to break this tool.

WAT is the WebAssembly Text format and is defined in the WebAssembly spec.

Usage

SWL can be installed from Cargo:

$ cargo install silly-wat-linker

All work is done on the textual representation. SWL can invoke wabt’s wat2wasm for you to produce a binary file instead:

$ silly-wat-linker ./main.wat      # Emits .wat test file
$ silly-wat-linker -c ./main.wat      # Emits .wasm binary

Features

SWL has a handful of features to make your life easier when hand-writing WAT files. Most features are enabled by default, but you can explicitly select which features to enable using the --features flag.

# This will only run the `size_adjust` and `sort` feature.
$ silly-wat-linker --features size_adjust,sort ./my-file.wat

File Importer (import)

Adds support for importing another .wat file into the current one.

(module
	(import "other_file.wat" (file))
	;; ...
)

Data Importer (data_import)

Allows you to import other files as data segments.

(module
	(data (i32.const 1024) (import "other_file.wat" (raw))
	;; ...
)

Const Expression (constexpr)

Adds const expressions to WAT, allowing evaluation of complex expressions at compile time. Globals that aren’t themselves using const expressions are available.

(module
	(global $DATA_PTR i32 (i32.const 0x4000))
	(data
		(i32.constexpr
			(i32.add
				(global.get $DATA_PTR)
				(i32.const 0x100)))
		"My data")
	;; ...
)

Also supported specifically for the offset attribute for store and load operations:

(module
	(func
		(i32.store
			offset=(i32.constexp
				(i32.add
					(i32.const 0x123)
					(i32.const 0x100)))
			(i32.const 4)))
	;; ...
)

Size Adjuster (size_adjust)

Automatically adjust the size of memory directives to be big enough to hold all active data segments. (This feature is also supposed to do the same for tables and elem segments, but this hasn’t been implemented yet.)

Start Merger (start_merge)

If there are multiple (start) directives (which can easily happen in a multi-file project), SWL will create a new, singular start function that calls all the other start functions.

Sorter (sort)

Sorts all top-level module segments so that imports come first. This feature mostly exists because wat2wasm requires imports to come first.


License Apache-2.0

You might also like...
Pure rust library for reading / writing DNG files providing access to the raw data in a zero-copy friendly way.

DNG-rs   A pure rust library for reading / writing DNG files providing access to the raw data in a zero-copy friendly way. Also containing code for re

A tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK.
A tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK.

FileQL - File Query Language FileQL is a tool that allow you to run SQL-like query on local files instead of database files using the GitQL SDK. Sampl

Turns lines of text into SVG files.

Sentences 2 svg Does what it says on the tin. This takes in a file with some sentences and outputs numbered svgs. There are 3 arguments to keep in min

Command-line tool that provides a workflow for extending, editing, diffing, and writing to vim-style grep lines.

Grug Grug is a command-line tool that provides a workflow for expanding, editing, diffing, and writing edits to files using vim-styled grep lines (suc

Rust File Management CLI is a command-line tool written in Rust that provides essential file management functionalities. Whether you're working with files or directories, this tool simplifies common file operations with ease.

Rust FileOps Rust File Management CLI is a command-line tool written in Rust that provides essential file management functionalities. Whether you're w

dye is a tool to easily color text in shell.
dye is a tool to easily color text in shell.

Dye dye is a tool to easily color text in shell. Usage See the gif below to see these commands in action. echo $(dye --red WARN) This tool will knock

hj is a command line tool to convert HTTP/1-style text into JSON

hj hj is a command line tool to convert HTTP/1-style text into JSON. This command is inspired by yusukebe/rj, which is a standalone HTTP client that s

A simple (but really fast!) CLI tool to convert an epub into a text file.

epub_to_txt A simple (but really fast!) CLI tool written in Rust to convert an epub into a text file (in Markdown format). Usage epub_to_txt filename.

visual guide for writing Intrinsics(SIMD)

wasm-pack-template A template for kick starting a Rust and WebAssembly project using wasm-pack. Tutorial | Chat Built with 🦀 🕸 by The Rust and WebAs

Comments
Owner
Surma
DX at Shopify. Web Platform Advocate. Craving simplicity, finding it nowhere. Internetrovert 🏳️‍🌈
Surma
CLI tool that make it easier to perform multiple lighthouse runs towards a single target and output the result in a plotable format.

Lighthouse Aggregator CLI tool that make it easier to perform multiple lighthouse runs towards a single target and output the result in a "plotable" f

Polestar 1 Jan 12, 2022
Croc-look is a tool to make testing and debuging proc macros easier

croc-look croc-look is a tool to make testing and debuging proc macros easier by these two features Printing the implementation specific generated cod

weegee 7 Dec 2, 2022
An implementation of Piet's text interface using cosmic-text

piet-cosmic-text Implements piet's Text interface using the cosmic-text crate. License piet-cosmic-text is free software: you can redistribute it and/

John Nunley 7 Mar 12, 2023
Warp is a blazingly fast, Rust-based terminal that makes you and your team more productive at running, debugging, and deploying code and infrastructure.

Warp is a blazingly fast, Rust-based terminal that makes you and your team more productive at running, debugging, and deploying code and infrastructure.

Warp 10.4k Jan 4, 2023
A Rust CLI that makes mechanical keyboard sound effects on every key press

Rustyvibes A Rust CLI that makes mechanical keyboard sound effects on every key press Rustyvibes.mp4 Installation macOS: brew install kb24x7/rustyvibe

Kunal Bagaria 95 Dec 14, 2022
procs makes it easy to find and manage system processes

procs procs makes it easy to find and manage system processes. Right now, the main usage is finding processes by the ports it is listening on, but mor

Kurt Wolf 3 Aug 29, 2022
png_defringe_rs is a port of Immorpher's PNG Defringe program written in Rust to achieve easier installation and faster performance.

png_defringe_rs png_defringe_rs is a port of Immorpher's PNG Defringe program written in Rust to achieve easier installation and faster performance. U

null 2 Nov 17, 2022
Set of tools that make it easier for the operator to manage a TAPLE network.

⚠️ TAPLE is in early development and should not be used in production ⚠️ TAPLE Tools TAPLE (pronounced T+ ?? ['tapəl]) stands for Tracking (Autonomous

Open Canarias 5 Jan 25, 2023
A small program which makes a rofi game launcher menu possible by creating .desktop entries for games

rofi-games A small program which makes a `rofi` game launcher menu possible by creating `.desktop` entries for games Installation Manual Clone repo: g

Rolv Apneseth 20 May 4, 2023
A little application that makes it possible to display mpv's subs anywhere you want.

Mpv Subs Popout A little application that makes it possible to display mpv's subs anywhere you want. Why? You can now watch shows in foreign languages

sdaqo 4 Jul 14, 2023