-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1052d00
commit e55b60f
Showing
22 changed files
with
316 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Wasm2wat | ||
|
||
## Basic example | ||
|
||
Given a file `42.wasm`: | ||
|
||
```sh | ||
$ owi wasm2wat ./42.wasm | ||
(module | ||
(func | ||
i32.const 20 | ||
i32.const 22 | ||
i32.add | ||
drop | ||
) | ||
(start 0) | ||
) | ||
``` | ||
|
||
## Man page | ||
|
||
```sh | ||
$ owi wasm2wat --help=plain | ||
NAME | ||
owi-wasm2wat - Generate a text format file (.wat) file from a binary | ||
format file (.wasm) | ||
|
||
SYNOPSIS | ||
owi wasm2wat [OPTION]… [ARG]… | ||
|
||
COMMON OPTIONS | ||
--help[=FMT] (default=auto) | ||
Show this help in format FMT. The value FMT must be one of auto, | ||
pager, groff or plain. With auto, the format is pager or plain | ||
whenever the TERM env var is dumb or undefined. | ||
|
||
--version | ||
Show version information. | ||
|
||
EXIT STATUS | ||
owi wasm2wat exits with: | ||
|
||
0 on success. | ||
|
||
123 on indiscriminate errors reported on standard error. | ||
|
||
124 on command line parsing errors. | ||
|
||
125 on unexpected internal errors (bugs). | ||
|
||
BUGS | ||
Email them to <[email protected]>. | ||
|
||
SEE ALSO | ||
owi(1) | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(mdx | ||
(libraries owi) | ||
(deps %{bin:owi} 42.wasm) | ||
(files README.md)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(* SPDX-License-Identifier: AGPL-3.0-or-later *) | ||
(* Copyright © 2021-2024 OCamlPro *) | ||
(* Written by the Owi programmers *) | ||
|
||
open Syntax | ||
|
||
let cmd_one file = | ||
let ext = Fpath.get_ext file in | ||
match ext with | ||
| ".wasm" -> | ||
let* m = Binary_deserializer.from_file file in | ||
Ok (Format.pp_std "%a@\n" Simplified.Pp.modul m) | ||
| ext -> Error (`Msg (Format.sprintf "invalid extension: `%s`" ext)) | ||
|
||
let cmd files = list_iter cmd_one files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
(* SPDX-License-Identifier: AGPL-3.0-or-later *) | ||
(* Copyright © 2021-2024 OCamlPro *) | ||
(* Written by the Owi programmers *) | ||
|
||
val cmd : Fpath.t list -> unit Result.t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
cmd_script | ||
cmd_sym | ||
cmd_validate | ||
cmd_wasm2wat | ||
compile | ||
concrete | ||
concrete_choice | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$ owi wasm2wat done.wasm | ||
(module | ||
(func | ||
i32.const 22 | ||
i32.const 20 | ||
call 0 | ||
drop | ||
) | ||
(func (param i32) (param i32) (result i32) | ||
local.get 0 | ||
local.get 1 | ||
i32.add | ||
) | ||
(start 1) | ||
) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(cram | ||
(deps %{bin:owi} done.wasm m.wasm locals.wasm locals_drop.wasm)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
$ owi wasm2wat locals.wasm | ||
(module | ||
(func | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 0 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 1 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 2 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 3 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 4 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 5 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 6 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 7 | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 0 | ||
local.get 1 | ||
i32.add | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 4 | ||
local.get 0 | ||
i32.add | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 2 | ||
i32.const 0 | ||
i32.add | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 1 | ||
i32.const 0 | ||
i32.add | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 0 | ||
i32.const 0 | ||
i32.add | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 4 | ||
i32.const 0 | ||
i32.add | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 3 | ||
i32.const 0 | ||
i32.add | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 3 | ||
local.get 4 | ||
i32.add | ||
drop | ||
) | ||
(start 8) | ||
) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
$ owi wasm2wat locals_drop.wasm | ||
(module | ||
(func | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 0 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 1 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 2 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 3 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 4 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 5 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 6 | ||
i32.const 0 | ||
i32.const 1 | ||
i32.const 2 | ||
call 7 | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 0 | ||
drop | ||
local.get 1 | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 4 | ||
drop | ||
local.get 0 | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 2 | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 1 | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 0 | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 4 | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 3 | ||
drop | ||
) | ||
(func (param i32) (param i32) (param i32) (local i32) (local i32) | ||
local.get 3 | ||
drop | ||
local.get 4 | ||
drop | ||
) | ||
(start 8) | ||
) |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
$ owi wasm2wat idontexist.wat | ||
owi: no file 'idontexist.wat' | ||
Usage: owi wasm2wat [OPTION]… [ARG]… | ||
Try 'owi wasm2wat --help' or 'owi --help' for more information. | ||
[124] |
Oops, something went wrong.