Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions packages/wasm-parser/src/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1101,23 +1101,21 @@ export function decode(ab: ArrayBuffer, opts: DecoderOpts): Program {
return t.globalType(type, globalType);
}

// function parseNameModule() {
// const lenu32 = readVaruint32();
// eatBytes(lenu32.nextIndex);

// console.log("len", lenu32);
function parseNameModule() {
const lenu32 = readVaruint32();
eatBytes(lenu32.nextIndex);

// const strlen = lenu32.value;
const strlen = lenu32.value;

// dump([strlen], "string length");
dump([strlen], "string length");

// const bytes = readBytes(strlen);
// eatBytes(strlen);
const bytes = readBytes(strlen);
eatBytes(strlen);

// const value = utf8.decode(bytes);
const value = utf8.decode(bytes);

// return [t.moduleNameMetadata(value)];
// }
return [t.moduleNameMetadata(value)];
}

// this section contains an array of function names and indices
function parseNameSectionFunctions() {
Expand Down Expand Up @@ -1189,16 +1187,10 @@ export function decode(ab: ArrayBuffer, opts: DecoderOpts): Program {
eatBytes(subSectionSizeInBytesu32.nextIndex);

switch (sectionTypeByte.value) {
// case 0: {
// TODO(sven): re-enable that
// Current status: it seems that when we decode the module's name
// no name_payload_len is used.
//
// See https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#name-section
//
// nameMetadata.push(...parseNameModule());
// break;
// }
case 0: {
nameMetadata.push(...parseNameModule());
break;
}
case 1: {
nameMetadata.push(...parseNameSectionFunctions());
break;
Expand Down
6 changes: 6 additions & 0 deletions packages/wasm-parser/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ function stripMetadata(ast) {
delete node.loc;
},

// wasm doesn't have comments
BlockComment(path) {
path.remove();
},

// wasm doesn't have comments
LeadingComment(path) {
path.remove();
}
});

Expand Down