Files
tinygo/testdata/wasmexport-noscheduler.go
T
Randy Reddig 24c11d4ba5 compiler: conform to latest iteration of wasm types proposal (#4501)
compiler: align with current wasm types proposal

https://github.com/golang/go/issues/66984

- Remove int and uint as allowed types in params, results, pointers, or struct fields
- Only allow small integers in pointers, arrays, or struct fields
- enforce structs.HostLayout usage per wasm types proposal
https://github.com/golang/go/issues/66984
- require go1.23 for structs.HostLayout
- use an interface to check if GoVersion() exists
This permits TinyGo to compile with Go 1.21.
- use goenv.Compare instead of WantGoVersion
- testdata/wasmexport: use int32 instead of int
- compiler/testdata: add structs.HostLayout
- compiler/testdata: improve tests for structs.HostLayout
2024-10-22 18:05:04 +02:00

36 lines
619 B
Go

package main
func init() {
println("called init")
}
//go:wasmimport tester callTestMain
func callTestMain()
func main() {
// 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
}