github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/internal/testing/binaryencoding/function.go (about) 1 package binaryencoding 2 3 import ( 4 "github.com/wasilibs/wazerox/internal/wasm" 5 ) 6 7 // EncodeFunctionType returns the wasm.FunctionType encoded in WebAssembly 1.0 (20191205) Binary Format. 8 // 9 // Note: Function types are encoded by the byte 0x60 followed by the respective vectors of parameter and result types. 10 // See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#function-types%E2%91%A4 11 func EncodeFunctionType(t *wasm.FunctionType) []byte { 12 // Only reached when "multi-value" is enabled because WebAssembly 1.0 (20191205) supports at most 1 result. 13 data := append([]byte{0x60}, EncodeValTypes(t.Params)...) 14 return append(data, EncodeValTypes(t.Results)...) 15 }