Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(651)

Unified Diff: test/mjsunit/wasm/wasm-module-builder.js

Issue 2650053005: [wasm-test] WasmModuleBuilder.addCustomSection in the JS builder API. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/wasm/js-api.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « test/mjsunit/wasm/js-api.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698