refactor binary encoding to its own package (#1187)
move binary encoder to its own package Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
This commit is contained in:
@@ -13,10 +13,10 @@ import (
|
||||
"github.com/tetratelabs/wazero"
|
||||
"github.com/tetratelabs/wazero/api"
|
||||
"github.com/tetratelabs/wazero/internal/platform"
|
||||
"github.com/tetratelabs/wazero/internal/testing/binaryencoding"
|
||||
"github.com/tetratelabs/wazero/internal/testing/proxy"
|
||||
"github.com/tetratelabs/wazero/internal/testing/require"
|
||||
"github.com/tetratelabs/wazero/internal/wasm"
|
||||
"github.com/tetratelabs/wazero/internal/wasm/binary"
|
||||
"github.com/tetratelabs/wazero/sys"
|
||||
)
|
||||
|
||||
@@ -507,7 +507,7 @@ func callReturnImportWasm(t *testing.T, importedModule, importingModule string,
|
||||
},
|
||||
}
|
||||
require.NoError(t, module.Validate(api.CoreFeaturesV2))
|
||||
return binary.EncodeModule(module)
|
||||
return binaryencoding.EncodeModule(module)
|
||||
}
|
||||
|
||||
func callOuterInnerWasm(t *testing.T, importedModule, importingModule string) []byte {
|
||||
@@ -543,7 +543,7 @@ func callOuterInnerWasm(t *testing.T, importedModule, importingModule string) []
|
||||
},
|
||||
}
|
||||
require.NoError(t, module.Validate(api.CoreFeaturesV2))
|
||||
return binary.EncodeModule(module)
|
||||
return binaryencoding.EncodeModule(module)
|
||||
}
|
||||
|
||||
func testCloseInFlight(t *testing.T, r wazero.Runtime) {
|
||||
@@ -700,7 +700,7 @@ func testMemOps(t *testing.T, r wazero.Runtime) {
|
||||
}
|
||||
|
||||
func testMultipleInstantiation(t *testing.T, r wazero.Runtime) {
|
||||
bin := binary.EncodeModule(&wasm.Module{
|
||||
bin := binaryencoding.EncodeModule(&wasm.Module{
|
||||
TypeSection: []*wasm.FunctionType{{}},
|
||||
FunctionSection: []wasm.Index{0},
|
||||
MemorySection: &wasm.Memory{Min: 1, Cap: 1, Max: 1, IsMaxEncoded: true},
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
|
||||
"github.com/tetratelabs/wazero"
|
||||
"github.com/tetratelabs/wazero/api"
|
||||
"github.com/tetratelabs/wazero/internal/testing/binaryencoding"
|
||||
"github.com/tetratelabs/wazero/internal/wasm"
|
||||
"github.com/tetratelabs/wazero/internal/wasm/binary"
|
||||
)
|
||||
|
||||
// require_no_diff ensures that the behavior is the same between the compiler and the interpreter for any given binary.
|
||||
@@ -219,7 +219,7 @@ func ensureDummyImports(r wazero.Runtime, origin *wasm.Module, requireNoError fu
|
||||
}
|
||||
m.ExportSection = append(m.ExportSection, &wasm.Export{Type: imp.Type, Name: imp.Name, Index: index})
|
||||
}
|
||||
_, err := r.Instantiate(context.Background(), binary.EncodeModule(m))
|
||||
_, err := r.Instantiate(context.Background(), binaryencoding.EncodeModule(m))
|
||||
requireNoError(err)
|
||||
}
|
||||
return
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"github.com/tetratelabs/wazero"
|
||||
"github.com/tetratelabs/wazero/api"
|
||||
"github.com/tetratelabs/wazero/internal/platform"
|
||||
"github.com/tetratelabs/wazero/internal/testing/binaryencoding"
|
||||
"github.com/tetratelabs/wazero/internal/testing/require"
|
||||
"github.com/tetratelabs/wazero/internal/wasm"
|
||||
"github.com/tetratelabs/wazero/internal/wasm/binary"
|
||||
)
|
||||
|
||||
var ctx = context.Background()
|
||||
@@ -354,7 +354,7 @@ func Test888(t *testing.T) {
|
||||
// This tests that importing FuncRef type globals and using it as an initialization of the locally-defined
|
||||
// FuncRef global works fine.
|
||||
run(t, func(t *testing.T, r wazero.Runtime) {
|
||||
imported := binary.EncodeModule(&wasm.Module{
|
||||
imported := binaryencoding.EncodeModule(&wasm.Module{
|
||||
MemorySection: &wasm.Memory{Min: 0, Max: 5, IsMaxEncoded: true},
|
||||
GlobalSection: []*wasm.Global{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user