Chromium Code Reviews| 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 fecd164b56b00430af074f7f55da9b586484f259..dcfca5d47213637c4d442a8eab9c919592e2044c 100644 |
| --- a/test/mjsunit/wasm/wasm-module-builder.js |
| +++ b/test/mjsunit/wasm/wasm-module-builder.js |
| @@ -104,6 +104,7 @@ class WasmModuleBuilder { |
| constructor() { |
| this.types = []; |
| this.imports = []; |
| + this.globals = []; |
| this.functions = []; |
| this.exports = []; |
| this.table = []; |
| @@ -138,6 +139,11 @@ class WasmModuleBuilder { |
| return this.types.length - 1; |
| } |
| + addGlobal(local_type) { |
| + this.globals.push(local_type); |
| + return this.globals.length - 1; |
| + } |
| + |
| addFunction(name, type) { |
| let type_index = (typeof type) == "number" ? type : this.addType(type); |
| let func = new WasmFunctionBuilder(name, type_index); |
| @@ -192,6 +198,18 @@ class WasmModuleBuilder { |
| }); |
| } |
| + if (wasm.globals.length > 0) { |
| + if (debug) print ("emitting globals @ " + binary.length); |
| + binary.emit_section(kDeclGlobals, section => { |
| + section.emit_varint(wasm.globals.length); |
| + for (let global_type of wasm.globals) { |
| + section.emit_varint(0); //length of global name |
|
bradnelson
2016/08/30 23:36:20
Formatting on this comment is odd.
Mircea Trofin
2016/08/31 00:08:15
Done.
|
| + section.emit_u8(global_type); |
| + section.emit_u8(false); // we do not support exported globals |
|
bradnelson
2016/08/30 23:36:21
These should be 2 spaces.
Mircea Trofin
2016/08/31 00:08:15
Done.
|
| + } |
| + }); |
| + } |
| + |
| // Add imports section |
| if (wasm.imports.length > 0) { |
| if (debug) print("emitting imports @ " + binary.length); |