-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drops support for the WebAssembly text format
This drops the text format (%.wat) and renames InstantiateModuleFromCode to InstantiateModuleFromBinary as it is no longer ambiguous. We decided to stop supporting the text format as it isn't typically used in production, yet costs a lot of work to develop. Given the resources available and the increased work added with WebAssembly 2.0 and soon WASI 2, we can't afford to spend the time on it. The old parser is used only internally and will eventually be moved to its own repository named watzero, possibly towards archival. See #59 Signed-off-by: Adrian Cole <[email protected]>
- Loading branch information
Adrian Cole
committed
Jun 1, 2022
1 parent
50d504c
commit 7345177
Showing
69 changed files
with
651 additions
and
467 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
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
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.
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 @@ | ||
(module | ||
;; Define the optional module name. '$' prefixing is a part of the text format. | ||
$wasm/math | ||
|
||
;; add returns $x+$y. | ||
;; | ||
;; Notes: | ||
;; * The stack begins empty and anything left must match the result type. | ||
;; * export allows api.Module to return this via ExportedFunction("add") | ||
(func (export "add") (param $x i32) (param $y i32) (result i32) | ||
local.get $x ;; stack: [$x] | ||
local.get $y ;; stack: [$x, $y] | ||
i32.add ;; stack: [$x+$y] | ||
) | ||
) |
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.
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,25 @@ | ||
(module $age-calculator | ||
|
||
;; In WebAssembly, you don't import an entire module, rather each function. | ||
;; This imports the functions and gives them names which are easier to read | ||
;; than the alternative (zero-based index). | ||
;; | ||
;; Note: Importing unused functions is not an error in WebAssembly. | ||
(import "env" "log_i32" (func $log (param i32))) | ||
(import "env" "current_year" (func $year (result i32))) | ||
|
||
;; get_age looks up the current year and subtracts the input from it. | ||
(func $get_age (export "get_age") (param $year_born i32) (result i32) | ||
call $year ;; stack: [$year.result] | ||
local.get $year_born ;; stack: [$year.result, $year_born] | ||
i32.sub ;; stack: [$year.result-$year_born] | ||
) | ||
|
||
;; log_age calls $log with the result of $get_age | ||
(func (export "log_age") (param $year_born i32) | ||
;; stack: [] | ||
local.get $year_born ;; stack: [$year_born] | ||
call $get_age ;; stack: [$get_age.result] | ||
call $log ;; stack: [] | ||
) | ||
) |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
## Multiple results example | ||
|
||
This example shows how to return more than one result from WebAssembly or Go-defined functions. | ||
This example shows how to return more than one result from WebAssembly or | ||
Go-defined functions. |
Oops, something went wrong.