Socket
Socket
Sign inDemoInstall

@webassemblyjs/wasm-parser

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webassemblyjs/wasm-parser - npm Package Compare versions

Comparing version 1.7.1-0 to 1.7.1

85

esm/decoder.js

@@ -6,19 +6,6 @@ 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); } }

import * as utf8 from "@webassemblyjs/utf8";
import * as t from "@webassemblyjs/ast";
import { decodeInt32, decodeUInt32, MAX_NUMBER_OF_BYTE_U32, decodeInt64, decodeUInt64, MAX_NUMBER_OF_BYTE_U64 } from "@webassemblyjs/leb128";
import constants from "@webassemblyjs/helper-wasm-bytecode";
var t = require("@webassemblyjs/ast");
var _require = require("@webassemblyjs/helper-wasm-bytecode"),
importTypes = _require.importTypes,
symbolsByByte = _require.symbolsByByte,
blockTypes = _require.blockTypes,
tableTypes = _require.tableTypes,
globalTypes = _require.globalTypes,
exportTypes = _require.exportTypes,
types = _require.types,
magicModuleHeader = _require.magicModuleHeader,
valtypes = _require.valtypes,
moduleVersion = _require.moduleVersion,
sections = _require.sections;
function toHex(n) {

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

if (byteArrayEq(magicModuleHeader, header) === false) {
if (byteArrayEq(constants.magicModuleHeader, header) === false) {
throw new CompileError("magic header not detected");

@@ -294,3 +281,3 @@ }

if (byteArrayEq(moduleVersion, version) === false) {
if (byteArrayEq(constants.moduleVersion, version) === false) {
throw new CompileError("unknown binary version");

@@ -343,6 +330,6 @@ }

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

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

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

@@ -400,3 +387,3 @@ var endLoc = getPosition();

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

@@ -421,3 +408,3 @@

var id = t.numberLiteralFromRaw(typeindex);
var id = getUniqueName("func");
importDescr = t.funcImportDescr(id, t.signature(signature.params, signature.result));

@@ -504,3 +491,3 @@ state.functionsInModule.push({

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

@@ -514,3 +501,3 @@

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

@@ -524,3 +511,3 @@

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

@@ -534,3 +521,3 @@

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

@@ -552,3 +539,3 @@

name: name.value,
type: exportTypes[typeIndex],
type: constants.exportTypes[typeIndex],
signature: signature,

@@ -594,3 +581,3 @@ id: id,

eatBytes(1);
var type = valtypes[valtypeByte];
var type = constants.valtypes[valtypeByte];
locals.push(type);

@@ -631,3 +618,3 @@ dump([valtypeByte], type);

var instruction = symbolsByByte[instructionByte];
var instruction = constants.symbolsByByte[instructionByte];

@@ -657,3 +644,3 @@ if (typeof instruction === "undefined") {

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

@@ -676,3 +663,3 @@

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

@@ -709,3 +696,3 @@

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

@@ -926,3 +913,3 @@

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

@@ -941,3 +928,3 @@ if (typeof elementType === "undefined") {

eatBytes(1);
var type = valtypes[valtypeByte];
var type = constants.valtypes[valtypeByte];
dump([valtypeByte], type);

@@ -951,3 +938,3 @@

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

@@ -1199,6 +1186,6 @@

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

@@ -1216,3 +1203,3 @@

switch (sectionId) {
case sections.type:
case constants.sections.type:
{

@@ -1242,3 +1229,3 @@ dumpSep("section Type");

case sections.table:
case constants.sections.table:
{

@@ -1271,3 +1258,3 @@ dumpSep("section Table");

case sections.import:
case constants.sections.import:
{

@@ -1299,3 +1286,3 @@ dumpSep("section Import");

case sections.func:
case constants.sections.func:
{

@@ -1325,3 +1312,3 @@ dumpSep("section Function");

case sections.export:
case constants.sections.export:
{

@@ -1352,3 +1339,3 @@ dumpSep("section Export");

case sections.code:
case constants.sections.code:
{

@@ -1385,3 +1372,3 @@ dumpSep("section Code");

case sections.start:
case constants.sections.start:
{

@@ -1402,3 +1389,3 @@ dumpSep("section Start");

case sections.element:
case constants.sections.element:
{

@@ -1428,3 +1415,3 @@ dumpSep("section Element");

case sections.global:
case constants.sections.global:
{

@@ -1454,3 +1441,3 @@ dumpSep("section Global");

case sections.memory:
case constants.sections.memory:
{

@@ -1481,3 +1468,3 @@ dumpSep("section Memory");

case sections.data:
case constants.sections.data:
{

@@ -1523,3 +1510,3 @@ dumpSep("section Data");

case sections.custom:
case constants.sections.custom:
{

@@ -1526,0 +1513,0 @@ dumpSep("section Custom");

@@ -1,4 +0,3 @@

var t = require("@webassemblyjs/ast");
import * as decoder from "./decoder";
import * as t from "@webassemblyjs/ast";
var defaultDecoderOpts = {

@@ -97,4 +96,4 @@ dump: false,

// $FlowIgnore
var nodeName = node.descr.id;
var index = nodeName.value;
var indexBasedFunctionName = node.descr.id;
var index = Number(indexBasedFunctionName.replace("func_", ""));
var functionName = functionNames.find(function (f) {

@@ -101,0 +100,0 @@ return f.index === index;

@@ -14,4 +14,10 @@ "use strict";

var t = _interopRequireWildcard(require("@webassemblyjs/ast"));
var _leb = require("@webassemblyjs/leb128");
var _helperWasmBytecode = _interopRequireDefault(require("@webassemblyjs/helper-wasm-bytecode"));
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; } }

@@ -21,17 +27,2 @@

var t = require("@webassemblyjs/ast");
var _require = require("@webassemblyjs/helper-wasm-bytecode"),
importTypes = _require.importTypes,
symbolsByByte = _require.symbolsByByte,
blockTypes = _require.blockTypes,
tableTypes = _require.tableTypes,
globalTypes = _require.globalTypes,
exportTypes = _require.exportTypes,
types = _require.types,
magicModuleHeader = _require.magicModuleHeader,
valtypes = _require.valtypes,
moduleVersion = _require.moduleVersion,
sections = _require.sections;
function toHex(n) {

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

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

@@ -307,3 +298,3 @@ }

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

@@ -356,6 +347,6 @@ }

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

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

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

@@ -413,3 +404,3 @@ var endLoc = getPosition();

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

@@ -434,3 +425,3 @@

var id = t.numberLiteralFromRaw(typeindex);
var id = getUniqueName("func");
importDescr = t.funcImportDescr(id, t.signature(signature.params, signature.result));

@@ -517,3 +508,3 @@ state.functionsInModule.push({

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

@@ -527,3 +518,3 @@

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

@@ -537,3 +528,3 @@

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

@@ -547,3 +538,3 @@

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

@@ -565,3 +556,3 @@

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

@@ -607,3 +598,3 @@ id: id,

eatBytes(1);
var type = valtypes[valtypeByte];
var type = _helperWasmBytecode.default.valtypes[valtypeByte];
locals.push(type);

@@ -644,3 +635,3 @@ dump([valtypeByte], type);

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

@@ -670,3 +661,3 @@ if (typeof instruction === "undefined") {

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

@@ -689,3 +680,3 @@

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

@@ -722,3 +713,3 @@

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

@@ -939,3 +930,3 @@

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

@@ -954,3 +945,3 @@ if (typeof elementType === "undefined") {

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

@@ -964,3 +955,3 @@

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

@@ -1212,6 +1203,6 @@

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

@@ -1229,3 +1220,3 @@

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

@@ -1255,3 +1246,3 @@ dumpSep("section Type");

case sections.table:
case _helperWasmBytecode.default.sections.table:
{

@@ -1284,3 +1275,3 @@ dumpSep("section Table");

case sections.import:
case _helperWasmBytecode.default.sections.import:
{

@@ -1312,3 +1303,3 @@ dumpSep("section Import");

case sections.func:
case _helperWasmBytecode.default.sections.func:
{

@@ -1338,3 +1329,3 @@ dumpSep("section Function");

case sections.export:
case _helperWasmBytecode.default.sections.export:
{

@@ -1365,3 +1356,3 @@ dumpSep("section Export");

case sections.code:
case _helperWasmBytecode.default.sections.code:
{

@@ -1398,3 +1389,3 @@ dumpSep("section Code");

case sections.start:
case _helperWasmBytecode.default.sections.start:
{

@@ -1415,3 +1406,3 @@ dumpSep("section Start");

case sections.element:
case _helperWasmBytecode.default.sections.element:
{

@@ -1441,3 +1432,3 @@ dumpSep("section Element");

case sections.global:
case _helperWasmBytecode.default.sections.global:
{

@@ -1467,3 +1458,3 @@ dumpSep("section Global");

case sections.memory:
case _helperWasmBytecode.default.sections.memory:
{

@@ -1494,3 +1485,3 @@ dumpSep("section Memory");

case sections.data:
case _helperWasmBytecode.default.sections.data:
{

@@ -1536,3 +1527,3 @@ dumpSep("section Data");

case sections.custom:
case _helperWasmBytecode.default.sections.custom:
{

@@ -1539,0 +1530,0 @@ dumpSep("section Custom");

@@ -10,6 +10,6 @@ "use strict";

var t = _interopRequireWildcard(require("@webassemblyjs/ast"));
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; } }
var t = require("@webassemblyjs/ast");
var defaultDecoderOpts = {

@@ -108,4 +108,4 @@ dump: false,

// $FlowIgnore
var nodeName = node.descr.id;
var index = nodeName.value;
var indexBasedFunctionName = node.descr.id;
var index = Number(indexBasedFunctionName.replace("func_", ""));
var functionName = functionNames.find(function (f) {

@@ -112,0 +112,0 @@ return f.index === index;

{
"name": "@webassemblyjs/wasm-parser",
"version": "1.7.1-0",
"version": "1.7.1",
"keywords": [

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

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

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

"devDependencies": {
"@webassemblyjs/helper-buffer": "1.7.1-0",
"@webassemblyjs/helper-test-framework": "1.7.1-0",
"@webassemblyjs/helper-wasm-bytecode": "1.7.1-0",
"@webassemblyjs/wasm-gen": "1.7.1-0",
"@webassemblyjs/wast-parser": "1.7.1-0",
"@webassemblyjs/helper-buffer": "1.7.1",
"@webassemblyjs/helper-test-framework": "1.7.1",
"@webassemblyjs/helper-wasm-bytecode": "1.7.1",
"@webassemblyjs/wasm-gen": "1.7.1",
"@webassemblyjs/wast-parser": "1.7.1",
"wabt": "^1.0.0"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc