WasmTransformer

Test

一个为 WebAssembly 二进制文件提供转换操作的包。 灵感来源于 Rust 实现

可用的转换

lowerI64Imports

public func lowerI64Imports(_ input: [UInt8]) throws -> [UInt8]

为具有 i64 参数或返回值的导入插入 trampoline 函数。 这对于在不支持 JavaScript BigInt -> Wasm i64 集成的浏览器中运行 Wasm 模块很有用。 特别是对于 i64 WASI 导入的情况。

stripCustomSections

public func stripCustomSections(_ input: [UInt8]) throws -> [UInt8]

从输入的 WebAssembly 二进制文件中删除所有自定义 section。

测试

  1. 将环境变量 SWIFT_TOOLCHAIN 设置为 SwiftWasm 工具链的路径。 例如:$HOME/Library/Developer/Toolchains/swift-wasm-5.7.3-RELEASE.xctoolchain/usr
  2. 通过以下方式设置测试 fixtures:(cd ./Fixtures/ && npm install && npm run build && make all)
  3. 运行 swift test