github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/testing/binaryencoding/export.go (about)

     1  package binaryencoding
     2  
     3  import (
     4  	"github.com/bananabytelabs/wazero/internal/leb128"
     5  	"github.com/bananabytelabs/wazero/internal/wasm"
     6  )
     7  
     8  // encodeExport returns the wasm.Export encoded in WebAssembly 1.0 (20191205) Binary Format.
     9  //
    10  // See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#export-section%E2%91%A0
    11  func encodeExport(i *wasm.Export) []byte {
    12  	data := encodeSizePrefixed([]byte(i.Name))
    13  	data = append(data, i.Type)
    14  	data = append(data, leb128.EncodeUint32(i.Index)...)
    15  	return data
    16  }