mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
24c11d4ba5
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
36 lines
619 B
Go
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
|
|
}
|