Index: test/mjsunit/wasm/wasm-module-builder.js |
diff --git a/test/mjsunit/wasm/wasm-module-builder.js b/test/mjsunit/wasm/wasm-module-builder.js |
index 5fade5bc8dbda288463539b565bf9342211e299a..1e05a52a6504f4d7e3ea4be315d80d951640f53c 100644 |
--- a/test/mjsunit/wasm/wasm-module-builder.js |
+++ b/test/mjsunit/wasm/wasm-module-builder.js |
@@ -160,6 +160,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); |