github.com/tetratelabs/wazero@v1.7.3-0.20240513003603-48f702e154b5/internal/testing/binaryencoding/global.go (about) 1 package binaryencoding 2 3 import ( 4 "github.com/tetratelabs/wazero/internal/wasm" 5 ) 6 7 // encodeGlobal returns the wasm.Global encoded in WebAssembly 1.0 (20191205) Binary Format. 8 // 9 // See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#global-section%E2%91%A0 10 func encodeGlobal(g wasm.Global) (data []byte) { 11 var mutable byte 12 if g.Type.Mutable { 13 mutable = 1 14 } 15 data = []byte{g.Type.ValType, mutable} 16 data = append(data, encodeConstantExpression(g.Init)...) 17 return 18 }