Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var _helperApiError = require("@webassemblyjs/helper-api-error");
var ieee754 = _interopRequireWildcard(require("@webassemblyjs/ieee754"));
var utf8 = _interopRequireWildcard(require("@webassemblyjs/utf8"));
var _leb = require("@webassemblyjs/leb128");
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 _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); } }
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;
/**
* FIXME(sven): we can't do that because number > 2**53 will fail here
* because they cannot be represented in js.
*/
/**
* Name
*/
const name = readUTF8String();
eatBytes(name.nextIndex);
dump([], `name (${name.value})`);
/**
* Import descr
*/
const descrTypeByte = readByte();
eatBytes(1);
const descrType = constants.importTypes[descrTypeByte];
dump([descrTypeByte], "import kind");
if (typeof descrType === "undefined") {
throw new CompileError(
"Unknown import description type: " + toHex(descrTypeByte)
);
}
let importDescr;
if (descrType === "func") {
const indexU32 = readU32();
const typeindex = indexU32.value;
eatBytes(indexU32.nextIndex);
eatBytes(moduleName.nextIndex);
dump([], "module name (".concat(moduleName.value, ")"));
/**
* Name
*/
var name = readUTF8String();
eatBytes(name.nextIndex);
dump([], "name (".concat(name.value, ")"));
/**
* Import descr
*/
var descrTypeByte = readByte();
eatBytes(1);
var descrType = constants.importTypes[descrTypeByte];
dump([descrTypeByte], "import kind");
if (typeof descrType === "undefined") {
throw new CompileError("Unknown import description type: " + toHex(descrTypeByte));
}
var importDescr = void 0;
if (descrType === "func") {
var indexU32 = readU32();
var typeindex = indexU32.value;
eatBytes(indexU32.nextIndex);
dump([typeindex], "type index");
var signature = state.typesInModule[typeindex];
if (typeof signature === "undefined") {
eatBytes(moduleName.nextIndex);
dump([], "module name (".concat(moduleName.value, ")"));
/**
* Name
*/
var name = readUTF8String();
eatBytes(name.nextIndex);
dump([], "name (".concat(name.value, ")"));
/**
* Import descr
*/
var descrTypeByte = readByte();
eatBytes(1);
var descrType = constants.importTypes[descrTypeByte];
dump([descrTypeByte], "import kind");
if (typeof descrType === "undefined") {
throw new CompileError("Unknown import description type: " + toHex(descrTypeByte));
}
var importDescr = void 0;
if (descrType === "func") {
var indexU32 = readU32();
var typeindex = indexU32.value;
eatBytes(indexU32.nextIndex);
dump([typeindex], "type index");
var signature = state.typesInModule[typeindex];
if (typeof signature === "undefined") {
eatBytes(moduleName.nextIndex);
dump([], "module name (".concat(moduleName.value, ")"));
/**
* Name
*/
var name = readUTF8String();
eatBytes(name.nextIndex);
dump([], "name (".concat(name.value, ")"));
/**
* Import descr
*/
var descrTypeByte = readByte();
eatBytes(1);
var descrType = constants.importTypes[descrTypeByte];
dump([descrTypeByte], "import kind");
if (typeof descrType === "undefined") {
throw new CompileError("Unknown import description type: " + toHex(descrTypeByte));
}
var importDescr = void 0;
if (descrType === "func") {
var indexU32 = readU32();
var typeindex = indexU32.value;
eatBytes(indexU32.nextIndex);
dump([typeindex], "type index");
var signature = state.typesInModule[typeindex];
if (typeof signature === "undefined") {