| 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..f0cf9d18d3570a5a6e161074f738609ff6d208b1 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
|
| + section.emit_u8(global_type);
|
| + section.emit_u8(false); // we do not support exported globals
|
| + }
|
| + });
|
| + }
|
| +
|
| // Add imports section
|
| if (wasm.imports.length > 0) {
|
| if (debug) print("emitting imports @ " + binary.length);
|
|
|