github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/testing/binaryencoding/function.go (about) 1 package binaryencoding 2 3 import ( 4 "github.com/tetratelabs/wazero/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 }