diff options
Diffstat (limited to 'deps/v8/test/mjsunit/wasm/wasm-module-builder.js')
-rw-r--r-- | deps/v8/test/mjsunit/wasm/wasm-module-builder.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/wasm/wasm-module-builder.js b/deps/v8/test/mjsunit/wasm/wasm-module-builder.js index df26fed12a..334a8a14b8 100644 --- a/deps/v8/test/mjsunit/wasm/wasm-module-builder.js +++ b/deps/v8/test/mjsunit/wasm/wasm-module-builder.js @@ -168,6 +168,22 @@ class WasmModuleBuilder { return this; } + stringToBytes(name) { + var result = new Binary(); + result.emit_u32v(name.length); + for (var i = 0; i < name.length; i++) { + result.emit_u8(name.charCodeAt(i)); + } + return result; + } + + addCustomSection(name, bytes) { + name = this.stringToBytes(name); + var length = new Binary(); + length.emit_u32v(name.length + bytes.length); + this.explicit.push([0, ...length, ...name, ...bytes]); + } + addType(type) { // TODO: canonicalize types? this.types.push(type); |