Avoid console.assert (doesn't throw)

This commit is contained in:
Fabian 2020-12-31 19:14:30 -06:00
parent 5bbc11a51d
commit acb8ad5423
14 changed files with 93 additions and 82 deletions

View file

@ -1,6 +1,7 @@
#!/usr/bin/env node
"use strict";
const assert = require("assert").strict;
const fs = require("fs");
const path = require("path");
const x86_table = require("./x86_table");
@ -19,7 +20,7 @@ const to_generate = {
analyzer0f_32: gen_all || table_arg === "analyzer0f_32",
};
console.assert(
assert(
Object.keys(to_generate).some(k => to_generate[k]),
"Pass --table [analyzer|analyzer0f_16|analyzer0f_32] or --all to pick which tables to generate"
);
@ -49,7 +50,7 @@ function gen_read_imm_call(op, size_variant)
}
else
{
console.assert(op.imm1632 || op.imm16 || op.imm32);
assert(op.imm1632 || op.imm16 || op.imm32);
if(op.imm1632 && size === 16 || op.imm16)
{
@ -57,7 +58,7 @@ function gen_read_imm_call(op, size_variant)
}
else
{
console.assert(op.imm1632 && size === 32 || op.imm32);
assert(op.imm1632 && size === 32 || op.imm32);
return "cpu.read_imm32()";
}
}
@ -87,8 +88,8 @@ function make_instruction_name(encoding, size)
const second_prefix = (encoding.opcode & 0xFF0000) === 0 ? "" : hex(encoding.opcode >> 16 & 0xFF, 2);
const fixed_g_suffix = encoding.fixed_g === undefined ? "" : `_${encoding.fixed_g}`;
console.assert(first_prefix === "" || first_prefix === "0F" || first_prefix === "F2" || first_prefix === "F3");
console.assert(second_prefix === "" || second_prefix === "66" || second_prefix === "F2" || second_prefix === "F3");
assert(first_prefix === "" || first_prefix === "0F" || first_prefix === "F2" || first_prefix === "F3");
assert(second_prefix === "" || second_prefix === "66" || second_prefix === "F2" || second_prefix === "F3");
return `instr${suffix}_${second_prefix}${first_prefix}${opcode_hex}${fixed_g_suffix}`;
}
@ -112,12 +113,12 @@ function gen_instruction_body(encodings, size)
if(has_F2.length || has_F3.length)
{
console.assert((encoding.opcode & 0xFF0000) === 0 || (encoding.opcode & 0xFF00) === 0x0F00);
assert((encoding.opcode & 0xFF0000) === 0 || (encoding.opcode & 0xFF00) === 0x0F00);
}
if(has_66.length)
{
console.assert((encoding.opcode & 0xFF00) === 0x0F00);
assert((encoding.opcode & 0xFF00) === 0x0F00);
}
const code = [];
@ -171,13 +172,13 @@ function gen_instruction_body_after_prefix(encodings, size)
if(encoding.fixed_g !== undefined)
{
console.assert(encoding.e);
assert(encoding.e);
// instruction with modrm byte where the middle 3 bits encode the instruction
// group by opcode without prefix plus middle bits of modrm byte
let cases = encodings.reduce((cases_by_opcode, case_) => {
console.assert(typeof case_.fixed_g === "number");
assert(typeof case_.fixed_g === "number");
cases_by_opcode[case_.opcode & 0xFFFF | case_.fixed_g << 16] = case_;
return cases_by_opcode;
}, Object.create(null));
@ -207,7 +208,7 @@ function gen_instruction_body_after_prefix(encodings, size)
];
}
else {
console.assert(encodings.length === 1);
assert(encodings.length === 1);
return gen_instruction_body_after_fixed_g(encodings[0], size);
}
}
@ -233,7 +234,7 @@ function gen_instruction_body_after_fixed_g(encoding, size)
const instruction_name = "::analysis::" + make_instruction_name(encoding, size) + "_analyze";
const args = ["cpu", "analysis"];
console.assert(!imm_read);
assert(!imm_read);
return [].concat(
gen_call(instruction_name, args),
@ -246,7 +247,7 @@ function gen_instruction_body_after_fixed_g(encoding, size)
if(encoding.ignore_mod)
{
console.assert(!imm_read, "Unexpected instruction (ignore mod with immediate value)");
assert(!imm_read, "Unexpected instruction (ignore mod with immediate value)");
// Has modrm byte, but the 2 mod bits are ignored and both
// operands are always registers (0f20-0f24)
@ -284,7 +285,7 @@ function gen_instruction_body_after_fixed_g(encoding, size)
if(encoding.conditional_jump)
{
console.assert(
assert(
(encoding.opcode & ~0xF) === 0x70 ||
(encoding.opcode & ~0xF) === 0x0F80 ||
(encoding.opcode & ~0x3) === 0xE0
@ -305,12 +306,12 @@ function gen_instruction_body_after_fixed_g(encoding, size)
if(encoding.extra_imm16)
{
console.assert(imm_read);
assert(imm_read);
body.push(gen_call("cpu.read_imm16"));
}
else if(encoding.extra_imm8)
{
console.assert(imm_read);
assert(imm_read);
body.push(gen_call("cpu.read_imm8"));
}
@ -348,7 +349,7 @@ function gen_table()
for(let opcode = 0; opcode < 0x100; opcode++)
{
let encoding = by_opcode[opcode];
console.assert(encoding && encoding.length);
assert(encoding && encoding.length);
let opcode_hex = hex(opcode, 2);
let opcode_high_hex = hex(opcode | 0x100, 2);
@ -403,7 +404,7 @@ function gen_table()
{
let encoding = by_opcode0f[opcode];
console.assert(encoding && encoding.length);
assert(encoding && encoding.length);
let opcode_hex = hex(opcode, 2);

View file

@ -1,6 +1,7 @@
#!/usr/bin/env node
"use strict";
const assert = require("assert").strict;
const fs = require("fs");
const path = require("path");
const x86_table = require("./x86_table");
@ -19,7 +20,7 @@ const to_generate = {
interpreter0f_32: gen_all || table_arg === "interpreter0f_32",
};
console.assert(
assert(
Object.keys(to_generate).some(k => to_generate[k]),
"Pass --table [interpreter|interpreter0f_16|interpreter0f_32] or --all to pick which tables to generate"
);
@ -54,7 +55,7 @@ function gen_read_imm_call(op, size_variant)
}
else
{
console.assert(op.imm1632 || op.imm16 || op.imm32);
assert(op.imm1632 || op.imm16 || op.imm32);
if(op.imm1632 && size === 16 || op.imm16)
{
@ -62,7 +63,7 @@ function gen_read_imm_call(op, size_variant)
}
else
{
console.assert(op.imm1632 && size === 32 || op.imm32);
assert(op.imm1632 && size === 32 || op.imm32);
return wrap_imm_call("read_imm32s()");
}
}
@ -92,8 +93,8 @@ function make_instruction_name(encoding, size)
const second_prefix = (encoding.opcode & 0xFF0000) === 0 ? "" : hex(encoding.opcode >> 16 & 0xFF, 2);
const fixed_g_suffix = encoding.fixed_g === undefined ? "" : `_${encoding.fixed_g}`;
console.assert(first_prefix === "" || first_prefix === "0F" || first_prefix === "F2" || first_prefix === "F3");
console.assert(second_prefix === "" || second_prefix === "66" || second_prefix === "F2" || second_prefix === "F3");
assert(first_prefix === "" || first_prefix === "0F" || first_prefix === "F2" || first_prefix === "F3");
assert(second_prefix === "" || second_prefix === "66" || second_prefix === "F2" || second_prefix === "F3");
return `instr${suffix}_${second_prefix}${first_prefix}${opcode_hex}${fixed_g_suffix}`;
}
@ -117,12 +118,12 @@ function gen_instruction_body(encodings, size)
if(has_F2.length || has_F3.length)
{
console.assert((encoding.opcode & 0xFF0000) === 0 || (encoding.opcode & 0xFF00) === 0x0F00);
assert((encoding.opcode & 0xFF0000) === 0 || (encoding.opcode & 0xFF00) === 0x0F00);
}
if(has_66.length)
{
console.assert((encoding.opcode & 0xFF00) === 0x0F00);
assert((encoding.opcode & 0xFF00) === 0x0F00);
}
const code = [];
@ -182,13 +183,13 @@ function gen_instruction_body_after_prefix(encodings, size)
if(encoding.fixed_g !== undefined)
{
console.assert(encoding.e);
assert(encoding.e);
// instruction with modrm byte where the middle 3 bits encode the instruction
// group by opcode without prefix plus middle bits of modrm byte
let cases = encodings.reduce((cases_by_opcode, case_) => {
console.assert(typeof case_.fixed_g === "number");
assert(typeof case_.fixed_g === "number");
cases_by_opcode[case_.opcode & 0xFFFF | case_.fixed_g << 16] = case_;
return cases_by_opcode;
}, Object.create(null));
@ -218,7 +219,7 @@ function gen_instruction_body_after_prefix(encodings, size)
];
}
else {
console.assert(encodings.length === 1);
assert(encodings.length === 1);
return gen_instruction_body_after_fixed_g(encodings[0], size);
}
}
@ -256,7 +257,7 @@ function gen_instruction_body_after_fixed_g(encoding, size)
if(encoding.ignore_mod)
{
console.assert(!imm_read, "Unexpected instruction (ignore mod with immediate value)");
assert(!imm_read, "Unexpected instruction (ignore mod with immediate value)");
// Has modrm byte, but the 2 mod bits are ignored and both
// operands are always registers (0f20-0f24)
@ -326,12 +327,12 @@ function gen_instruction_body_after_fixed_g(encoding, size)
if(encoding.extra_imm16)
{
console.assert(imm_read);
assert(imm_read);
args.push(wrap_imm_call("read_imm16()"));
}
else if(encoding.extra_imm8)
{
console.assert(imm_read);
assert(imm_read);
args.push(wrap_imm_call("read_imm8()"));
}
@ -370,7 +371,7 @@ function gen_table()
for(let opcode = 0; opcode < 0x100; opcode++)
{
let encoding = by_opcode[opcode];
console.assert(encoding && encoding.length);
assert(encoding && encoding.length);
let opcode_hex = hex(opcode, 2);
let opcode_high_hex = hex(opcode | 0x100, 2);
@ -429,7 +430,7 @@ function gen_table()
{
let encoding = by_opcode0f[opcode];
console.assert(encoding && encoding.length);
assert(encoding && encoding.length);
let opcode_hex = hex(opcode, 2);

View file

@ -1,6 +1,7 @@
#!/usr/bin/env node
"use strict";
const assert = require("assert").strict;
const fs = require("fs");
const path = require("path");
const x86_table = require("./x86_table");
@ -19,7 +20,7 @@ const to_generate = {
jit0f_32: gen_all || table_arg === "jit0f_32",
};
console.assert(
assert(
Object.keys(to_generate).some(k => to_generate[k]),
"Pass --table [jit|jit0f_16|jit0f_32] or --all to pick which tables to generate"
);
@ -49,7 +50,7 @@ function gen_read_imm_call(op, size_variant)
}
else
{
console.assert(op.imm1632 || op.imm16 || op.imm32);
assert(op.imm1632 || op.imm16 || op.imm32);
if(op.imm1632 && size === 16 || op.imm16)
{
@ -57,7 +58,7 @@ function gen_read_imm_call(op, size_variant)
}
else
{
console.assert(op.imm1632 && size === 32 || op.imm32);
assert(op.imm1632 && size === 32 || op.imm32);
return "ctx.cpu.read_imm32()";
}
}
@ -87,8 +88,8 @@ function make_instruction_name(encoding, size)
const second_prefix = (encoding.opcode & 0xFF0000) === 0 ? "" : hex(encoding.opcode >> 16 & 0xFF, 2);
const fixed_g_suffix = encoding.fixed_g === undefined ? "" : `_${encoding.fixed_g}`;
console.assert(first_prefix === "" || first_prefix === "0F" || first_prefix === "F2" || first_prefix === "F3");
console.assert(second_prefix === "" || second_prefix === "66" || second_prefix === "F2" || second_prefix === "F3");
assert(first_prefix === "" || first_prefix === "0F" || first_prefix === "F2" || first_prefix === "F3");
assert(second_prefix === "" || second_prefix === "66" || second_prefix === "F2" || second_prefix === "F3");
return `instr${suffix}_${second_prefix}${first_prefix}${opcode_hex}${fixed_g_suffix}`;
}
@ -112,12 +113,12 @@ function gen_instruction_body(encodings, size)
if(has_F2.length || has_F3.length)
{
console.assert((encoding.opcode & 0xFF0000) === 0 || (encoding.opcode & 0xFF00) === 0x0F00);
assert((encoding.opcode & 0xFF0000) === 0 || (encoding.opcode & 0xFF00) === 0x0F00);
}
if(has_66.length)
{
console.assert((encoding.opcode & 0xFF00) === 0x0F00);
assert((encoding.opcode & 0xFF00) === 0x0F00);
}
const code = [];
@ -171,13 +172,13 @@ function gen_instruction_body_after_prefix(encodings, size)
if(encoding.fixed_g !== undefined)
{
console.assert(encoding.e);
assert(encoding.e);
// instruction with modrm byte where the middle 3 bits encode the instruction
// group by opcode without prefix plus middle bits of modrm byte
let cases = encodings.reduce((cases_by_opcode, case_) => {
console.assert(typeof case_.fixed_g === "number");
assert(typeof case_.fixed_g === "number");
cases_by_opcode[case_.opcode & 0xFFFF | case_.fixed_g << 16] = case_;
return cases_by_opcode;
}, Object.create(null));
@ -207,7 +208,7 @@ function gen_instruction_body_after_prefix(encodings, size)
];
}
else {
console.assert(encodings.length === 1);
assert(encodings.length === 1);
return gen_instruction_body_after_fixed_g(encodings[0], size);
}
}
@ -276,7 +277,7 @@ function gen_instruction_body_after_fixed_g(encoding, size)
if(encoding.ignore_mod)
{
console.assert(!imm_read, "Unexpected instruction (ignore mod with immediate value)");
assert(!imm_read, "Unexpected instruction (ignore mod with immediate value)");
// Has modrm byte, but the 2 mod bits are ignored and both
// operands are always registers (0f20-0f24)
@ -408,13 +409,13 @@ function gen_instruction_body_after_fixed_g(encoding, size)
if(encoding.extra_imm16)
{
console.assert(imm_read);
assert(imm_read);
imm_read_bindings.push(`let imm2 = ctx.cpu.read_imm16() as u32;`);
args.push("imm2");
}
else if(encoding.extra_imm8)
{
console.assert(imm_read);
assert(imm_read);
imm_read_bindings.push(`let imm2 = ctx.cpu.read_imm8() as u32;`);
args.push("imm2");
}
@ -455,7 +456,7 @@ function gen_table()
for(let opcode = 0; opcode < 0x100; opcode++)
{
let encoding = by_opcode[opcode];
console.assert(encoding && encoding.length);
assert(encoding && encoding.length);
let opcode_hex = hex(opcode, 2);
let opcode_high_hex = hex(opcode | 0x100, 2);
@ -510,7 +511,7 @@ function gen_table()
{
let encoding = by_opcode0f[opcode];
console.assert(encoding && encoding.length);
assert(encoding && encoding.length);
let opcode_hex = hex(opcode, 2);

View file

@ -1,5 +1,7 @@
"use strict";
const assert = require("assert").strict;
function repeat(s, n)
{
let out = "";
@ -24,13 +26,13 @@ function print_syntax_tree(statements)
}
else if(statement.type === "switch")
{
console.assert(statement.condition);
assert(statement.condition);
const cases = [];
for(let case_ of statement.cases)
{
console.assert(case_.conditions.length >= 1);
assert(case_.conditions.length >= 1);
cases.push(case_.conditions.join(" | ") + " => {");
cases.push.apply(cases, indent(print_syntax_tree(case_.body), 4));
@ -50,7 +52,7 @@ function print_syntax_tree(statements)
}
else if(statement.type === "if-else")
{
console.assert(statement.if_blocks.length >= 1);
assert(statement.if_blocks.length >= 1);
let first_if_block = statement.if_blocks[0];
@ -76,7 +78,7 @@ function print_syntax_tree(statements)
}
else
{
console.assert(false, "Unexpected type: " + statement.type, "In:", statement);
assert(false, "Unexpected type: " + statement.type, "In:", statement);
}
}

View file

@ -161,10 +161,7 @@ FS.prototype.HandleEvent = function(id) {
FS.prototype.load_from_json = function(fs, done)
{
if(DEBUG)
{
console.assert(fs, "Invalid fs passed to load_from_json");
}
dbg_assert(fs, "Invalid fs passed to load_from_json");
if(fs["version"] !== JSONFS_VERSION)
{

View file

@ -6,6 +6,7 @@ process.on("unhandledRejection", exn => { throw exn; });
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
var V86 = require(`../../build/${TEST_RELEASE_BUILD ? "libv86" : "libv86-debug"}.js`).V86;
const assert = require("assert").strict;
var fs = require("fs");
const config_async_cdrom = {
@ -40,7 +41,7 @@ function run_test(name, config, done)
if(error)
{
console.error(error);
console.assert(false);
assert(false);
}
setTimeout(function()

View file

@ -3,6 +3,7 @@
const TEST_RELEASE_BUILD = +process.env.TEST_RELEASE_BUILD;
const assert = require("assert").strict;
const fs = require("fs");
const path = require("path");
const { spawnSync } = require("child_process");
@ -199,8 +200,8 @@ Hint: Use tests/expect/run.js --interactive to interactively accept changes.
else
{
console.log("%s ok", name);
console.assert(!result.stdout);
console.assert(!result.stderr);
assert(!result.stdout);
assert(!result.stderr);
}
onfinished();

View file

@ -21,6 +21,7 @@ catch(e)
process.exit(1);
}
const assert = require("assert").strict;
var cluster = require("cluster");
var os = require("os");
var fs = require("fs");
@ -517,7 +518,7 @@ function run_test(test, done)
console.log("Starting test: %s", test.name);
let image = test.fda || test.hda || test.cdrom || test.bzimage || test.filesystem.basefs;
console.assert(image, "Bootable drive expected");
assert(image, "Bootable drive expected");
if(!fs.existsSync(image))
{

View file

@ -4,6 +4,7 @@
// TODO
// - multiple random tests
const assert = require("assert").strict;
const fs = require("fs");
const encodings = require("../../gen/x86_table.js");
const Prand = require("./prand.js");
@ -88,7 +89,7 @@ function create_nasm_modrm_combinations_16()
let has_imm8 = mod === 1;
let has_imm16 = mod === 2 || rm === 6 && mod === 0;
console.assert(!has_imm8 || !has_imm16);
assert(!has_imm8 || !has_imm16);
let line = ["db " + modrm];
if(has_imm8) line.push("db 9ah");
@ -117,7 +118,7 @@ function create_nasm_modrm_combinations_32()
let has_imm32 = mod === 2 || rm === 5 && mod === 0;
let has_sib = rm === 4;
console.assert(!has_imm8 || !has_imm32);
assert(!has_imm8 || !has_imm32);
if(has_sib)
{
@ -278,7 +279,7 @@ function create_nasm(op, config)
if(opcode === 0x8D)
{
// special case: lea: generate 16-bit addressing and all modrm combinations
console.assert(is_modrm);
assert(is_modrm);
codes.push([].concat(
create_nasm_modrm_combinations_16().map(lines => ["db 67h", "db 8dh"].concat(lines).join("\n")),
@ -287,18 +288,18 @@ function create_nasm(op, config)
}
else
{
console.assert(opcode < 0x1000000);
assert(opcode < 0x1000000);
if(opcode >= 0x10000)
{
let c = opcode >> 16;
console.assert(c === 0x66 || c === 0xF3 || c === 0xF2);
assert(c === 0x66 || c === 0xF3 || c === 0xF2);
codes.push("db " + c);
opcode &= ~0xFF0000;
}
if(opcode >= 0x100)
{
let c = opcode >> 8;
console.assert(c === 0x0F || c === 0xF2 || c === 0xF3, "Expected 0F, F2, or F3 prefix, got " + c.toString(16));
assert(c === 0x0F || c === 0xF2 || c === 0xF3, "Expected 0F, F2, or F3 prefix, got " + c.toString(16));
codes.push("db " + c);
opcode &= ~0xFF00;
}
@ -353,7 +354,7 @@ function create_nasm(op, config)
}
else
{
console.assert(op.imm1632 || op.imm16 || op.imm32);
assert(op.imm1632 || op.imm16 || op.imm32);
if(op.imm1632 && size === 16 || op.imm16)
{
@ -361,7 +362,7 @@ function create_nasm(op, config)
}
else
{
console.assert(op.imm1632 && size === 32 || op.imm32);
assert(op.imm1632 && size === 32 || op.imm32);
codes.push("dd 1234abcdh");
}
}

View file

@ -1,6 +1,7 @@
#!/usr/bin/env node
"use strict";
const assert = require("assert").strict;
const fs = require("fs");
const os = require("os");
const path = require("path");
@ -47,7 +48,7 @@ function chunk(source, num_chunks)
}
return ret;
}
console.assert(
assert(
JSON.stringify(chunk("0 0 1 1 2 2 2 3 3 3".split(" "), 4)) ===
JSON.stringify([["0", "0"],
["1", "1"],

View file

@ -15,6 +15,7 @@ process.on("unhandledRejection", exn => { throw exn; });
// A #UD might indicate a bug in the test generation
const assert = require("assert").strict;
const fs = require("fs");
const path = require("path");
const os = require("os");
@ -58,8 +59,8 @@ catch(e) {
function float_equal(x, y)
{
console.assert(typeof x === "number");
console.assert(typeof y === "number");
assert(typeof x === "number");
assert(typeof y === "number");
if(x === Infinity && y === Infinity || x === -Infinity && y === -Infinity || isNaN(x) && isNaN(y))
{

View file

@ -3,6 +3,7 @@
const QEMU = "qemu-system-x86_64";
const assert = require("assert").strict;
const fs = require("fs");
const { spawn, spawnSync } = require("child_process");
const path = require("path");
@ -12,7 +13,7 @@ const share_dir_9p = fs.mkdtempSync("/tmp/v86-test-qemu-9p");
fs.copyFileSync(path.join(__dirname, "/test-i386"), path.join(share_dir_9p, "/test-i386"));
const qemu_version = spawnSync(QEMU, ["--version"]);
console.assert(qemu_version.status === 0, "QEMU not found, return code: " + qemu_version.status);
assert(qemu_version.status === 0, "QEMU not found, return code: " + qemu_version.status);
console.error("Using QEMU:");
console.error(qemu_version.stdout.toString("utf8"));

View file

@ -3,6 +3,7 @@
process.on("unhandledRejection", exn => { throw exn; });
const assert = require("assert").strict;
const fs = require("fs");
const path = require("path");
@ -29,5 +30,5 @@ function foo(arg) {
const i = new WebAssembly.Instance(wm, { "e": { m: mem, baz, foo } });
i.exports.f();
console.assert(baz_recd_arg === 2, `baz returned: "${baz_recd_arg}"`);
console.assert(foo_recd_arg === 456, `foo returned: "${foo_recd_arg}"`);
assert(baz_recd_arg === 2, `baz returned: "${baz_recd_arg}"`);
assert(foo_recd_arg === 456, `foo returned: "${foo_recd_arg}"`);

View file

@ -9,6 +9,7 @@
process.on("unhandledRejection", exn => { throw exn; });
const assert = require("assert").strict;
const fs = require("fs");
const SECTION_IMPORT = 2;
@ -25,11 +26,11 @@ function main()
var ptr = 0;
// magic
console.assert(view.getUint32(ptr, true) === 0x6d736100);
assert(view.getUint32(ptr, true) === 0x6d736100);
ptr += 4;
// version
console.assert(view.getUint32(ptr, true) === 1);
assert(view.getUint32(ptr, true) === 1);
ptr += 4;
while(ptr < view.byteLength)
@ -75,10 +76,10 @@ function patch_import_section(ptr, view)
{
const table_offset = ptr;
var { ptr, value: table_element_type } = read_leb_u32(ptr, view);
console.assert(table_element_type === 0x70);
assert(table_element_type === 0x70);
const maximum_present = new Uint8Array(view.buffer, ptr, 1);
console.assert(maximum_present[0] === 0 || maximum_present[0] === 1);
assert(maximum_present[0] === 0 || maximum_present[0] === 1);
ptr++;
var { ptr, value: initial_table_size, leb_view: initial_table_size_view } = read_leb_u32(ptr, view);
@ -111,7 +112,7 @@ function patch_import_section(ptr, view)
else if(kind === IMPORT_KIND_MEMORY)
{
const maximum_present = view.getUint8(ptr);
console.assert(maximum_present === 0 || maximum_present === 1);
assert(maximum_present === 0 || maximum_present === 1);
ptr++;
var { ptr, value: initial_memory_size } = read_leb_u32(ptr, view);
@ -126,12 +127,12 @@ function patch_import_section(ptr, view)
const content_type = view.getUint8(ptr);
ptr++;
const mutability = view.getUint8(ptr);
console.assert(mutability === 0 || mutability === 1);
assert(mutability === 0 || mutability === 1);
ptr++;
}
else
{
console.assert(false, `Unexpected import kind: 0x${kind.toString(16)} at offset ${ptr - 1}`);
assert(false, `Unexpected import kind: 0x${kind.toString(16)} at offset ${ptr - 1}`);
}
}
}
@ -143,7 +144,7 @@ function patch_maximum_limit(maximum_present, initial_size, maximum_size)
// set the highest bit of the initial size, in order to use it to pad the existing maximum size bytes
const last_byte_initial_size = initial_size[initial_size.length - 1];
console.assert((last_byte_initial_size & 0x80) === 0);
assert((last_byte_initial_size & 0x80) === 0);
initial_size[initial_size.length - 1] = last_byte_initial_size | 0x80;
for(let i = 0; i < maximum_size.length - 1; i++)
@ -174,7 +175,7 @@ function read_leb_u32(ptr, view)
}
}
console.assert(byte_length <= 4);
assert(byte_length <= 4);
const leb_view = new Uint8Array(view.buffer, ptr - byte_length, byte_length);