github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/internal/testing/binaryencoding/data.go (about) 1 package binaryencoding 2 3 import ( 4 "github.com/wasilibs/wazerox/internal/leb128" 5 "github.com/wasilibs/wazerox/internal/wasm" 6 ) 7 8 func encodeDataSegment(d *wasm.DataSegment) (ret []byte) { 9 // Currently multiple memories are not supported. 10 if d.Passive { 11 ret = append(ret, leb128.EncodeInt32(1)...) 12 } else { 13 ret = append(ret, leb128.EncodeInt32(0)...) // active segment 14 ret = append(ret, encodeConstantExpression(d.OffsetExpression)...) 15 } 16 ret = append(ret, leb128.EncodeUint32(uint32(len(d.Init)))...) 17 ret = append(ret, d.Init...) 18 return 19 }