https://github.com/no-defun-allowed/wasm2ps
ruin the sanctity of your printer with ONE WEIRD TRICK
https://github.com/no-defun-allowed/wasm2ps
Last synced: about 2 months ago
JSON representation
ruin the sanctity of your printer with ONE WEIRD TRICK
- Host: GitHub
- URL: https://github.com/no-defun-allowed/wasm2ps
- Owner: no-defun-allowed
- License: bsd-2-clause
- Created: 2021-07-01T02:10:32.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-02T16:10:22.000Z (10 months ago)
- Last Synced: 2025-03-26T04:15:45.769Z (2 months ago)
- Language: Common Lisp
- Size: 4.88 KB
- Stars: 67
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
this project converts a very small subset (integers and control flow)
of WASM to PostScript so you can run it on the printercorporate implementations target web browsers, servers, crabs, but
none target the untapped potential of the shitty PostScript
interpreter your printer hasNote wasm2ps requires `wasm2wat` cause I am lazy and to be fair this
project should not exist# Usage
Write `fib.c`:
```c
int fib(int n) {
return n < 2 ? n : fib(n - 1) + fib(n - 2);
}int ps_main() {
return fib(20);
}
``````sh
clang --target=wasm32-unknown-wasi -O3 -c fib.c
``````lisp
(wasm2ps:wasm2ps "fib.o" :output "fib.ps")
```Now view `fib.ps` and the value returned by `ps_main()` will be
printed on the single page# Performance
Non existent. The so-called compiler implemented uses the dumbest
possible implementation of control flow and looks up every local in a
lexical, so combined with a crappy PS implementation and a slow
printer processor, you will be waiting about 30 seconds for `fib(20)`.