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

     1  package binaryencoding
     2  
     3  import (
     4  	"github.com/tetratelabs/wazero/internal/wasm"
     5  )
     6  
     7  func encodeConstantExpression(expr wasm.ConstantExpression) (ret []byte) {
     8  	if expr.Opcode == wasm.OpcodeVecV128Const {
     9  		ret = append(ret, wasm.OpcodeVecPrefix)
    10  	}
    11  	ret = append(ret, expr.Opcode)
    12  	ret = append(ret, expr.Data...)
    13  	ret = append(ret, wasm.OpcodeEnd)
    14  	return
    15  }