package binaryimport ()// decodeLimitsType returns the `limitsType` (min, max) decoded with the WebAssembly 1.0 (20191205) Binary Format.//// See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#limits%E2%91%A6//// Extended in threads proposal: https://webassembly.github.io/threads/core/binary/types.html#limitsfunc decodeLimitsType( *bytes.Reader) ( uint32, *uint32, bool, error) {varbyteif , = .ReadByte(); != nil { = fmt.Errorf("read leading byte: %v", )return }switch {case0x00, 0x02: , _, = leb128.DecodeUint32()if != nil { = fmt.Errorf("read min of limit: %v", ) }case0x01, 0x03: , _, = leb128.DecodeUint32()if != nil { = fmt.Errorf("read min of limit: %v", )return }varuint32if , _, = leb128.DecodeUint32(); != nil { = fmt.Errorf("read max of limit: %v", ) } else { = & }default: = fmt.Errorf("%v for limits: %#x not in (0x00, 0x01, 0x02, 0x03)", ErrInvalidByte, ) } = == 0x02 || == 0x03return}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.