aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMauri de Souza Meneguzzo <mauri870@gmail.com>2024-01-10 21:15:55 +0000
committerCherry Mui <cherryyz@google.com>2024-01-11 16:53:50 +0000
commitd1674cb4c6531df6573bc3be136b302d2b362c56 (patch)
tree2424ed348d1e8f32333b48dd25044499ce2cbea1
parentee4b61a32e9cbc8ef5ce484dbf1e5133459b8771 (diff)
downloadgo-d1674cb4c6531df6573bc3be136b302d2b362c56.tar.gz
go-d1674cb4c6531df6573bc3be136b302d2b362c56.zip
cmd/compile: document go:wasmimport directive
Fixes #64972 Change-Id: I784a8728afbdef9736681d56f0a79c82a00609d6 GitHub-Last-Rev: bf158dbeaaa495dc258c590c7a21cf9e25e76ee7 GitHub-Pull-Request: golang/go#64991 Reviewed-on: https://go-review.googlesource.com/c/go/+/554455 Reviewed-by: Achille Roussel <achille.roussel@gmail.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
-rw-r--r--src/cmd/compile/doc.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/cmd/compile/doc.go b/src/cmd/compile/doc.go
index 0a60368afa..507899e222 100644
--- a/src/cmd/compile/doc.go
+++ b/src/cmd/compile/doc.go
@@ -295,5 +295,27 @@ The declaration of lower.f may also have a linkname directive with a
single argument, f. This is optional, but helps alert the reader that
the function is accessed from outside the package.
+ //go:wasmimport importmodule importname
+
+The //go:wasmimport directive is wasm-only and must be followed by a
+function declaration.
+It specifies that the function is provided by a wasm module identified
+by ``importmodule`` and ``importname``.
+
+ //go:wasmimport a_module f
+ func g()
+
+The types of parameters and return values to the Go function are translated to
+Wasm according to the following table:
+
+ Go types Wasm types
+ int32, uint32 i32
+ int64, uint64 i64
+ float32 f32
+ float64 f64
+ unsafe.Pointer i32
+
+Any other parameter types are disallowed by the compiler.
+
*/
package main