github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/testing/binaryencoding/export.go (about)

     1  package binaryencoding
     2  
     3  import (
     4  	"github.com/tetratelabs/wazero/internal/leb128"
     5  	"github.com/tetratelabs/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  }