blob: cc99d7136a2d0551902e42e2d026b8001ae176a2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
package main
import "time"
func init() {
println("called init")
}
//go:wasmimport tester callTestMain
func callTestMain()
func main() {
// Check that exported functions can still be called after calling
// time.Sleep.
time.Sleep(time.Millisecond)
// main.main is not used when using -buildmode=c-shared.
callTestMain()
}
//go:wasmexport hello
func hello() {
println("hello!")
}
//go:wasmexport add
func add(a, b int32) int32 {
println("called add:", a, b)
return a + b
}
//go:wasmimport tester callOutside
func callOutside(a, b int32) int32
//go:wasmexport reentrantCall
func reentrantCall(a, b int32) int32 {
println("reentrantCall:", a, b)
result := callOutside(a, b)
println("reentrantCall result:", result)
return result
}
|