Skip to content

Commit d1674cb

Browse files
mauri870cherrymui
authored andcommitted
cmd/compile: document go:wasmimport directive
Fixes #64972 Change-Id: I784a8728afbdef9736681d56f0a79c82a00609d6 GitHub-Last-Rev: bf158db GitHub-Pull-Request: #64991 Reviewed-on: https://go-review.googlesource.com/c/go/+/554455 Reviewed-by: Achille Roussel <[email protected]> Reviewed-by: Johan Brandhorst-Satzkorn <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Austin Clements <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent ee4b61a commit d1674cb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/cmd/compile/doc.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,5 +295,27 @@ The declaration of lower.f may also have a linkname directive with a
295295
single argument, f. This is optional, but helps alert the reader that
296296
the function is accessed from outside the package.
297297
298+
//go:wasmimport importmodule importname
299+
300+
The //go:wasmimport directive is wasm-only and must be followed by a
301+
function declaration.
302+
It specifies that the function is provided by a wasm module identified
303+
by ``importmodule`` and ``importname``.
304+
305+
//go:wasmimport a_module f
306+
func g()
307+
308+
The types of parameters and return values to the Go function are translated to
309+
Wasm according to the following table:
310+
311+
Go types Wasm types
312+
int32, uint32 i32
313+
int64, uint64 i64
314+
float32 f32
315+
float64 f64
316+
unsafe.Pointer i32
317+
318+
Any other parameter types are disallowed by the compiler.
319+
298320
*/
299321
package main

0 commit comments

Comments
 (0)