@webassemblyjs/wasm-parser
Advanced tools
Comparing version 1.6.0 to 1.7.0-0
@@ -237,2 +237,16 @@ "use strict"; | ||
} | ||
function readVaruint32() { | ||
// where 32 bits = max 4 bytes | ||
var bytes = readBytes(4); | ||
var buffer = Buffer.from(bytes); | ||
return (0, _leb.decodeUInt32)(buffer); | ||
} | ||
function readVaruint7() { | ||
// where 7 bits = max 1 bytes | ||
var bytes = readBytes(1); | ||
var buffer = Buffer.from(bytes); | ||
return (0, _leb.decodeUInt32)(buffer); | ||
} | ||
/** | ||
@@ -950,4 +964,2 @@ * Decode a signed 32bits interger | ||
var functionNames = []; | ||
var subSectionSizeInBytesu32 = readU32(); | ||
eatBytes(subSectionSizeInBytesu32.nextIndex); | ||
var numberOfFunctionsu32 = readU32(); | ||
@@ -970,8 +982,6 @@ var numbeOfFunctions = numberOfFunctionsu32.value; | ||
function parseNameSectionLocals() { | ||
var subSectionSizeInBytesu32 = readU32(); | ||
eatBytes(subSectionSizeInBytesu32.nextIndex); | ||
var localNames = []; | ||
var numbeOfFunctionsu32 = readU32(); | ||
var numbeOfFunctions = numbeOfFunctionsu32.value; | ||
eatBytes(numbeOfFunctionsu32.nextIndex); | ||
var localNames = []; | ||
@@ -1006,11 +1016,33 @@ for (var i = 0; i < numbeOfFunctions; i++) { | ||
while (offset - initialOffset < remainingBytes) { | ||
var sectionTypeByte = readByte(); | ||
eatBytes(1); | ||
// name_type | ||
var sectionTypeByte = readVaruint7(); | ||
eatBytes(sectionTypeByte.nextIndex); // name_payload_len | ||
if (sectionTypeByte === 0) { | ||
nameMetadata.push.apply(nameMetadata, _toConsumableArray(parseNameModule())); | ||
} else if (sectionTypeByte === 1) { | ||
nameMetadata.push.apply(nameMetadata, _toConsumableArray(parseNameSectionFunctions())); | ||
} else if (sectionTypeByte === 2) { | ||
nameMetadata.push.apply(nameMetadata, _toConsumableArray(parseNameSectionLocals())); | ||
var subSectionSizeInBytesu32 = readVaruint32(); | ||
eatBytes(subSectionSizeInBytesu32.nextIndex); | ||
switch (sectionTypeByte.value) { | ||
case 0: | ||
{ | ||
nameMetadata.push.apply(nameMetadata, _toConsumableArray(parseNameModule())); | ||
break; | ||
} | ||
case 1: | ||
{ | ||
nameMetadata.push.apply(nameMetadata, _toConsumableArray(parseNameSectionFunctions())); | ||
break; | ||
} | ||
case 2: | ||
{ | ||
nameMetadata.push.apply(nameMetadata, _toConsumableArray(parseNameSectionLocals())); | ||
break; | ||
} | ||
default: | ||
{ | ||
// skip unknown subsection | ||
eatBytes(subSectionSizeInBytesu32.value); | ||
} | ||
} | ||
@@ -1454,4 +1486,3 @@ } | ||
if (opts.ignoreDataSection === true) { | ||
var _remainingBytes = // $FlowIgnore | ||
sectionSizeInBytes - _numberOfElements2.nextIndex; | ||
var _remainingBytes = sectionSizeInBytes - _numberOfElementsu2.nextIndex; | ||
@@ -1490,3 +1521,8 @@ eatBytes(_remainingBytes); // eat the entire section | ||
if (sectionName.value === "name") { | ||
_metadata12.push.apply(_metadata12, _toConsumableArray(parseNameSection(_remainingBytes2))); | ||
try { | ||
_metadata12.push.apply(_metadata12, _toConsumableArray(parseNameSection(_remainingBytes2))); | ||
} catch (e) { | ||
console.warn("Failed to decode custom \"name\" section @".concat(offset, "; ignoring (").concat(e.message, ").")); | ||
eatBytes(_remainingBytes2); | ||
} | ||
} else { | ||
@@ -1493,0 +1529,0 @@ // We don't parse the custom section |
@@ -225,3 +225,9 @@ "use strict"; | ||
var node = _ref7.node; | ||
node.id = moduleNameMetadataPath.node.value; | ||
var name = moduleNameMetadataPath.node.value; // compatiblity with wast-parser | ||
if (name === "") { | ||
name = null; | ||
} | ||
node.id = name; | ||
}) | ||
@@ -228,0 +234,0 @@ }); |
{ | ||
"name": "@webassemblyjs/wasm-parser", | ||
"version": "1.6.0", | ||
"version": "1.7.0-0", | ||
"keywords": [ | ||
@@ -13,2 +13,3 @@ "webassembly", | ||
"main": "lib/index.js", | ||
"module": "esm/index.js", | ||
"scripts": { | ||
@@ -20,8 +21,8 @@ "test": "mocha" | ||
"dependencies": { | ||
"@webassemblyjs/ast": "1.6.0", | ||
"@webassemblyjs/helper-api-error": "1.6.0", | ||
"@webassemblyjs/helper-wasm-bytecode": "1.6.0", | ||
"@webassemblyjs/ieee754": "1.6.0", | ||
"@webassemblyjs/leb128": "1.6.0", | ||
"@webassemblyjs/utf8": "1.6.0" | ||
"@webassemblyjs/ast": "1.7.0-0", | ||
"@webassemblyjs/helper-api-error": "1.7.0-0", | ||
"@webassemblyjs/helper-wasm-bytecode": "1.7.0-0", | ||
"@webassemblyjs/ieee754": "1.7.0-0", | ||
"@webassemblyjs/leb128": "1.7.0-0", | ||
"@webassemblyjs/utf8": "1.7.0-0" | ||
}, | ||
@@ -36,9 +37,9 @@ "repository": { | ||
"devDependencies": { | ||
"@webassemblyjs/helper-buffer": "1.6.0", | ||
"@webassemblyjs/helper-test-framework": "1.6.0", | ||
"@webassemblyjs/helper-wasm-bytecode": "1.6.0", | ||
"@webassemblyjs/wasm-gen": "1.6.0", | ||
"@webassemblyjs/wast-parser": "1.6.0", | ||
"@webassemblyjs/helper-buffer": "1.7.0-0", | ||
"@webassemblyjs/helper-test-framework": "1.7.0-0", | ||
"@webassemblyjs/helper-wasm-bytecode": "1.7.0-0", | ||
"@webassemblyjs/wasm-gen": "1.7.0-0", | ||
"@webassemblyjs/wast-parser": "1.7.0-0", | ||
"wabt": "^1.0.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111195
8
3008
2
+ Added@webassemblyjs/ast@1.7.0-0(transitive)
+ Added@webassemblyjs/floating-point-hex-parser@1.7.0-0(transitive)
+ Added@webassemblyjs/helper-api-error@1.7.0-0(transitive)
+ Added@webassemblyjs/helper-code-frame@1.7.0-0(transitive)
+ Added@webassemblyjs/helper-fsm@1.7.0-0(transitive)
+ Added@webassemblyjs/helper-module-context@1.7.0-0(transitive)
+ Added@webassemblyjs/helper-wasm-bytecode@1.7.0-0(transitive)
+ Added@webassemblyjs/ieee754@1.7.0-0(transitive)
+ Added@webassemblyjs/leb128@1.7.0-0(transitive)
+ Added@webassemblyjs/utf8@1.7.0-0(transitive)
+ Added@webassemblyjs/wast-parser@1.7.0-0(transitive)
+ Added@webassemblyjs/wast-printer@1.7.0-0(transitive)
- Removed@webassemblyjs/ast@1.6.0(transitive)
- Removed@webassemblyjs/floating-point-hex-parser@1.6.0(transitive)
- Removed@webassemblyjs/helper-api-error@1.6.0(transitive)
- Removed@webassemblyjs/helper-code-frame@1.6.0(transitive)
- Removed@webassemblyjs/helper-fsm@1.6.0(transitive)
- Removed@webassemblyjs/helper-module-context@1.6.0(transitive)
- Removed@webassemblyjs/helper-wasm-bytecode@1.6.0(transitive)
- Removed@webassemblyjs/ieee754@1.6.0(transitive)
- Removed@webassemblyjs/leb128@1.6.0(transitive)
- Removed@webassemblyjs/utf8@1.6.0(transitive)
- Removed@webassemblyjs/wast-parser@1.6.0(transitive)
- Removed@webassemblyjs/wast-printer@1.6.0(transitive)
Updated@webassemblyjs/ast@1.7.0-0
Updated@webassemblyjs/utf8@1.7.0-0