printing!!!

This commit is contained in:
nora 2023-07-29 21:32:19 +02:00
parent 27a4ecc46b
commit 761f78de0b
6 changed files with 165 additions and 26 deletions

View file

@ -136,7 +136,13 @@ function printString(s: string, f: Formatter) {
}
function printBinaryString(buf: Uint8Array, f: Formatter) {
f.word(`"${buf.toString()}"`);
const parts: string[] = [];
for (let i = 0; i < buf.length; i++) {
const idx = buf[i];
parts.push(`\\${idx.toString(16).padStart(2, "0")}`);
}
f.word(`"${parts.join("")}"`);
}
function printId(id: string | undefined, f: Formatter) {
@ -200,12 +206,12 @@ function printBlockType(type: Blocktype, f: Formatter) {
}
function printMemarg(arg: MemArg, f: Formatter) {
if (arg.offset /*0->false*/) {
f.word(`offset=${arg.offset}`);
}
if (arg.align !== undefined) {
f.word(`align=${arg.align}`);
}
if (arg.offset /*0->false*/) {
`offset=${arg.offset}`;
}
}
/**