Socket
Socket
Sign inDemoInstall

@webassemblyjs/wasm-parser

Package Overview
Dependencies
6
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.11.1 to 1.11.3

183

esm/decoder.js

@@ -1,3 +0,13 @@

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
import { CompileError } from "@webassemblyjs/helper-api-error";

@@ -306,6 +316,7 @@ import * as ieee754 from "@webassemblyjs/ieee754";

for (var i = 0; i < length; i++) {
var byte = readByte();
var _byte = readByte();
eatBytes(1);
var value = cast(byte);
dump([byte], value);
var value = cast(_byte);
dump([_byte], value);

@@ -427,3 +438,3 @@ if (typeof value === "undefined") {

importDescr = parseTableType(i);
} else if (descrType === "mem") {
} else if (descrType === "memory") {
var memoryNode = parseMemoryType(0);

@@ -518,3 +529,3 @@ state.memoriesInModule.push(memoryNode);

signature = null;
} else if (constants.exportTypes[typeIndex] === "Mem") {
} else if (constants.exportTypes[typeIndex] === "Memory") {
var memNode = state.memoriesInModule[index];

@@ -663,2 +674,3 @@

var args = [];
var namedArgs = void 0;

@@ -833,2 +845,4 @@ if (instruction.name === "loop") {

dump([_offset2], "offset");
if (namedArgs === undefined) namedArgs = {};
namedArgs.offset = t.numberLiteralFromRaw(_offset2);
}

@@ -933,3 +947,3 @@ } else if (instructionByte >= 0x41 && instructionByte <= 0x44) {

var endLoc = getPosition();
return t.withLoc(t.objectInstruction(instruction.name, instruction.object, args), endLoc, _startLoc6);
return t.withLoc(t.objectInstruction(instruction.name, instruction.object, args, namedArgs), endLoc, _startLoc6);
}();

@@ -941,3 +955,3 @@

var endLoc = getPosition();
return t.withLoc(t.instruction(instruction.name, args), endLoc, _startLoc6);
return t.withLoc(t.instruction(instruction.name, args, namedArgs), endLoc, _startLoc6);
}();

@@ -961,11 +975,11 @@

) {
var u32min = readU32();
min = parseInt(u32min.value);
eatBytes(u32min.nextIndex);
dump([min], "min");
var u32max = readU32();
max = parseInt(u32max.value);
eatBytes(u32max.nextIndex);
dump([max], "max");
}
var u32min = readU32();
min = parseInt(u32min.value);
eatBytes(u32min.nextIndex);
dump([min], "min");
var u32max = readU32();
max = parseInt(u32max.value);
eatBytes(u32max.nextIndex);
dump([max], "max");
}

@@ -1349,13 +1363,10 @@ if (limitType === 0x00) {

eatBytes(_u.nextIndex);
var _metadata = t.sectionMetadata("type", startOffset, sectionSizeInBytesNode, function () {
var metadata = t.sectionMetadata("type", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();
return t.withLoc(t.numberLiteralFromRaw(numberOfTypes), endLoc, _startLoc13);
}());
var _nodes = parseTypeSection(numberOfTypes);
var nodes = parseTypeSection(numberOfTypes);
return {
nodes: _nodes,
metadata: _metadata,
nodes: nodes,
metadata: metadata,
nextSectionIndex: nextSectionIndex

@@ -1379,3 +1390,3 @@ };

var _metadata2 = t.sectionMetadata("table", startOffset, sectionSizeInBytesNode, function () {
var _metadata = t.sectionMetadata("table", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1385,7 +1396,7 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfTable), endLoc, _startLoc14);

var _nodes2 = parseTableSection(numberOfTable);
var _nodes = parseTableSection(numberOfTable);
return {
nodes: _nodes2,
metadata: _metadata2,
nodes: _nodes,
metadata: _metadata,
nextSectionIndex: nextSectionIndex

@@ -1395,3 +1406,3 @@ };

case constants.sections.import:
case constants.sections["import"]:
{

@@ -1409,3 +1420,3 @@ dumpSep("section Import");

var _metadata3 = t.sectionMetadata("import", startOffset, sectionSizeInBytesNode, function () {
var _metadata2 = t.sectionMetadata("import", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1415,7 +1426,7 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfImports), endLoc, _startLoc15);

var _nodes3 = parseImportSection(numberOfImports);
var _nodes2 = parseImportSection(numberOfImports);
return {
nodes: _nodes3,
metadata: _metadata3,
nodes: _nodes2,
metadata: _metadata2,
nextSectionIndex: nextSectionIndex

@@ -1437,3 +1448,3 @@ };

var _metadata4 = t.sectionMetadata("func", startOffset, sectionSizeInBytesNode, function () {
var _metadata3 = t.sectionMetadata("func", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1444,6 +1455,6 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfFunctions), endLoc, _startLoc16);

parseFuncSection(numberOfFunctions);
var _nodes4 = [];
var _nodes3 = [];
return {
nodes: _nodes4,
metadata: _metadata4,
nodes: _nodes3,
metadata: _metadata3,
nextSectionIndex: nextSectionIndex

@@ -1453,3 +1464,3 @@ };

case constants.sections.export:
case constants.sections["export"]:
{

@@ -1467,3 +1478,3 @@ dumpSep("section Export");

var _metadata5 = t.sectionMetadata("export", startOffset, sectionSizeInBytesNode, function () {
var _metadata4 = t.sectionMetadata("export", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1474,6 +1485,6 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfExport), endLoc, _startLoc17);

parseExportSection(numberOfExport);
var _nodes5 = [];
var _nodes4 = [];
return {
nodes: _nodes5,
metadata: _metadata5,
nodes: _nodes4,
metadata: _metadata4,
nextSectionIndex: nextSectionIndex

@@ -1496,3 +1507,3 @@ };

var _metadata6 = t.sectionMetadata("code", startOffset, sectionSizeInBytesNode, function () {
var _metadata5 = t.sectionMetadata("code", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1509,6 +1520,6 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfFuncs), endLoc, _startLoc18);

var _nodes6 = [];
var _nodes5 = [];
return {
nodes: _nodes6,
metadata: _metadata6,
nodes: _nodes5,
metadata: _metadata5,
nextSectionIndex: nextSectionIndex

@@ -1524,8 +1535,8 @@ };

var _metadata7 = t.sectionMetadata("start", startOffset, sectionSizeInBytesNode);
var _metadata6 = t.sectionMetadata("start", startOffset, sectionSizeInBytesNode);
var _nodes7 = [parseStartSection()];
var _nodes6 = [parseStartSection()];
return {
nodes: _nodes7,
metadata: _metadata7,
nodes: _nodes6,
metadata: _metadata6,
nextSectionIndex: nextSectionIndex

@@ -1547,3 +1558,3 @@ };

var _metadata8 = t.sectionMetadata("element", startOffset, sectionSizeInBytesNode, function () {
var _metadata7 = t.sectionMetadata("element", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1553,7 +1564,7 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfElements), endLoc, _startLoc19);

var _nodes8 = parseElemSection(numberOfElements);
var _nodes7 = parseElemSection(numberOfElements);
return {
nodes: _nodes8,
metadata: _metadata8,
nodes: _nodes7,
metadata: _metadata7,
nextSectionIndex: nextSectionIndex

@@ -1575,3 +1586,3 @@ };

var _metadata9 = t.sectionMetadata("global", startOffset, sectionSizeInBytesNode, function () {
var _metadata8 = t.sectionMetadata("global", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1581,7 +1592,7 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfGlobals), endLoc, _startLoc20);

var _nodes9 = parseGlobalSection(numberOfGlobals);
var _nodes8 = parseGlobalSection(numberOfGlobals);
return {
nodes: _nodes9,
metadata: _metadata9,
nodes: _nodes8,
metadata: _metadata8,
nextSectionIndex: nextSectionIndex

@@ -1604,3 +1615,3 @@ };

var _metadata10 = t.sectionMetadata("memory", startOffset, sectionSizeInBytesNode, function () {
var _metadata9 = t.sectionMetadata("memory", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1610,7 +1621,7 @@ return t.withLoc(t.numberLiteralFromRaw(_numberOfElements), endLoc, _startLoc21);

var _nodes10 = parseMemorySection(_numberOfElements);
var _nodes9 = parseMemorySection(_numberOfElements);
return {
nodes: _nodes10,
metadata: _metadata10,
nodes: _nodes9,
metadata: _metadata9,
nextSectionIndex: nextSectionIndex

@@ -1626,3 +1637,3 @@ };

var _metadata11 = t.sectionMetadata("data", startOffset, sectionSizeInBytesNode);
var _metadata10 = t.sectionMetadata("data", startOffset, sectionSizeInBytesNode);

@@ -1636,3 +1647,3 @@ var _startLoc22 = getPosition();

_metadata11.vectorOfSize = function () {
_metadata10.vectorOfSize = function () {
var endLoc = getPosition();

@@ -1650,11 +1661,11 @@ return t.withLoc(t.numberLiteralFromRaw(_numberOfElements2), endLoc, _startLoc22);

nodes: [],
metadata: _metadata11,
metadata: _metadata10,
nextSectionIndex: nextSectionIndex
};
} else {
var _nodes11 = parseDataSection(_numberOfElements2);
var _nodes10 = parseDataSection(_numberOfElements2);
return {
nodes: _nodes11,
metadata: _metadata11,
nodes: _nodes10,
metadata: _metadata10,
nextSectionIndex: nextSectionIndex

@@ -1670,3 +1681,3 @@ };

dump([sectionSizeInBytes], "section size");
var _metadata12 = [t.sectionMetadata("custom", startOffset, sectionSizeInBytesNode)];
var _metadata11 = [t.sectionMetadata("custom", startOffset, sectionSizeInBytesNode)];
var sectionName = readUTF8String();

@@ -1682,3 +1693,3 @@ eatBytes(sectionName.nextIndex);

try {
_metadata12.push.apply(_metadata12, _toConsumableArray(parseNameSection(_remainingBytes2)));
_metadata11.push.apply(_metadata11, _toConsumableArray(parseNameSection(_remainingBytes2)));
} catch (e) {

@@ -1692,3 +1703,3 @@ console.warn("Failed to decode custom \"name\" section @".concat(offset, "; ignoring (").concat(e.message, ")."));

try {
_metadata12.push(parseProducersSection());
_metadata11.push(parseProducersSection());
} catch (e) {

@@ -1706,3 +1717,3 @@ console.warn("Failed to decode custom \"producers\" section @".concat(offset, "; ignoring (").concat(e.message, ")."));

nodes: [],
metadata: _metadata12,
metadata: _metadata11,
nextSectionIndex: nextSectionIndex

@@ -1713,3 +1724,16 @@ };

throw new CompileError("Unexpected section: " + toHex(sectionId));
if (opts.errorOnUnknownSection) {
throw new CompileError("Unexpected section: " + toHex(sectionId));
} else {
dumpSep("section " + toHex(sectionId));
dump([sectionId], "section code");
dump([sectionSizeInBytes], "section size");
eatBytes(sectionSizeInBytes);
dumpSep("ignoring (" + sectionSizeInBytes + " bytes)");
return {
nodes: [],
metadata: [],
nextSectionIndex: 0
};
}
}

@@ -1733,13 +1757,14 @@

var _parseSection = parseSection(sectionIndex),
_nodes12 = _parseSection.nodes,
_metadata13 = _parseSection.metadata,
nodes = _parseSection.nodes,
metadata = _parseSection.metadata,
nextSectionIndex = _parseSection.nextSectionIndex;
moduleFields.push.apply(moduleFields, _toConsumableArray(_nodes12));
var metadataArray = Array.isArray(_metadata13) ? _metadata13 : [_metadata13];
moduleFields.push.apply(moduleFields, _toConsumableArray(nodes));
var metadataArray = Array.isArray(metadata) ? metadata : [metadata];
metadataArray.forEach(function (metadataItem) {
// $FlowIgnore
if (metadataItem.type === "FunctionNameMetadata") {
moduleMetadata.functionNames.push(metadataItem);
moduleMetadata.functionNames.push(metadataItem); // $FlowIgnore
} else if (metadataItem.type === "LocalNameMetadata") {
moduleMetadata.localNames.push(metadataItem);
moduleMetadata.localNames.push(metadataItem); // $FlowIgnore
} else if (metadataItem.type === "ProducersSectionMetadata") {

@@ -1746,0 +1771,0 @@ moduleMetadata.producers.push(metadataItem);

@@ -55,3 +55,4 @@ import * as decoder from "./decoder";

var oldValue = nodeName.value;
nodeName.value = functionName.name;
nodeName.value = functionName.name; // $FlowIgnore
nodeName.numeric = oldValue; // $FlowIgnore

@@ -58,0 +59,0 @@

"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
Object.defineProperty(exports, "__esModule", {

@@ -20,8 +22,20 @@ value: true

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function toHex(n) {

@@ -287,3 +301,3 @@ return "0x" + Number(n).toString(16);

if (byteArrayEq(_helperWasmBytecode.default.magicModuleHeader, header) === false) {
if (byteArrayEq(_helperWasmBytecode["default"].magicModuleHeader, header) === false) {
throw new _helperApiError.CompileError("magic header not detected");

@@ -303,3 +317,3 @@ }

if (byteArrayEq(_helperWasmBytecode.default.moduleVersion, version) === false) {
if (byteArrayEq(_helperWasmBytecode["default"].moduleVersion, version) === false) {
throw new _helperApiError.CompileError("unknown binary version");

@@ -325,6 +339,7 @@ }

for (var i = 0; i < length; i++) {
var byte = readByte();
var _byte = readByte();
eatBytes(1);
var value = cast(byte);
dump([byte], value);
var value = cast(_byte);
dump([_byte], value);

@@ -354,6 +369,6 @@ if (typeof value === "undefined") {

if (type == _helperWasmBytecode.default.types.func) {
if (type == _helperWasmBytecode["default"].types.func) {
dump([type], "func");
var paramValtypes = parseVec(function (b) {
return _helperWasmBytecode.default.valtypes[b];
return _helperWasmBytecode["default"].valtypes[b];
});

@@ -366,3 +381,3 @@ var params = paramValtypes.map(function (v) {

var result = parseVec(function (b) {
return _helperWasmBytecode.default.valtypes[b];
return _helperWasmBytecode["default"].valtypes[b];
});

@@ -415,3 +430,3 @@ typeInstructionNodes.push(function () {

eatBytes(1);
var descrType = _helperWasmBytecode.default.importTypes[descrTypeByte];
var descrType = _helperWasmBytecode["default"].importTypes[descrTypeByte];
dump([descrTypeByte], "import kind");

@@ -449,3 +464,3 @@

importDescr = parseTableType(i);
} else if (descrType === "mem") {
} else if (descrType === "memory") {
var memoryNode = parseMemoryType(0);

@@ -522,3 +537,3 @@ state.memoriesInModule.push(memoryNode);

if (_helperWasmBytecode.default.exportTypes[typeIndex] === "Func") {
if (_helperWasmBytecode["default"].exportTypes[typeIndex] === "Func") {
var func = state.functionsInModule[index];

@@ -532,3 +547,3 @@

signature = func.signature;
} else if (_helperWasmBytecode.default.exportTypes[typeIndex] === "Table") {
} else if (_helperWasmBytecode["default"].exportTypes[typeIndex] === "Table") {
var table = state.tablesInModule[index];

@@ -542,3 +557,3 @@

signature = null;
} else if (_helperWasmBytecode.default.exportTypes[typeIndex] === "Mem") {
} else if (_helperWasmBytecode["default"].exportTypes[typeIndex] === "Memory") {
var memNode = state.memoriesInModule[index];

@@ -552,3 +567,3 @@

signature = null;
} else if (_helperWasmBytecode.default.exportTypes[typeIndex] === "Global") {
} else if (_helperWasmBytecode["default"].exportTypes[typeIndex] === "Global") {
var global = state.globalsInModule[index];

@@ -570,3 +585,3 @@

name: name.value,
type: _helperWasmBytecode.default.exportTypes[typeIndex],
type: _helperWasmBytecode["default"].exportTypes[typeIndex],
signature: signature,

@@ -615,3 +630,3 @@ id: id,

eatBytes(1);
var type = _helperWasmBytecode.default.valtypes[valtypeByte];
var type = _helperWasmBytecode["default"].valtypes[valtypeByte];
var args = [];

@@ -663,3 +678,3 @@

var instruction = _helperWasmBytecode.default.symbolsByByte[instructionByte];
var instruction = _helperWasmBytecode["default"].symbolsByByte[instructionByte];

@@ -691,2 +706,3 @@ if (typeof instruction === "undefined") {

var args = [];
var namedArgs = void 0;

@@ -698,3 +714,3 @@ if (instruction.name === "loop") {

eatBytes(1);
var blocktype = _helperWasmBytecode.default.blockTypes[blocktypeByte];
var blocktype = _helperWasmBytecode["default"].blockTypes[blocktypeByte];
dump([blocktypeByte], "blocktype");

@@ -724,3 +740,3 @@

eatBytes(1);
var _blocktype = _helperWasmBytecode.default.blockTypes[_blocktypeByte];
var _blocktype = _helperWasmBytecode["default"].blockTypes[_blocktypeByte];
dump([_blocktypeByte], "blocktype");

@@ -764,3 +780,3 @@

eatBytes(1);
var _blocktype2 = _helperWasmBytecode.default.blockTypes[_blocktypeByte2];
var _blocktype2 = _helperWasmBytecode["default"].blockTypes[_blocktypeByte2];
dump([_blocktypeByte2], "blocktype");

@@ -864,2 +880,4 @@

dump([_offset2], "offset");
if (namedArgs === undefined) namedArgs = {};
namedArgs.offset = t.numberLiteralFromRaw(_offset2);
}

@@ -964,3 +982,3 @@ } else if (instructionByte >= 0x41 && instructionByte <= 0x44) {

var endLoc = getPosition();
return t.withLoc(t.objectInstruction(instruction.name, instruction.object, args), endLoc, _startLoc6);
return t.withLoc(t.objectInstruction(instruction.name, instruction.object, args, namedArgs), endLoc, _startLoc6);
}();

@@ -972,3 +990,3 @@

var endLoc = getPosition();
return t.withLoc(t.instruction(instruction.name, args), endLoc, _startLoc6);
return t.withLoc(t.instruction(instruction.name, args, namedArgs), endLoc, _startLoc6);
}();

@@ -992,11 +1010,11 @@

) {
var u32min = readU32();
min = parseInt(u32min.value);
eatBytes(u32min.nextIndex);
dump([min], "min");
var u32max = readU32();
max = parseInt(u32max.value);
eatBytes(u32max.nextIndex);
dump([max], "max");
}
var u32min = readU32();
min = parseInt(u32min.value);
eatBytes(u32min.nextIndex);
dump([min], "min");
var u32max = readU32();
max = parseInt(u32max.value);
eatBytes(u32max.nextIndex);
dump([max], "max");
}

@@ -1020,3 +1038,3 @@ if (limitType === 0x00) {

dump([elementTypeByte], "element type");
var elementType = _helperWasmBytecode.default.tableTypes[elementTypeByte];
var elementType = _helperWasmBytecode["default"].tableTypes[elementTypeByte];

@@ -1035,3 +1053,3 @@ if (typeof elementType === "undefined") {

eatBytes(1);
var type = _helperWasmBytecode.default.valtypes[valtypeByte];
var type = _helperWasmBytecode["default"].valtypes[valtypeByte];
dump([valtypeByte], type);

@@ -1045,3 +1063,3 @@

eatBytes(1);
var globalType = _helperWasmBytecode.default.globalTypes[globalTypeByte];
var globalType = _helperWasmBytecode["default"].globalTypes[globalTypeByte];
dump([globalTypeByte], "global type (".concat(globalType, ")"));

@@ -1352,6 +1370,6 @@

if (sectionId >= sectionIndex || sectionIndex === _helperWasmBytecode.default.sections.custom) {
if (sectionId >= sectionIndex || sectionIndex === _helperWasmBytecode["default"].sections.custom) {
sectionIndex = sectionId + 1;
} else {
if (sectionId !== _helperWasmBytecode.default.sections.custom) throw new _helperApiError.CompileError("Unexpected section: " + toHex(sectionId));
if (sectionId !== _helperWasmBytecode["default"].sections.custom) throw new _helperApiError.CompileError("Unexpected section: " + toHex(sectionId));
}

@@ -1372,3 +1390,3 @@

switch (sectionId) {
case _helperWasmBytecode.default.sections.type:
case _helperWasmBytecode["default"].sections.type:
{

@@ -1385,13 +1403,10 @@ dumpSep("section Type");

eatBytes(_u.nextIndex);
var _metadata = t.sectionMetadata("type", startOffset, sectionSizeInBytesNode, function () {
var metadata = t.sectionMetadata("type", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();
return t.withLoc(t.numberLiteralFromRaw(numberOfTypes), endLoc, _startLoc13);
}());
var _nodes = parseTypeSection(numberOfTypes);
var nodes = parseTypeSection(numberOfTypes);
return {
nodes: _nodes,
metadata: _metadata,
nodes: nodes,
metadata: metadata,
nextSectionIndex: nextSectionIndex

@@ -1401,3 +1416,3 @@ };

case _helperWasmBytecode.default.sections.table:
case _helperWasmBytecode["default"].sections.table:
{

@@ -1416,3 +1431,3 @@ dumpSep("section Table");

var _metadata2 = t.sectionMetadata("table", startOffset, sectionSizeInBytesNode, function () {
var _metadata = t.sectionMetadata("table", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1422,7 +1437,7 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfTable), endLoc, _startLoc14);

var _nodes2 = parseTableSection(numberOfTable);
var _nodes = parseTableSection(numberOfTable);
return {
nodes: _nodes2,
metadata: _metadata2,
nodes: _nodes,
metadata: _metadata,
nextSectionIndex: nextSectionIndex

@@ -1432,3 +1447,3 @@ };

case _helperWasmBytecode.default.sections.import:
case _helperWasmBytecode["default"].sections["import"]:
{

@@ -1446,3 +1461,3 @@ dumpSep("section Import");

var _metadata3 = t.sectionMetadata("import", startOffset, sectionSizeInBytesNode, function () {
var _metadata2 = t.sectionMetadata("import", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1452,7 +1467,7 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfImports), endLoc, _startLoc15);

var _nodes3 = parseImportSection(numberOfImports);
var _nodes2 = parseImportSection(numberOfImports);
return {
nodes: _nodes3,
metadata: _metadata3,
nodes: _nodes2,
metadata: _metadata2,
nextSectionIndex: nextSectionIndex

@@ -1462,3 +1477,3 @@ };

case _helperWasmBytecode.default.sections.func:
case _helperWasmBytecode["default"].sections.func:
{

@@ -1475,3 +1490,3 @@ dumpSep("section Function");

var _metadata4 = t.sectionMetadata("func", startOffset, sectionSizeInBytesNode, function () {
var _metadata3 = t.sectionMetadata("func", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1482,6 +1497,6 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfFunctions), endLoc, _startLoc16);

parseFuncSection(numberOfFunctions);
var _nodes4 = [];
var _nodes3 = [];
return {
nodes: _nodes4,
metadata: _metadata4,
nodes: _nodes3,
metadata: _metadata3,
nextSectionIndex: nextSectionIndex

@@ -1491,3 +1506,3 @@ };

case _helperWasmBytecode.default.sections.export:
case _helperWasmBytecode["default"].sections["export"]:
{

@@ -1505,3 +1520,3 @@ dumpSep("section Export");

var _metadata5 = t.sectionMetadata("export", startOffset, sectionSizeInBytesNode, function () {
var _metadata4 = t.sectionMetadata("export", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1512,6 +1527,6 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfExport), endLoc, _startLoc17);

parseExportSection(numberOfExport);
var _nodes5 = [];
var _nodes4 = [];
return {
nodes: _nodes5,
metadata: _metadata5,
nodes: _nodes4,
metadata: _metadata4,
nextSectionIndex: nextSectionIndex

@@ -1521,3 +1536,3 @@ };

case _helperWasmBytecode.default.sections.code:
case _helperWasmBytecode["default"].sections.code:
{

@@ -1535,3 +1550,3 @@ dumpSep("section Code");

var _metadata6 = t.sectionMetadata("code", startOffset, sectionSizeInBytesNode, function () {
var _metadata5 = t.sectionMetadata("code", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1548,6 +1563,6 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfFuncs), endLoc, _startLoc18);

var _nodes6 = [];
var _nodes5 = [];
return {
nodes: _nodes6,
metadata: _metadata6,
nodes: _nodes5,
metadata: _metadata5,
nextSectionIndex: nextSectionIndex

@@ -1557,3 +1572,3 @@ };

case _helperWasmBytecode.default.sections.start:
case _helperWasmBytecode["default"].sections.start:
{

@@ -1564,8 +1579,8 @@ dumpSep("section Start");

var _metadata7 = t.sectionMetadata("start", startOffset, sectionSizeInBytesNode);
var _metadata6 = t.sectionMetadata("start", startOffset, sectionSizeInBytesNode);
var _nodes7 = [parseStartSection()];
var _nodes6 = [parseStartSection()];
return {
nodes: _nodes7,
metadata: _metadata7,
nodes: _nodes6,
metadata: _metadata6,
nextSectionIndex: nextSectionIndex

@@ -1575,3 +1590,3 @@ };

case _helperWasmBytecode.default.sections.element:
case _helperWasmBytecode["default"].sections.element:
{

@@ -1588,3 +1603,3 @@ dumpSep("section Element");

var _metadata8 = t.sectionMetadata("element", startOffset, sectionSizeInBytesNode, function () {
var _metadata7 = t.sectionMetadata("element", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1594,7 +1609,7 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfElements), endLoc, _startLoc19);

var _nodes8 = parseElemSection(numberOfElements);
var _nodes7 = parseElemSection(numberOfElements);
return {
nodes: _nodes8,
metadata: _metadata8,
nodes: _nodes7,
metadata: _metadata7,
nextSectionIndex: nextSectionIndex

@@ -1604,3 +1619,3 @@ };

case _helperWasmBytecode.default.sections.global:
case _helperWasmBytecode["default"].sections.global:
{

@@ -1617,3 +1632,3 @@ dumpSep("section Global");

var _metadata9 = t.sectionMetadata("global", startOffset, sectionSizeInBytesNode, function () {
var _metadata8 = t.sectionMetadata("global", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1623,7 +1638,7 @@ return t.withLoc(t.numberLiteralFromRaw(numberOfGlobals), endLoc, _startLoc20);

var _nodes9 = parseGlobalSection(numberOfGlobals);
var _nodes8 = parseGlobalSection(numberOfGlobals);
return {
nodes: _nodes9,
metadata: _metadata9,
nodes: _nodes8,
metadata: _metadata8,
nextSectionIndex: nextSectionIndex

@@ -1633,3 +1648,3 @@ };

case _helperWasmBytecode.default.sections.memory:
case _helperWasmBytecode["default"].sections.memory:
{

@@ -1647,3 +1662,3 @@ dumpSep("section Memory");

var _metadata10 = t.sectionMetadata("memory", startOffset, sectionSizeInBytesNode, function () {
var _metadata9 = t.sectionMetadata("memory", startOffset, sectionSizeInBytesNode, function () {
var endLoc = getPosition();

@@ -1653,7 +1668,7 @@ return t.withLoc(t.numberLiteralFromRaw(_numberOfElements), endLoc, _startLoc21);

var _nodes10 = parseMemorySection(_numberOfElements);
var _nodes9 = parseMemorySection(_numberOfElements);
return {
nodes: _nodes10,
metadata: _metadata10,
nodes: _nodes9,
metadata: _metadata9,
nextSectionIndex: nextSectionIndex

@@ -1663,3 +1678,3 @@ };

case _helperWasmBytecode.default.sections.data:
case _helperWasmBytecode["default"].sections.data:
{

@@ -1670,3 +1685,3 @@ dumpSep("section Data");

var _metadata11 = t.sectionMetadata("data", startOffset, sectionSizeInBytesNode);
var _metadata10 = t.sectionMetadata("data", startOffset, sectionSizeInBytesNode);

@@ -1680,3 +1695,3 @@ var _startLoc22 = getPosition();

_metadata11.vectorOfSize = function () {
_metadata10.vectorOfSize = function () {
var endLoc = getPosition();

@@ -1694,11 +1709,11 @@ return t.withLoc(t.numberLiteralFromRaw(_numberOfElements2), endLoc, _startLoc22);

nodes: [],
metadata: _metadata11,
metadata: _metadata10,
nextSectionIndex: nextSectionIndex
};
} else {
var _nodes11 = parseDataSection(_numberOfElements2);
var _nodes10 = parseDataSection(_numberOfElements2);
return {
nodes: _nodes11,
metadata: _metadata11,
nodes: _nodes10,
metadata: _metadata10,
nextSectionIndex: nextSectionIndex

@@ -1709,3 +1724,3 @@ };

case _helperWasmBytecode.default.sections.custom:
case _helperWasmBytecode["default"].sections.custom:
{

@@ -1715,3 +1730,3 @@ dumpSep("section Custom");

dump([sectionSizeInBytes], "section size");
var _metadata12 = [t.sectionMetadata("custom", startOffset, sectionSizeInBytesNode)];
var _metadata11 = [t.sectionMetadata("custom", startOffset, sectionSizeInBytesNode)];
var sectionName = readUTF8String();

@@ -1727,3 +1742,3 @@ eatBytes(sectionName.nextIndex);

try {
_metadata12.push.apply(_metadata12, _toConsumableArray(parseNameSection(_remainingBytes2)));
_metadata11.push.apply(_metadata11, _toConsumableArray(parseNameSection(_remainingBytes2)));
} catch (e) {

@@ -1737,3 +1752,3 @@ console.warn("Failed to decode custom \"name\" section @".concat(offset, "; ignoring (").concat(e.message, ")."));

try {
_metadata12.push(parseProducersSection());
_metadata11.push(parseProducersSection());
} catch (e) {

@@ -1751,3 +1766,3 @@ console.warn("Failed to decode custom \"producers\" section @".concat(offset, "; ignoring (").concat(e.message, ")."));

nodes: [],
metadata: _metadata12,
metadata: _metadata11,
nextSectionIndex: nextSectionIndex

@@ -1758,3 +1773,16 @@ };

throw new _helperApiError.CompileError("Unexpected section: " + toHex(sectionId));
if (opts.errorOnUnknownSection) {
throw new _helperApiError.CompileError("Unexpected section: " + toHex(sectionId));
} else {
dumpSep("section " + toHex(sectionId));
dump([sectionId], "section code");
dump([sectionSizeInBytes], "section size");
eatBytes(sectionSizeInBytes);
dumpSep("ignoring (" + sectionSizeInBytes + " bytes)");
return {
nodes: [],
metadata: [],
nextSectionIndex: 0
};
}
}

@@ -1778,13 +1806,14 @@

var _parseSection = parseSection(sectionIndex),
_nodes12 = _parseSection.nodes,
_metadata13 = _parseSection.metadata,
nodes = _parseSection.nodes,
metadata = _parseSection.metadata,
nextSectionIndex = _parseSection.nextSectionIndex;
moduleFields.push.apply(moduleFields, _toConsumableArray(_nodes12));
var metadataArray = Array.isArray(_metadata13) ? _metadata13 : [_metadata13];
moduleFields.push.apply(moduleFields, _toConsumableArray(nodes));
var metadataArray = Array.isArray(metadata) ? metadata : [metadata];
metadataArray.forEach(function (metadataItem) {
// $FlowIgnore
if (metadataItem.type === "FunctionNameMetadata") {
moduleMetadata.functionNames.push(metadataItem);
moduleMetadata.functionNames.push(metadataItem); // $FlowIgnore
} else if (metadataItem.type === "LocalNameMetadata") {
moduleMetadata.localNames.push(metadataItem);
moduleMetadata.localNames.push(metadataItem); // $FlowIgnore
} else if (metadataItem.type === "ProducersSectionMetadata") {

@@ -1791,0 +1820,0 @@ moduleMetadata.producers.push(metadataItem);

"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
Object.defineProperty(exports, "__esModule", {

@@ -12,4 +14,6 @@ value: true

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
/**

@@ -66,3 +70,4 @@ * TODO(sven): I added initial props, but we should rather fix

var oldValue = nodeName.value;
nodeName.value = functionName.name;
nodeName.value = functionName.name; // $FlowIgnore
nodeName.numeric = oldValue; // $FlowIgnore

@@ -69,0 +74,0 @@

{
"name": "@webassemblyjs/wasm-parser",
"version": "1.11.1",
"version": "1.11.3",
"keywords": [

@@ -20,8 +20,8 @@ "webassembly",

"dependencies": {
"@webassemblyjs/ast": "1.11.1",
"@webassemblyjs/helper-api-error": "1.11.1",
"@webassemblyjs/helper-wasm-bytecode": "1.11.1",
"@webassemblyjs/ieee754": "1.11.1",
"@webassemblyjs/leb128": "1.11.1",
"@webassemblyjs/utf8": "1.11.1"
"@webassemblyjs/ast": "1.11.3",
"@webassemblyjs/helper-api-error": "1.11.3",
"@webassemblyjs/helper-wasm-bytecode": "1.11.3",
"@webassemblyjs/ieee754": "1.11.3",
"@webassemblyjs/leb128": "1.11.3",
"@webassemblyjs/utf8": "1.11.3"
},

@@ -36,11 +36,11 @@ "repository": {

"devDependencies": {
"@webassemblyjs/helper-buffer": "1.11.1",
"@webassemblyjs/helper-test-framework": "1.11.1",
"@webassemblyjs/helper-buffer": "1.11.3",
"@webassemblyjs/helper-test-framework": "1.11.3",
"@webassemblyjs/helper-wasm-bytecode": "1.7.7",
"@webassemblyjs/wasm-gen": "1.11.1",
"@webassemblyjs/wast-parser": "1.11.1",
"@webassemblyjs/wasm-gen": "1.11.3",
"@webassemblyjs/wast-parser": "1.11.3",
"mamacro": "^0.0.7",
"wabt": "1.0.12"
},
"gitHead": "3f07e2db2031afe0ce686630418c542938c1674b"
"gitHead": "5fd2425602b752576bbe8089c343d5d70ebc861c"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc