github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/testing/binaryencoding/limits.go (about) 1 package binaryencoding 2 3 import ( 4 "github.com/bananabytelabs/wazero/internal/leb128" 5 ) 6 7 // EncodeLimitsType returns the `limitsType` (min, max) encoded in WebAssembly 1.0 (20191205) Binary Format. 8 // 9 // See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#limits%E2%91%A6 10 func EncodeLimitsType(min uint32, max *uint32) []byte { 11 if max == nil { 12 return append(leb128.EncodeUint32(0x00), leb128.EncodeUint32(min)...) 13 } 14 return append(leb128.EncodeUint32(0x01), append(leb128.EncodeUint32(min), leb128.EncodeUint32(*max)...)...) 15 }