diff options
author | 2020-11-18 23:26:45 +0100 | |
---|---|---|
committer | 2020-11-18 23:26:45 +0100 | |
commit | 81ddf9b700bc48a1f8e472209f080f9c1d9a9b09 (patch) | |
tree | 8b959d50c5a614cbf9fcb346ed556140374d4b6d /node_modules/@webassemblyjs | |
parent | 1870f3fdf43707a15fda0f609a021f516f45eb63 (diff) | |
download | website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.gz website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.tar.bz2 website_creator-81ddf9b700bc48a1f8e472209f080f9c1d9a9b09.zip |
rm node_modules
Diffstat (limited to 'node_modules/@webassemblyjs')
152 files changed, 0 insertions, 25813 deletions
diff --git a/node_modules/@webassemblyjs/ast/LICENSE b/node_modules/@webassemblyjs/ast/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/ast/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/ast/README.md b/node_modules/@webassemblyjs/ast/README.md deleted file mode 100644 index 7560244..0000000 --- a/node_modules/@webassemblyjs/ast/README.md +++ /dev/null @@ -1,167 +0,0 @@ -# @webassemblyjs/ast - -> AST utils for webassemblyjs - -## Installation - -```sh -yarn add @webassemblyjs/ast -``` - -## Usage - -### Traverse - -```js -import { traverse } from "@webassemblyjs/ast"; - -traverse(ast, { - Module(path) { - console.log(path.node); - } -}); -``` - -### Instruction signatures - -```js -import { signatures } from "@webassemblyjs/ast"; - -console.log(signatures); -``` - -### Path methods - -- `findParent: NodeLocator` -- `replaceWith: Node => void` -- `remove: () => void` -- `insertBefore: Node => void` -- `insertAfter: Node => void` -- `stop: () => void` - -### AST utils - -- function `module(id, fields, metadata)` -- function `moduleMetadata(sections, functionNames, localNames)` -- function `moduleNameMetadata(value)` -- function `functionNameMetadata(value, index)` -- function `localNameMetadata(value, localIndex, functionIndex)` -- function `binaryModule(id, blob)` -- function `quoteModule(id, string)` -- function `sectionMetadata(section, startOffset, size, vectorOfSize)` -- function `loopInstruction(label, resulttype, instr)` -- function `instruction(id, args, namedArgs)` -- function `objectInstruction(id, object, args, namedArgs)` -- function `ifInstruction(testLabel, test, result, consequent, alternate)` -- function `stringLiteral(value)` -- function `numberLiteralFromRaw(value, raw)` -- function `longNumberLiteral(value, raw)` -- function `floatLiteral(value, nan, inf, raw)` -- function `elem(table, offset, funcs)` -- function `indexInFuncSection(index)` -- function `valtypeLiteral(name)` -- function `typeInstruction(id, functype)` -- function `start(index)` -- function `globalType(valtype, mutability)` -- function `leadingComment(value)` -- function `blockComment(value)` -- function `data(memoryIndex, offset, init)` -- function `global(globalType, init, name)` -- function `table(elementType, limits, name, elements)` -- function `memory(limits, id)` -- function `funcImportDescr(id, signature)` -- function `moduleImport(module, name, descr)` -- function `moduleExportDescr(exportType, id)` -- function `moduleExport(name, descr)` -- function `limit(min, max)` -- function `signature(params, results)` -- function `program(body)` -- function `identifier(value, raw)` -- function `blockInstruction(label, instr, result)` -- function `callInstruction(index, instrArgs)` -- function `callIndirectInstruction(signature, intrs)` -- function `byteArray(values)` -- function `func(name, signature, body, isExternal, metadata)` -- Constant`isModule` -- Constant`isModuleMetadata` -- Constant`isModuleNameMetadata` -- Constant`isFunctionNameMetadata` -- Constant`isLocalNameMetadata` -- Constant`isBinaryModule` -- Constant`isQuoteModule` -- Constant`isSectionMetadata` -- Constant`isLoopInstruction` -- Constant`isInstruction` -- Constant`isObjectInstruction` -- Constant`isIfInstruction` -- Constant`isStringLiteral` -- Constant`isNumberLiteral` -- Constant`isLongNumberLiteral` -- Constant`isFloatLiteral` -- Constant`isElem` -- Constant`isIndexInFuncSection` -- Constant`isValtypeLiteral` -- Constant`isTypeInstruction` -- Constant`isStart` -- Constant`isGlobalType` -- Constant`isLeadingComment` -- Constant`isBlockComment` -- Constant`isData` -- Constant`isGlobal` -- Constant`isTable` -- Constant`isMemory` -- Constant`isFuncImportDescr` -- Constant`isModuleImport` -- Constant`isModuleExportDescr` -- Constant`isModuleExport` -- Constant`isLimit` -- Constant`isSignature` -- Constant`isProgram` -- Constant`isIdentifier` -- Constant`isBlockInstruction` -- Constant`isCallInstruction` -- Constant`isCallIndirectInstruction` -- Constant`isByteArray` -- Constant`isFunc` -- Constant`assertModule` -- Constant`assertModuleMetadata` -- Constant`assertModuleNameMetadata` -- Constant`assertFunctionNameMetadata` -- Constant`assertLocalNameMetadata` -- Constant`assertBinaryModule` -- Constant`assertQuoteModule` -- Constant`assertSectionMetadata` -- Constant`assertLoopInstruction` -- Constant`assertInstruction` -- Constant`assertObjectInstruction` -- Constant`assertIfInstruction` -- Constant`assertStringLiteral` -- Constant`assertNumberLiteral` -- Constant`assertLongNumberLiteral` -- Constant`assertFloatLiteral` -- Constant`assertElem` -- Constant`assertIndexInFuncSection` -- Constant`assertValtypeLiteral` -- Constant`assertTypeInstruction` -- Constant`assertStart` -- Constant`assertGlobalType` -- Constant`assertLeadingComment` -- Constant`assertBlockComment` -- Constant`assertData` -- Constant`assertGlobal` -- Constant`assertTable` -- Constant`assertMemory` -- Constant`assertFuncImportDescr` -- Constant`assertModuleImport` -- Constant`assertModuleExportDescr` -- Constant`assertModuleExport` -- Constant`assertLimit` -- Constant`assertSignature` -- Constant`assertProgram` -- Constant`assertIdentifier` -- Constant`assertBlockInstruction` -- Constant`assertCallInstruction` -- Constant`assertCallIndirectInstruction` -- Constant`assertByteArray` -- Constant`assertFunc` - diff --git a/node_modules/@webassemblyjs/ast/esm/clone.js b/node_modules/@webassemblyjs/ast/esm/clone.js deleted file mode 100644 index 92c3f5f..0000000 --- a/node_modules/@webassemblyjs/ast/esm/clone.js +++ /dev/null @@ -1,10 +0,0 @@ -export function cloneNode(n) { - // $FlowIgnore - var newObj = {}; - - for (var k in n) { - newObj[k] = n[k]; - } - - return newObj; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/esm/definitions.js b/node_modules/@webassemblyjs/ast/esm/definitions.js deleted file mode 100644 index 120311b..0000000 --- a/node_modules/@webassemblyjs/ast/esm/definitions.js +++ /dev/null @@ -1,663 +0,0 @@ -var definitions = {}; - -function defineType(typeName, metadata) { - definitions[typeName] = metadata; -} - -defineType("Module", { - spec: { - wasm: "https://webassembly.github.io/spec/core/binary/modules.html#binary-module", - wat: "https://webassembly.github.io/spec/core/text/modules.html#text-module" - }, - doc: "A module consists of a sequence of sections (termed fields in the text format).", - unionType: ["Node"], - fields: { - id: { - maybe: true, - type: "string" - }, - fields: { - array: true, - type: "Node" - }, - metadata: { - optional: true, - type: "ModuleMetadata" - } - } -}); -defineType("ModuleMetadata", { - unionType: ["Node"], - fields: { - sections: { - array: true, - type: "SectionMetadata" - }, - functionNames: { - optional: true, - array: true, - type: "FunctionNameMetadata" - }, - localNames: { - optional: true, - array: true, - type: "ModuleMetadata" - }, - producers: { - optional: true, - array: true, - type: "ProducersSectionMetadata" - } - } -}); -defineType("ModuleNameMetadata", { - unionType: ["Node"], - fields: { - value: { - type: "string" - } - } -}); -defineType("FunctionNameMetadata", { - unionType: ["Node"], - fields: { - value: { - type: "string" - }, - index: { - type: "number" - } - } -}); -defineType("LocalNameMetadata", { - unionType: ["Node"], - fields: { - value: { - type: "string" - }, - localIndex: { - type: "number" - }, - functionIndex: { - type: "number" - } - } -}); -defineType("BinaryModule", { - unionType: ["Node"], - fields: { - id: { - maybe: true, - type: "string" - }, - blob: { - array: true, - type: "string" - } - } -}); -defineType("QuoteModule", { - unionType: ["Node"], - fields: { - id: { - maybe: true, - type: "string" - }, - string: { - array: true, - type: "string" - } - } -}); -defineType("SectionMetadata", { - unionType: ["Node"], - fields: { - section: { - type: "SectionName" - }, - startOffset: { - type: "number" - }, - size: { - type: "NumberLiteral" - }, - vectorOfSize: { - comment: "Size of the vector in the section (if any)", - type: "NumberLiteral" - } - } -}); -defineType("ProducersSectionMetadata", { - unionType: ["Node"], - fields: { - producers: { - array: true, - type: "ProducerMetadata" - } - } -}); -defineType("ProducerMetadata", { - unionType: ["Node"], - fields: { - language: { - type: "ProducerMetadataVersionedName", - array: true - }, - processedBy: { - type: "ProducerMetadataVersionedName", - array: true - }, - sdk: { - type: "ProducerMetadataVersionedName", - array: true - } - } -}); -defineType("ProducerMetadataVersionedName", { - unionType: ["Node"], - fields: { - name: { - type: "string" - }, - version: { - type: "string" - } - } -}); -/* -Instructions -*/ - -defineType("LoopInstruction", { - unionType: ["Node", "Block", "Instruction"], - fields: { - id: { - constant: true, - type: "string", - value: "loop" - }, - label: { - maybe: true, - type: "Identifier" - }, - resulttype: { - maybe: true, - type: "Valtype" - }, - instr: { - array: true, - type: "Instruction" - } - } -}); -defineType("Instr", { - unionType: ["Node", "Expression", "Instruction"], - fields: { - id: { - type: "string" - }, - object: { - optional: true, - type: "Valtype" - }, - args: { - array: true, - type: "Expression" - }, - namedArgs: { - optional: true, - type: "Object" - } - } -}); -defineType("IfInstruction", { - unionType: ["Node", "Instruction"], - fields: { - id: { - constant: true, - type: "string", - value: "if" - }, - testLabel: { - comment: "only for WAST", - type: "Identifier" - }, - test: { - array: true, - type: "Instruction" - }, - result: { - maybe: true, - type: "Valtype" - }, - consequent: { - array: true, - type: "Instruction" - }, - alternate: { - array: true, - type: "Instruction" - } - } -}); -/* -Concrete value types -*/ - -defineType("StringLiteral", { - unionType: ["Node", "Expression"], - fields: { - value: { - type: "string" - } - } -}); -defineType("NumberLiteral", { - unionType: ["Node", "NumericLiteral", "Expression"], - fields: { - value: { - type: "number" - }, - raw: { - type: "string" - } - } -}); -defineType("LongNumberLiteral", { - unionType: ["Node", "NumericLiteral", "Expression"], - fields: { - value: { - type: "LongNumber" - }, - raw: { - type: "string" - } - } -}); -defineType("FloatLiteral", { - unionType: ["Node", "NumericLiteral", "Expression"], - fields: { - value: { - type: "number" - }, - nan: { - optional: true, - type: "boolean" - }, - inf: { - optional: true, - type: "boolean" - }, - raw: { - type: "string" - } - } -}); -defineType("Elem", { - unionType: ["Node"], - fields: { - table: { - type: "Index" - }, - offset: { - array: true, - type: "Instruction" - }, - funcs: { - array: true, - type: "Index" - } - } -}); -defineType("IndexInFuncSection", { - unionType: ["Node"], - fields: { - index: { - type: "Index" - } - } -}); -defineType("ValtypeLiteral", { - unionType: ["Node", "Expression"], - fields: { - name: { - type: "Valtype" - } - } -}); -defineType("TypeInstruction", { - unionType: ["Node", "Instruction"], - fields: { - id: { - maybe: true, - type: "Index" - }, - functype: { - type: "Signature" - } - } -}); -defineType("Start", { - unionType: ["Node"], - fields: { - index: { - type: "Index" - } - } -}); -defineType("GlobalType", { - unionType: ["Node", "ImportDescr"], - fields: { - valtype: { - type: "Valtype" - }, - mutability: { - type: "Mutability" - } - } -}); -defineType("LeadingComment", { - unionType: ["Node"], - fields: { - value: { - type: "string" - } - } -}); -defineType("BlockComment", { - unionType: ["Node"], - fields: { - value: { - type: "string" - } - } -}); -defineType("Data", { - unionType: ["Node"], - fields: { - memoryIndex: { - type: "Memidx" - }, - offset: { - type: "Instruction" - }, - init: { - type: "ByteArray" - } - } -}); -defineType("Global", { - unionType: ["Node"], - fields: { - globalType: { - type: "GlobalType" - }, - init: { - array: true, - type: "Instruction" - }, - name: { - maybe: true, - type: "Identifier" - } - } -}); -defineType("Table", { - unionType: ["Node", "ImportDescr"], - fields: { - elementType: { - type: "TableElementType" - }, - limits: { - assertNodeType: true, - type: "Limit" - }, - name: { - maybe: true, - type: "Identifier" - }, - elements: { - array: true, - optional: true, - type: "Index" - } - } -}); -defineType("Memory", { - unionType: ["Node", "ImportDescr"], - fields: { - limits: { - type: "Limit" - }, - id: { - maybe: true, - type: "Index" - } - } -}); -defineType("FuncImportDescr", { - unionType: ["Node", "ImportDescr"], - fields: { - id: { - type: "Identifier" - }, - signature: { - type: "Signature" - } - } -}); -defineType("ModuleImport", { - unionType: ["Node"], - fields: { - module: { - type: "string" - }, - name: { - type: "string" - }, - descr: { - type: "ImportDescr" - } - } -}); -defineType("ModuleExportDescr", { - unionType: ["Node"], - fields: { - exportType: { - type: "ExportDescrType" - }, - id: { - type: "Index" - } - } -}); -defineType("ModuleExport", { - unionType: ["Node"], - fields: { - name: { - type: "string" - }, - descr: { - type: "ModuleExportDescr" - } - } -}); -defineType("Limit", { - unionType: ["Node"], - fields: { - min: { - type: "number" - }, - max: { - optional: true, - type: "number" - } - } -}); -defineType("Signature", { - unionType: ["Node"], - fields: { - params: { - array: true, - type: "FuncParam" - }, - results: { - array: true, - type: "Valtype" - } - } -}); -defineType("Program", { - unionType: ["Node"], - fields: { - body: { - array: true, - type: "Node" - } - } -}); -defineType("Identifier", { - unionType: ["Node", "Expression"], - fields: { - value: { - type: "string" - }, - raw: { - optional: true, - type: "string" - } - } -}); -defineType("BlockInstruction", { - unionType: ["Node", "Block", "Instruction"], - fields: { - id: { - constant: true, - type: "string", - value: "block" - }, - label: { - maybe: true, - type: "Identifier" - }, - instr: { - array: true, - type: "Instruction" - }, - result: { - maybe: true, - type: "Valtype" - } - } -}); -defineType("CallInstruction", { - unionType: ["Node", "Instruction"], - fields: { - id: { - constant: true, - type: "string", - value: "call" - }, - index: { - type: "Index" - }, - instrArgs: { - array: true, - optional: true, - type: "Expression" - }, - numeric: { - type: "Index", - optional: true - } - } -}); -defineType("CallIndirectInstruction", { - unionType: ["Node", "Instruction"], - fields: { - id: { - constant: true, - type: "string", - value: "call_indirect" - }, - signature: { - type: "SignatureOrTypeRef" - }, - intrs: { - array: true, - optional: true, - type: "Expression" - } - } -}); -defineType("ByteArray", { - unionType: ["Node"], - fields: { - values: { - array: true, - type: "Byte" - } - } -}); -defineType("Func", { - unionType: ["Node", "Block"], - fields: { - name: { - maybe: true, - type: "Index" - }, - signature: { - type: "SignatureOrTypeRef" - }, - body: { - array: true, - type: "Instruction" - }, - isExternal: { - comment: "means that it has been imported from the outside js", - optional: true, - type: "boolean" - }, - metadata: { - optional: true, - type: "FuncMetadata" - } - } -}); -/** - * Intrinsics - */ - -defineType("InternalBrUnless", { - unionType: ["Node", "Intrinsic"], - fields: { - target: { - type: "number" - } - } -}); -defineType("InternalGoto", { - unionType: ["Node", "Intrinsic"], - fields: { - target: { - type: "number" - } - } -}); -defineType("InternalCallExtern", { - unionType: ["Node", "Intrinsic"], - fields: { - target: { - type: "number" - } - } -}); // function bodies are terminated by an `end` instruction but are missing a -// return instruction -// -// Since we can't inject a new instruction we are injecting a new instruction. - -defineType("InternalEndAndReturn", { - unionType: ["Node", "Intrinsic"], - fields: {} -}); -module.exports = definitions;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/esm/index.js b/node_modules/@webassemblyjs/ast/esm/index.js deleted file mode 100644 index 3bce891..0000000 --- a/node_modules/@webassemblyjs/ast/esm/index.js +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./nodes"; -export { numberLiteralFromRaw, withLoc, withRaw, funcParam, indexLiteral, memIndexLiteral, instruction, objectInstruction } from "./node-helpers.js"; -export { traverse } from "./traverse"; -export { signatures } from "./signatures"; -export * from "./utils"; -export { cloneNode } from "./clone";
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/esm/node-helpers.js b/node_modules/@webassemblyjs/ast/esm/node-helpers.js deleted file mode 100644 index fb91cae..0000000 --- a/node_modules/@webassemblyjs/ast/esm/node-helpers.js +++ /dev/null @@ -1,84 +0,0 @@ -import { parse32F, parse64F, parse32I, parse64I, parseU32, isNanLiteral, isInfLiteral } from "@webassemblyjs/wast-parser"; -import { longNumberLiteral, floatLiteral, numberLiteral, instr } from "./nodes"; -export function numberLiteralFromRaw(rawValue) { - var instructionType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "i32"; - var original = rawValue; // Remove numeric separators _ - - if (typeof rawValue === "string") { - rawValue = rawValue.replace(/_/g, ""); - } - - if (typeof rawValue === "number") { - return numberLiteral(rawValue, String(original)); - } else { - switch (instructionType) { - case "i32": - { - return numberLiteral(parse32I(rawValue), String(original)); - } - - case "u32": - { - return numberLiteral(parseU32(rawValue), String(original)); - } - - case "i64": - { - return longNumberLiteral(parse64I(rawValue), String(original)); - } - - case "f32": - { - return floatLiteral(parse32F(rawValue), isNanLiteral(rawValue), isInfLiteral(rawValue), String(original)); - } - // f64 - - default: - { - return floatLiteral(parse64F(rawValue), isNanLiteral(rawValue), isInfLiteral(rawValue), String(original)); - } - } - } -} -export function instruction(id) { - var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - var namedArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - return instr(id, undefined, args, namedArgs); -} -export function objectInstruction(id, object) { - var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; - var namedArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; - return instr(id, object, args, namedArgs); -} -/** - * Decorators - */ - -export function withLoc(n, end, start) { - var loc = { - start: start, - end: end - }; - n.loc = loc; - return n; -} -export function withRaw(n, raw) { - n.raw = raw; - return n; -} -export function funcParam(valtype, id) { - return { - id: id, - valtype: valtype - }; -} -export function indexLiteral(value) { - // $FlowIgnore - var x = numberLiteralFromRaw(value, "u32"); - return x; -} -export function memIndexLiteral(value) { - // $FlowIgnore - var x = numberLiteralFromRaw(value, "u32"); - return x; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/esm/node-path.js b/node_modules/@webassemblyjs/ast/esm/node-path.js deleted file mode 100644 index 99909ae..0000000 --- a/node_modules/@webassemblyjs/ast/esm/node-path.js +++ /dev/null @@ -1,137 +0,0 @@ -function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } - -function findParent(_ref, cb) { - var parentPath = _ref.parentPath; - - if (parentPath == null) { - throw new Error("node is root"); - } - - var currentPath = parentPath; - - while (cb(currentPath) !== false) { - // Hit the root node, stop - // $FlowIgnore - if (currentPath.parentPath == null) { - return null; - } // $FlowIgnore - - - currentPath = currentPath.parentPath; - } - - return currentPath.node; -} - -function insertBefore(context, newNode) { - return insert(context, newNode); -} - -function insertAfter(context, newNode) { - return insert(context, newNode, 1); -} - -function insert(_ref2, newNode) { - var node = _ref2.node, - inList = _ref2.inList, - parentPath = _ref2.parentPath, - parentKey = _ref2.parentKey; - var indexOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - - if (!inList) { - throw new Error('inList' + " error: " + ("insert can only be used for nodes that are within lists" || "unknown")); - } - - if (!(parentPath != null)) { - throw new Error('parentPath != null' + " error: " + ("Can not remove root node" || "unknown")); - } - - // $FlowIgnore - var parentList = parentPath.node[parentKey]; - var indexInList = parentList.findIndex(function (n) { - return n === node; - }); - parentList.splice(indexInList + indexOffset, 0, newNode); -} - -function remove(_ref3) { - var node = _ref3.node, - parentKey = _ref3.parentKey, - parentPath = _ref3.parentPath; - - if (!(parentPath != null)) { - throw new Error('parentPath != null' + " error: " + ("Can not remove root node" || "unknown")); - } - - // $FlowIgnore - var parentNode = parentPath.node; // $FlowIgnore - - var parentProperty = parentNode[parentKey]; - - if (Array.isArray(parentProperty)) { - // $FlowIgnore - parentNode[parentKey] = parentProperty.filter(function (n) { - return n !== node; - }); - } else { - // $FlowIgnore - delete parentNode[parentKey]; - } - - node._deleted = true; -} - -function stop(context) { - context.shouldStop = true; -} - -function replaceWith(context, newNode) { - // $FlowIgnore - var parentNode = context.parentPath.node; // $FlowIgnore - - var parentProperty = parentNode[context.parentKey]; - - if (Array.isArray(parentProperty)) { - var indexInList = parentProperty.findIndex(function (n) { - return n === context.node; - }); - parentProperty.splice(indexInList, 1, newNode); - } else { - // $FlowIgnore - parentNode[context.parentKey] = newNode; - } - - context.node._deleted = true; - context.node = newNode; -} // bind the context to the first argument of node operations - - -function bindNodeOperations(operations, context) { - var keys = Object.keys(operations); - var boundOperations = {}; - keys.forEach(function (key) { - boundOperations[key] = operations[key].bind(null, context); - }); - return boundOperations; -} - -function createPathOperations(context) { - // $FlowIgnore - return bindNodeOperations({ - findParent: findParent, - replaceWith: replaceWith, - remove: remove, - insertBefore: insertBefore, - insertAfter: insertAfter, - stop: stop - }, context); -} - -export function createPath(context) { - var path = _extends({}, context); // $FlowIgnore - - - Object.assign(path, createPathOperations(path)); // $FlowIgnore - - return path; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/esm/nodes.js b/node_modules/@webassemblyjs/ast/esm/nodes.js deleted file mode 100644 index 0f70793..0000000 --- a/node_modules/@webassemblyjs/ast/esm/nodes.js +++ /dev/null @@ -1,915 +0,0 @@ -function _typeof(obj) { 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); } - -// THIS FILE IS AUTOGENERATED -// see scripts/generateNodeUtils.js -function isTypeOf(t) { - return function (n) { - return n.type === t; - }; -} - -function assertTypeOf(t) { - return function (n) { - return function () { - if (!(n.type === t)) { - throw new Error('n.type === t' + " error: " + (undefined || "unknown")); - } - }(); - }; -} - -export function module(id, fields, metadata) { - if (id !== null && id !== undefined) { - if (!(typeof id === "string")) { - throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown")); - } - } - - if (!(_typeof(fields) === "object" && typeof fields.length !== "undefined")) { - throw new Error('typeof fields === "object" && typeof fields.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "Module", - id: id, - fields: fields - }; - - if (typeof metadata !== "undefined") { - node.metadata = metadata; - } - - return node; -} -export function moduleMetadata(sections, functionNames, localNames, producers) { - if (!(_typeof(sections) === "object" && typeof sections.length !== "undefined")) { - throw new Error('typeof sections === "object" && typeof sections.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (functionNames !== null && functionNames !== undefined) { - if (!(_typeof(functionNames) === "object" && typeof functionNames.length !== "undefined")) { - throw new Error('typeof functionNames === "object" && typeof functionNames.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - } - - if (localNames !== null && localNames !== undefined) { - if (!(_typeof(localNames) === "object" && typeof localNames.length !== "undefined")) { - throw new Error('typeof localNames === "object" && typeof localNames.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - } - - if (producers !== null && producers !== undefined) { - if (!(_typeof(producers) === "object" && typeof producers.length !== "undefined")) { - throw new Error('typeof producers === "object" && typeof producers.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - } - - var node = { - type: "ModuleMetadata", - sections: sections - }; - - if (typeof functionNames !== "undefined" && functionNames.length > 0) { - node.functionNames = functionNames; - } - - if (typeof localNames !== "undefined" && localNames.length > 0) { - node.localNames = localNames; - } - - if (typeof producers !== "undefined" && producers.length > 0) { - node.producers = producers; - } - - return node; -} -export function moduleNameMetadata(value) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - var node = { - type: "ModuleNameMetadata", - value: value - }; - return node; -} -export function functionNameMetadata(value, index) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - if (!(typeof index === "number")) { - throw new Error('typeof index === "number"' + " error: " + ("Argument index must be of type number, given: " + _typeof(index) || "unknown")); - } - - var node = { - type: "FunctionNameMetadata", - value: value, - index: index - }; - return node; -} -export function localNameMetadata(value, localIndex, functionIndex) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - if (!(typeof localIndex === "number")) { - throw new Error('typeof localIndex === "number"' + " error: " + ("Argument localIndex must be of type number, given: " + _typeof(localIndex) || "unknown")); - } - - if (!(typeof functionIndex === "number")) { - throw new Error('typeof functionIndex === "number"' + " error: " + ("Argument functionIndex must be of type number, given: " + _typeof(functionIndex) || "unknown")); - } - - var node = { - type: "LocalNameMetadata", - value: value, - localIndex: localIndex, - functionIndex: functionIndex - }; - return node; -} -export function binaryModule(id, blob) { - if (id !== null && id !== undefined) { - if (!(typeof id === "string")) { - throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown")); - } - } - - if (!(_typeof(blob) === "object" && typeof blob.length !== "undefined")) { - throw new Error('typeof blob === "object" && typeof blob.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "BinaryModule", - id: id, - blob: blob - }; - return node; -} -export function quoteModule(id, string) { - if (id !== null && id !== undefined) { - if (!(typeof id === "string")) { - throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown")); - } - } - - if (!(_typeof(string) === "object" && typeof string.length !== "undefined")) { - throw new Error('typeof string === "object" && typeof string.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "QuoteModule", - id: id, - string: string - }; - return node; -} -export function sectionMetadata(section, startOffset, size, vectorOfSize) { - if (!(typeof startOffset === "number")) { - throw new Error('typeof startOffset === "number"' + " error: " + ("Argument startOffset must be of type number, given: " + _typeof(startOffset) || "unknown")); - } - - var node = { - type: "SectionMetadata", - section: section, - startOffset: startOffset, - size: size, - vectorOfSize: vectorOfSize - }; - return node; -} -export function producersSectionMetadata(producers) { - if (!(_typeof(producers) === "object" && typeof producers.length !== "undefined")) { - throw new Error('typeof producers === "object" && typeof producers.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "ProducersSectionMetadata", - producers: producers - }; - return node; -} -export function producerMetadata(language, processedBy, sdk) { - if (!(_typeof(language) === "object" && typeof language.length !== "undefined")) { - throw new Error('typeof language === "object" && typeof language.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (!(_typeof(processedBy) === "object" && typeof processedBy.length !== "undefined")) { - throw new Error('typeof processedBy === "object" && typeof processedBy.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (!(_typeof(sdk) === "object" && typeof sdk.length !== "undefined")) { - throw new Error('typeof sdk === "object" && typeof sdk.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "ProducerMetadata", - language: language, - processedBy: processedBy, - sdk: sdk - }; - return node; -} -export function producerMetadataVersionedName(name, version) { - if (!(typeof name === "string")) { - throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown")); - } - - if (!(typeof version === "string")) { - throw new Error('typeof version === "string"' + " error: " + ("Argument version must be of type string, given: " + _typeof(version) || "unknown")); - } - - var node = { - type: "ProducerMetadataVersionedName", - name: name, - version: version - }; - return node; -} -export function loopInstruction(label, resulttype, instr) { - if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) { - throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "LoopInstruction", - id: "loop", - label: label, - resulttype: resulttype, - instr: instr - }; - return node; -} -export function instr(id, object, args, namedArgs) { - if (!(typeof id === "string")) { - throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown")); - } - - if (!(_typeof(args) === "object" && typeof args.length !== "undefined")) { - throw new Error('typeof args === "object" && typeof args.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "Instr", - id: id, - args: args - }; - - if (typeof object !== "undefined") { - node.object = object; - } - - if (typeof namedArgs !== "undefined" && Object.keys(namedArgs).length !== 0) { - node.namedArgs = namedArgs; - } - - return node; -} -export function ifInstruction(testLabel, test, result, consequent, alternate) { - if (!(_typeof(test) === "object" && typeof test.length !== "undefined")) { - throw new Error('typeof test === "object" && typeof test.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (!(_typeof(consequent) === "object" && typeof consequent.length !== "undefined")) { - throw new Error('typeof consequent === "object" && typeof consequent.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (!(_typeof(alternate) === "object" && typeof alternate.length !== "undefined")) { - throw new Error('typeof alternate === "object" && typeof alternate.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "IfInstruction", - id: "if", - testLabel: testLabel, - test: test, - result: result, - consequent: consequent, - alternate: alternate - }; - return node; -} -export function stringLiteral(value) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - var node = { - type: "StringLiteral", - value: value - }; - return node; -} -export function numberLiteral(value, raw) { - if (!(typeof value === "number")) { - throw new Error('typeof value === "number"' + " error: " + ("Argument value must be of type number, given: " + _typeof(value) || "unknown")); - } - - if (!(typeof raw === "string")) { - throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown")); - } - - var node = { - type: "NumberLiteral", - value: value, - raw: raw - }; - return node; -} -export function longNumberLiteral(value, raw) { - if (!(typeof raw === "string")) { - throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown")); - } - - var node = { - type: "LongNumberLiteral", - value: value, - raw: raw - }; - return node; -} -export function floatLiteral(value, nan, inf, raw) { - if (!(typeof value === "number")) { - throw new Error('typeof value === "number"' + " error: " + ("Argument value must be of type number, given: " + _typeof(value) || "unknown")); - } - - if (nan !== null && nan !== undefined) { - if (!(typeof nan === "boolean")) { - throw new Error('typeof nan === "boolean"' + " error: " + ("Argument nan must be of type boolean, given: " + _typeof(nan) || "unknown")); - } - } - - if (inf !== null && inf !== undefined) { - if (!(typeof inf === "boolean")) { - throw new Error('typeof inf === "boolean"' + " error: " + ("Argument inf must be of type boolean, given: " + _typeof(inf) || "unknown")); - } - } - - if (!(typeof raw === "string")) { - throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown")); - } - - var node = { - type: "FloatLiteral", - value: value, - raw: raw - }; - - if (nan === true) { - node.nan = true; - } - - if (inf === true) { - node.inf = true; - } - - return node; -} -export function elem(table, offset, funcs) { - if (!(_typeof(offset) === "object" && typeof offset.length !== "undefined")) { - throw new Error('typeof offset === "object" && typeof offset.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (!(_typeof(funcs) === "object" && typeof funcs.length !== "undefined")) { - throw new Error('typeof funcs === "object" && typeof funcs.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "Elem", - table: table, - offset: offset, - funcs: funcs - }; - return node; -} -export function indexInFuncSection(index) { - var node = { - type: "IndexInFuncSection", - index: index - }; - return node; -} -export function valtypeLiteral(name) { - var node = { - type: "ValtypeLiteral", - name: name - }; - return node; -} -export function typeInstruction(id, functype) { - var node = { - type: "TypeInstruction", - id: id, - functype: functype - }; - return node; -} -export function start(index) { - var node = { - type: "Start", - index: index - }; - return node; -} -export function globalType(valtype, mutability) { - var node = { - type: "GlobalType", - valtype: valtype, - mutability: mutability - }; - return node; -} -export function leadingComment(value) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - var node = { - type: "LeadingComment", - value: value - }; - return node; -} -export function blockComment(value) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - var node = { - type: "BlockComment", - value: value - }; - return node; -} -export function data(memoryIndex, offset, init) { - var node = { - type: "Data", - memoryIndex: memoryIndex, - offset: offset, - init: init - }; - return node; -} -export function global(globalType, init, name) { - if (!(_typeof(init) === "object" && typeof init.length !== "undefined")) { - throw new Error('typeof init === "object" && typeof init.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "Global", - globalType: globalType, - init: init, - name: name - }; - return node; -} -export function table(elementType, limits, name, elements) { - if (!(limits.type === "Limit")) { - throw new Error('limits.type === "Limit"' + " error: " + ("Argument limits must be of type Limit, given: " + limits.type || "unknown")); - } - - if (elements !== null && elements !== undefined) { - if (!(_typeof(elements) === "object" && typeof elements.length !== "undefined")) { - throw new Error('typeof elements === "object" && typeof elements.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - } - - var node = { - type: "Table", - elementType: elementType, - limits: limits, - name: name - }; - - if (typeof elements !== "undefined" && elements.length > 0) { - node.elements = elements; - } - - return node; -} -export function memory(limits, id) { - var node = { - type: "Memory", - limits: limits, - id: id - }; - return node; -} -export function funcImportDescr(id, signature) { - var node = { - type: "FuncImportDescr", - id: id, - signature: signature - }; - return node; -} -export function moduleImport(module, name, descr) { - if (!(typeof module === "string")) { - throw new Error('typeof module === "string"' + " error: " + ("Argument module must be of type string, given: " + _typeof(module) || "unknown")); - } - - if (!(typeof name === "string")) { - throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown")); - } - - var node = { - type: "ModuleImport", - module: module, - name: name, - descr: descr - }; - return node; -} -export function moduleExportDescr(exportType, id) { - var node = { - type: "ModuleExportDescr", - exportType: exportType, - id: id - }; - return node; -} -export function moduleExport(name, descr) { - if (!(typeof name === "string")) { - throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown")); - } - - var node = { - type: "ModuleExport", - name: name, - descr: descr - }; - return node; -} -export function limit(min, max) { - if (!(typeof min === "number")) { - throw new Error('typeof min === "number"' + " error: " + ("Argument min must be of type number, given: " + _typeof(min) || "unknown")); - } - - if (max !== null && max !== undefined) { - if (!(typeof max === "number")) { - throw new Error('typeof max === "number"' + " error: " + ("Argument max must be of type number, given: " + _typeof(max) || "unknown")); - } - } - - var node = { - type: "Limit", - min: min - }; - - if (typeof max !== "undefined") { - node.max = max; - } - - return node; -} -export function signature(params, results) { - if (!(_typeof(params) === "object" && typeof params.length !== "undefined")) { - throw new Error('typeof params === "object" && typeof params.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (!(_typeof(results) === "object" && typeof results.length !== "undefined")) { - throw new Error('typeof results === "object" && typeof results.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "Signature", - params: params, - results: results - }; - return node; -} -export function program(body) { - if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) { - throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "Program", - body: body - }; - return node; -} -export function identifier(value, raw) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - if (raw !== null && raw !== undefined) { - if (!(typeof raw === "string")) { - throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown")); - } - } - - var node = { - type: "Identifier", - value: value - }; - - if (typeof raw !== "undefined") { - node.raw = raw; - } - - return node; -} -export function blockInstruction(label, instr, result) { - if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) { - throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "BlockInstruction", - id: "block", - label: label, - instr: instr, - result: result - }; - return node; -} -export function callInstruction(index, instrArgs, numeric) { - if (instrArgs !== null && instrArgs !== undefined) { - if (!(_typeof(instrArgs) === "object" && typeof instrArgs.length !== "undefined")) { - throw new Error('typeof instrArgs === "object" && typeof instrArgs.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - } - - var node = { - type: "CallInstruction", - id: "call", - index: index - }; - - if (typeof instrArgs !== "undefined" && instrArgs.length > 0) { - node.instrArgs = instrArgs; - } - - if (typeof numeric !== "undefined") { - node.numeric = numeric; - } - - return node; -} -export function callIndirectInstruction(signature, intrs) { - if (intrs !== null && intrs !== undefined) { - if (!(_typeof(intrs) === "object" && typeof intrs.length !== "undefined")) { - throw new Error('typeof intrs === "object" && typeof intrs.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - } - - var node = { - type: "CallIndirectInstruction", - id: "call_indirect", - signature: signature - }; - - if (typeof intrs !== "undefined" && intrs.length > 0) { - node.intrs = intrs; - } - - return node; -} -export function byteArray(values) { - if (!(_typeof(values) === "object" && typeof values.length !== "undefined")) { - throw new Error('typeof values === "object" && typeof values.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "ByteArray", - values: values - }; - return node; -} -export function func(name, signature, body, isExternal, metadata) { - if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) { - throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (isExternal !== null && isExternal !== undefined) { - if (!(typeof isExternal === "boolean")) { - throw new Error('typeof isExternal === "boolean"' + " error: " + ("Argument isExternal must be of type boolean, given: " + _typeof(isExternal) || "unknown")); - } - } - - var node = { - type: "Func", - name: name, - signature: signature, - body: body - }; - - if (isExternal === true) { - node.isExternal = true; - } - - if (typeof metadata !== "undefined") { - node.metadata = metadata; - } - - return node; -} -export function internalBrUnless(target) { - if (!(typeof target === "number")) { - throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown")); - } - - var node = { - type: "InternalBrUnless", - target: target - }; - return node; -} -export function internalGoto(target) { - if (!(typeof target === "number")) { - throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown")); - } - - var node = { - type: "InternalGoto", - target: target - }; - return node; -} -export function internalCallExtern(target) { - if (!(typeof target === "number")) { - throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown")); - } - - var node = { - type: "InternalCallExtern", - target: target - }; - return node; -} -export function internalEndAndReturn() { - var node = { - type: "InternalEndAndReturn" - }; - return node; -} -export var isModule = isTypeOf("Module"); -export var isModuleMetadata = isTypeOf("ModuleMetadata"); -export var isModuleNameMetadata = isTypeOf("ModuleNameMetadata"); -export var isFunctionNameMetadata = isTypeOf("FunctionNameMetadata"); -export var isLocalNameMetadata = isTypeOf("LocalNameMetadata"); -export var isBinaryModule = isTypeOf("BinaryModule"); -export var isQuoteModule = isTypeOf("QuoteModule"); -export var isSectionMetadata = isTypeOf("SectionMetadata"); -export var isProducersSectionMetadata = isTypeOf("ProducersSectionMetadata"); -export var isProducerMetadata = isTypeOf("ProducerMetadata"); -export var isProducerMetadataVersionedName = isTypeOf("ProducerMetadataVersionedName"); -export var isLoopInstruction = isTypeOf("LoopInstruction"); -export var isInstr = isTypeOf("Instr"); -export var isIfInstruction = isTypeOf("IfInstruction"); -export var isStringLiteral = isTypeOf("StringLiteral"); -export var isNumberLiteral = isTypeOf("NumberLiteral"); -export var isLongNumberLiteral = isTypeOf("LongNumberLiteral"); -export var isFloatLiteral = isTypeOf("FloatLiteral"); -export var isElem = isTypeOf("Elem"); -export var isIndexInFuncSection = isTypeOf("IndexInFuncSection"); -export var isValtypeLiteral = isTypeOf("ValtypeLiteral"); -export var isTypeInstruction = isTypeOf("TypeInstruction"); -export var isStart = isTypeOf("Start"); -export var isGlobalType = isTypeOf("GlobalType"); -export var isLeadingComment = isTypeOf("LeadingComment"); -export var isBlockComment = isTypeOf("BlockComment"); -export var isData = isTypeOf("Data"); -export var isGlobal = isTypeOf("Global"); -export var isTable = isTypeOf("Table"); -export var isMemory = isTypeOf("Memory"); -export var isFuncImportDescr = isTypeOf("FuncImportDescr"); -export var isModuleImport = isTypeOf("ModuleImport"); -export var isModuleExportDescr = isTypeOf("ModuleExportDescr"); -export var isModuleExport = isTypeOf("ModuleExport"); -export var isLimit = isTypeOf("Limit"); -export var isSignature = isTypeOf("Signature"); -export var isProgram = isTypeOf("Program"); -export var isIdentifier = isTypeOf("Identifier"); -export var isBlockInstruction = isTypeOf("BlockInstruction"); -export var isCallInstruction = isTypeOf("CallInstruction"); -export var isCallIndirectInstruction = isTypeOf("CallIndirectInstruction"); -export var isByteArray = isTypeOf("ByteArray"); -export var isFunc = isTypeOf("Func"); -export var isInternalBrUnless = isTypeOf("InternalBrUnless"); -export var isInternalGoto = isTypeOf("InternalGoto"); -export var isInternalCallExtern = isTypeOf("InternalCallExtern"); -export var isInternalEndAndReturn = isTypeOf("InternalEndAndReturn"); -export var isNode = function isNode(node) { - return isModule(node) || isModuleMetadata(node) || isModuleNameMetadata(node) || isFunctionNameMetadata(node) || isLocalNameMetadata(node) || isBinaryModule(node) || isQuoteModule(node) || isSectionMetadata(node) || isProducersSectionMetadata(node) || isProducerMetadata(node) || isProducerMetadataVersionedName(node) || isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isElem(node) || isIndexInFuncSection(node) || isValtypeLiteral(node) || isTypeInstruction(node) || isStart(node) || isGlobalType(node) || isLeadingComment(node) || isBlockComment(node) || isData(node) || isGlobal(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node) || isModuleImport(node) || isModuleExportDescr(node) || isModuleExport(node) || isLimit(node) || isSignature(node) || isProgram(node) || isIdentifier(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node) || isByteArray(node) || isFunc(node) || isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node); -}; -export var isBlock = function isBlock(node) { - return isLoopInstruction(node) || isBlockInstruction(node) || isFunc(node); -}; -export var isInstruction = function isInstruction(node) { - return isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isTypeInstruction(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node); -}; -export var isExpression = function isExpression(node) { - return isInstr(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isValtypeLiteral(node) || isIdentifier(node); -}; -export var isNumericLiteral = function isNumericLiteral(node) { - return isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node); -}; -export var isImportDescr = function isImportDescr(node) { - return isGlobalType(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node); -}; -export var isIntrinsic = function isIntrinsic(node) { - return isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node); -}; -export var assertModule = assertTypeOf("Module"); -export var assertModuleMetadata = assertTypeOf("ModuleMetadata"); -export var assertModuleNameMetadata = assertTypeOf("ModuleNameMetadata"); -export var assertFunctionNameMetadata = assertTypeOf("FunctionNameMetadata"); -export var assertLocalNameMetadata = assertTypeOf("LocalNameMetadata"); -export var assertBinaryModule = assertTypeOf("BinaryModule"); -export var assertQuoteModule = assertTypeOf("QuoteModule"); -export var assertSectionMetadata = assertTypeOf("SectionMetadata"); -export var assertProducersSectionMetadata = assertTypeOf("ProducersSectionMetadata"); -export var assertProducerMetadata = assertTypeOf("ProducerMetadata"); -export var assertProducerMetadataVersionedName = assertTypeOf("ProducerMetadataVersionedName"); -export var assertLoopInstruction = assertTypeOf("LoopInstruction"); -export var assertInstr = assertTypeOf("Instr"); -export var assertIfInstruction = assertTypeOf("IfInstruction"); -export var assertStringLiteral = assertTypeOf("StringLiteral"); -export var assertNumberLiteral = assertTypeOf("NumberLiteral"); -export var assertLongNumberLiteral = assertTypeOf("LongNumberLiteral"); -export var assertFloatLiteral = assertTypeOf("FloatLiteral"); -export var assertElem = assertTypeOf("Elem"); -export var assertIndexInFuncSection = assertTypeOf("IndexInFuncSection"); -export var assertValtypeLiteral = assertTypeOf("ValtypeLiteral"); -export var assertTypeInstruction = assertTypeOf("TypeInstruction"); -export var assertStart = assertTypeOf("Start"); -export var assertGlobalType = assertTypeOf("GlobalType"); -export var assertLeadingComment = assertTypeOf("LeadingComment"); -export var assertBlockComment = assertTypeOf("BlockComment"); -export var assertData = assertTypeOf("Data"); -export var assertGlobal = assertTypeOf("Global"); -export var assertTable = assertTypeOf("Table"); -export var assertMemory = assertTypeOf("Memory"); -export var assertFuncImportDescr = assertTypeOf("FuncImportDescr"); -export var assertModuleImport = assertTypeOf("ModuleImport"); -export var assertModuleExportDescr = assertTypeOf("ModuleExportDescr"); -export var assertModuleExport = assertTypeOf("ModuleExport"); -export var assertLimit = assertTypeOf("Limit"); -export var assertSignature = assertTypeOf("Signature"); -export var assertProgram = assertTypeOf("Program"); -export var assertIdentifier = assertTypeOf("Identifier"); -export var assertBlockInstruction = assertTypeOf("BlockInstruction"); -export var assertCallInstruction = assertTypeOf("CallInstruction"); -export var assertCallIndirectInstruction = assertTypeOf("CallIndirectInstruction"); -export var assertByteArray = assertTypeOf("ByteArray"); -export var assertFunc = assertTypeOf("Func"); -export var assertInternalBrUnless = assertTypeOf("InternalBrUnless"); -export var assertInternalGoto = assertTypeOf("InternalGoto"); -export var assertInternalCallExtern = assertTypeOf("InternalCallExtern"); -export var assertInternalEndAndReturn = assertTypeOf("InternalEndAndReturn"); -export var unionTypesMap = { - Module: ["Node"], - ModuleMetadata: ["Node"], - ModuleNameMetadata: ["Node"], - FunctionNameMetadata: ["Node"], - LocalNameMetadata: ["Node"], - BinaryModule: ["Node"], - QuoteModule: ["Node"], - SectionMetadata: ["Node"], - ProducersSectionMetadata: ["Node"], - ProducerMetadata: ["Node"], - ProducerMetadataVersionedName: ["Node"], - LoopInstruction: ["Node", "Block", "Instruction"], - Instr: ["Node", "Expression", "Instruction"], - IfInstruction: ["Node", "Instruction"], - StringLiteral: ["Node", "Expression"], - NumberLiteral: ["Node", "NumericLiteral", "Expression"], - LongNumberLiteral: ["Node", "NumericLiteral", "Expression"], - FloatLiteral: ["Node", "NumericLiteral", "Expression"], - Elem: ["Node"], - IndexInFuncSection: ["Node"], - ValtypeLiteral: ["Node", "Expression"], - TypeInstruction: ["Node", "Instruction"], - Start: ["Node"], - GlobalType: ["Node", "ImportDescr"], - LeadingComment: ["Node"], - BlockComment: ["Node"], - Data: ["Node"], - Global: ["Node"], - Table: ["Node", "ImportDescr"], - Memory: ["Node", "ImportDescr"], - FuncImportDescr: ["Node", "ImportDescr"], - ModuleImport: ["Node"], - ModuleExportDescr: ["Node"], - ModuleExport: ["Node"], - Limit: ["Node"], - Signature: ["Node"], - Program: ["Node"], - Identifier: ["Node", "Expression"], - BlockInstruction: ["Node", "Block", "Instruction"], - CallInstruction: ["Node", "Instruction"], - CallIndirectInstruction: ["Node", "Instruction"], - ByteArray: ["Node"], - Func: ["Node", "Block"], - InternalBrUnless: ["Node", "Intrinsic"], - InternalGoto: ["Node", "Intrinsic"], - InternalCallExtern: ["Node", "Intrinsic"], - InternalEndAndReturn: ["Node", "Intrinsic"] -}; -export var nodeAndUnionTypes = ["Module", "ModuleMetadata", "ModuleNameMetadata", "FunctionNameMetadata", "LocalNameMetadata", "BinaryModule", "QuoteModule", "SectionMetadata", "ProducersSectionMetadata", "ProducerMetadata", "ProducerMetadataVersionedName", "LoopInstruction", "Instr", "IfInstruction", "StringLiteral", "NumberLiteral", "LongNumberLiteral", "FloatLiteral", "Elem", "IndexInFuncSection", "ValtypeLiteral", "TypeInstruction", "Start", "GlobalType", "LeadingComment", "BlockComment", "Data", "Global", "Table", "Memory", "FuncImportDescr", "ModuleImport", "ModuleExportDescr", "ModuleExport", "Limit", "Signature", "Program", "Identifier", "BlockInstruction", "CallInstruction", "CallIndirectInstruction", "ByteArray", "Func", "InternalBrUnless", "InternalGoto", "InternalCallExtern", "InternalEndAndReturn", "Node", "Block", "Instruction", "Expression", "NumericLiteral", "ImportDescr", "Intrinsic"];
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/esm/signatures.js b/node_modules/@webassemblyjs/ast/esm/signatures.js deleted file mode 100644 index 2f2750b..0000000 --- a/node_modules/@webassemblyjs/ast/esm/signatures.js +++ /dev/null @@ -1,199 +0,0 @@ -function sign(input, output) { - return [input, output]; -} - -var u32 = "u32"; -var i32 = "i32"; -var i64 = "i64"; -var f32 = "f32"; -var f64 = "f64"; - -var vector = function vector(t) { - var vecType = [t]; // $FlowIgnore - - vecType.vector = true; - return vecType; -}; - -var controlInstructions = { - unreachable: sign([], []), - nop: sign([], []), - // block ? - // loop ? - // if ? - // if else ? - br: sign([u32], []), - br_if: sign([u32], []), - br_table: sign(vector(u32), []), - return: sign([], []), - call: sign([u32], []), - call_indirect: sign([u32], []) -}; -var parametricInstructions = { - drop: sign([], []), - select: sign([], []) -}; -var variableInstructions = { - get_local: sign([u32], []), - set_local: sign([u32], []), - tee_local: sign([u32], []), - get_global: sign([u32], []), - set_global: sign([u32], []) -}; -var memoryInstructions = { - "i32.load": sign([u32, u32], [i32]), - "i64.load": sign([u32, u32], []), - "f32.load": sign([u32, u32], []), - "f64.load": sign([u32, u32], []), - "i32.load8_s": sign([u32, u32], [i32]), - "i32.load8_u": sign([u32, u32], [i32]), - "i32.load16_s": sign([u32, u32], [i32]), - "i32.load16_u": sign([u32, u32], [i32]), - "i64.load8_s": sign([u32, u32], [i64]), - "i64.load8_u": sign([u32, u32], [i64]), - "i64.load16_s": sign([u32, u32], [i64]), - "i64.load16_u": sign([u32, u32], [i64]), - "i64.load32_s": sign([u32, u32], [i64]), - "i64.load32_u": sign([u32, u32], [i64]), - "i32.store": sign([u32, u32], []), - "i64.store": sign([u32, u32], []), - "f32.store": sign([u32, u32], []), - "f64.store": sign([u32, u32], []), - "i32.store8": sign([u32, u32], []), - "i32.store16": sign([u32, u32], []), - "i64.store8": sign([u32, u32], []), - "i64.store16": sign([u32, u32], []), - "i64.store32": sign([u32, u32], []), - current_memory: sign([], []), - grow_memory: sign([], []) -}; -var numericInstructions = { - "i32.const": sign([i32], [i32]), - "i64.const": sign([i64], [i64]), - "f32.const": sign([f32], [f32]), - "f64.const": sign([f64], [f64]), - "i32.eqz": sign([i32], [i32]), - "i32.eq": sign([i32, i32], [i32]), - "i32.ne": sign([i32, i32], [i32]), - "i32.lt_s": sign([i32, i32], [i32]), - "i32.lt_u": sign([i32, i32], [i32]), - "i32.gt_s": sign([i32, i32], [i32]), - "i32.gt_u": sign([i32, i32], [i32]), - "i32.le_s": sign([i32, i32], [i32]), - "i32.le_u": sign([i32, i32], [i32]), - "i32.ge_s": sign([i32, i32], [i32]), - "i32.ge_u": sign([i32, i32], [i32]), - "i64.eqz": sign([i64], [i64]), - "i64.eq": sign([i64, i64], [i32]), - "i64.ne": sign([i64, i64], [i32]), - "i64.lt_s": sign([i64, i64], [i32]), - "i64.lt_u": sign([i64, i64], [i32]), - "i64.gt_s": sign([i64, i64], [i32]), - "i64.gt_u": sign([i64, i64], [i32]), - "i64.le_s": sign([i64, i64], [i32]), - "i64.le_u": sign([i64, i64], [i32]), - "i64.ge_s": sign([i64, i64], [i32]), - "i64.ge_u": sign([i64, i64], [i32]), - "f32.eq": sign([f32, f32], [i32]), - "f32.ne": sign([f32, f32], [i32]), - "f32.lt": sign([f32, f32], [i32]), - "f32.gt": sign([f32, f32], [i32]), - "f32.le": sign([f32, f32], [i32]), - "f32.ge": sign([f32, f32], [i32]), - "f64.eq": sign([f64, f64], [i32]), - "f64.ne": sign([f64, f64], [i32]), - "f64.lt": sign([f64, f64], [i32]), - "f64.gt": sign([f64, f64], [i32]), - "f64.le": sign([f64, f64], [i32]), - "f64.ge": sign([f64, f64], [i32]), - "i32.clz": sign([i32], [i32]), - "i32.ctz": sign([i32], [i32]), - "i32.popcnt": sign([i32], [i32]), - "i32.add": sign([i32, i32], [i32]), - "i32.sub": sign([i32, i32], [i32]), - "i32.mul": sign([i32, i32], [i32]), - "i32.div_s": sign([i32, i32], [i32]), - "i32.div_u": sign([i32, i32], [i32]), - "i32.rem_s": sign([i32, i32], [i32]), - "i32.rem_u": sign([i32, i32], [i32]), - "i32.and": sign([i32, i32], [i32]), - "i32.or": sign([i32, i32], [i32]), - "i32.xor": sign([i32, i32], [i32]), - "i32.shl": sign([i32, i32], [i32]), - "i32.shr_s": sign([i32, i32], [i32]), - "i32.shr_u": sign([i32, i32], [i32]), - "i32.rotl": sign([i32, i32], [i32]), - "i32.rotr": sign([i32, i32], [i32]), - "i64.clz": sign([i64], [i64]), - "i64.ctz": sign([i64], [i64]), - "i64.popcnt": sign([i64], [i64]), - "i64.add": sign([i64, i64], [i64]), - "i64.sub": sign([i64, i64], [i64]), - "i64.mul": sign([i64, i64], [i64]), - "i64.div_s": sign([i64, i64], [i64]), - "i64.div_u": sign([i64, i64], [i64]), - "i64.rem_s": sign([i64, i64], [i64]), - "i64.rem_u": sign([i64, i64], [i64]), - "i64.and": sign([i64, i64], [i64]), - "i64.or": sign([i64, i64], [i64]), - "i64.xor": sign([i64, i64], [i64]), - "i64.shl": sign([i64, i64], [i64]), - "i64.shr_s": sign([i64, i64], [i64]), - "i64.shr_u": sign([i64, i64], [i64]), - "i64.rotl": sign([i64, i64], [i64]), - "i64.rotr": sign([i64, i64], [i64]), - "f32.abs": sign([f32], [f32]), - "f32.neg": sign([f32], [f32]), - "f32.ceil": sign([f32], [f32]), - "f32.floor": sign([f32], [f32]), - "f32.trunc": sign([f32], [f32]), - "f32.nearest": sign([f32], [f32]), - "f32.sqrt": sign([f32], [f32]), - "f32.add": sign([f32, f32], [f32]), - "f32.sub": sign([f32, f32], [f32]), - "f32.mul": sign([f32, f32], [f32]), - "f32.div": sign([f32, f32], [f32]), - "f32.min": sign([f32, f32], [f32]), - "f32.max": sign([f32, f32], [f32]), - "f32.copysign": sign([f32, f32], [f32]), - "f64.abs": sign([f64], [f64]), - "f64.neg": sign([f64], [f64]), - "f64.ceil": sign([f64], [f64]), - "f64.floor": sign([f64], [f64]), - "f64.trunc": sign([f64], [f64]), - "f64.nearest": sign([f64], [f64]), - "f64.sqrt": sign([f64], [f64]), - "f64.add": sign([f64, f64], [f64]), - "f64.sub": sign([f64, f64], [f64]), - "f64.mul": sign([f64, f64], [f64]), - "f64.div": sign([f64, f64], [f64]), - "f64.min": sign([f64, f64], [f64]), - "f64.max": sign([f64, f64], [f64]), - "f64.copysign": sign([f64, f64], [f64]), - "i32.wrap/i64": sign([i64], [i32]), - "i32.trunc_s/f32": sign([f32], [i32]), - "i32.trunc_u/f32": sign([f32], [i32]), - "i32.trunc_s/f64": sign([f32], [i32]), - "i32.trunc_u/f64": sign([f64], [i32]), - "i64.extend_s/i32": sign([i32], [i64]), - "i64.extend_u/i32": sign([i32], [i64]), - "i64.trunc_s/f32": sign([f32], [i64]), - "i64.trunc_u/f32": sign([f32], [i64]), - "i64.trunc_s/f64": sign([f64], [i64]), - "i64.trunc_u/f64": sign([f64], [i64]), - "f32.convert_s/i32": sign([i32], [f32]), - "f32.convert_u/i32": sign([i32], [f32]), - "f32.convert_s/i64": sign([i64], [f32]), - "f32.convert_u/i64": sign([i64], [f32]), - "f32.demote/f64": sign([f64], [f32]), - "f64.convert_s/i32": sign([i32], [f64]), - "f64.convert_u/i32": sign([i32], [f64]), - "f64.convert_s/i64": sign([i64], [f64]), - "f64.convert_u/i64": sign([i64], [f64]), - "f64.promote/f32": sign([f32], [f64]), - "i32.reinterpret/f32": sign([f32], [i32]), - "i64.reinterpret/f64": sign([f64], [i64]), - "f32.reinterpret/i32": sign([i32], [f32]), - "f64.reinterpret/i64": sign([i64], [f64]) -}; -export var signatures = Object.assign({}, controlInstructions, parametricInstructions, variableInstructions, memoryInstructions, numericInstructions);
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/esm/transform/denormalize-type-references/index.js b/node_modules/@webassemblyjs/ast/esm/transform/denormalize-type-references/index.js deleted file mode 100644 index 26891f9..0000000 --- a/node_modules/@webassemblyjs/ast/esm/transform/denormalize-type-references/index.js +++ /dev/null @@ -1,76 +0,0 @@ -var t = require("../../index"); // func and call_indirect instructions can either define a signature inline, or -// reference a signature, e.g. -// -// ;; inline signature -// (func (result i64) -// (i64.const 2) -// ) -// ;; signature reference -// (type (func (result i64))) -// (func (type 0) -// (i64.const 2)) -// ) -// -// this AST transform denormalises the type references, making all signatures within the module -// inline. - - -export function transform(ast) { - var typeInstructions = []; - t.traverse(ast, { - TypeInstruction: function TypeInstruction(_ref) { - var node = _ref.node; - typeInstructions.push(node); - } - }); - - if (!typeInstructions.length) { - return; - } - - function denormalizeSignature(signature) { - // signature referenced by identifier - if (signature.type === "Identifier") { - var identifier = signature; - var typeInstruction = typeInstructions.find(function (t) { - return t.id.type === identifier.type && t.id.value === identifier.value; - }); - - if (!typeInstruction) { - throw new Error("A type instruction reference was not found ".concat(JSON.stringify(signature))); - } - - return typeInstruction.functype; - } // signature referenced by index - - - if (signature.type === "NumberLiteral") { - var signatureRef = signature; - var _typeInstruction = typeInstructions[signatureRef.value]; - return _typeInstruction.functype; - } - - return signature; - } - - t.traverse(ast, { - Func: function (_Func) { - function Func(_x) { - return _Func.apply(this, arguments); - } - - Func.toString = function () { - return _Func.toString(); - }; - - return Func; - }(function (_ref2) { - var node = _ref2.node; - node.signature = denormalizeSignature(node.signature); - }), - CallIndirectInstruction: function CallIndirectInstruction(_ref3) { - var node = _ref3.node; - node.signature = denormalizeSignature(node.signature); - } - }); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/esm/transform/wast-identifier-to-index/index.js b/node_modules/@webassemblyjs/ast/esm/transform/wast-identifier-to-index/index.js deleted file mode 100644 index bea35f3..0000000 --- a/node_modules/@webassemblyjs/ast/esm/transform/wast-identifier-to-index/index.js +++ /dev/null @@ -1,216 +0,0 @@ -function _typeof(obj) { 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); } - -function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - -function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } } - -import { isBlock, isFunc, isIdentifier, numberLiteralFromRaw, traverse } from "../../index"; -import { moduleContextFromModuleAST } from "@webassemblyjs/helper-module-context"; // FIXME(sven): do the same with all block instructions, must be more generic here - -function newUnexpectedFunction(i) { - return new Error("unknown function at offset: " + i); -} - -export function transform(ast) { - var module; - traverse(ast, { - Module: function (_Module) { - function Module(_x) { - return _Module.apply(this, arguments); - } - - Module.toString = function () { - return _Module.toString(); - }; - - return Module; - }(function (path) { - module = path.node; - }) - }); - var moduleContext = moduleContextFromModuleAST(module); // Transform the actual instruction in function bodies - - traverse(ast, { - Func: function (_Func) { - function Func(_x2) { - return _Func.apply(this, arguments); - } - - Func.toString = function () { - return _Func.toString(); - }; - - return Func; - }(function (path) { - transformFuncPath(path, moduleContext); - }), - Start: function (_Start) { - function Start(_x3) { - return _Start.apply(this, arguments); - } - - Start.toString = function () { - return _Start.toString(); - }; - - return Start; - }(function (path) { - var index = path.node.index; - - if (isIdentifier(index) === true) { - var offsetInModule = moduleContext.getFunctionOffsetByIdentifier(index.value); - - if (typeof offsetInModule === "undefined") { - throw newUnexpectedFunction(index.value); - } // Replace the index Identifier - // $FlowIgnore: reference? - - - path.node.index = numberLiteralFromRaw(offsetInModule); - } - }) - }); -} - -function transformFuncPath(funcPath, moduleContext) { - var funcNode = funcPath.node; - var signature = funcNode.signature; - - if (signature.type !== "Signature") { - throw new Error("Function signatures must be denormalised before execution"); - } - - var params = signature.params; // Add func locals in the context - - params.forEach(function (p) { - return moduleContext.addLocal(p.valtype); - }); - traverse(funcNode, { - Instr: function (_Instr) { - function Instr(_x4) { - return _Instr.apply(this, arguments); - } - - Instr.toString = function () { - return _Instr.toString(); - }; - - return Instr; - }(function (instrPath) { - var instrNode = instrPath.node; - /** - * Local access - */ - - if (instrNode.id === "get_local" || instrNode.id === "set_local" || instrNode.id === "tee_local") { - var _instrNode$args = _slicedToArray(instrNode.args, 1), - firstArg = _instrNode$args[0]; - - if (firstArg.type === "Identifier") { - var offsetInParams = params.findIndex(function (_ref) { - var id = _ref.id; - return id === firstArg.value; - }); - - if (offsetInParams === -1) { - throw new Error("".concat(firstArg.value, " not found in ").concat(instrNode.id, ": not declared in func params")); - } // Replace the Identifer node by our new NumberLiteral node - - - instrNode.args[0] = numberLiteralFromRaw(offsetInParams); - } - } - /** - * Global access - */ - - - if (instrNode.id === "get_global" || instrNode.id === "set_global") { - var _instrNode$args2 = _slicedToArray(instrNode.args, 1), - _firstArg = _instrNode$args2[0]; - - if (isIdentifier(_firstArg) === true) { - var globalOffset = moduleContext.getGlobalOffsetByIdentifier( // $FlowIgnore: reference? - _firstArg.value); - - if (typeof globalOffset === "undefined") { - // $FlowIgnore: reference? - throw new Error("global ".concat(_firstArg.value, " not found in module")); - } // Replace the Identifer node by our new NumberLiteral node - - - instrNode.args[0] = numberLiteralFromRaw(globalOffset); - } - } - /** - * Labels lookup - */ - - - if (instrNode.id === "br") { - var _instrNode$args3 = _slicedToArray(instrNode.args, 1), - _firstArg2 = _instrNode$args3[0]; - - if (isIdentifier(_firstArg2) === true) { - // if the labels is not found it is going to be replaced with -1 - // which is invalid. - var relativeBlockCount = -1; // $FlowIgnore: reference? - - instrPath.findParent(function (_ref2) { - var node = _ref2.node; - - if (isBlock(node)) { - relativeBlockCount++; // $FlowIgnore: reference? - - var name = node.label || node.name; - - if (_typeof(name) === "object") { - // $FlowIgnore: isIdentifier ensures that - if (name.value === _firstArg2.value) { - // Found it - return false; - } - } - } - - if (isFunc(node)) { - return false; - } - }); // Replace the Identifer node by our new NumberLiteral node - - instrNode.args[0] = numberLiteralFromRaw(relativeBlockCount); - } - } - }), - - /** - * Func lookup - */ - CallInstruction: function (_CallInstruction) { - function CallInstruction(_x5) { - return _CallInstruction.apply(this, arguments); - } - - CallInstruction.toString = function () { - return _CallInstruction.toString(); - }; - - return CallInstruction; - }(function (_ref3) { - var node = _ref3.node; - var index = node.index; - - if (isIdentifier(index) === true) { - var offsetInModule = moduleContext.getFunctionOffsetByIdentifier(index.value); - - if (typeof offsetInModule === "undefined") { - throw newUnexpectedFunction(index.value); - } // Replace the index Identifier - // $FlowIgnore: reference? - - - node.index = numberLiteralFromRaw(offsetInModule); - } - }) - }); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/esm/traverse.js b/node_modules/@webassemblyjs/ast/esm/traverse.js deleted file mode 100644 index 328dc09..0000000 --- a/node_modules/@webassemblyjs/ast/esm/traverse.js +++ /dev/null @@ -1,96 +0,0 @@ -import { createPath } from "./node-path"; -import { unionTypesMap, nodeAndUnionTypes } from "./nodes"; // recursively walks the AST starting at the given node. The callback is invoked for -// and object that has a 'type' property. - -function walk(context, callback) { - var stop = false; - - function innerWalk(context, callback) { - if (stop) { - return; - } - - var node = context.node; - - if (node === undefined) { - console.warn("traversing with an empty context"); - return; - } - - if (node._deleted === true) { - return; - } - - var path = createPath(context); - callback(node.type, path); - - if (path.shouldStop) { - stop = true; - return; - } - - Object.keys(node).forEach(function (prop) { - var value = node[prop]; - - if (value === null || value === undefined) { - return; - } - - var valueAsArray = Array.isArray(value) ? value : [value]; - valueAsArray.forEach(function (childNode) { - if (typeof childNode.type === "string") { - var childContext = { - node: childNode, - parentKey: prop, - parentPath: path, - shouldStop: false, - inList: Array.isArray(value) - }; - innerWalk(childContext, callback); - } - }); - }); - } - - innerWalk(context, callback); -} - -var noop = function noop() {}; - -export function traverse(node, visitors) { - var before = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop; - var after = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop; - Object.keys(visitors).forEach(function (visitor) { - if (!nodeAndUnionTypes.includes(visitor)) { - throw new Error("Unexpected visitor ".concat(visitor)); - } - }); - var context = { - node: node, - inList: false, - shouldStop: false, - parentPath: null, - parentKey: null - }; - walk(context, function (type, path) { - if (typeof visitors[type] === "function") { - before(type, path); - visitors[type](path); - after(type, path); - } - - var unionTypes = unionTypesMap[type]; - - if (!unionTypes) { - throw new Error("Unexpected node type ".concat(type)); - } - - unionTypes.forEach(function (unionType) { - if (typeof visitors[unionType] === "function") { - before(unionType, path); - visitors[unionType](path); - after(unionType, path); - } - }); - }); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/esm/types/basic.js b/node_modules/@webassemblyjs/ast/esm/types/basic.js deleted file mode 100644 index e69de29..0000000 --- a/node_modules/@webassemblyjs/ast/esm/types/basic.js +++ /dev/null diff --git a/node_modules/@webassemblyjs/ast/esm/types/nodes.js b/node_modules/@webassemblyjs/ast/esm/types/nodes.js deleted file mode 100644 index e69de29..0000000 --- a/node_modules/@webassemblyjs/ast/esm/types/nodes.js +++ /dev/null diff --git a/node_modules/@webassemblyjs/ast/esm/types/traverse.js b/node_modules/@webassemblyjs/ast/esm/types/traverse.js deleted file mode 100644 index e69de29..0000000 --- a/node_modules/@webassemblyjs/ast/esm/types/traverse.js +++ /dev/null diff --git a/node_modules/@webassemblyjs/ast/esm/utils.js b/node_modules/@webassemblyjs/ast/esm/utils.js deleted file mode 100644 index 850410e..0000000 --- a/node_modules/@webassemblyjs/ast/esm/utils.js +++ /dev/null @@ -1,265 +0,0 @@ -function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - -function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } } - -function _typeof(obj) { 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); } - -import { signatures } from "./signatures"; -import { traverse } from "./traverse"; -import constants from "@webassemblyjs/helper-wasm-bytecode"; -import { getSectionForNode } from "@webassemblyjs/helper-wasm-bytecode"; -export function isAnonymous(ident) { - return ident.raw === ""; -} -export function getSectionMetadata(ast, name) { - var section; - traverse(ast, { - SectionMetadata: function (_SectionMetadata) { - function SectionMetadata(_x) { - return _SectionMetadata.apply(this, arguments); - } - - SectionMetadata.toString = function () { - return _SectionMetadata.toString(); - }; - - return SectionMetadata; - }(function (_ref) { - var node = _ref.node; - - if (node.section === name) { - section = node; - } - }) - }); - return section; -} -export function getSectionMetadatas(ast, name) { - var sections = []; - traverse(ast, { - SectionMetadata: function (_SectionMetadata2) { - function SectionMetadata(_x2) { - return _SectionMetadata2.apply(this, arguments); - } - - SectionMetadata.toString = function () { - return _SectionMetadata2.toString(); - }; - - return SectionMetadata; - }(function (_ref2) { - var node = _ref2.node; - - if (node.section === name) { - sections.push(node); - } - }) - }); - return sections; -} -export function sortSectionMetadata(m) { - if (m.metadata == null) { - console.warn("sortSectionMetadata: no metadata to sort"); - return; - } // $FlowIgnore - - - m.metadata.sections.sort(function (a, b) { - var aId = constants.sections[a.section]; - var bId = constants.sections[b.section]; - - if (typeof aId !== "number" || typeof bId !== "number") { - throw new Error("Section id not found"); - } - - return aId - bId; - }); -} -export function orderedInsertNode(m, n) { - assertHasLoc(n); - var didInsert = false; - - if (n.type === "ModuleExport") { - m.fields.push(n); - return; - } - - m.fields = m.fields.reduce(function (acc, field) { - var fieldEndCol = Infinity; - - if (field.loc != null) { - // $FlowIgnore - fieldEndCol = field.loc.end.column; - } // $FlowIgnore: assertHasLoc ensures that - - - if (didInsert === false && n.loc.start.column < fieldEndCol) { - didInsert = true; - acc.push(n); - } - - acc.push(field); - return acc; - }, []); // Handles empty modules or n is the last element - - if (didInsert === false) { - m.fields.push(n); - } -} -export function assertHasLoc(n) { - if (n.loc == null || n.loc.start == null || n.loc.end == null) { - throw new Error("Internal failure: node (".concat(JSON.stringify(n.type), ") has no location information")); - } -} -export function getEndOfSection(s) { - assertHasLoc(s.size); - return s.startOffset + s.size.value + ( // $FlowIgnore - s.size.loc.end.column - s.size.loc.start.column); -} -export function shiftLoc(node, delta) { - // $FlowIgnore - node.loc.start.column += delta; // $FlowIgnore - - node.loc.end.column += delta; -} -export function shiftSection(ast, node, delta) { - if (node.type !== "SectionMetadata") { - throw new Error("Can not shift node " + JSON.stringify(node.type)); - } - - node.startOffset += delta; - - if (_typeof(node.size.loc) === "object") { - shiftLoc(node.size, delta); - } // Custom sections doesn't have vectorOfSize - - - if (_typeof(node.vectorOfSize) === "object" && _typeof(node.vectorOfSize.loc) === "object") { - shiftLoc(node.vectorOfSize, delta); - } - - var sectionName = node.section; // shift node locations within that section - - traverse(ast, { - Node: function Node(_ref3) { - var node = _ref3.node; - var section = getSectionForNode(node); - - if (section === sectionName && _typeof(node.loc) === "object") { - shiftLoc(node, delta); - } - } - }); -} -export function signatureForOpcode(object, name) { - var opcodeName = name; - - if (object !== undefined && object !== "") { - opcodeName = object + "." + name; - } - - var sign = signatures[opcodeName]; - - if (sign == undefined) { - // TODO: Uncomment this when br_table and others has been done - //throw new Error("Invalid opcode: "+opcodeName); - return [object, object]; - } - - return sign[0]; -} -export function getUniqueNameGenerator() { - var inc = {}; - return function () { - var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "temp"; - - if (!(prefix in inc)) { - inc[prefix] = 0; - } else { - inc[prefix] = inc[prefix] + 1; - } - - return prefix + "_" + inc[prefix]; - }; -} -export function getStartByteOffset(n) { - // $FlowIgnore - if (typeof n.loc === "undefined" || typeof n.loc.start === "undefined") { - throw new Error( // $FlowIgnore - "Can not get byte offset without loc informations, node: " + String(n.id)); - } - - return n.loc.start.column; -} -export function getEndByteOffset(n) { - // $FlowIgnore - if (typeof n.loc === "undefined" || typeof n.loc.end === "undefined") { - throw new Error("Can not get byte offset without loc informations, node: " + n.type); - } - - return n.loc.end.column; -} -export function getFunctionBeginingByteOffset(n) { - if (!(n.body.length > 0)) { - throw new Error('n.body.length > 0' + " error: " + (undefined || "unknown")); - } - - var _n$body = _slicedToArray(n.body, 1), - firstInstruction = _n$body[0]; - - return getStartByteOffset(firstInstruction); -} -export function getEndBlockByteOffset(n) { - // $FlowIgnore - if (!(n.instr.length > 0 || n.body.length > 0)) { - throw new Error('n.instr.length > 0 || n.body.length > 0' + " error: " + (undefined || "unknown")); - } - - var lastInstruction; - - if (n.instr) { - // $FlowIgnore - lastInstruction = n.instr[n.instr.length - 1]; - } - - if (n.body) { - // $FlowIgnore - lastInstruction = n.body[n.body.length - 1]; - } - - if (!(_typeof(lastInstruction) === "object")) { - throw new Error('typeof lastInstruction === "object"' + " error: " + (undefined || "unknown")); - } - - // $FlowIgnore - return getStartByteOffset(lastInstruction); -} -export function getStartBlockByteOffset(n) { - // $FlowIgnore - if (!(n.instr.length > 0 || n.body.length > 0)) { - throw new Error('n.instr.length > 0 || n.body.length > 0' + " error: " + (undefined || "unknown")); - } - - var fistInstruction; - - if (n.instr) { - // $FlowIgnore - var _n$instr = _slicedToArray(n.instr, 1); - - fistInstruction = _n$instr[0]; - } - - if (n.body) { - // $FlowIgnore - var _n$body2 = _slicedToArray(n.body, 1); - - fistInstruction = _n$body2[0]; - } - - if (!(_typeof(fistInstruction) === "object")) { - throw new Error('typeof fistInstruction === "object"' + " error: " + (undefined || "unknown")); - } - - // $FlowIgnore - return getStartByteOffset(fistInstruction); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/lib/clone.js b/node_modules/@webassemblyjs/ast/lib/clone.js deleted file mode 100644 index 7c386a4..0000000 --- a/node_modules/@webassemblyjs/ast/lib/clone.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.cloneNode = cloneNode; - -function cloneNode(n) { - // $FlowIgnore - var newObj = {}; - - for (var k in n) { - newObj[k] = n[k]; - } - - return newObj; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/lib/definitions.js b/node_modules/@webassemblyjs/ast/lib/definitions.js deleted file mode 100644 index 120311b..0000000 --- a/node_modules/@webassemblyjs/ast/lib/definitions.js +++ /dev/null @@ -1,663 +0,0 @@ -var definitions = {}; - -function defineType(typeName, metadata) { - definitions[typeName] = metadata; -} - -defineType("Module", { - spec: { - wasm: "https://webassembly.github.io/spec/core/binary/modules.html#binary-module", - wat: "https://webassembly.github.io/spec/core/text/modules.html#text-module" - }, - doc: "A module consists of a sequence of sections (termed fields in the text format).", - unionType: ["Node"], - fields: { - id: { - maybe: true, - type: "string" - }, - fields: { - array: true, - type: "Node" - }, - metadata: { - optional: true, - type: "ModuleMetadata" - } - } -}); -defineType("ModuleMetadata", { - unionType: ["Node"], - fields: { - sections: { - array: true, - type: "SectionMetadata" - }, - functionNames: { - optional: true, - array: true, - type: "FunctionNameMetadata" - }, - localNames: { - optional: true, - array: true, - type: "ModuleMetadata" - }, - producers: { - optional: true, - array: true, - type: "ProducersSectionMetadata" - } - } -}); -defineType("ModuleNameMetadata", { - unionType: ["Node"], - fields: { - value: { - type: "string" - } - } -}); -defineType("FunctionNameMetadata", { - unionType: ["Node"], - fields: { - value: { - type: "string" - }, - index: { - type: "number" - } - } -}); -defineType("LocalNameMetadata", { - unionType: ["Node"], - fields: { - value: { - type: "string" - }, - localIndex: { - type: "number" - }, - functionIndex: { - type: "number" - } - } -}); -defineType("BinaryModule", { - unionType: ["Node"], - fields: { - id: { - maybe: true, - type: "string" - }, - blob: { - array: true, - type: "string" - } - } -}); -defineType("QuoteModule", { - unionType: ["Node"], - fields: { - id: { - maybe: true, - type: "string" - }, - string: { - array: true, - type: "string" - } - } -}); -defineType("SectionMetadata", { - unionType: ["Node"], - fields: { - section: { - type: "SectionName" - }, - startOffset: { - type: "number" - }, - size: { - type: "NumberLiteral" - }, - vectorOfSize: { - comment: "Size of the vector in the section (if any)", - type: "NumberLiteral" - } - } -}); -defineType("ProducersSectionMetadata", { - unionType: ["Node"], - fields: { - producers: { - array: true, - type: "ProducerMetadata" - } - } -}); -defineType("ProducerMetadata", { - unionType: ["Node"], - fields: { - language: { - type: "ProducerMetadataVersionedName", - array: true - }, - processedBy: { - type: "ProducerMetadataVersionedName", - array: true - }, - sdk: { - type: "ProducerMetadataVersionedName", - array: true - } - } -}); -defineType("ProducerMetadataVersionedName", { - unionType: ["Node"], - fields: { - name: { - type: "string" - }, - version: { - type: "string" - } - } -}); -/* -Instructions -*/ - -defineType("LoopInstruction", { - unionType: ["Node", "Block", "Instruction"], - fields: { - id: { - constant: true, - type: "string", - value: "loop" - }, - label: { - maybe: true, - type: "Identifier" - }, - resulttype: { - maybe: true, - type: "Valtype" - }, - instr: { - array: true, - type: "Instruction" - } - } -}); -defineType("Instr", { - unionType: ["Node", "Expression", "Instruction"], - fields: { - id: { - type: "string" - }, - object: { - optional: true, - type: "Valtype" - }, - args: { - array: true, - type: "Expression" - }, - namedArgs: { - optional: true, - type: "Object" - } - } -}); -defineType("IfInstruction", { - unionType: ["Node", "Instruction"], - fields: { - id: { - constant: true, - type: "string", - value: "if" - }, - testLabel: { - comment: "only for WAST", - type: "Identifier" - }, - test: { - array: true, - type: "Instruction" - }, - result: { - maybe: true, - type: "Valtype" - }, - consequent: { - array: true, - type: "Instruction" - }, - alternate: { - array: true, - type: "Instruction" - } - } -}); -/* -Concrete value types -*/ - -defineType("StringLiteral", { - unionType: ["Node", "Expression"], - fields: { - value: { - type: "string" - } - } -}); -defineType("NumberLiteral", { - unionType: ["Node", "NumericLiteral", "Expression"], - fields: { - value: { - type: "number" - }, - raw: { - type: "string" - } - } -}); -defineType("LongNumberLiteral", { - unionType: ["Node", "NumericLiteral", "Expression"], - fields: { - value: { - type: "LongNumber" - }, - raw: { - type: "string" - } - } -}); -defineType("FloatLiteral", { - unionType: ["Node", "NumericLiteral", "Expression"], - fields: { - value: { - type: "number" - }, - nan: { - optional: true, - type: "boolean" - }, - inf: { - optional: true, - type: "boolean" - }, - raw: { - type: "string" - } - } -}); -defineType("Elem", { - unionType: ["Node"], - fields: { - table: { - type: "Index" - }, - offset: { - array: true, - type: "Instruction" - }, - funcs: { - array: true, - type: "Index" - } - } -}); -defineType("IndexInFuncSection", { - unionType: ["Node"], - fields: { - index: { - type: "Index" - } - } -}); -defineType("ValtypeLiteral", { - unionType: ["Node", "Expression"], - fields: { - name: { - type: "Valtype" - } - } -}); -defineType("TypeInstruction", { - unionType: ["Node", "Instruction"], - fields: { - id: { - maybe: true, - type: "Index" - }, - functype: { - type: "Signature" - } - } -}); -defineType("Start", { - unionType: ["Node"], - fields: { - index: { - type: "Index" - } - } -}); -defineType("GlobalType", { - unionType: ["Node", "ImportDescr"], - fields: { - valtype: { - type: "Valtype" - }, - mutability: { - type: "Mutability" - } - } -}); -defineType("LeadingComment", { - unionType: ["Node"], - fields: { - value: { - type: "string" - } - } -}); -defineType("BlockComment", { - unionType: ["Node"], - fields: { - value: { - type: "string" - } - } -}); -defineType("Data", { - unionType: ["Node"], - fields: { - memoryIndex: { - type: "Memidx" - }, - offset: { - type: "Instruction" - }, - init: { - type: "ByteArray" - } - } -}); -defineType("Global", { - unionType: ["Node"], - fields: { - globalType: { - type: "GlobalType" - }, - init: { - array: true, - type: "Instruction" - }, - name: { - maybe: true, - type: "Identifier" - } - } -}); -defineType("Table", { - unionType: ["Node", "ImportDescr"], - fields: { - elementType: { - type: "TableElementType" - }, - limits: { - assertNodeType: true, - type: "Limit" - }, - name: { - maybe: true, - type: "Identifier" - }, - elements: { - array: true, - optional: true, - type: "Index" - } - } -}); -defineType("Memory", { - unionType: ["Node", "ImportDescr"], - fields: { - limits: { - type: "Limit" - }, - id: { - maybe: true, - type: "Index" - } - } -}); -defineType("FuncImportDescr", { - unionType: ["Node", "ImportDescr"], - fields: { - id: { - type: "Identifier" - }, - signature: { - type: "Signature" - } - } -}); -defineType("ModuleImport", { - unionType: ["Node"], - fields: { - module: { - type: "string" - }, - name: { - type: "string" - }, - descr: { - type: "ImportDescr" - } - } -}); -defineType("ModuleExportDescr", { - unionType: ["Node"], - fields: { - exportType: { - type: "ExportDescrType" - }, - id: { - type: "Index" - } - } -}); -defineType("ModuleExport", { - unionType: ["Node"], - fields: { - name: { - type: "string" - }, - descr: { - type: "ModuleExportDescr" - } - } -}); -defineType("Limit", { - unionType: ["Node"], - fields: { - min: { - type: "number" - }, - max: { - optional: true, - type: "number" - } - } -}); -defineType("Signature", { - unionType: ["Node"], - fields: { - params: { - array: true, - type: "FuncParam" - }, - results: { - array: true, - type: "Valtype" - } - } -}); -defineType("Program", { - unionType: ["Node"], - fields: { - body: { - array: true, - type: "Node" - } - } -}); -defineType("Identifier", { - unionType: ["Node", "Expression"], - fields: { - value: { - type: "string" - }, - raw: { - optional: true, - type: "string" - } - } -}); -defineType("BlockInstruction", { - unionType: ["Node", "Block", "Instruction"], - fields: { - id: { - constant: true, - type: "string", - value: "block" - }, - label: { - maybe: true, - type: "Identifier" - }, - instr: { - array: true, - type: "Instruction" - }, - result: { - maybe: true, - type: "Valtype" - } - } -}); -defineType("CallInstruction", { - unionType: ["Node", "Instruction"], - fields: { - id: { - constant: true, - type: "string", - value: "call" - }, - index: { - type: "Index" - }, - instrArgs: { - array: true, - optional: true, - type: "Expression" - }, - numeric: { - type: "Index", - optional: true - } - } -}); -defineType("CallIndirectInstruction", { - unionType: ["Node", "Instruction"], - fields: { - id: { - constant: true, - type: "string", - value: "call_indirect" - }, - signature: { - type: "SignatureOrTypeRef" - }, - intrs: { - array: true, - optional: true, - type: "Expression" - } - } -}); -defineType("ByteArray", { - unionType: ["Node"], - fields: { - values: { - array: true, - type: "Byte" - } - } -}); -defineType("Func", { - unionType: ["Node", "Block"], - fields: { - name: { - maybe: true, - type: "Index" - }, - signature: { - type: "SignatureOrTypeRef" - }, - body: { - array: true, - type: "Instruction" - }, - isExternal: { - comment: "means that it has been imported from the outside js", - optional: true, - type: "boolean" - }, - metadata: { - optional: true, - type: "FuncMetadata" - } - } -}); -/** - * Intrinsics - */ - -defineType("InternalBrUnless", { - unionType: ["Node", "Intrinsic"], - fields: { - target: { - type: "number" - } - } -}); -defineType("InternalGoto", { - unionType: ["Node", "Intrinsic"], - fields: { - target: { - type: "number" - } - } -}); -defineType("InternalCallExtern", { - unionType: ["Node", "Intrinsic"], - fields: { - target: { - type: "number" - } - } -}); // function bodies are terminated by an `end` instruction but are missing a -// return instruction -// -// Since we can't inject a new instruction we are injecting a new instruction. - -defineType("InternalEndAndReturn", { - unionType: ["Node", "Intrinsic"], - fields: {} -}); -module.exports = definitions;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/lib/index.js b/node_modules/@webassemblyjs/ast/lib/index.js deleted file mode 100644 index e5dda7e..0000000 --- a/node_modules/@webassemblyjs/ast/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -var _exportNames = { - numberLiteralFromRaw: true, - withLoc: true, - withRaw: true, - funcParam: true, - indexLiteral: true, - memIndexLiteral: true, - instruction: true, - objectInstruction: true, - traverse: true, - signatures: true, - cloneNode: true -}; -Object.defineProperty(exports, "numberLiteralFromRaw", { - enumerable: true, - get: function get() { - return _nodeHelpers.numberLiteralFromRaw; - } -}); -Object.defineProperty(exports, "withLoc", { - enumerable: true, - get: function get() { - return _nodeHelpers.withLoc; - } -}); -Object.defineProperty(exports, "withRaw", { - enumerable: true, - get: function get() { - return _nodeHelpers.withRaw; - } -}); -Object.defineProperty(exports, "funcParam", { - enumerable: true, - get: function get() { - return _nodeHelpers.funcParam; - } -}); -Object.defineProperty(exports, "indexLiteral", { - enumerable: true, - get: function get() { - return _nodeHelpers.indexLiteral; - } -}); -Object.defineProperty(exports, "memIndexLiteral", { - enumerable: true, - get: function get() { - return _nodeHelpers.memIndexLiteral; - } -}); -Object.defineProperty(exports, "instruction", { - enumerable: true, - get: function get() { - return _nodeHelpers.instruction; - } -}); -Object.defineProperty(exports, "objectInstruction", { - enumerable: true, - get: function get() { - return _nodeHelpers.objectInstruction; - } -}); -Object.defineProperty(exports, "traverse", { - enumerable: true, - get: function get() { - return _traverse.traverse; - } -}); -Object.defineProperty(exports, "signatures", { - enumerable: true, - get: function get() { - return _signatures.signatures; - } -}); -Object.defineProperty(exports, "cloneNode", { - enumerable: true, - get: function get() { - return _clone.cloneNode; - } -}); - -var _nodes = require("./nodes"); - -Object.keys(_nodes).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _nodes[key]; - } - }); -}); - -var _nodeHelpers = require("./node-helpers.js"); - -var _traverse = require("./traverse"); - -var _signatures = require("./signatures"); - -var _utils = require("./utils"); - -Object.keys(_utils).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _utils[key]; - } - }); -}); - -var _clone = require("./clone");
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/lib/node-helpers.js b/node_modules/@webassemblyjs/ast/lib/node-helpers.js deleted file mode 100644 index 50dab1f..0000000 --- a/node_modules/@webassemblyjs/ast/lib/node-helpers.js +++ /dev/null @@ -1,107 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.numberLiteralFromRaw = numberLiteralFromRaw; -exports.instruction = instruction; -exports.objectInstruction = objectInstruction; -exports.withLoc = withLoc; -exports.withRaw = withRaw; -exports.funcParam = funcParam; -exports.indexLiteral = indexLiteral; -exports.memIndexLiteral = memIndexLiteral; - -var _wastParser = require("@webassemblyjs/wast-parser"); - -var _nodes = require("./nodes"); - -function numberLiteralFromRaw(rawValue) { - var instructionType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "i32"; - var original = rawValue; // Remove numeric separators _ - - if (typeof rawValue === "string") { - rawValue = rawValue.replace(/_/g, ""); - } - - if (typeof rawValue === "number") { - return (0, _nodes.numberLiteral)(rawValue, String(original)); - } else { - switch (instructionType) { - case "i32": - { - return (0, _nodes.numberLiteral)((0, _wastParser.parse32I)(rawValue), String(original)); - } - - case "u32": - { - return (0, _nodes.numberLiteral)((0, _wastParser.parseU32)(rawValue), String(original)); - } - - case "i64": - { - return (0, _nodes.longNumberLiteral)((0, _wastParser.parse64I)(rawValue), String(original)); - } - - case "f32": - { - return (0, _nodes.floatLiteral)((0, _wastParser.parse32F)(rawValue), (0, _wastParser.isNanLiteral)(rawValue), (0, _wastParser.isInfLiteral)(rawValue), String(original)); - } - // f64 - - default: - { - return (0, _nodes.floatLiteral)((0, _wastParser.parse64F)(rawValue), (0, _wastParser.isNanLiteral)(rawValue), (0, _wastParser.isInfLiteral)(rawValue), String(original)); - } - } - } -} - -function instruction(id) { - var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; - var namedArgs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - return (0, _nodes.instr)(id, undefined, args, namedArgs); -} - -function objectInstruction(id, object) { - var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; - var namedArgs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; - return (0, _nodes.instr)(id, object, args, namedArgs); -} -/** - * Decorators - */ - - -function withLoc(n, end, start) { - var loc = { - start: start, - end: end - }; - n.loc = loc; - return n; -} - -function withRaw(n, raw) { - n.raw = raw; - return n; -} - -function funcParam(valtype, id) { - return { - id: id, - valtype: valtype - }; -} - -function indexLiteral(value) { - // $FlowIgnore - var x = numberLiteralFromRaw(value, "u32"); - return x; -} - -function memIndexLiteral(value) { - // $FlowIgnore - var x = numberLiteralFromRaw(value, "u32"); - return x; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/lib/node-path.js b/node_modules/@webassemblyjs/ast/lib/node-path.js deleted file mode 100644 index cf85534..0000000 --- a/node_modules/@webassemblyjs/ast/lib/node-path.js +++ /dev/null @@ -1,144 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.createPath = createPath; - -function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } - -function findParent(_ref, cb) { - var parentPath = _ref.parentPath; - - if (parentPath == null) { - throw new Error("node is root"); - } - - var currentPath = parentPath; - - while (cb(currentPath) !== false) { - // Hit the root node, stop - // $FlowIgnore - if (currentPath.parentPath == null) { - return null; - } // $FlowIgnore - - - currentPath = currentPath.parentPath; - } - - return currentPath.node; -} - -function insertBefore(context, newNode) { - return insert(context, newNode); -} - -function insertAfter(context, newNode) { - return insert(context, newNode, 1); -} - -function insert(_ref2, newNode) { - var node = _ref2.node, - inList = _ref2.inList, - parentPath = _ref2.parentPath, - parentKey = _ref2.parentKey; - var indexOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - - if (!inList) { - throw new Error('inList' + " error: " + ("insert can only be used for nodes that are within lists" || "unknown")); - } - - if (!(parentPath != null)) { - throw new Error('parentPath != null' + " error: " + ("Can not remove root node" || "unknown")); - } - - // $FlowIgnore - var parentList = parentPath.node[parentKey]; - var indexInList = parentList.findIndex(function (n) { - return n === node; - }); - parentList.splice(indexInList + indexOffset, 0, newNode); -} - -function remove(_ref3) { - var node = _ref3.node, - parentKey = _ref3.parentKey, - parentPath = _ref3.parentPath; - - if (!(parentPath != null)) { - throw new Error('parentPath != null' + " error: " + ("Can not remove root node" || "unknown")); - } - - // $FlowIgnore - var parentNode = parentPath.node; // $FlowIgnore - - var parentProperty = parentNode[parentKey]; - - if (Array.isArray(parentProperty)) { - // $FlowIgnore - parentNode[parentKey] = parentProperty.filter(function (n) { - return n !== node; - }); - } else { - // $FlowIgnore - delete parentNode[parentKey]; - } - - node._deleted = true; -} - -function stop(context) { - context.shouldStop = true; -} - -function replaceWith(context, newNode) { - // $FlowIgnore - var parentNode = context.parentPath.node; // $FlowIgnore - - var parentProperty = parentNode[context.parentKey]; - - if (Array.isArray(parentProperty)) { - var indexInList = parentProperty.findIndex(function (n) { - return n === context.node; - }); - parentProperty.splice(indexInList, 1, newNode); - } else { - // $FlowIgnore - parentNode[context.parentKey] = newNode; - } - - context.node._deleted = true; - context.node = newNode; -} // bind the context to the first argument of node operations - - -function bindNodeOperations(operations, context) { - var keys = Object.keys(operations); - var boundOperations = {}; - keys.forEach(function (key) { - boundOperations[key] = operations[key].bind(null, context); - }); - return boundOperations; -} - -function createPathOperations(context) { - // $FlowIgnore - return bindNodeOperations({ - findParent: findParent, - replaceWith: replaceWith, - remove: remove, - insertBefore: insertBefore, - insertAfter: insertAfter, - stop: stop - }, context); -} - -function createPath(context) { - var path = _extends({}, context); // $FlowIgnore - - - Object.assign(path, createPathOperations(path)); // $FlowIgnore - - return path; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/lib/nodes.js b/node_modules/@webassemblyjs/ast/lib/nodes.js deleted file mode 100644 index d99db0f..0000000 --- a/node_modules/@webassemblyjs/ast/lib/nodes.js +++ /dev/null @@ -1,1134 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.module = _module; -exports.moduleMetadata = moduleMetadata; -exports.moduleNameMetadata = moduleNameMetadata; -exports.functionNameMetadata = functionNameMetadata; -exports.localNameMetadata = localNameMetadata; -exports.binaryModule = binaryModule; -exports.quoteModule = quoteModule; -exports.sectionMetadata = sectionMetadata; -exports.producersSectionMetadata = producersSectionMetadata; -exports.producerMetadata = producerMetadata; -exports.producerMetadataVersionedName = producerMetadataVersionedName; -exports.loopInstruction = loopInstruction; -exports.instr = instr; -exports.ifInstruction = ifInstruction; -exports.stringLiteral = stringLiteral; -exports.numberLiteral = numberLiteral; -exports.longNumberLiteral = longNumberLiteral; -exports.floatLiteral = floatLiteral; -exports.elem = elem; -exports.indexInFuncSection = indexInFuncSection; -exports.valtypeLiteral = valtypeLiteral; -exports.typeInstruction = typeInstruction; -exports.start = start; -exports.globalType = globalType; -exports.leadingComment = leadingComment; -exports.blockComment = blockComment; -exports.data = data; -exports.global = global; -exports.table = table; -exports.memory = memory; -exports.funcImportDescr = funcImportDescr; -exports.moduleImport = moduleImport; -exports.moduleExportDescr = moduleExportDescr; -exports.moduleExport = moduleExport; -exports.limit = limit; -exports.signature = signature; -exports.program = program; -exports.identifier = identifier; -exports.blockInstruction = blockInstruction; -exports.callInstruction = callInstruction; -exports.callIndirectInstruction = callIndirectInstruction; -exports.byteArray = byteArray; -exports.func = func; -exports.internalBrUnless = internalBrUnless; -exports.internalGoto = internalGoto; -exports.internalCallExtern = internalCallExtern; -exports.internalEndAndReturn = internalEndAndReturn; -exports.assertInternalCallExtern = exports.assertInternalGoto = exports.assertInternalBrUnless = exports.assertFunc = exports.assertByteArray = exports.assertCallIndirectInstruction = exports.assertCallInstruction = exports.assertBlockInstruction = exports.assertIdentifier = exports.assertProgram = exports.assertSignature = exports.assertLimit = exports.assertModuleExport = exports.assertModuleExportDescr = exports.assertModuleImport = exports.assertFuncImportDescr = exports.assertMemory = exports.assertTable = exports.assertGlobal = exports.assertData = exports.assertBlockComment = exports.assertLeadingComment = exports.assertGlobalType = exports.assertStart = exports.assertTypeInstruction = exports.assertValtypeLiteral = exports.assertIndexInFuncSection = exports.assertElem = exports.assertFloatLiteral = exports.assertLongNumberLiteral = exports.assertNumberLiteral = exports.assertStringLiteral = exports.assertIfInstruction = exports.assertInstr = exports.assertLoopInstruction = exports.assertProducerMetadataVersionedName = exports.assertProducerMetadata = exports.assertProducersSectionMetadata = exports.assertSectionMetadata = exports.assertQuoteModule = exports.assertBinaryModule = exports.assertLocalNameMetadata = exports.assertFunctionNameMetadata = exports.assertModuleNameMetadata = exports.assertModuleMetadata = exports.assertModule = exports.isIntrinsic = exports.isImportDescr = exports.isNumericLiteral = exports.isExpression = exports.isInstruction = exports.isBlock = exports.isNode = exports.isInternalEndAndReturn = exports.isInternalCallExtern = exports.isInternalGoto = exports.isInternalBrUnless = exports.isFunc = exports.isByteArray = exports.isCallIndirectInstruction = exports.isCallInstruction = exports.isBlockInstruction = exports.isIdentifier = exports.isProgram = exports.isSignature = exports.isLimit = exports.isModuleExport = exports.isModuleExportDescr = exports.isModuleImport = exports.isFuncImportDescr = exports.isMemory = exports.isTable = exports.isGlobal = exports.isData = exports.isBlockComment = exports.isLeadingComment = exports.isGlobalType = exports.isStart = exports.isTypeInstruction = exports.isValtypeLiteral = exports.isIndexInFuncSection = exports.isElem = exports.isFloatLiteral = exports.isLongNumberLiteral = exports.isNumberLiteral = exports.isStringLiteral = exports.isIfInstruction = exports.isInstr = exports.isLoopInstruction = exports.isProducerMetadataVersionedName = exports.isProducerMetadata = exports.isProducersSectionMetadata = exports.isSectionMetadata = exports.isQuoteModule = exports.isBinaryModule = exports.isLocalNameMetadata = exports.isFunctionNameMetadata = exports.isModuleNameMetadata = exports.isModuleMetadata = exports.isModule = void 0; -exports.nodeAndUnionTypes = exports.unionTypesMap = exports.assertInternalEndAndReturn = void 0; - -function _typeof(obj) { 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); } - -// THIS FILE IS AUTOGENERATED -// see scripts/generateNodeUtils.js -function isTypeOf(t) { - return function (n) { - return n.type === t; - }; -} - -function assertTypeOf(t) { - return function (n) { - return function () { - if (!(n.type === t)) { - throw new Error('n.type === t' + " error: " + (undefined || "unknown")); - } - }(); - }; -} - -function _module(id, fields, metadata) { - if (id !== null && id !== undefined) { - if (!(typeof id === "string")) { - throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown")); - } - } - - if (!(_typeof(fields) === "object" && typeof fields.length !== "undefined")) { - throw new Error('typeof fields === "object" && typeof fields.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "Module", - id: id, - fields: fields - }; - - if (typeof metadata !== "undefined") { - node.metadata = metadata; - } - - return node; -} - -function moduleMetadata(sections, functionNames, localNames, producers) { - if (!(_typeof(sections) === "object" && typeof sections.length !== "undefined")) { - throw new Error('typeof sections === "object" && typeof sections.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (functionNames !== null && functionNames !== undefined) { - if (!(_typeof(functionNames) === "object" && typeof functionNames.length !== "undefined")) { - throw new Error('typeof functionNames === "object" && typeof functionNames.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - } - - if (localNames !== null && localNames !== undefined) { - if (!(_typeof(localNames) === "object" && typeof localNames.length !== "undefined")) { - throw new Error('typeof localNames === "object" && typeof localNames.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - } - - if (producers !== null && producers !== undefined) { - if (!(_typeof(producers) === "object" && typeof producers.length !== "undefined")) { - throw new Error('typeof producers === "object" && typeof producers.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - } - - var node = { - type: "ModuleMetadata", - sections: sections - }; - - if (typeof functionNames !== "undefined" && functionNames.length > 0) { - node.functionNames = functionNames; - } - - if (typeof localNames !== "undefined" && localNames.length > 0) { - node.localNames = localNames; - } - - if (typeof producers !== "undefined" && producers.length > 0) { - node.producers = producers; - } - - return node; -} - -function moduleNameMetadata(value) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - var node = { - type: "ModuleNameMetadata", - value: value - }; - return node; -} - -function functionNameMetadata(value, index) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - if (!(typeof index === "number")) { - throw new Error('typeof index === "number"' + " error: " + ("Argument index must be of type number, given: " + _typeof(index) || "unknown")); - } - - var node = { - type: "FunctionNameMetadata", - value: value, - index: index - }; - return node; -} - -function localNameMetadata(value, localIndex, functionIndex) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - if (!(typeof localIndex === "number")) { - throw new Error('typeof localIndex === "number"' + " error: " + ("Argument localIndex must be of type number, given: " + _typeof(localIndex) || "unknown")); - } - - if (!(typeof functionIndex === "number")) { - throw new Error('typeof functionIndex === "number"' + " error: " + ("Argument functionIndex must be of type number, given: " + _typeof(functionIndex) || "unknown")); - } - - var node = { - type: "LocalNameMetadata", - value: value, - localIndex: localIndex, - functionIndex: functionIndex - }; - return node; -} - -function binaryModule(id, blob) { - if (id !== null && id !== undefined) { - if (!(typeof id === "string")) { - throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown")); - } - } - - if (!(_typeof(blob) === "object" && typeof blob.length !== "undefined")) { - throw new Error('typeof blob === "object" && typeof blob.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "BinaryModule", - id: id, - blob: blob - }; - return node; -} - -function quoteModule(id, string) { - if (id !== null && id !== undefined) { - if (!(typeof id === "string")) { - throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown")); - } - } - - if (!(_typeof(string) === "object" && typeof string.length !== "undefined")) { - throw new Error('typeof string === "object" && typeof string.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "QuoteModule", - id: id, - string: string - }; - return node; -} - -function sectionMetadata(section, startOffset, size, vectorOfSize) { - if (!(typeof startOffset === "number")) { - throw new Error('typeof startOffset === "number"' + " error: " + ("Argument startOffset must be of type number, given: " + _typeof(startOffset) || "unknown")); - } - - var node = { - type: "SectionMetadata", - section: section, - startOffset: startOffset, - size: size, - vectorOfSize: vectorOfSize - }; - return node; -} - -function producersSectionMetadata(producers) { - if (!(_typeof(producers) === "object" && typeof producers.length !== "undefined")) { - throw new Error('typeof producers === "object" && typeof producers.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "ProducersSectionMetadata", - producers: producers - }; - return node; -} - -function producerMetadata(language, processedBy, sdk) { - if (!(_typeof(language) === "object" && typeof language.length !== "undefined")) { - throw new Error('typeof language === "object" && typeof language.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (!(_typeof(processedBy) === "object" && typeof processedBy.length !== "undefined")) { - throw new Error('typeof processedBy === "object" && typeof processedBy.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (!(_typeof(sdk) === "object" && typeof sdk.length !== "undefined")) { - throw new Error('typeof sdk === "object" && typeof sdk.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "ProducerMetadata", - language: language, - processedBy: processedBy, - sdk: sdk - }; - return node; -} - -function producerMetadataVersionedName(name, version) { - if (!(typeof name === "string")) { - throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown")); - } - - if (!(typeof version === "string")) { - throw new Error('typeof version === "string"' + " error: " + ("Argument version must be of type string, given: " + _typeof(version) || "unknown")); - } - - var node = { - type: "ProducerMetadataVersionedName", - name: name, - version: version - }; - return node; -} - -function loopInstruction(label, resulttype, instr) { - if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) { - throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "LoopInstruction", - id: "loop", - label: label, - resulttype: resulttype, - instr: instr - }; - return node; -} - -function instr(id, object, args, namedArgs) { - if (!(typeof id === "string")) { - throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown")); - } - - if (!(_typeof(args) === "object" && typeof args.length !== "undefined")) { - throw new Error('typeof args === "object" && typeof args.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "Instr", - id: id, - args: args - }; - - if (typeof object !== "undefined") { - node.object = object; - } - - if (typeof namedArgs !== "undefined" && Object.keys(namedArgs).length !== 0) { - node.namedArgs = namedArgs; - } - - return node; -} - -function ifInstruction(testLabel, test, result, consequent, alternate) { - if (!(_typeof(test) === "object" && typeof test.length !== "undefined")) { - throw new Error('typeof test === "object" && typeof test.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (!(_typeof(consequent) === "object" && typeof consequent.length !== "undefined")) { - throw new Error('typeof consequent === "object" && typeof consequent.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (!(_typeof(alternate) === "object" && typeof alternate.length !== "undefined")) { - throw new Error('typeof alternate === "object" && typeof alternate.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "IfInstruction", - id: "if", - testLabel: testLabel, - test: test, - result: result, - consequent: consequent, - alternate: alternate - }; - return node; -} - -function stringLiteral(value) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - var node = { - type: "StringLiteral", - value: value - }; - return node; -} - -function numberLiteral(value, raw) { - if (!(typeof value === "number")) { - throw new Error('typeof value === "number"' + " error: " + ("Argument value must be of type number, given: " + _typeof(value) || "unknown")); - } - - if (!(typeof raw === "string")) { - throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown")); - } - - var node = { - type: "NumberLiteral", - value: value, - raw: raw - }; - return node; -} - -function longNumberLiteral(value, raw) { - if (!(typeof raw === "string")) { - throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown")); - } - - var node = { - type: "LongNumberLiteral", - value: value, - raw: raw - }; - return node; -} - -function floatLiteral(value, nan, inf, raw) { - if (!(typeof value === "number")) { - throw new Error('typeof value === "number"' + " error: " + ("Argument value must be of type number, given: " + _typeof(value) || "unknown")); - } - - if (nan !== null && nan !== undefined) { - if (!(typeof nan === "boolean")) { - throw new Error('typeof nan === "boolean"' + " error: " + ("Argument nan must be of type boolean, given: " + _typeof(nan) || "unknown")); - } - } - - if (inf !== null && inf !== undefined) { - if (!(typeof inf === "boolean")) { - throw new Error('typeof inf === "boolean"' + " error: " + ("Argument inf must be of type boolean, given: " + _typeof(inf) || "unknown")); - } - } - - if (!(typeof raw === "string")) { - throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown")); - } - - var node = { - type: "FloatLiteral", - value: value, - raw: raw - }; - - if (nan === true) { - node.nan = true; - } - - if (inf === true) { - node.inf = true; - } - - return node; -} - -function elem(table, offset, funcs) { - if (!(_typeof(offset) === "object" && typeof offset.length !== "undefined")) { - throw new Error('typeof offset === "object" && typeof offset.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (!(_typeof(funcs) === "object" && typeof funcs.length !== "undefined")) { - throw new Error('typeof funcs === "object" && typeof funcs.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "Elem", - table: table, - offset: offset, - funcs: funcs - }; - return node; -} - -function indexInFuncSection(index) { - var node = { - type: "IndexInFuncSection", - index: index - }; - return node; -} - -function valtypeLiteral(name) { - var node = { - type: "ValtypeLiteral", - name: name - }; - return node; -} - -function typeInstruction(id, functype) { - var node = { - type: "TypeInstruction", - id: id, - functype: functype - }; - return node; -} - -function start(index) { - var node = { - type: "Start", - index: index - }; - return node; -} - -function globalType(valtype, mutability) { - var node = { - type: "GlobalType", - valtype: valtype, - mutability: mutability - }; - return node; -} - -function leadingComment(value) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - var node = { - type: "LeadingComment", - value: value - }; - return node; -} - -function blockComment(value) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - var node = { - type: "BlockComment", - value: value - }; - return node; -} - -function data(memoryIndex, offset, init) { - var node = { - type: "Data", - memoryIndex: memoryIndex, - offset: offset, - init: init - }; - return node; -} - -function global(globalType, init, name) { - if (!(_typeof(init) === "object" && typeof init.length !== "undefined")) { - throw new Error('typeof init === "object" && typeof init.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "Global", - globalType: globalType, - init: init, - name: name - }; - return node; -} - -function table(elementType, limits, name, elements) { - if (!(limits.type === "Limit")) { - throw new Error('limits.type === "Limit"' + " error: " + ("Argument limits must be of type Limit, given: " + limits.type || "unknown")); - } - - if (elements !== null && elements !== undefined) { - if (!(_typeof(elements) === "object" && typeof elements.length !== "undefined")) { - throw new Error('typeof elements === "object" && typeof elements.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - } - - var node = { - type: "Table", - elementType: elementType, - limits: limits, - name: name - }; - - if (typeof elements !== "undefined" && elements.length > 0) { - node.elements = elements; - } - - return node; -} - -function memory(limits, id) { - var node = { - type: "Memory", - limits: limits, - id: id - }; - return node; -} - -function funcImportDescr(id, signature) { - var node = { - type: "FuncImportDescr", - id: id, - signature: signature - }; - return node; -} - -function moduleImport(module, name, descr) { - if (!(typeof module === "string")) { - throw new Error('typeof module === "string"' + " error: " + ("Argument module must be of type string, given: " + _typeof(module) || "unknown")); - } - - if (!(typeof name === "string")) { - throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown")); - } - - var node = { - type: "ModuleImport", - module: module, - name: name, - descr: descr - }; - return node; -} - -function moduleExportDescr(exportType, id) { - var node = { - type: "ModuleExportDescr", - exportType: exportType, - id: id - }; - return node; -} - -function moduleExport(name, descr) { - if (!(typeof name === "string")) { - throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown")); - } - - var node = { - type: "ModuleExport", - name: name, - descr: descr - }; - return node; -} - -function limit(min, max) { - if (!(typeof min === "number")) { - throw new Error('typeof min === "number"' + " error: " + ("Argument min must be of type number, given: " + _typeof(min) || "unknown")); - } - - if (max !== null && max !== undefined) { - if (!(typeof max === "number")) { - throw new Error('typeof max === "number"' + " error: " + ("Argument max must be of type number, given: " + _typeof(max) || "unknown")); - } - } - - var node = { - type: "Limit", - min: min - }; - - if (typeof max !== "undefined") { - node.max = max; - } - - return node; -} - -function signature(params, results) { - if (!(_typeof(params) === "object" && typeof params.length !== "undefined")) { - throw new Error('typeof params === "object" && typeof params.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (!(_typeof(results) === "object" && typeof results.length !== "undefined")) { - throw new Error('typeof results === "object" && typeof results.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "Signature", - params: params, - results: results - }; - return node; -} - -function program(body) { - if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) { - throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "Program", - body: body - }; - return node; -} - -function identifier(value, raw) { - if (!(typeof value === "string")) { - throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown")); - } - - if (raw !== null && raw !== undefined) { - if (!(typeof raw === "string")) { - throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown")); - } - } - - var node = { - type: "Identifier", - value: value - }; - - if (typeof raw !== "undefined") { - node.raw = raw; - } - - return node; -} - -function blockInstruction(label, instr, result) { - if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) { - throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "BlockInstruction", - id: "block", - label: label, - instr: instr, - result: result - }; - return node; -} - -function callInstruction(index, instrArgs, numeric) { - if (instrArgs !== null && instrArgs !== undefined) { - if (!(_typeof(instrArgs) === "object" && typeof instrArgs.length !== "undefined")) { - throw new Error('typeof instrArgs === "object" && typeof instrArgs.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - } - - var node = { - type: "CallInstruction", - id: "call", - index: index - }; - - if (typeof instrArgs !== "undefined" && instrArgs.length > 0) { - node.instrArgs = instrArgs; - } - - if (typeof numeric !== "undefined") { - node.numeric = numeric; - } - - return node; -} - -function callIndirectInstruction(signature, intrs) { - if (intrs !== null && intrs !== undefined) { - if (!(_typeof(intrs) === "object" && typeof intrs.length !== "undefined")) { - throw new Error('typeof intrs === "object" && typeof intrs.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - } - - var node = { - type: "CallIndirectInstruction", - id: "call_indirect", - signature: signature - }; - - if (typeof intrs !== "undefined" && intrs.length > 0) { - node.intrs = intrs; - } - - return node; -} - -function byteArray(values) { - if (!(_typeof(values) === "object" && typeof values.length !== "undefined")) { - throw new Error('typeof values === "object" && typeof values.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - var node = { - type: "ByteArray", - values: values - }; - return node; -} - -function func(name, signature, body, isExternal, metadata) { - if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) { - throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown")); - } - - if (isExternal !== null && isExternal !== undefined) { - if (!(typeof isExternal === "boolean")) { - throw new Error('typeof isExternal === "boolean"' + " error: " + ("Argument isExternal must be of type boolean, given: " + _typeof(isExternal) || "unknown")); - } - } - - var node = { - type: "Func", - name: name, - signature: signature, - body: body - }; - - if (isExternal === true) { - node.isExternal = true; - } - - if (typeof metadata !== "undefined") { - node.metadata = metadata; - } - - return node; -} - -function internalBrUnless(target) { - if (!(typeof target === "number")) { - throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown")); - } - - var node = { - type: "InternalBrUnless", - target: target - }; - return node; -} - -function internalGoto(target) { - if (!(typeof target === "number")) { - throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown")); - } - - var node = { - type: "InternalGoto", - target: target - }; - return node; -} - -function internalCallExtern(target) { - if (!(typeof target === "number")) { - throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown")); - } - - var node = { - type: "InternalCallExtern", - target: target - }; - return node; -} - -function internalEndAndReturn() { - var node = { - type: "InternalEndAndReturn" - }; - return node; -} - -var isModule = isTypeOf("Module"); -exports.isModule = isModule; -var isModuleMetadata = isTypeOf("ModuleMetadata"); -exports.isModuleMetadata = isModuleMetadata; -var isModuleNameMetadata = isTypeOf("ModuleNameMetadata"); -exports.isModuleNameMetadata = isModuleNameMetadata; -var isFunctionNameMetadata = isTypeOf("FunctionNameMetadata"); -exports.isFunctionNameMetadata = isFunctionNameMetadata; -var isLocalNameMetadata = isTypeOf("LocalNameMetadata"); -exports.isLocalNameMetadata = isLocalNameMetadata; -var isBinaryModule = isTypeOf("BinaryModule"); -exports.isBinaryModule = isBinaryModule; -var isQuoteModule = isTypeOf("QuoteModule"); -exports.isQuoteModule = isQuoteModule; -var isSectionMetadata = isTypeOf("SectionMetadata"); -exports.isSectionMetadata = isSectionMetadata; -var isProducersSectionMetadata = isTypeOf("ProducersSectionMetadata"); -exports.isProducersSectionMetadata = isProducersSectionMetadata; -var isProducerMetadata = isTypeOf("ProducerMetadata"); -exports.isProducerMetadata = isProducerMetadata; -var isProducerMetadataVersionedName = isTypeOf("ProducerMetadataVersionedName"); -exports.isProducerMetadataVersionedName = isProducerMetadataVersionedName; -var isLoopInstruction = isTypeOf("LoopInstruction"); -exports.isLoopInstruction = isLoopInstruction; -var isInstr = isTypeOf("Instr"); -exports.isInstr = isInstr; -var isIfInstruction = isTypeOf("IfInstruction"); -exports.isIfInstruction = isIfInstruction; -var isStringLiteral = isTypeOf("StringLiteral"); -exports.isStringLiteral = isStringLiteral; -var isNumberLiteral = isTypeOf("NumberLiteral"); -exports.isNumberLiteral = isNumberLiteral; -var isLongNumberLiteral = isTypeOf("LongNumberLiteral"); -exports.isLongNumberLiteral = isLongNumberLiteral; -var isFloatLiteral = isTypeOf("FloatLiteral"); -exports.isFloatLiteral = isFloatLiteral; -var isElem = isTypeOf("Elem"); -exports.isElem = isElem; -var isIndexInFuncSection = isTypeOf("IndexInFuncSection"); -exports.isIndexInFuncSection = isIndexInFuncSection; -var isValtypeLiteral = isTypeOf("ValtypeLiteral"); -exports.isValtypeLiteral = isValtypeLiteral; -var isTypeInstruction = isTypeOf("TypeInstruction"); -exports.isTypeInstruction = isTypeInstruction; -var isStart = isTypeOf("Start"); -exports.isStart = isStart; -var isGlobalType = isTypeOf("GlobalType"); -exports.isGlobalType = isGlobalType; -var isLeadingComment = isTypeOf("LeadingComment"); -exports.isLeadingComment = isLeadingComment; -var isBlockComment = isTypeOf("BlockComment"); -exports.isBlockComment = isBlockComment; -var isData = isTypeOf("Data"); -exports.isData = isData; -var isGlobal = isTypeOf("Global"); -exports.isGlobal = isGlobal; -var isTable = isTypeOf("Table"); -exports.isTable = isTable; -var isMemory = isTypeOf("Memory"); -exports.isMemory = isMemory; -var isFuncImportDescr = isTypeOf("FuncImportDescr"); -exports.isFuncImportDescr = isFuncImportDescr; -var isModuleImport = isTypeOf("ModuleImport"); -exports.isModuleImport = isModuleImport; -var isModuleExportDescr = isTypeOf("ModuleExportDescr"); -exports.isModuleExportDescr = isModuleExportDescr; -var isModuleExport = isTypeOf("ModuleExport"); -exports.isModuleExport = isModuleExport; -var isLimit = isTypeOf("Limit"); -exports.isLimit = isLimit; -var isSignature = isTypeOf("Signature"); -exports.isSignature = isSignature; -var isProgram = isTypeOf("Program"); -exports.isProgram = isProgram; -var isIdentifier = isTypeOf("Identifier"); -exports.isIdentifier = isIdentifier; -var isBlockInstruction = isTypeOf("BlockInstruction"); -exports.isBlockInstruction = isBlockInstruction; -var isCallInstruction = isTypeOf("CallInstruction"); -exports.isCallInstruction = isCallInstruction; -var isCallIndirectInstruction = isTypeOf("CallIndirectInstruction"); -exports.isCallIndirectInstruction = isCallIndirectInstruction; -var isByteArray = isTypeOf("ByteArray"); -exports.isByteArray = isByteArray; -var isFunc = isTypeOf("Func"); -exports.isFunc = isFunc; -var isInternalBrUnless = isTypeOf("InternalBrUnless"); -exports.isInternalBrUnless = isInternalBrUnless; -var isInternalGoto = isTypeOf("InternalGoto"); -exports.isInternalGoto = isInternalGoto; -var isInternalCallExtern = isTypeOf("InternalCallExtern"); -exports.isInternalCallExtern = isInternalCallExtern; -var isInternalEndAndReturn = isTypeOf("InternalEndAndReturn"); -exports.isInternalEndAndReturn = isInternalEndAndReturn; - -var isNode = function isNode(node) { - return isModule(node) || isModuleMetadata(node) || isModuleNameMetadata(node) || isFunctionNameMetadata(node) || isLocalNameMetadata(node) || isBinaryModule(node) || isQuoteModule(node) || isSectionMetadata(node) || isProducersSectionMetadata(node) || isProducerMetadata(node) || isProducerMetadataVersionedName(node) || isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isElem(node) || isIndexInFuncSection(node) || isValtypeLiteral(node) || isTypeInstruction(node) || isStart(node) || isGlobalType(node) || isLeadingComment(node) || isBlockComment(node) || isData(node) || isGlobal(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node) || isModuleImport(node) || isModuleExportDescr(node) || isModuleExport(node) || isLimit(node) || isSignature(node) || isProgram(node) || isIdentifier(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node) || isByteArray(node) || isFunc(node) || isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node); -}; - -exports.isNode = isNode; - -var isBlock = function isBlock(node) { - return isLoopInstruction(node) || isBlockInstruction(node) || isFunc(node); -}; - -exports.isBlock = isBlock; - -var isInstruction = function isInstruction(node) { - return isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isTypeInstruction(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node); -}; - -exports.isInstruction = isInstruction; - -var isExpression = function isExpression(node) { - return isInstr(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isValtypeLiteral(node) || isIdentifier(node); -}; - -exports.isExpression = isExpression; - -var isNumericLiteral = function isNumericLiteral(node) { - return isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node); -}; - -exports.isNumericLiteral = isNumericLiteral; - -var isImportDescr = function isImportDescr(node) { - return isGlobalType(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node); -}; - -exports.isImportDescr = isImportDescr; - -var isIntrinsic = function isIntrinsic(node) { - return isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node); -}; - -exports.isIntrinsic = isIntrinsic; -var assertModule = assertTypeOf("Module"); -exports.assertModule = assertModule; -var assertModuleMetadata = assertTypeOf("ModuleMetadata"); -exports.assertModuleMetadata = assertModuleMetadata; -var assertModuleNameMetadata = assertTypeOf("ModuleNameMetadata"); -exports.assertModuleNameMetadata = assertModuleNameMetadata; -var assertFunctionNameMetadata = assertTypeOf("FunctionNameMetadata"); -exports.assertFunctionNameMetadata = assertFunctionNameMetadata; -var assertLocalNameMetadata = assertTypeOf("LocalNameMetadata"); -exports.assertLocalNameMetadata = assertLocalNameMetadata; -var assertBinaryModule = assertTypeOf("BinaryModule"); -exports.assertBinaryModule = assertBinaryModule; -var assertQuoteModule = assertTypeOf("QuoteModule"); -exports.assertQuoteModule = assertQuoteModule; -var assertSectionMetadata = assertTypeOf("SectionMetadata"); -exports.assertSectionMetadata = assertSectionMetadata; -var assertProducersSectionMetadata = assertTypeOf("ProducersSectionMetadata"); -exports.assertProducersSectionMetadata = assertProducersSectionMetadata; -var assertProducerMetadata = assertTypeOf("ProducerMetadata"); -exports.assertProducerMetadata = assertProducerMetadata; -var assertProducerMetadataVersionedName = assertTypeOf("ProducerMetadataVersionedName"); -exports.assertProducerMetadataVersionedName = assertProducerMetadataVersionedName; -var assertLoopInstruction = assertTypeOf("LoopInstruction"); -exports.assertLoopInstruction = assertLoopInstruction; -var assertInstr = assertTypeOf("Instr"); -exports.assertInstr = assertInstr; -var assertIfInstruction = assertTypeOf("IfInstruction"); -exports.assertIfInstruction = assertIfInstruction; -var assertStringLiteral = assertTypeOf("StringLiteral"); -exports.assertStringLiteral = assertStringLiteral; -var assertNumberLiteral = assertTypeOf("NumberLiteral"); -exports.assertNumberLiteral = assertNumberLiteral; -var assertLongNumberLiteral = assertTypeOf("LongNumberLiteral"); -exports.assertLongNumberLiteral = assertLongNumberLiteral; -var assertFloatLiteral = assertTypeOf("FloatLiteral"); -exports.assertFloatLiteral = assertFloatLiteral; -var assertElem = assertTypeOf("Elem"); -exports.assertElem = assertElem; -var assertIndexInFuncSection = assertTypeOf("IndexInFuncSection"); -exports.assertIndexInFuncSection = assertIndexInFuncSection; -var assertValtypeLiteral = assertTypeOf("ValtypeLiteral"); -exports.assertValtypeLiteral = assertValtypeLiteral; -var assertTypeInstruction = assertTypeOf("TypeInstruction"); -exports.assertTypeInstruction = assertTypeInstruction; -var assertStart = assertTypeOf("Start"); -exports.assertStart = assertStart; -var assertGlobalType = assertTypeOf("GlobalType"); -exports.assertGlobalType = assertGlobalType; -var assertLeadingComment = assertTypeOf("LeadingComment"); -exports.assertLeadingComment = assertLeadingComment; -var assertBlockComment = assertTypeOf("BlockComment"); -exports.assertBlockComment = assertBlockComment; -var assertData = assertTypeOf("Data"); -exports.assertData = assertData; -var assertGlobal = assertTypeOf("Global"); -exports.assertGlobal = assertGlobal; -var assertTable = assertTypeOf("Table"); -exports.assertTable = assertTable; -var assertMemory = assertTypeOf("Memory"); -exports.assertMemory = assertMemory; -var assertFuncImportDescr = assertTypeOf("FuncImportDescr"); -exports.assertFuncImportDescr = assertFuncImportDescr; -var assertModuleImport = assertTypeOf("ModuleImport"); -exports.assertModuleImport = assertModuleImport; -var assertModuleExportDescr = assertTypeOf("ModuleExportDescr"); -exports.assertModuleExportDescr = assertModuleExportDescr; -var assertModuleExport = assertTypeOf("ModuleExport"); -exports.assertModuleExport = assertModuleExport; -var assertLimit = assertTypeOf("Limit"); -exports.assertLimit = assertLimit; -var assertSignature = assertTypeOf("Signature"); -exports.assertSignature = assertSignature; -var assertProgram = assertTypeOf("Program"); -exports.assertProgram = assertProgram; -var assertIdentifier = assertTypeOf("Identifier"); -exports.assertIdentifier = assertIdentifier; -var assertBlockInstruction = assertTypeOf("BlockInstruction"); -exports.assertBlockInstruction = assertBlockInstruction; -var assertCallInstruction = assertTypeOf("CallInstruction"); -exports.assertCallInstruction = assertCallInstruction; -var assertCallIndirectInstruction = assertTypeOf("CallIndirectInstruction"); -exports.assertCallIndirectInstruction = assertCallIndirectInstruction; -var assertByteArray = assertTypeOf("ByteArray"); -exports.assertByteArray = assertByteArray; -var assertFunc = assertTypeOf("Func"); -exports.assertFunc = assertFunc; -var assertInternalBrUnless = assertTypeOf("InternalBrUnless"); -exports.assertInternalBrUnless = assertInternalBrUnless; -var assertInternalGoto = assertTypeOf("InternalGoto"); -exports.assertInternalGoto = assertInternalGoto; -var assertInternalCallExtern = assertTypeOf("InternalCallExtern"); -exports.assertInternalCallExtern = assertInternalCallExtern; -var assertInternalEndAndReturn = assertTypeOf("InternalEndAndReturn"); -exports.assertInternalEndAndReturn = assertInternalEndAndReturn; -var unionTypesMap = { - Module: ["Node"], - ModuleMetadata: ["Node"], - ModuleNameMetadata: ["Node"], - FunctionNameMetadata: ["Node"], - LocalNameMetadata: ["Node"], - BinaryModule: ["Node"], - QuoteModule: ["Node"], - SectionMetadata: ["Node"], - ProducersSectionMetadata: ["Node"], - ProducerMetadata: ["Node"], - ProducerMetadataVersionedName: ["Node"], - LoopInstruction: ["Node", "Block", "Instruction"], - Instr: ["Node", "Expression", "Instruction"], - IfInstruction: ["Node", "Instruction"], - StringLiteral: ["Node", "Expression"], - NumberLiteral: ["Node", "NumericLiteral", "Expression"], - LongNumberLiteral: ["Node", "NumericLiteral", "Expression"], - FloatLiteral: ["Node", "NumericLiteral", "Expression"], - Elem: ["Node"], - IndexInFuncSection: ["Node"], - ValtypeLiteral: ["Node", "Expression"], - TypeInstruction: ["Node", "Instruction"], - Start: ["Node"], - GlobalType: ["Node", "ImportDescr"], - LeadingComment: ["Node"], - BlockComment: ["Node"], - Data: ["Node"], - Global: ["Node"], - Table: ["Node", "ImportDescr"], - Memory: ["Node", "ImportDescr"], - FuncImportDescr: ["Node", "ImportDescr"], - ModuleImport: ["Node"], - ModuleExportDescr: ["Node"], - ModuleExport: ["Node"], - Limit: ["Node"], - Signature: ["Node"], - Program: ["Node"], - Identifier: ["Node", "Expression"], - BlockInstruction: ["Node", "Block", "Instruction"], - CallInstruction: ["Node", "Instruction"], - CallIndirectInstruction: ["Node", "Instruction"], - ByteArray: ["Node"], - Func: ["Node", "Block"], - InternalBrUnless: ["Node", "Intrinsic"], - InternalGoto: ["Node", "Intrinsic"], - InternalCallExtern: ["Node", "Intrinsic"], - InternalEndAndReturn: ["Node", "Intrinsic"] -}; -exports.unionTypesMap = unionTypesMap; -var nodeAndUnionTypes = ["Module", "ModuleMetadata", "ModuleNameMetadata", "FunctionNameMetadata", "LocalNameMetadata", "BinaryModule", "QuoteModule", "SectionMetadata", "ProducersSectionMetadata", "ProducerMetadata", "ProducerMetadataVersionedName", "LoopInstruction", "Instr", "IfInstruction", "StringLiteral", "NumberLiteral", "LongNumberLiteral", "FloatLiteral", "Elem", "IndexInFuncSection", "ValtypeLiteral", "TypeInstruction", "Start", "GlobalType", "LeadingComment", "BlockComment", "Data", "Global", "Table", "Memory", "FuncImportDescr", "ModuleImport", "ModuleExportDescr", "ModuleExport", "Limit", "Signature", "Program", "Identifier", "BlockInstruction", "CallInstruction", "CallIndirectInstruction", "ByteArray", "Func", "InternalBrUnless", "InternalGoto", "InternalCallExtern", "InternalEndAndReturn", "Node", "Block", "Instruction", "Expression", "NumericLiteral", "ImportDescr", "Intrinsic"]; -exports.nodeAndUnionTypes = nodeAndUnionTypes;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/lib/signatures.js b/node_modules/@webassemblyjs/ast/lib/signatures.js deleted file mode 100644 index 0efc766..0000000 --- a/node_modules/@webassemblyjs/ast/lib/signatures.js +++ /dev/null @@ -1,207 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.signatures = void 0; - -function sign(input, output) { - return [input, output]; -} - -var u32 = "u32"; -var i32 = "i32"; -var i64 = "i64"; -var f32 = "f32"; -var f64 = "f64"; - -var vector = function vector(t) { - var vecType = [t]; // $FlowIgnore - - vecType.vector = true; - return vecType; -}; - -var controlInstructions = { - unreachable: sign([], []), - nop: sign([], []), - // block ? - // loop ? - // if ? - // if else ? - br: sign([u32], []), - br_if: sign([u32], []), - br_table: sign(vector(u32), []), - return: sign([], []), - call: sign([u32], []), - call_indirect: sign([u32], []) -}; -var parametricInstructions = { - drop: sign([], []), - select: sign([], []) -}; -var variableInstructions = { - get_local: sign([u32], []), - set_local: sign([u32], []), - tee_local: sign([u32], []), - get_global: sign([u32], []), - set_global: sign([u32], []) -}; -var memoryInstructions = { - "i32.load": sign([u32, u32], [i32]), - "i64.load": sign([u32, u32], []), - "f32.load": sign([u32, u32], []), - "f64.load": sign([u32, u32], []), - "i32.load8_s": sign([u32, u32], [i32]), - "i32.load8_u": sign([u32, u32], [i32]), - "i32.load16_s": sign([u32, u32], [i32]), - "i32.load16_u": sign([u32, u32], [i32]), - "i64.load8_s": sign([u32, u32], [i64]), - "i64.load8_u": sign([u32, u32], [i64]), - "i64.load16_s": sign([u32, u32], [i64]), - "i64.load16_u": sign([u32, u32], [i64]), - "i64.load32_s": sign([u32, u32], [i64]), - "i64.load32_u": sign([u32, u32], [i64]), - "i32.store": sign([u32, u32], []), - "i64.store": sign([u32, u32], []), - "f32.store": sign([u32, u32], []), - "f64.store": sign([u32, u32], []), - "i32.store8": sign([u32, u32], []), - "i32.store16": sign([u32, u32], []), - "i64.store8": sign([u32, u32], []), - "i64.store16": sign([u32, u32], []), - "i64.store32": sign([u32, u32], []), - current_memory: sign([], []), - grow_memory: sign([], []) -}; -var numericInstructions = { - "i32.const": sign([i32], [i32]), - "i64.const": sign([i64], [i64]), - "f32.const": sign([f32], [f32]), - "f64.const": sign([f64], [f64]), - "i32.eqz": sign([i32], [i32]), - "i32.eq": sign([i32, i32], [i32]), - "i32.ne": sign([i32, i32], [i32]), - "i32.lt_s": sign([i32, i32], [i32]), - "i32.lt_u": sign([i32, i32], [i32]), - "i32.gt_s": sign([i32, i32], [i32]), - "i32.gt_u": sign([i32, i32], [i32]), - "i32.le_s": sign([i32, i32], [i32]), - "i32.le_u": sign([i32, i32], [i32]), - "i32.ge_s": sign([i32, i32], [i32]), - "i32.ge_u": sign([i32, i32], [i32]), - "i64.eqz": sign([i64], [i64]), - "i64.eq": sign([i64, i64], [i32]), - "i64.ne": sign([i64, i64], [i32]), - "i64.lt_s": sign([i64, i64], [i32]), - "i64.lt_u": sign([i64, i64], [i32]), - "i64.gt_s": sign([i64, i64], [i32]), - "i64.gt_u": sign([i64, i64], [i32]), - "i64.le_s": sign([i64, i64], [i32]), - "i64.le_u": sign([i64, i64], [i32]), - "i64.ge_s": sign([i64, i64], [i32]), - "i64.ge_u": sign([i64, i64], [i32]), - "f32.eq": sign([f32, f32], [i32]), - "f32.ne": sign([f32, f32], [i32]), - "f32.lt": sign([f32, f32], [i32]), - "f32.gt": sign([f32, f32], [i32]), - "f32.le": sign([f32, f32], [i32]), - "f32.ge": sign([f32, f32], [i32]), - "f64.eq": sign([f64, f64], [i32]), - "f64.ne": sign([f64, f64], [i32]), - "f64.lt": sign([f64, f64], [i32]), - "f64.gt": sign([f64, f64], [i32]), - "f64.le": sign([f64, f64], [i32]), - "f64.ge": sign([f64, f64], [i32]), - "i32.clz": sign([i32], [i32]), - "i32.ctz": sign([i32], [i32]), - "i32.popcnt": sign([i32], [i32]), - "i32.add": sign([i32, i32], [i32]), - "i32.sub": sign([i32, i32], [i32]), - "i32.mul": sign([i32, i32], [i32]), - "i32.div_s": sign([i32, i32], [i32]), - "i32.div_u": sign([i32, i32], [i32]), - "i32.rem_s": sign([i32, i32], [i32]), - "i32.rem_u": sign([i32, i32], [i32]), - "i32.and": sign([i32, i32], [i32]), - "i32.or": sign([i32, i32], [i32]), - "i32.xor": sign([i32, i32], [i32]), - "i32.shl": sign([i32, i32], [i32]), - "i32.shr_s": sign([i32, i32], [i32]), - "i32.shr_u": sign([i32, i32], [i32]), - "i32.rotl": sign([i32, i32], [i32]), - "i32.rotr": sign([i32, i32], [i32]), - "i64.clz": sign([i64], [i64]), - "i64.ctz": sign([i64], [i64]), - "i64.popcnt": sign([i64], [i64]), - "i64.add": sign([i64, i64], [i64]), - "i64.sub": sign([i64, i64], [i64]), - "i64.mul": sign([i64, i64], [i64]), - "i64.div_s": sign([i64, i64], [i64]), - "i64.div_u": sign([i64, i64], [i64]), - "i64.rem_s": sign([i64, i64], [i64]), - "i64.rem_u": sign([i64, i64], [i64]), - "i64.and": sign([i64, i64], [i64]), - "i64.or": sign([i64, i64], [i64]), - "i64.xor": sign([i64, i64], [i64]), - "i64.shl": sign([i64, i64], [i64]), - "i64.shr_s": sign([i64, i64], [i64]), - "i64.shr_u": sign([i64, i64], [i64]), - "i64.rotl": sign([i64, i64], [i64]), - "i64.rotr": sign([i64, i64], [i64]), - "f32.abs": sign([f32], [f32]), - "f32.neg": sign([f32], [f32]), - "f32.ceil": sign([f32], [f32]), - "f32.floor": sign([f32], [f32]), - "f32.trunc": sign([f32], [f32]), - "f32.nearest": sign([f32], [f32]), - "f32.sqrt": sign([f32], [f32]), - "f32.add": sign([f32, f32], [f32]), - "f32.sub": sign([f32, f32], [f32]), - "f32.mul": sign([f32, f32], [f32]), - "f32.div": sign([f32, f32], [f32]), - "f32.min": sign([f32, f32], [f32]), - "f32.max": sign([f32, f32], [f32]), - "f32.copysign": sign([f32, f32], [f32]), - "f64.abs": sign([f64], [f64]), - "f64.neg": sign([f64], [f64]), - "f64.ceil": sign([f64], [f64]), - "f64.floor": sign([f64], [f64]), - "f64.trunc": sign([f64], [f64]), - "f64.nearest": sign([f64], [f64]), - "f64.sqrt": sign([f64], [f64]), - "f64.add": sign([f64, f64], [f64]), - "f64.sub": sign([f64, f64], [f64]), - "f64.mul": sign([f64, f64], [f64]), - "f64.div": sign([f64, f64], [f64]), - "f64.min": sign([f64, f64], [f64]), - "f64.max": sign([f64, f64], [f64]), - "f64.copysign": sign([f64, f64], [f64]), - "i32.wrap/i64": sign([i64], [i32]), - "i32.trunc_s/f32": sign([f32], [i32]), - "i32.trunc_u/f32": sign([f32], [i32]), - "i32.trunc_s/f64": sign([f32], [i32]), - "i32.trunc_u/f64": sign([f64], [i32]), - "i64.extend_s/i32": sign([i32], [i64]), - "i64.extend_u/i32": sign([i32], [i64]), - "i64.trunc_s/f32": sign([f32], [i64]), - "i64.trunc_u/f32": sign([f32], [i64]), - "i64.trunc_s/f64": sign([f64], [i64]), - "i64.trunc_u/f64": sign([f64], [i64]), - "f32.convert_s/i32": sign([i32], [f32]), - "f32.convert_u/i32": sign([i32], [f32]), - "f32.convert_s/i64": sign([i64], [f32]), - "f32.convert_u/i64": sign([i64], [f32]), - "f32.demote/f64": sign([f64], [f32]), - "f64.convert_s/i32": sign([i32], [f64]), - "f64.convert_u/i32": sign([i32], [f64]), - "f64.convert_s/i64": sign([i64], [f64]), - "f64.convert_u/i64": sign([i64], [f64]), - "f64.promote/f32": sign([f32], [f64]), - "i32.reinterpret/f32": sign([f32], [i32]), - "i64.reinterpret/f64": sign([f64], [i64]), - "f32.reinterpret/i32": sign([i32], [f32]), - "f64.reinterpret/i64": sign([i64], [f64]) -}; -var signatures = Object.assign({}, controlInstructions, parametricInstructions, variableInstructions, memoryInstructions, numericInstructions); -exports.signatures = signatures;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/lib/transform/denormalize-type-references/index.js b/node_modules/@webassemblyjs/ast/lib/transform/denormalize-type-references/index.js deleted file mode 100644 index 3258f84..0000000 --- a/node_modules/@webassemblyjs/ast/lib/transform/denormalize-type-references/index.js +++ /dev/null @@ -1,83 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.transform = transform; - -var t = require("../../index"); // func and call_indirect instructions can either define a signature inline, or -// reference a signature, e.g. -// -// ;; inline signature -// (func (result i64) -// (i64.const 2) -// ) -// ;; signature reference -// (type (func (result i64))) -// (func (type 0) -// (i64.const 2)) -// ) -// -// this AST transform denormalises the type references, making all signatures within the module -// inline. - - -function transform(ast) { - var typeInstructions = []; - t.traverse(ast, { - TypeInstruction: function TypeInstruction(_ref) { - var node = _ref.node; - typeInstructions.push(node); - } - }); - - if (!typeInstructions.length) { - return; - } - - function denormalizeSignature(signature) { - // signature referenced by identifier - if (signature.type === "Identifier") { - var identifier = signature; - var typeInstruction = typeInstructions.find(function (t) { - return t.id.type === identifier.type && t.id.value === identifier.value; - }); - - if (!typeInstruction) { - throw new Error("A type instruction reference was not found ".concat(JSON.stringify(signature))); - } - - return typeInstruction.functype; - } // signature referenced by index - - - if (signature.type === "NumberLiteral") { - var signatureRef = signature; - var _typeInstruction = typeInstructions[signatureRef.value]; - return _typeInstruction.functype; - } - - return signature; - } - - t.traverse(ast, { - Func: function (_Func) { - function Func(_x) { - return _Func.apply(this, arguments); - } - - Func.toString = function () { - return _Func.toString(); - }; - - return Func; - }(function (_ref2) { - var node = _ref2.node; - node.signature = denormalizeSignature(node.signature); - }), - CallIndirectInstruction: function CallIndirectInstruction(_ref3) { - var node = _ref3.node; - node.signature = denormalizeSignature(node.signature); - } - }); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/lib/transform/wast-identifier-to-index/index.js b/node_modules/@webassemblyjs/ast/lib/transform/wast-identifier-to-index/index.js deleted file mode 100644 index 33130bf..0000000 --- a/node_modules/@webassemblyjs/ast/lib/transform/wast-identifier-to-index/index.js +++ /dev/null @@ -1,225 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.transform = transform; - -var _index = require("../../index"); - -var _helperModuleContext = require("@webassemblyjs/helper-module-context"); - -function _typeof(obj) { 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); } - -function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - -function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } } - -// FIXME(sven): do the same with all block instructions, must be more generic here -function newUnexpectedFunction(i) { - return new Error("unknown function at offset: " + i); -} - -function transform(ast) { - var module; - (0, _index.traverse)(ast, { - Module: function (_Module) { - function Module(_x) { - return _Module.apply(this, arguments); - } - - Module.toString = function () { - return _Module.toString(); - }; - - return Module; - }(function (path) { - module = path.node; - }) - }); - var moduleContext = (0, _helperModuleContext.moduleContextFromModuleAST)(module); // Transform the actual instruction in function bodies - - (0, _index.traverse)(ast, { - Func: function (_Func) { - function Func(_x2) { - return _Func.apply(this, arguments); - } - - Func.toString = function () { - return _Func.toString(); - }; - - return Func; - }(function (path) { - transformFuncPath(path, moduleContext); - }), - Start: function (_Start) { - function Start(_x3) { - return _Start.apply(this, arguments); - } - - Start.toString = function () { - return _Start.toString(); - }; - - return Start; - }(function (path) { - var index = path.node.index; - - if ((0, _index.isIdentifier)(index) === true) { - var offsetInModule = moduleContext.getFunctionOffsetByIdentifier(index.value); - - if (typeof offsetInModule === "undefined") { - throw newUnexpectedFunction(index.value); - } // Replace the index Identifier - // $FlowIgnore: reference? - - - path.node.index = (0, _index.numberLiteralFromRaw)(offsetInModule); - } - }) - }); -} - -function transformFuncPath(funcPath, moduleContext) { - var funcNode = funcPath.node; - var signature = funcNode.signature; - - if (signature.type !== "Signature") { - throw new Error("Function signatures must be denormalised before execution"); - } - - var params = signature.params; // Add func locals in the context - - params.forEach(function (p) { - return moduleContext.addLocal(p.valtype); - }); - (0, _index.traverse)(funcNode, { - Instr: function (_Instr) { - function Instr(_x4) { - return _Instr.apply(this, arguments); - } - - Instr.toString = function () { - return _Instr.toString(); - }; - - return Instr; - }(function (instrPath) { - var instrNode = instrPath.node; - /** - * Local access - */ - - if (instrNode.id === "get_local" || instrNode.id === "set_local" || instrNode.id === "tee_local") { - var _instrNode$args = _slicedToArray(instrNode.args, 1), - firstArg = _instrNode$args[0]; - - if (firstArg.type === "Identifier") { - var offsetInParams = params.findIndex(function (_ref) { - var id = _ref.id; - return id === firstArg.value; - }); - - if (offsetInParams === -1) { - throw new Error("".concat(firstArg.value, " not found in ").concat(instrNode.id, ": not declared in func params")); - } // Replace the Identifer node by our new NumberLiteral node - - - instrNode.args[0] = (0, _index.numberLiteralFromRaw)(offsetInParams); - } - } - /** - * Global access - */ - - - if (instrNode.id === "get_global" || instrNode.id === "set_global") { - var _instrNode$args2 = _slicedToArray(instrNode.args, 1), - _firstArg = _instrNode$args2[0]; - - if ((0, _index.isIdentifier)(_firstArg) === true) { - var globalOffset = moduleContext.getGlobalOffsetByIdentifier( // $FlowIgnore: reference? - _firstArg.value); - - if (typeof globalOffset === "undefined") { - // $FlowIgnore: reference? - throw new Error("global ".concat(_firstArg.value, " not found in module")); - } // Replace the Identifer node by our new NumberLiteral node - - - instrNode.args[0] = (0, _index.numberLiteralFromRaw)(globalOffset); - } - } - /** - * Labels lookup - */ - - - if (instrNode.id === "br") { - var _instrNode$args3 = _slicedToArray(instrNode.args, 1), - _firstArg2 = _instrNode$args3[0]; - - if ((0, _index.isIdentifier)(_firstArg2) === true) { - // if the labels is not found it is going to be replaced with -1 - // which is invalid. - var relativeBlockCount = -1; // $FlowIgnore: reference? - - instrPath.findParent(function (_ref2) { - var node = _ref2.node; - - if ((0, _index.isBlock)(node)) { - relativeBlockCount++; // $FlowIgnore: reference? - - var name = node.label || node.name; - - if (_typeof(name) === "object") { - // $FlowIgnore: isIdentifier ensures that - if (name.value === _firstArg2.value) { - // Found it - return false; - } - } - } - - if ((0, _index.isFunc)(node)) { - return false; - } - }); // Replace the Identifer node by our new NumberLiteral node - - instrNode.args[0] = (0, _index.numberLiteralFromRaw)(relativeBlockCount); - } - } - }), - - /** - * Func lookup - */ - CallInstruction: function (_CallInstruction) { - function CallInstruction(_x5) { - return _CallInstruction.apply(this, arguments); - } - - CallInstruction.toString = function () { - return _CallInstruction.toString(); - }; - - return CallInstruction; - }(function (_ref3) { - var node = _ref3.node; - var index = node.index; - - if ((0, _index.isIdentifier)(index) === true) { - var offsetInModule = moduleContext.getFunctionOffsetByIdentifier(index.value); - - if (typeof offsetInModule === "undefined") { - throw newUnexpectedFunction(index.value); - } // Replace the index Identifier - // $FlowIgnore: reference? - - - node.index = (0, _index.numberLiteralFromRaw)(offsetInModule); - } - }) - }); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/lib/traverse.js b/node_modules/@webassemblyjs/ast/lib/traverse.js deleted file mode 100644 index 86803ce..0000000 --- a/node_modules/@webassemblyjs/ast/lib/traverse.js +++ /dev/null @@ -1,105 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.traverse = traverse; - -var _nodePath = require("./node-path"); - -var _nodes = require("./nodes"); - -// recursively walks the AST starting at the given node. The callback is invoked for -// and object that has a 'type' property. -function walk(context, callback) { - var stop = false; - - function innerWalk(context, callback) { - if (stop) { - return; - } - - var node = context.node; - - if (node === undefined) { - console.warn("traversing with an empty context"); - return; - } - - if (node._deleted === true) { - return; - } - - var path = (0, _nodePath.createPath)(context); - callback(node.type, path); - - if (path.shouldStop) { - stop = true; - return; - } - - Object.keys(node).forEach(function (prop) { - var value = node[prop]; - - if (value === null || value === undefined) { - return; - } - - var valueAsArray = Array.isArray(value) ? value : [value]; - valueAsArray.forEach(function (childNode) { - if (typeof childNode.type === "string") { - var childContext = { - node: childNode, - parentKey: prop, - parentPath: path, - shouldStop: false, - inList: Array.isArray(value) - }; - innerWalk(childContext, callback); - } - }); - }); - } - - innerWalk(context, callback); -} - -var noop = function noop() {}; - -function traverse(node, visitors) { - var before = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop; - var after = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop; - Object.keys(visitors).forEach(function (visitor) { - if (!_nodes.nodeAndUnionTypes.includes(visitor)) { - throw new Error("Unexpected visitor ".concat(visitor)); - } - }); - var context = { - node: node, - inList: false, - shouldStop: false, - parentPath: null, - parentKey: null - }; - walk(context, function (type, path) { - if (typeof visitors[type] === "function") { - before(type, path); - visitors[type](path); - after(type, path); - } - - var unionTypes = _nodes.unionTypesMap[type]; - - if (!unionTypes) { - throw new Error("Unexpected node type ".concat(type)); - } - - unionTypes.forEach(function (unionType) { - if (typeof visitors[unionType] === "function") { - before(unionType, path); - visitors[unionType](path); - after(unionType, path); - } - }); - }); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/lib/types/basic.js b/node_modules/@webassemblyjs/ast/lib/types/basic.js deleted file mode 100644 index e69de29..0000000 --- a/node_modules/@webassemblyjs/ast/lib/types/basic.js +++ /dev/null diff --git a/node_modules/@webassemblyjs/ast/lib/types/nodes.js b/node_modules/@webassemblyjs/ast/lib/types/nodes.js deleted file mode 100644 index e69de29..0000000 --- a/node_modules/@webassemblyjs/ast/lib/types/nodes.js +++ /dev/null diff --git a/node_modules/@webassemblyjs/ast/lib/types/traverse.js b/node_modules/@webassemblyjs/ast/lib/types/traverse.js deleted file mode 100644 index e69de29..0000000 --- a/node_modules/@webassemblyjs/ast/lib/types/traverse.js +++ /dev/null diff --git a/node_modules/@webassemblyjs/ast/lib/utils.js b/node_modules/@webassemblyjs/ast/lib/utils.js deleted file mode 100644 index d8330fc..0000000 --- a/node_modules/@webassemblyjs/ast/lib/utils.js +++ /dev/null @@ -1,306 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.isAnonymous = isAnonymous; -exports.getSectionMetadata = getSectionMetadata; -exports.getSectionMetadatas = getSectionMetadatas; -exports.sortSectionMetadata = sortSectionMetadata; -exports.orderedInsertNode = orderedInsertNode; -exports.assertHasLoc = assertHasLoc; -exports.getEndOfSection = getEndOfSection; -exports.shiftLoc = shiftLoc; -exports.shiftSection = shiftSection; -exports.signatureForOpcode = signatureForOpcode; -exports.getUniqueNameGenerator = getUniqueNameGenerator; -exports.getStartByteOffset = getStartByteOffset; -exports.getEndByteOffset = getEndByteOffset; -exports.getFunctionBeginingByteOffset = getFunctionBeginingByteOffset; -exports.getEndBlockByteOffset = getEndBlockByteOffset; -exports.getStartBlockByteOffset = getStartBlockByteOffset; - -var _signatures = require("./signatures"); - -var _traverse = require("./traverse"); - -var _helperWasmBytecode = _interopRequireWildcard(require("@webassemblyjs/helper-wasm-bytecode")); - -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 _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - -function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } } - -function _typeof(obj) { 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); } - -function isAnonymous(ident) { - return ident.raw === ""; -} - -function getSectionMetadata(ast, name) { - var section; - (0, _traverse.traverse)(ast, { - SectionMetadata: function (_SectionMetadata) { - function SectionMetadata(_x) { - return _SectionMetadata.apply(this, arguments); - } - - SectionMetadata.toString = function () { - return _SectionMetadata.toString(); - }; - - return SectionMetadata; - }(function (_ref) { - var node = _ref.node; - - if (node.section === name) { - section = node; - } - }) - }); - return section; -} - -function getSectionMetadatas(ast, name) { - var sections = []; - (0, _traverse.traverse)(ast, { - SectionMetadata: function (_SectionMetadata2) { - function SectionMetadata(_x2) { - return _SectionMetadata2.apply(this, arguments); - } - - SectionMetadata.toString = function () { - return _SectionMetadata2.toString(); - }; - - return SectionMetadata; - }(function (_ref2) { - var node = _ref2.node; - - if (node.section === name) { - sections.push(node); - } - }) - }); - return sections; -} - -function sortSectionMetadata(m) { - if (m.metadata == null) { - console.warn("sortSectionMetadata: no metadata to sort"); - return; - } // $FlowIgnore - - - m.metadata.sections.sort(function (a, b) { - var aId = _helperWasmBytecode.default.sections[a.section]; - var bId = _helperWasmBytecode.default.sections[b.section]; - - if (typeof aId !== "number" || typeof bId !== "number") { - throw new Error("Section id not found"); - } - - return aId - bId; - }); -} - -function orderedInsertNode(m, n) { - assertHasLoc(n); - var didInsert = false; - - if (n.type === "ModuleExport") { - m.fields.push(n); - return; - } - - m.fields = m.fields.reduce(function (acc, field) { - var fieldEndCol = Infinity; - - if (field.loc != null) { - // $FlowIgnore - fieldEndCol = field.loc.end.column; - } // $FlowIgnore: assertHasLoc ensures that - - - if (didInsert === false && n.loc.start.column < fieldEndCol) { - didInsert = true; - acc.push(n); - } - - acc.push(field); - return acc; - }, []); // Handles empty modules or n is the last element - - if (didInsert === false) { - m.fields.push(n); - } -} - -function assertHasLoc(n) { - if (n.loc == null || n.loc.start == null || n.loc.end == null) { - throw new Error("Internal failure: node (".concat(JSON.stringify(n.type), ") has no location information")); - } -} - -function getEndOfSection(s) { - assertHasLoc(s.size); - return s.startOffset + s.size.value + ( // $FlowIgnore - s.size.loc.end.column - s.size.loc.start.column); -} - -function shiftLoc(node, delta) { - // $FlowIgnore - node.loc.start.column += delta; // $FlowIgnore - - node.loc.end.column += delta; -} - -function shiftSection(ast, node, delta) { - if (node.type !== "SectionMetadata") { - throw new Error("Can not shift node " + JSON.stringify(node.type)); - } - - node.startOffset += delta; - - if (_typeof(node.size.loc) === "object") { - shiftLoc(node.size, delta); - } // Custom sections doesn't have vectorOfSize - - - if (_typeof(node.vectorOfSize) === "object" && _typeof(node.vectorOfSize.loc) === "object") { - shiftLoc(node.vectorOfSize, delta); - } - - var sectionName = node.section; // shift node locations within that section - - (0, _traverse.traverse)(ast, { - Node: function Node(_ref3) { - var node = _ref3.node; - var section = (0, _helperWasmBytecode.getSectionForNode)(node); - - if (section === sectionName && _typeof(node.loc) === "object") { - shiftLoc(node, delta); - } - } - }); -} - -function signatureForOpcode(object, name) { - var opcodeName = name; - - if (object !== undefined && object !== "") { - opcodeName = object + "." + name; - } - - var sign = _signatures.signatures[opcodeName]; - - if (sign == undefined) { - // TODO: Uncomment this when br_table and others has been done - //throw new Error("Invalid opcode: "+opcodeName); - return [object, object]; - } - - return sign[0]; -} - -function getUniqueNameGenerator() { - var inc = {}; - return function () { - var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "temp"; - - if (!(prefix in inc)) { - inc[prefix] = 0; - } else { - inc[prefix] = inc[prefix] + 1; - } - - return prefix + "_" + inc[prefix]; - }; -} - -function getStartByteOffset(n) { - // $FlowIgnore - if (typeof n.loc === "undefined" || typeof n.loc.start === "undefined") { - throw new Error( // $FlowIgnore - "Can not get byte offset without loc informations, node: " + String(n.id)); - } - - return n.loc.start.column; -} - -function getEndByteOffset(n) { - // $FlowIgnore - if (typeof n.loc === "undefined" || typeof n.loc.end === "undefined") { - throw new Error("Can not get byte offset without loc informations, node: " + n.type); - } - - return n.loc.end.column; -} - -function getFunctionBeginingByteOffset(n) { - if (!(n.body.length > 0)) { - throw new Error('n.body.length > 0' + " error: " + (undefined || "unknown")); - } - - var _n$body = _slicedToArray(n.body, 1), - firstInstruction = _n$body[0]; - - return getStartByteOffset(firstInstruction); -} - -function getEndBlockByteOffset(n) { - // $FlowIgnore - if (!(n.instr.length > 0 || n.body.length > 0)) { - throw new Error('n.instr.length > 0 || n.body.length > 0' + " error: " + (undefined || "unknown")); - } - - var lastInstruction; - - if (n.instr) { - // $FlowIgnore - lastInstruction = n.instr[n.instr.length - 1]; - } - - if (n.body) { - // $FlowIgnore - lastInstruction = n.body[n.body.length - 1]; - } - - if (!(_typeof(lastInstruction) === "object")) { - throw new Error('typeof lastInstruction === "object"' + " error: " + (undefined || "unknown")); - } - - // $FlowIgnore - return getStartByteOffset(lastInstruction); -} - -function getStartBlockByteOffset(n) { - // $FlowIgnore - if (!(n.instr.length > 0 || n.body.length > 0)) { - throw new Error('n.instr.length > 0 || n.body.length > 0' + " error: " + (undefined || "unknown")); - } - - var fistInstruction; - - if (n.instr) { - // $FlowIgnore - var _n$instr = _slicedToArray(n.instr, 1); - - fistInstruction = _n$instr[0]; - } - - if (n.body) { - // $FlowIgnore - var _n$body2 = _slicedToArray(n.body, 1); - - fistInstruction = _n$body2[0]; - } - - if (!(_typeof(fistInstruction) === "object")) { - throw new Error('typeof fistInstruction === "object"' + " error: " + (undefined || "unknown")); - } - - // $FlowIgnore - return getStartByteOffset(fistInstruction); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ast/package.json b/node_modules/@webassemblyjs/ast/package.json deleted file mode 100644 index 953fc2b..0000000 --- a/node_modules/@webassemblyjs/ast/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "_from": "@webassemblyjs/ast@1.9.0", - "_id": "@webassemblyjs/ast@1.9.0", - "_inBundle": false, - "_integrity": "sha512-C6wW5L+b7ogSDVqymbkkvuW9kruN//YisMED04xzeBBqjHa2FYnmvOlS6Xj68xWQRgWvI9cIglsjFowH/RJyEA==", - "_location": "/@webassemblyjs/ast", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/ast@1.9.0", - "name": "@webassemblyjs/ast", - "escapedName": "@webassemblyjs%2fast", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/helper-module-context", - "/@webassemblyjs/helper-wasm-section", - "/@webassemblyjs/wasm-edit", - "/@webassemblyjs/wasm-gen", - "/@webassemblyjs/wasm-opt", - "/@webassemblyjs/wasm-parser", - "/@webassemblyjs/wast-parser", - "/@webassemblyjs/wast-printer", - "/webpack" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.9.0.tgz", - "_shasum": "bd850604b4042459a5a41cd7d338cbed695ed964", - "_spec": "@webassemblyjs/ast@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/webpack", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "dependencies": { - "@webassemblyjs/helper-module-context": "1.9.0", - "@webassemblyjs/helper-wasm-bytecode": "1.9.0", - "@webassemblyjs/wast-parser": "1.9.0" - }, - "deprecated": false, - "description": "AST utils for webassemblyjs", - "devDependencies": { - "@webassemblyjs/helper-test-framework": "1.9.0", - "array.prototype.flatmap": "^1.2.1", - "dump-exports": "^0.1.0", - "mamacro": "^0.0.7" - }, - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "keywords": [ - "webassembly", - "javascript", - "ast" - ], - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/ast", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/ast/scripts/generateNodeUtils.js b/node_modules/@webassemblyjs/ast/scripts/generateNodeUtils.js deleted file mode 100644 index 46178a9..0000000 --- a/node_modules/@webassemblyjs/ast/scripts/generateNodeUtils.js +++ /dev/null @@ -1,219 +0,0 @@ -const definitions = require("../src/definitions"); -const flatMap = require("array.prototype.flatmap"); -const { - typeSignature, - iterateProps, - mapProps, - filterProps, - unique -} = require("./util"); - -const stdout = process.stdout; - -const jsTypes = ["string", "number", "boolean"]; - -const quote = value => `"${value}"`; - -function params(fields) { - const optionalDefault = field => (field.default ? ` = ${field.default}` : ""); - return mapProps(fields) - .map(field => `${typeSignature(field)}${optionalDefault(field)}`) - .join(","); -} - -function assertParamType({ assertNodeType, array, name, type }) { - if (array) { - // TODO - assert contents of array? - return `assert(typeof ${name} === "object" && typeof ${name}.length !== "undefined")\n`; - } else { - if (jsTypes.includes(type)) { - return `assert( - typeof ${name} === "${type}", - "Argument ${name} must be of type ${type}, given: " + typeof ${name} - )`; - } - - if (assertNodeType === true) { - return `assert( - ${name}.type === "${type}", - "Argument ${name} must be of type ${type}, given: " + ${name}.type - )`; - } - - return ""; - } -} - -function assertParam(meta) { - const paramAssertion = assertParamType(meta); - - if (paramAssertion === "") { - return ""; - } - - if (meta.maybe || meta.optional) { - return ` - if (${meta.name} !== null && ${meta.name} !== undefined) { - ${paramAssertion}; - } - `; - } else { - return paramAssertion; - } -} - -function assertParams(fields) { - return mapProps(fields) - .map(assertParam) - .join("\n"); -} - -function buildObject(typeDef) { - const optionalField = meta => { - if (meta.array) { - // omit optional array properties if the constructor function was supplied - // with an empty array - return ` - if (typeof ${meta.name} !== "undefined" && ${meta.name}.length > 0) { - node.${meta.name} = ${meta.name}; - } - `; - } else if (meta.type === "Object") { - // omit optional object properties if they have no keys - return ` - if (typeof ${meta.name} !== "undefined" && Object.keys(${ - meta.name - }).length !== 0) { - node.${meta.name} = ${meta.name}; - } - `; - } else if (meta.type === "boolean") { - // omit optional boolean properties if they are not true - return ` - if (${meta.name} === true) { - node.${meta.name} = true; - } - `; - } else { - return ` - if (typeof ${meta.name} !== "undefined") { - node.${meta.name} = ${meta.name}; - } - `; - } - }; - - const fields = mapProps(typeDef.fields) - .filter(f => !f.optional && !f.constant) - .map(f => f.name); - - const constants = mapProps(typeDef.fields) - .filter(f => f.constant) - .map(f => `${f.name}: "${f.value}"`); - - return ` - const node: ${typeDef.flowTypeName || typeDef.name} = { - type: "${typeDef.name}", - ${constants.concat(fields).join(",")} - } - - ${mapProps(typeDef.fields) - .filter(f => f.optional) - .map(optionalField) - .join("")} - `; -} - -function lowerCamelCase(name) { - return name.substring(0, 1).toLowerCase() + name.substring(1); -} - -function generate() { - stdout.write(` - // @flow - - // THIS FILE IS AUTOGENERATED - // see scripts/generateNodeUtils.js - - import { assert } from "mamacro"; - - function isTypeOf(t: string) { - return (n: Node) => n.type === t; - } - - function assertTypeOf(t: string) { - return (n: Node) => assert(n.type === t); - } - `); - - // Node builders - iterateProps(definitions, typeDefinition => { - stdout.write(` - export function ${lowerCamelCase(typeDefinition.name)} ( - ${params(filterProps(typeDefinition.fields, f => !f.constant))} - ): ${typeDefinition.name} { - - ${assertParams(filterProps(typeDefinition.fields, f => !f.constant))} - ${buildObject(typeDefinition)} - - return node; - } - `); - }); - - // Node testers - iterateProps(definitions, typeDefinition => { - stdout.write(` - export const is${typeDefinition.name} = - isTypeOf("${typeDefinition.name}"); - `); - }); - - // Node union type testers - const unionTypes = unique( - flatMap(mapProps(definitions).filter(d => d.unionType), d => d.unionType) - ); - unionTypes.forEach(unionType => { - stdout.write( - ` - export const is${unionType} = (node: Node) => ` + - mapProps(definitions) - .filter(d => d.unionType && d.unionType.includes(unionType)) - .map(d => `is${d.name}(node) `) - .join("||") + - ";\n\n" - ); - }); - - // Node assertion - iterateProps(definitions, typeDefinition => { - stdout.write(` - export const assert${typeDefinition.name} = - assertTypeOf("${typeDefinition.name}"); - `); - }); - - // a map from node type to its set of union types - stdout.write( - ` - export const unionTypesMap = {` + - mapProps(definitions) - .filter(d => d.unionType) - .map(t => `"${t.name}": [${t.unionType.map(quote).join(",")}]\n`) + - `}; - ` - ); - - // an array of all node and union types - stdout.write( - ` - export const nodeAndUnionTypes = [` + - mapProps(definitions) - .map(t => `"${t.name}"`) - .concat(unionTypes.map(quote)) - .join(",") + - `];` - ); -} - -generate(); diff --git a/node_modules/@webassemblyjs/ast/scripts/generateTypeDefinitions.js b/node_modules/@webassemblyjs/ast/scripts/generateTypeDefinitions.js deleted file mode 100644 index 99ba0ae..0000000 --- a/node_modules/@webassemblyjs/ast/scripts/generateTypeDefinitions.js +++ /dev/null @@ -1,47 +0,0 @@ -const definitions = require("../src/definitions"); -const flatMap = require("array.prototype.flatmap"); -const { typeSignature, mapProps, iterateProps, unique } = require("./util"); - -const stdout = process.stdout; - -function params(fields) { - return mapProps(fields) - .map(typeSignature) - .join(","); -} - -function generate() { - stdout.write(` - // @flow - /* eslint no-unused-vars: off */ - - // THIS FILE IS AUTOGENERATED - // see scripts/generateTypeDefinitions.js - `); - - // generate union types - const unionTypes = unique( - flatMap(mapProps(definitions).filter(d => d.unionType), d => d.unionType) - ); - unionTypes.forEach(unionType => { - stdout.write( - `type ${unionType} = ` + - mapProps(definitions) - .filter(d => d.unionType && d.unionType.includes(unionType)) - .map(d => d.name) - .join("|") + - ";\n\n" - ); - }); - - // generate the type definitions - iterateProps(definitions, typeDef => { - stdout.write(`type ${typeDef.name} = { - ...BaseNode, - type: "${typeDef.name}", - ${params(typeDef.fields)} - };\n\n`); - }); -} - -generate(); diff --git a/node_modules/@webassemblyjs/ast/scripts/util.js b/node_modules/@webassemblyjs/ast/scripts/util.js deleted file mode 100644 index c2ccfa0..0000000 --- a/node_modules/@webassemblyjs/ast/scripts/util.js +++ /dev/null @@ -1,38 +0,0 @@ -function iterateProps(obj, iterator) { - Object.keys(obj).forEach(key => iterator({ ...obj[key], name: key })); -} - -function mapProps(obj) { - return Object.keys(obj).map(key => ({ ...obj[key], name: key })); -} - -function filterProps(obj, filter) { - const ret = {}; - Object.keys(obj).forEach(key => { - if (filter(obj[key])) { - ret[key] = obj[key]; - } - }); - return ret; -} - -function typeSignature(meta) { - const type = meta.array ? `Array<${meta.type}>` : meta.type; - if (meta.optional) { - return `${meta.name}?: ${type}`; - } else if (meta.maybe) { - return `${meta.name}: ?${type}`; - } else { - return `${meta.name}: ${type}`; - } -} - -const unique = items => Array.from(new Set(items)); - -module.exports = { - iterateProps, - mapProps, - filterProps, - typeSignature, - unique -}; diff --git a/node_modules/@webassemblyjs/floating-point-hex-parser/LICENSE b/node_modules/@webassemblyjs/floating-point-hex-parser/LICENSE deleted file mode 100644 index d5471f8..0000000 --- a/node_modules/@webassemblyjs/floating-point-hex-parser/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License
-
-Copyright (c) 2017 Mauro Bringolf
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/floating-point-hex-parser/README.md b/node_modules/@webassemblyjs/floating-point-hex-parser/README.md deleted file mode 100644 index 648e09b..0000000 --- a/node_modules/@webassemblyjs/floating-point-hex-parser/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# Parser function for floating point hexadecimals - -[]() -[]() -[]() - -> A JavaScript function to parse floating point hexadecimals as defined by the [WebAssembly specification](https://webassembly.github.io/spec/core/text/values.html#text-hexfloat). - -## Usage - -```javascript -import parseHexFloat from '@webassemblyjs/floating-point-hex-parser' - -parseHexFloat('0x1p-1') // 0.5 -parseHexFloat('0x1.921fb54442d18p+2') // 6.283185307179586 -``` - -## Tests - -This module is tested in two ways. The first one is through a small set of test cases that can be found in [test/regular.test.js](https://github.com/maurobringolf/@webassemblyjs/floating-point-hex-parser/blob/master/test/regular.test.js). The second one is non-deterministic (sometimes called *fuzzing*): - -1. Generate a random IEEE754 double precision value `x`. -1. Compute its representation `y` in floating point hexadecimal format using the C standard library function `printf` since C supports this format. -1. Give both values to JS testcase and see if `parseHexFloat(y) === x`. - -By default one `npm test` run tests 100 random samples. If you want to do more, you can set the environment variable `FUZZ_AMOUNT` to whatever number of runs you'd like. Because it uses one child process for each sample, it is really slow though. For more details about the randomized tests see [the source](https://github.com/maurobringolf/@webassemblyjs/floating-point-hex-parser/tree/master/test/fuzzing). - -## Links - -* [maurobringolf.ch/2017/12/hexadecimal-floating-point-notation/](https://maurobringolf.ch/2017/12/hexadecimal-floating-point-notation/) - -* [github.com/xtuc/js-webassembly-interpreter/issues/32](https://github.com/xtuc/js-webassembly-interpreter/issues/32) - -* [github.com/WebAssembly/design/issues/292](https://github.com/WebAssembly/design/issues/292) diff --git a/node_modules/@webassemblyjs/floating-point-hex-parser/esm/index.js b/node_modules/@webassemblyjs/floating-point-hex-parser/esm/index.js deleted file mode 100644 index d8d858d..0000000 --- a/node_modules/@webassemblyjs/floating-point-hex-parser/esm/index.js +++ /dev/null @@ -1,42 +0,0 @@ -export default function parse(input) { - input = input.toUpperCase(); - var splitIndex = input.indexOf("P"); - var mantissa, exponent; - - if (splitIndex !== -1) { - mantissa = input.substring(0, splitIndex); - exponent = parseInt(input.substring(splitIndex + 1)); - } else { - mantissa = input; - exponent = 0; - } - - var dotIndex = mantissa.indexOf("."); - - if (dotIndex !== -1) { - var integerPart = parseInt(mantissa.substring(0, dotIndex), 16); - var sign = Math.sign(integerPart); - integerPart = sign * integerPart; - var fractionLength = mantissa.length - dotIndex - 1; - var fractionalPart = parseInt(mantissa.substring(dotIndex + 1), 16); - var fraction = fractionLength > 0 ? fractionalPart / Math.pow(16, fractionLength) : 0; - - if (sign === 0) { - if (fraction === 0) { - mantissa = sign; - } else { - if (Object.is(sign, -0)) { - mantissa = -fraction; - } else { - mantissa = fraction; - } - } - } else { - mantissa = sign * (integerPart + fraction); - } - } else { - mantissa = parseInt(mantissa, 16); - } - - return mantissa * (splitIndex !== -1 ? Math.pow(2, exponent) : 1); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/floating-point-hex-parser/lib/index.js b/node_modules/@webassemblyjs/floating-point-hex-parser/lib/index.js deleted file mode 100644 index a867699..0000000 --- a/node_modules/@webassemblyjs/floating-point-hex-parser/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = parse; - -function parse(input) { - input = input.toUpperCase(); - var splitIndex = input.indexOf("P"); - var mantissa, exponent; - - if (splitIndex !== -1) { - mantissa = input.substring(0, splitIndex); - exponent = parseInt(input.substring(splitIndex + 1)); - } else { - mantissa = input; - exponent = 0; - } - - var dotIndex = mantissa.indexOf("."); - - if (dotIndex !== -1) { - var integerPart = parseInt(mantissa.substring(0, dotIndex), 16); - var sign = Math.sign(integerPart); - integerPart = sign * integerPart; - var fractionLength = mantissa.length - dotIndex - 1; - var fractionalPart = parseInt(mantissa.substring(dotIndex + 1), 16); - var fraction = fractionLength > 0 ? fractionalPart / Math.pow(16, fractionLength) : 0; - - if (sign === 0) { - if (fraction === 0) { - mantissa = sign; - } else { - if (Object.is(sign, -0)) { - mantissa = -fraction; - } else { - mantissa = fraction; - } - } - } else { - mantissa = sign * (integerPart + fraction); - } - } else { - mantissa = parseInt(mantissa, 16); - } - - return mantissa * (splitIndex !== -1 ? Math.pow(2, exponent) : 1); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/floating-point-hex-parser/package.json b/node_modules/@webassemblyjs/floating-point-hex-parser/package.json deleted file mode 100644 index 424abcd..0000000 --- a/node_modules/@webassemblyjs/floating-point-hex-parser/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "_from": "@webassemblyjs/floating-point-hex-parser@1.9.0", - "_id": "@webassemblyjs/floating-point-hex-parser@1.9.0", - "_inBundle": false, - "_integrity": "sha512-TG5qcFsS8QB4g4MhrxK5TqfdNe7Ey/7YL/xN+36rRjl/BlGE/NcBvJcqsRgCP6Z92mRE+7N50pRIi8SmKUbcQA==", - "_location": "/@webassemblyjs/floating-point-hex-parser", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/floating-point-hex-parser@1.9.0", - "name": "@webassemblyjs/floating-point-hex-parser", - "escapedName": "@webassemblyjs%2ffloating-point-hex-parser", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/wast-parser" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.9.0.tgz", - "_shasum": "3c3d3b271bddfc84deb00f71344438311d52ffb4", - "_spec": "@webassemblyjs/floating-point-hex-parser@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/wast-parser", - "author": { - "name": "Mauro Bringolf" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "deprecated": false, - "description": "A function to parse floating point hexadecimal strings as defined by the WebAssembly specification", - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "keywords": [ - "webassembly", - "floating-point" - ], - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/floating-point-hex-parser", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "scripts": { - "build-fuzzer": "[ -f ./test/fuzzing/parse.out ] || gcc ./test/fuzzing/parse.c -o ./test/fuzzing/parse.out -lm -Wall" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/helper-api-error/LICENSE b/node_modules/@webassemblyjs/helper-api-error/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/helper-api-error/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/helper-api-error/esm/index.js b/node_modules/@webassemblyjs/helper-api-error/esm/index.js deleted file mode 100644 index 869d480..0000000 --- a/node_modules/@webassemblyjs/helper-api-error/esm/index.js +++ /dev/null @@ -1,47 +0,0 @@ -function _typeof(obj) { 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); } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -export var RuntimeError = -/*#__PURE__*/ -function (_Error) { - _inherits(RuntimeError, _Error); - - function RuntimeError() { - _classCallCheck(this, RuntimeError); - - return _possibleConstructorReturn(this, (RuntimeError.__proto__ || Object.getPrototypeOf(RuntimeError)).apply(this, arguments)); - } - - return RuntimeError; -}(Error); -export var CompileError = -/*#__PURE__*/ -function (_Error2) { - _inherits(CompileError, _Error2); - - function CompileError() { - _classCallCheck(this, CompileError); - - return _possibleConstructorReturn(this, (CompileError.__proto__ || Object.getPrototypeOf(CompileError)).apply(this, arguments)); - } - - return CompileError; -}(Error); -export var LinkError = -/*#__PURE__*/ -function (_Error3) { - _inherits(LinkError, _Error3); - - function LinkError() { - _classCallCheck(this, LinkError); - - return _possibleConstructorReturn(this, (LinkError.__proto__ || Object.getPrototypeOf(LinkError)).apply(this, arguments)); - } - - return LinkError; -}(Error);
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-api-error/lib/index.js b/node_modules/@webassemblyjs/helper-api-error/lib/index.js deleted file mode 100644 index 926ec47..0000000 --- a/node_modules/@webassemblyjs/helper-api-error/lib/index.js +++ /dev/null @@ -1,62 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.LinkError = exports.CompileError = exports.RuntimeError = void 0; - -function _typeof(obj) { 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); } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var RuntimeError = -/*#__PURE__*/ -function (_Error) { - _inherits(RuntimeError, _Error); - - function RuntimeError() { - _classCallCheck(this, RuntimeError); - - return _possibleConstructorReturn(this, (RuntimeError.__proto__ || Object.getPrototypeOf(RuntimeError)).apply(this, arguments)); - } - - return RuntimeError; -}(Error); - -exports.RuntimeError = RuntimeError; - -var CompileError = -/*#__PURE__*/ -function (_Error2) { - _inherits(CompileError, _Error2); - - function CompileError() { - _classCallCheck(this, CompileError); - - return _possibleConstructorReturn(this, (CompileError.__proto__ || Object.getPrototypeOf(CompileError)).apply(this, arguments)); - } - - return CompileError; -}(Error); - -exports.CompileError = CompileError; - -var LinkError = -/*#__PURE__*/ -function (_Error3) { - _inherits(LinkError, _Error3); - - function LinkError() { - _classCallCheck(this, LinkError); - - return _possibleConstructorReturn(this, (LinkError.__proto__ || Object.getPrototypeOf(LinkError)).apply(this, arguments)); - } - - return LinkError; -}(Error); - -exports.LinkError = LinkError;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-api-error/package.json b/node_modules/@webassemblyjs/helper-api-error/package.json deleted file mode 100644 index c16f206..0000000 --- a/node_modules/@webassemblyjs/helper-api-error/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "_from": "@webassemblyjs/helper-api-error@1.9.0", - "_id": "@webassemblyjs/helper-api-error@1.9.0", - "_inBundle": false, - "_integrity": "sha512-NcMLjoFMXpsASZFxJ5h2HZRcEhDkvnNFOAKneP5RbKRzaWJN36NC4jqQHKwStIhGXu5mUWlUUk7ygdtrO8lbmw==", - "_location": "/@webassemblyjs/helper-api-error", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/helper-api-error@1.9.0", - "name": "@webassemblyjs/helper-api-error", - "escapedName": "@webassemblyjs%2fhelper-api-error", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/wasm-parser", - "/@webassemblyjs/wast-parser" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.9.0.tgz", - "_shasum": "203f676e333b96c9da2eeab3ccef33c45928b6a2", - "_spec": "@webassemblyjs/helper-api-error@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/wast-parser", - "author": { - "name": "Sven Sauleau" - }, - "bundleDependencies": false, - "deprecated": false, - "description": "Common API errors", - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/helper-api-error", - "publishConfig": { - "access": "public" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/helper-buffer/LICENSE b/node_modules/@webassemblyjs/helper-buffer/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/helper-buffer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/helper-buffer/esm/compare.js b/node_modules/@webassemblyjs/helper-buffer/esm/compare.js deleted file mode 100644 index 8cea6b3..0000000 --- a/node_modules/@webassemblyjs/helper-buffer/esm/compare.js +++ /dev/null @@ -1,65 +0,0 @@ -// this are dev dependencies -var diff = require("jest-diff"); - -var _require = require("jest-diff/build/constants"), - NO_DIFF_MESSAGE = _require.NO_DIFF_MESSAGE; - -var _require2 = require("@webassemblyjs/wasm-parser"), - decode = _require2.decode; - -var oldConsoleLog = console.log; -export function compareArrayBuffers(l, r) { - /** - * Decode left - */ - var bufferL = ""; - - console.log = function () { - for (var _len = arguments.length, texts = new Array(_len), _key = 0; _key < _len; _key++) { - texts[_key] = arguments[_key]; - } - - return bufferL += texts.join("") + "\n"; - }; - - try { - decode(l, { - dump: true - }); - } catch (e) { - console.error(bufferL); - console.error(e); - throw e; - } - /** - * Decode right - */ - - - var bufferR = ""; - - console.log = function () { - for (var _len2 = arguments.length, texts = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - texts[_key2] = arguments[_key2]; - } - - return bufferR += texts.join("") + "\n"; - }; - - try { - decode(r, { - dump: true - }); - } catch (e) { - console.error(bufferR); - console.error(e); - throw e; - } - - console.log = oldConsoleLog; - var out = diff(bufferL, bufferR); - - if (out !== null && out !== NO_DIFF_MESSAGE) { - throw new Error("\n" + out); - } -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-buffer/esm/index.js b/node_modules/@webassemblyjs/helper-buffer/esm/index.js deleted file mode 100644 index 2c35b9e..0000000 --- a/node_modules/@webassemblyjs/helper-buffer/esm/index.js +++ /dev/null @@ -1,67 +0,0 @@ -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 concatUint8Arrays() { - for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) { - arrays[_key] = arguments[_key]; - } - - var totalLength = arrays.reduce(function (a, b) { - return a + b.length; - }, 0); - var result = new Uint8Array(totalLength); - var offset = 0; - - for (var _i = 0; _i < arrays.length; _i++) { - var arr = arrays[_i]; - - if (arr instanceof Uint8Array === false) { - throw new Error("arr must be of type Uint8Array"); - } - - result.set(arr, offset); - offset += arr.length; - } - - return result; -} - -export function overrideBytesInBuffer(buffer, startLoc, endLoc, newBytes) { - var beforeBytes = buffer.slice(0, startLoc); - var afterBytes = buffer.slice(endLoc, buffer.length); // replacement is empty, we can omit it - - if (newBytes.length === 0) { - return concatUint8Arrays(beforeBytes, afterBytes); - } - - var replacement = Uint8Array.from(newBytes); - return concatUint8Arrays(beforeBytes, replacement, afterBytes); -} -export function makeBuffer() { - for (var _len2 = arguments.length, splitedBytes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - splitedBytes[_key2] = arguments[_key2]; - } - - var bytes = [].concat.apply([], splitedBytes); - return new Uint8Array(bytes).buffer; -} -export function fromHexdump(str) { - var lines = str.split("\n"); // remove any leading left whitespace - - lines = lines.map(function (line) { - return line.trim(); - }); - var bytes = lines.reduce(function (acc, line) { - var cols = line.split(" "); // remove the offset, left column - - cols.shift(); - cols = cols.filter(function (x) { - return x !== ""; - }); - var bytes = cols.map(function (x) { - return parseInt(x, 16); - }); - acc.push.apply(acc, _toConsumableArray(bytes)); - return acc; - }, []); - return Buffer.from(bytes); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-buffer/lib/compare.js b/node_modules/@webassemblyjs/helper-buffer/lib/compare.js deleted file mode 100644 index b30dc07..0000000 --- a/node_modules/@webassemblyjs/helper-buffer/lib/compare.js +++ /dev/null @@ -1,73 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.compareArrayBuffers = compareArrayBuffers; - -// this are dev dependencies -var diff = require("jest-diff"); - -var _require = require("jest-diff/build/constants"), - NO_DIFF_MESSAGE = _require.NO_DIFF_MESSAGE; - -var _require2 = require("@webassemblyjs/wasm-parser"), - decode = _require2.decode; - -var oldConsoleLog = console.log; - -function compareArrayBuffers(l, r) { - /** - * Decode left - */ - var bufferL = ""; - - console.log = function () { - for (var _len = arguments.length, texts = new Array(_len), _key = 0; _key < _len; _key++) { - texts[_key] = arguments[_key]; - } - - return bufferL += texts.join("") + "\n"; - }; - - try { - decode(l, { - dump: true - }); - } catch (e) { - console.error(bufferL); - console.error(e); - throw e; - } - /** - * Decode right - */ - - - var bufferR = ""; - - console.log = function () { - for (var _len2 = arguments.length, texts = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - texts[_key2] = arguments[_key2]; - } - - return bufferR += texts.join("") + "\n"; - }; - - try { - decode(r, { - dump: true - }); - } catch (e) { - console.error(bufferR); - console.error(e); - throw e; - } - - console.log = oldConsoleLog; - var out = diff(bufferL, bufferR); - - if (out !== null && out !== NO_DIFF_MESSAGE) { - throw new Error("\n" + out); - } -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-buffer/lib/index.js b/node_modules/@webassemblyjs/helper-buffer/lib/index.js deleted file mode 100644 index b735b1f..0000000 --- a/node_modules/@webassemblyjs/helper-buffer/lib/index.js +++ /dev/null @@ -1,78 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.overrideBytesInBuffer = overrideBytesInBuffer; -exports.makeBuffer = makeBuffer; -exports.fromHexdump = fromHexdump; - -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 concatUint8Arrays() { - for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) { - arrays[_key] = arguments[_key]; - } - - var totalLength = arrays.reduce(function (a, b) { - return a + b.length; - }, 0); - var result = new Uint8Array(totalLength); - var offset = 0; - - for (var _i = 0; _i < arrays.length; _i++) { - var arr = arrays[_i]; - - if (arr instanceof Uint8Array === false) { - throw new Error("arr must be of type Uint8Array"); - } - - result.set(arr, offset); - offset += arr.length; - } - - return result; -} - -function overrideBytesInBuffer(buffer, startLoc, endLoc, newBytes) { - var beforeBytes = buffer.slice(0, startLoc); - var afterBytes = buffer.slice(endLoc, buffer.length); // replacement is empty, we can omit it - - if (newBytes.length === 0) { - return concatUint8Arrays(beforeBytes, afterBytes); - } - - var replacement = Uint8Array.from(newBytes); - return concatUint8Arrays(beforeBytes, replacement, afterBytes); -} - -function makeBuffer() { - for (var _len2 = arguments.length, splitedBytes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - splitedBytes[_key2] = arguments[_key2]; - } - - var bytes = [].concat.apply([], splitedBytes); - return new Uint8Array(bytes).buffer; -} - -function fromHexdump(str) { - var lines = str.split("\n"); // remove any leading left whitespace - - lines = lines.map(function (line) { - return line.trim(); - }); - var bytes = lines.reduce(function (acc, line) { - var cols = line.split(" "); // remove the offset, left column - - cols.shift(); - cols = cols.filter(function (x) { - return x !== ""; - }); - var bytes = cols.map(function (x) { - return parseInt(x, 16); - }); - acc.push.apply(acc, _toConsumableArray(bytes)); - return acc; - }, []); - return Buffer.from(bytes); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-buffer/package.json b/node_modules/@webassemblyjs/helper-buffer/package.json deleted file mode 100644 index 815adee..0000000 --- a/node_modules/@webassemblyjs/helper-buffer/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "_from": "@webassemblyjs/helper-buffer@1.9.0", - "_id": "@webassemblyjs/helper-buffer@1.9.0", - "_inBundle": false, - "_integrity": "sha512-qZol43oqhq6yBPx7YM3m9Bv7WMV9Eevj6kMi6InKOuZxhw+q9hOkvq5e/PpKSiLfyetpaBnogSbNCfBwyB00CA==", - "_location": "/@webassemblyjs/helper-buffer", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/helper-buffer@1.9.0", - "name": "@webassemblyjs/helper-buffer", - "escapedName": "@webassemblyjs%2fhelper-buffer", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/helper-wasm-section", - "/@webassemblyjs/wasm-edit", - "/@webassemblyjs/wasm-opt" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.9.0.tgz", - "_shasum": "a1442d269c5feb23fcbc9ef759dac3547f29de00", - "_spec": "@webassemblyjs/helper-buffer@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/wasm-edit", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "deprecated": false, - "description": "Buffer manipulation utility", - "devDependencies": { - "@webassemblyjs/wasm-parser": "1.9.0", - "jest-diff": "^24.0.0" - }, - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/helper-buffer", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/helper-code-frame/LICENSE b/node_modules/@webassemblyjs/helper-code-frame/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/helper-code-frame/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/helper-code-frame/esm/index.js b/node_modules/@webassemblyjs/helper-code-frame/esm/index.js deleted file mode 100644 index 791c65e..0000000 --- a/node_modules/@webassemblyjs/helper-code-frame/esm/index.js +++ /dev/null @@ -1,37 +0,0 @@ -function _typeof(obj) { 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); } - -import { print } from "@webassemblyjs/wast-printer"; -var SHOW_LINES_AROUND_POINTER = 5; - -function repeat(char, nb) { - return Array(nb).fill(char).join(""); -} // TODO(sven): allow arbitrary ast nodes - - -export function codeFrameFromAst(ast, loc) { - return codeFrameFromSource(print(ast), loc); -} -export function codeFrameFromSource(source, loc) { - var start = loc.start, - end = loc.end; - var length = 1; - - if (_typeof(end) === "object") { - length = end.column - start.column + 1; - } - - return source.split("\n").reduce(function (acc, line, lineNbr) { - if (Math.abs(start.line - lineNbr) < SHOW_LINES_AROUND_POINTER) { - acc += line + "\n"; - } // Add a new line with the pointer padded left - - - if (lineNbr === start.line - 1) { - acc += repeat(" ", start.column - 1); - acc += repeat("^", length); - acc += "\n"; - } - - return acc; - }, ""); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-code-frame/lib/index.js b/node_modules/@webassemblyjs/helper-code-frame/lib/index.js deleted file mode 100644 index 977de89..0000000 --- a/node_modules/@webassemblyjs/helper-code-frame/lib/index.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.codeFrameFromAst = codeFrameFromAst; -exports.codeFrameFromSource = codeFrameFromSource; - -var _wastPrinter = require("@webassemblyjs/wast-printer"); - -function _typeof(obj) { 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); } - -var SHOW_LINES_AROUND_POINTER = 5; - -function repeat(char, nb) { - return Array(nb).fill(char).join(""); -} // TODO(sven): allow arbitrary ast nodes - - -function codeFrameFromAst(ast, loc) { - return codeFrameFromSource((0, _wastPrinter.print)(ast), loc); -} - -function codeFrameFromSource(source, loc) { - var start = loc.start, - end = loc.end; - var length = 1; - - if (_typeof(end) === "object") { - length = end.column - start.column + 1; - } - - return source.split("\n").reduce(function (acc, line, lineNbr) { - if (Math.abs(start.line - lineNbr) < SHOW_LINES_AROUND_POINTER) { - acc += line + "\n"; - } // Add a new line with the pointer padded left - - - if (lineNbr === start.line - 1) { - acc += repeat(" ", start.column - 1); - acc += repeat("^", length); - acc += "\n"; - } - - return acc; - }, ""); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-code-frame/package.json b/node_modules/@webassemblyjs/helper-code-frame/package.json deleted file mode 100644 index ab94ff3..0000000 --- a/node_modules/@webassemblyjs/helper-code-frame/package.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "_from": "@webassemblyjs/helper-code-frame@1.9.0", - "_id": "@webassemblyjs/helper-code-frame@1.9.0", - "_inBundle": false, - "_integrity": "sha512-ERCYdJBkD9Vu4vtjUYe8LZruWuNIToYq/ME22igL+2vj2dQ2OOujIZr3MEFvfEaqKoVqpsFKAGsRdBSBjrIvZA==", - "_location": "/@webassemblyjs/helper-code-frame", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/helper-code-frame@1.9.0", - "name": "@webassemblyjs/helper-code-frame", - "escapedName": "@webassemblyjs%2fhelper-code-frame", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/wast-parser" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.9.0.tgz", - "_shasum": "647f8892cd2043a82ac0c8c5e75c36f1d9159f27", - "_spec": "@webassemblyjs/helper-code-frame@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/wast-parser", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "dependencies": { - "@webassemblyjs/wast-printer": "1.9.0" - }, - "deprecated": false, - "description": "", - "devDependencies": { - "@webassemblyjs/ast": "1.9.0" - }, - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/helper-code-frame", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/helper-fsm/LICENSE b/node_modules/@webassemblyjs/helper-fsm/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/helper-fsm/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/helper-fsm/esm/index.js b/node_modules/@webassemblyjs/helper-fsm/esm/index.js deleted file mode 100644 index c7266b8..0000000 --- a/node_modules/@webassemblyjs/helper-fsm/esm/index.js +++ /dev/null @@ -1,101 +0,0 @@ -function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - -function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } - -var STOP = Symbol("STOP"); - -function makeTransition(regex, nextState) { - var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, - _ref$n = _ref.n, - n = _ref$n === void 0 ? 1 : _ref$n, - allowedSeparator = _ref.allowedSeparator; - - return function (instance) { - if (allowedSeparator) { - if (instance.input[instance.ptr] === allowedSeparator) { - if (regex.test(instance.input.substring(instance.ptr - 1, instance.ptr))) { - // Consume the separator and stay in current state - return [instance.currentState, 1]; - } else { - return [instance.terminatingState, 0]; - } - } - } - - if (regex.test(instance.input.substring(instance.ptr, instance.ptr + n))) { - return [nextState, n]; - } - - return false; - }; -} - -function combineTransitions(transitions) { - return function () { - var match = false; - var currentTransitions = transitions[this.currentState] || []; - - for (var i = 0; i < currentTransitions.length; ++i) { - match = currentTransitions[i](this); - - if (match !== false) { - break; - } - } - - return match || [this.terminatingState, 0]; - }; -} - -var FSM = -/*#__PURE__*/ -function () { - function FSM(transitions, initialState) { - var terminatingState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : STOP; - - _classCallCheck(this, FSM); - - this.initialState = initialState; - this.terminatingState = terminatingState; - - if (terminatingState === STOP || !transitions[terminatingState]) { - transitions[terminatingState] = []; - } - - this.transitionFunction = combineTransitions.call(this, transitions); - } - - _createClass(FSM, [{ - key: "run", - value: function run(input) { - this.input = input; - this.ptr = 0; - this.currentState = this.initialState; - var value = ""; - var eatLength, nextState; - - while (this.currentState !== this.terminatingState && this.ptr < this.input.length) { - var _transitionFunction = this.transitionFunction(); - - var _transitionFunction2 = _slicedToArray(_transitionFunction, 2); - - nextState = _transitionFunction2[0]; - eatLength = _transitionFunction2[1]; - value += this.input.substring(this.ptr, this.ptr += eatLength); - this.currentState = nextState; - } - - return value; - } - }]); - - return FSM; -}(); - -export { makeTransition, FSM };
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-fsm/lib/index.js b/node_modules/@webassemblyjs/helper-fsm/lib/index.js deleted file mode 100644 index c23120d..0000000 --- a/node_modules/@webassemblyjs/helper-fsm/lib/index.js +++ /dev/null @@ -1,109 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.makeTransition = makeTransition; -exports.FSM = void 0; - -function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - -function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } - -var STOP = Symbol("STOP"); - -function makeTransition(regex, nextState) { - var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, - _ref$n = _ref.n, - n = _ref$n === void 0 ? 1 : _ref$n, - allowedSeparator = _ref.allowedSeparator; - - return function (instance) { - if (allowedSeparator) { - if (instance.input[instance.ptr] === allowedSeparator) { - if (regex.test(instance.input.substring(instance.ptr - 1, instance.ptr))) { - // Consume the separator and stay in current state - return [instance.currentState, 1]; - } else { - return [instance.terminatingState, 0]; - } - } - } - - if (regex.test(instance.input.substring(instance.ptr, instance.ptr + n))) { - return [nextState, n]; - } - - return false; - }; -} - -function combineTransitions(transitions) { - return function () { - var match = false; - var currentTransitions = transitions[this.currentState] || []; - - for (var i = 0; i < currentTransitions.length; ++i) { - match = currentTransitions[i](this); - - if (match !== false) { - break; - } - } - - return match || [this.terminatingState, 0]; - }; -} - -var FSM = -/*#__PURE__*/ -function () { - function FSM(transitions, initialState) { - var terminatingState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : STOP; - - _classCallCheck(this, FSM); - - this.initialState = initialState; - this.terminatingState = terminatingState; - - if (terminatingState === STOP || !transitions[terminatingState]) { - transitions[terminatingState] = []; - } - - this.transitionFunction = combineTransitions.call(this, transitions); - } - - _createClass(FSM, [{ - key: "run", - value: function run(input) { - this.input = input; - this.ptr = 0; - this.currentState = this.initialState; - var value = ""; - var eatLength, nextState; - - while (this.currentState !== this.terminatingState && this.ptr < this.input.length) { - var _transitionFunction = this.transitionFunction(); - - var _transitionFunction2 = _slicedToArray(_transitionFunction, 2); - - nextState = _transitionFunction2[0]; - eatLength = _transitionFunction2[1]; - value += this.input.substring(this.ptr, this.ptr += eatLength); - this.currentState = nextState; - } - - return value; - } - }]); - - return FSM; -}(); - -exports.FSM = FSM;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-fsm/package.json b/node_modules/@webassemblyjs/helper-fsm/package.json deleted file mode 100644 index ba42e7f..0000000 --- a/node_modules/@webassemblyjs/helper-fsm/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "_from": "@webassemblyjs/helper-fsm@1.9.0", - "_id": "@webassemblyjs/helper-fsm@1.9.0", - "_inBundle": false, - "_integrity": "sha512-OPRowhGbshCb5PxJ8LocpdX9Kl0uB4XsAjl6jH/dWKlk/mzsANvhwbiULsaiqT5GZGT9qinTICdj6PLuM5gslw==", - "_location": "/@webassemblyjs/helper-fsm", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/helper-fsm@1.9.0", - "name": "@webassemblyjs/helper-fsm", - "escapedName": "@webassemblyjs%2fhelper-fsm", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/wast-parser" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/helper-fsm/-/helper-fsm-1.9.0.tgz", - "_shasum": "c05256b71244214671f4b08ec108ad63b70eddb8", - "_spec": "@webassemblyjs/helper-fsm@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/wast-parser", - "author": { - "name": "Mauro Bringolf" - }, - "bundleDependencies": false, - "deprecated": false, - "description": "FSM implementation", - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "license": "ISC", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/helper-fsm", - "publishConfig": { - "access": "public" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/helper-module-context/LICENSE b/node_modules/@webassemblyjs/helper-module-context/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/helper-module-context/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/helper-module-context/esm/index.js b/node_modules/@webassemblyjs/helper-module-context/esm/index.js deleted file mode 100644 index 0f730e6..0000000 --- a/node_modules/@webassemblyjs/helper-module-context/esm/index.js +++ /dev/null @@ -1,378 +0,0 @@ -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } - -// TODO(sven): add flow in here -import { isSignature, isNumberLiteral } from "@webassemblyjs/ast"; -export function moduleContextFromModuleAST(m) { - var moduleContext = new ModuleContext(); - - if (!(m.type === "Module")) { - throw new Error('m.type === "Module"' + " error: " + (undefined || "unknown")); - } - - m.fields.forEach(function (field) { - switch (field.type) { - case "Start": - { - moduleContext.setStart(field.index); - break; - } - - case "TypeInstruction": - { - moduleContext.addType(field); - break; - } - - case "Func": - { - moduleContext.addFunction(field); - break; - } - - case "Global": - { - moduleContext.defineGlobal(field); - break; - } - - case "ModuleImport": - { - switch (field.descr.type) { - case "GlobalType": - { - moduleContext.importGlobal(field.descr.valtype, field.descr.mutability); - break; - } - - case "Memory": - { - moduleContext.addMemory(field.descr.limits.min, field.descr.limits.max); - break; - } - - case "FuncImportDescr": - { - moduleContext.importFunction(field.descr); - break; - } - - case "Table": - { - // FIXME(sven): not implemented yet - break; - } - - default: - throw new Error("Unsupported ModuleImport of type " + JSON.stringify(field.descr.type)); - } - - break; - } - - case "Memory": - { - moduleContext.addMemory(field.limits.min, field.limits.max); - break; - } - } - }); - return moduleContext; -} -/** - * Module context for type checking - */ - -export var ModuleContext = -/*#__PURE__*/ -function () { - function ModuleContext() { - _classCallCheck(this, ModuleContext); - - this.funcs = []; - this.funcsOffsetByIdentifier = []; - this.types = []; - this.globals = []; - this.globalsOffsetByIdentifier = []; - this.mems = []; // Current stack frame - - this.locals = []; - this.labels = []; - this.return = []; - this.debugName = "unknown"; - this.start = null; - } - /** - * Set start segment - */ - - - _createClass(ModuleContext, [{ - key: "setStart", - value: function setStart(index) { - this.start = index.value; - } - /** - * Get start function - */ - - }, { - key: "getStart", - value: function getStart() { - return this.start; - } - /** - * Reset the active stack frame - */ - - }, { - key: "newContext", - value: function newContext(debugName, expectedResult) { - this.locals = []; - this.labels = [expectedResult]; - this.return = expectedResult; - this.debugName = debugName; - } - /** - * Functions - */ - - }, { - key: "addFunction", - value: function addFunction(func - /*: Func*/ - ) { - // eslint-disable-next-line prefer-const - var _ref = func.signature || {}, - _ref$params = _ref.params, - args = _ref$params === void 0 ? [] : _ref$params, - _ref$results = _ref.results, - result = _ref$results === void 0 ? [] : _ref$results; - - args = args.map(function (arg) { - return arg.valtype; - }); - this.funcs.push({ - args: args, - result: result - }); - - if (typeof func.name !== "undefined") { - this.funcsOffsetByIdentifier[func.name.value] = this.funcs.length - 1; - } - } - }, { - key: "importFunction", - value: function importFunction(funcimport) { - if (isSignature(funcimport.signature)) { - // eslint-disable-next-line prefer-const - var _funcimport$signature = funcimport.signature, - args = _funcimport$signature.params, - result = _funcimport$signature.results; - args = args.map(function (arg) { - return arg.valtype; - }); - this.funcs.push({ - args: args, - result: result - }); - } else { - if (!isNumberLiteral(funcimport.signature)) { - throw new Error('isNumberLiteral(funcimport.signature)' + " error: " + (undefined || "unknown")); - } - - var typeId = funcimport.signature.value; - - if (!this.hasType(typeId)) { - throw new Error('this.hasType(typeId)' + " error: " + (undefined || "unknown")); - } - - var signature = this.getType(typeId); - this.funcs.push({ - args: signature.params.map(function (arg) { - return arg.valtype; - }), - result: signature.results - }); - } - - if (typeof funcimport.id !== "undefined") { - // imports are first, we can assume their index in the array - this.funcsOffsetByIdentifier[funcimport.id.value] = this.funcs.length - 1; - } - } - }, { - key: "hasFunction", - value: function hasFunction(index) { - return typeof this.getFunction(index) !== "undefined"; - } - }, { - key: "getFunction", - value: function getFunction(index) { - if (typeof index !== "number") { - throw new Error("getFunction only supported for number index"); - } - - return this.funcs[index]; - } - }, { - key: "getFunctionOffsetByIdentifier", - value: function getFunctionOffsetByIdentifier(name) { - if (!(typeof name === "string")) { - throw new Error('typeof name === "string"' + " error: " + (undefined || "unknown")); - } - - return this.funcsOffsetByIdentifier[name]; - } - /** - * Labels - */ - - }, { - key: "addLabel", - value: function addLabel(result) { - this.labels.unshift(result); - } - }, { - key: "hasLabel", - value: function hasLabel(index) { - return this.labels.length > index && index >= 0; - } - }, { - key: "getLabel", - value: function getLabel(index) { - return this.labels[index]; - } - }, { - key: "popLabel", - value: function popLabel() { - this.labels.shift(); - } - /** - * Locals - */ - - }, { - key: "hasLocal", - value: function hasLocal(index) { - return typeof this.getLocal(index) !== "undefined"; - } - }, { - key: "getLocal", - value: function getLocal(index) { - return this.locals[index]; - } - }, { - key: "addLocal", - value: function addLocal(type) { - this.locals.push(type); - } - /** - * Types - */ - - }, { - key: "addType", - value: function addType(type) { - if (!(type.functype.type === "Signature")) { - throw new Error('type.functype.type === "Signature"' + " error: " + (undefined || "unknown")); - } - - this.types.push(type.functype); - } - }, { - key: "hasType", - value: function hasType(index) { - return this.types[index] !== undefined; - } - }, { - key: "getType", - value: function getType(index) { - return this.types[index]; - } - /** - * Globals - */ - - }, { - key: "hasGlobal", - value: function hasGlobal(index) { - return this.globals.length > index && index >= 0; - } - }, { - key: "getGlobal", - value: function getGlobal(index) { - return this.globals[index].type; - } - }, { - key: "getGlobalOffsetByIdentifier", - value: function getGlobalOffsetByIdentifier(name) { - if (!(typeof name === "string")) { - throw new Error('typeof name === "string"' + " error: " + (undefined || "unknown")); - } - - return this.globalsOffsetByIdentifier[name]; - } - }, { - key: "defineGlobal", - value: function defineGlobal(global - /*: Global*/ - ) { - var type = global.globalType.valtype; - var mutability = global.globalType.mutability; - this.globals.push({ - type: type, - mutability: mutability - }); - - if (typeof global.name !== "undefined") { - this.globalsOffsetByIdentifier[global.name.value] = this.globals.length - 1; - } - } - }, { - key: "importGlobal", - value: function importGlobal(type, mutability) { - this.globals.push({ - type: type, - mutability: mutability - }); - } - }, { - key: "isMutableGlobal", - value: function isMutableGlobal(index) { - return this.globals[index].mutability === "var"; - } - }, { - key: "isImmutableGlobal", - value: function isImmutableGlobal(index) { - return this.globals[index].mutability === "const"; - } - /** - * Memories - */ - - }, { - key: "hasMemory", - value: function hasMemory(index) { - return this.mems.length > index && index >= 0; - } - }, { - key: "addMemory", - value: function addMemory(min, max) { - this.mems.push({ - min: min, - max: max - }); - } - }, { - key: "getMemory", - value: function getMemory(index) { - return this.mems[index]; - } - }]); - - return ModuleContext; -}();
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-module-context/lib/index.js b/node_modules/@webassemblyjs/helper-module-context/lib/index.js deleted file mode 100644 index 189e719..0000000 --- a/node_modules/@webassemblyjs/helper-module-context/lib/index.js +++ /dev/null @@ -1,389 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.moduleContextFromModuleAST = moduleContextFromModuleAST; -exports.ModuleContext = void 0; - -var _ast = require("@webassemblyjs/ast"); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } - -function moduleContextFromModuleAST(m) { - var moduleContext = new ModuleContext(); - - if (!(m.type === "Module")) { - throw new Error('m.type === "Module"' + " error: " + (undefined || "unknown")); - } - - m.fields.forEach(function (field) { - switch (field.type) { - case "Start": - { - moduleContext.setStart(field.index); - break; - } - - case "TypeInstruction": - { - moduleContext.addType(field); - break; - } - - case "Func": - { - moduleContext.addFunction(field); - break; - } - - case "Global": - { - moduleContext.defineGlobal(field); - break; - } - - case "ModuleImport": - { - switch (field.descr.type) { - case "GlobalType": - { - moduleContext.importGlobal(field.descr.valtype, field.descr.mutability); - break; - } - - case "Memory": - { - moduleContext.addMemory(field.descr.limits.min, field.descr.limits.max); - break; - } - - case "FuncImportDescr": - { - moduleContext.importFunction(field.descr); - break; - } - - case "Table": - { - // FIXME(sven): not implemented yet - break; - } - - default: - throw new Error("Unsupported ModuleImport of type " + JSON.stringify(field.descr.type)); - } - - break; - } - - case "Memory": - { - moduleContext.addMemory(field.limits.min, field.limits.max); - break; - } - } - }); - return moduleContext; -} -/** - * Module context for type checking - */ - - -var ModuleContext = -/*#__PURE__*/ -function () { - function ModuleContext() { - _classCallCheck(this, ModuleContext); - - this.funcs = []; - this.funcsOffsetByIdentifier = []; - this.types = []; - this.globals = []; - this.globalsOffsetByIdentifier = []; - this.mems = []; // Current stack frame - - this.locals = []; - this.labels = []; - this.return = []; - this.debugName = "unknown"; - this.start = null; - } - /** - * Set start segment - */ - - - _createClass(ModuleContext, [{ - key: "setStart", - value: function setStart(index) { - this.start = index.value; - } - /** - * Get start function - */ - - }, { - key: "getStart", - value: function getStart() { - return this.start; - } - /** - * Reset the active stack frame - */ - - }, { - key: "newContext", - value: function newContext(debugName, expectedResult) { - this.locals = []; - this.labels = [expectedResult]; - this.return = expectedResult; - this.debugName = debugName; - } - /** - * Functions - */ - - }, { - key: "addFunction", - value: function addFunction(func - /*: Func*/ - ) { - // eslint-disable-next-line prefer-const - var _ref = func.signature || {}, - _ref$params = _ref.params, - args = _ref$params === void 0 ? [] : _ref$params, - _ref$results = _ref.results, - result = _ref$results === void 0 ? [] : _ref$results; - - args = args.map(function (arg) { - return arg.valtype; - }); - this.funcs.push({ - args: args, - result: result - }); - - if (typeof func.name !== "undefined") { - this.funcsOffsetByIdentifier[func.name.value] = this.funcs.length - 1; - } - } - }, { - key: "importFunction", - value: function importFunction(funcimport) { - if ((0, _ast.isSignature)(funcimport.signature)) { - // eslint-disable-next-line prefer-const - var _funcimport$signature = funcimport.signature, - args = _funcimport$signature.params, - result = _funcimport$signature.results; - args = args.map(function (arg) { - return arg.valtype; - }); - this.funcs.push({ - args: args, - result: result - }); - } else { - if (!(0, _ast.isNumberLiteral)(funcimport.signature)) { - throw new Error('isNumberLiteral(funcimport.signature)' + " error: " + (undefined || "unknown")); - } - - var typeId = funcimport.signature.value; - - if (!this.hasType(typeId)) { - throw new Error('this.hasType(typeId)' + " error: " + (undefined || "unknown")); - } - - var signature = this.getType(typeId); - this.funcs.push({ - args: signature.params.map(function (arg) { - return arg.valtype; - }), - result: signature.results - }); - } - - if (typeof funcimport.id !== "undefined") { - // imports are first, we can assume their index in the array - this.funcsOffsetByIdentifier[funcimport.id.value] = this.funcs.length - 1; - } - } - }, { - key: "hasFunction", - value: function hasFunction(index) { - return typeof this.getFunction(index) !== "undefined"; - } - }, { - key: "getFunction", - value: function getFunction(index) { - if (typeof index !== "number") { - throw new Error("getFunction only supported for number index"); - } - - return this.funcs[index]; - } - }, { - key: "getFunctionOffsetByIdentifier", - value: function getFunctionOffsetByIdentifier(name) { - if (!(typeof name === "string")) { - throw new Error('typeof name === "string"' + " error: " + (undefined || "unknown")); - } - - return this.funcsOffsetByIdentifier[name]; - } - /** - * Labels - */ - - }, { - key: "addLabel", - value: function addLabel(result) { - this.labels.unshift(result); - } - }, { - key: "hasLabel", - value: function hasLabel(index) { - return this.labels.length > index && index >= 0; - } - }, { - key: "getLabel", - value: function getLabel(index) { - return this.labels[index]; - } - }, { - key: "popLabel", - value: function popLabel() { - this.labels.shift(); - } - /** - * Locals - */ - - }, { - key: "hasLocal", - value: function hasLocal(index) { - return typeof this.getLocal(index) !== "undefined"; - } - }, { - key: "getLocal", - value: function getLocal(index) { - return this.locals[index]; - } - }, { - key: "addLocal", - value: function addLocal(type) { - this.locals.push(type); - } - /** - * Types - */ - - }, { - key: "addType", - value: function addType(type) { - if (!(type.functype.type === "Signature")) { - throw new Error('type.functype.type === "Signature"' + " error: " + (undefined || "unknown")); - } - - this.types.push(type.functype); - } - }, { - key: "hasType", - value: function hasType(index) { - return this.types[index] !== undefined; - } - }, { - key: "getType", - value: function getType(index) { - return this.types[index]; - } - /** - * Globals - */ - - }, { - key: "hasGlobal", - value: function hasGlobal(index) { - return this.globals.length > index && index >= 0; - } - }, { - key: "getGlobal", - value: function getGlobal(index) { - return this.globals[index].type; - } - }, { - key: "getGlobalOffsetByIdentifier", - value: function getGlobalOffsetByIdentifier(name) { - if (!(typeof name === "string")) { - throw new Error('typeof name === "string"' + " error: " + (undefined || "unknown")); - } - - return this.globalsOffsetByIdentifier[name]; - } - }, { - key: "defineGlobal", - value: function defineGlobal(global - /*: Global*/ - ) { - var type = global.globalType.valtype; - var mutability = global.globalType.mutability; - this.globals.push({ - type: type, - mutability: mutability - }); - - if (typeof global.name !== "undefined") { - this.globalsOffsetByIdentifier[global.name.value] = this.globals.length - 1; - } - } - }, { - key: "importGlobal", - value: function importGlobal(type, mutability) { - this.globals.push({ - type: type, - mutability: mutability - }); - } - }, { - key: "isMutableGlobal", - value: function isMutableGlobal(index) { - return this.globals[index].mutability === "var"; - } - }, { - key: "isImmutableGlobal", - value: function isImmutableGlobal(index) { - return this.globals[index].mutability === "const"; - } - /** - * Memories - */ - - }, { - key: "hasMemory", - value: function hasMemory(index) { - return this.mems.length > index && index >= 0; - } - }, { - key: "addMemory", - value: function addMemory(min, max) { - this.mems.push({ - min: min, - max: max - }); - } - }, { - key: "getMemory", - value: function getMemory(index) { - return this.mems[index]; - } - }]); - - return ModuleContext; -}(); - -exports.ModuleContext = ModuleContext;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-module-context/package.json b/node_modules/@webassemblyjs/helper-module-context/package.json deleted file mode 100644 index ee1c610..0000000 --- a/node_modules/@webassemblyjs/helper-module-context/package.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "_from": "@webassemblyjs/helper-module-context@1.9.0", - "_id": "@webassemblyjs/helper-module-context@1.9.0", - "_inBundle": false, - "_integrity": "sha512-MJCW8iGC08tMk2enck1aPW+BE5Cw8/7ph/VGZxwyvGbJwjktKkDK7vy7gAmMDx88D7mhDTCNKAW5tED+gZ0W8g==", - "_location": "/@webassemblyjs/helper-module-context", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/helper-module-context@1.9.0", - "name": "@webassemblyjs/helper-module-context", - "escapedName": "@webassemblyjs%2fhelper-module-context", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/ast", - "/webpack" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/helper-module-context/-/helper-module-context-1.9.0.tgz", - "_shasum": "25d8884b76839871a08a6c6f806c3979ef712f07", - "_spec": "@webassemblyjs/helper-module-context@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/webpack", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "dependencies": { - "@webassemblyjs/ast": "1.9.0" - }, - "deprecated": false, - "description": "", - "devDependencies": { - "@webassemblyjs/wast-parser": "1.9.0", - "mamacro": "^0.0.7" - }, - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/helper-module-context", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/helper-module-context/src/index.js b/node_modules/@webassemblyjs/helper-module-context/src/index.js deleted file mode 100644 index e3171de..0000000 --- a/node_modules/@webassemblyjs/helper-module-context/src/index.js +++ /dev/null @@ -1,287 +0,0 @@ -// TODO(sven): add flow in here - -import { isSignature, isNumberLiteral } from "@webassemblyjs/ast"; -import { assert } from "mamacro"; - -export function moduleContextFromModuleAST(m) { - const moduleContext = new ModuleContext(); - - assert(m.type === "Module"); - - m.fields.forEach(field => { - switch (field.type) { - case "Start": { - moduleContext.setStart(field.index); - break; - } - case "TypeInstruction": { - moduleContext.addType(field); - break; - } - case "Func": { - moduleContext.addFunction(field); - break; - } - case "Global": { - moduleContext.defineGlobal(field); - break; - } - case "ModuleImport": { - switch (field.descr.type) { - case "GlobalType": { - moduleContext.importGlobal( - field.descr.valtype, - field.descr.mutability - ); - break; - } - case "Memory": { - moduleContext.addMemory( - field.descr.limits.min, - field.descr.limits.max - ); - break; - } - case "FuncImportDescr": { - moduleContext.importFunction(field.descr); - break; - } - - case "Table": { - // FIXME(sven): not implemented yet - break; - } - - default: - throw new Error( - "Unsupported ModuleImport of type " + - JSON.stringify(field.descr.type) - ); - } - break; - } - case "Memory": { - moduleContext.addMemory(field.limits.min, field.limits.max); - break; - } - } - }); - - return moduleContext; -} - -/** - * Module context for type checking - */ -export class ModuleContext { - constructor() { - this.funcs = []; - this.funcsOffsetByIdentifier = []; - - this.types = []; - - this.globals = []; - this.globalsOffsetByIdentifier = []; - - this.mems = []; - - // Current stack frame - this.locals = []; - this.labels = []; - this.return = []; - - this.debugName = "unknown"; - - this.start = null; - } - - /** - * Set start segment - */ - setStart(index) { - this.start = index.value; - } - - /** - * Get start function - */ - getStart() { - return this.start; - } - - /** - * Reset the active stack frame - */ - newContext(debugName, expectedResult) { - this.locals = []; - this.labels = [expectedResult]; - this.return = expectedResult; - this.debugName = debugName; - } - - /** - * Functions - */ - addFunction(func /*: Func*/) { - // eslint-disable-next-line prefer-const - let { params: args = [], results: result = [] } = func.signature || {}; - - args = args.map(arg => arg.valtype); - - this.funcs.push({ args, result }); - - if (typeof func.name !== "undefined") { - this.funcsOffsetByIdentifier[func.name.value] = this.funcs.length - 1; - } - } - - importFunction(funcimport) { - if (isSignature(funcimport.signature)) { - // eslint-disable-next-line prefer-const - let { params: args, results: result } = funcimport.signature; - args = args.map(arg => arg.valtype); - - this.funcs.push({ args, result }); - } else { - assert(isNumberLiteral(funcimport.signature)); - - const typeId = funcimport.signature.value; - assert(this.hasType(typeId)); - - const signature = this.getType(typeId); - this.funcs.push({ - args: signature.params.map(arg => arg.valtype), - result: signature.results - }); - } - - if (typeof funcimport.id !== "undefined") { - // imports are first, we can assume their index in the array - this.funcsOffsetByIdentifier[funcimport.id.value] = this.funcs.length - 1; - } - } - - hasFunction(index) { - return typeof this.getFunction(index) !== "undefined"; - } - - getFunction(index) { - if (typeof index !== "number") { - throw new Error("getFunction only supported for number index"); - } - - return this.funcs[index]; - } - - getFunctionOffsetByIdentifier(name) { - assert(typeof name === "string"); - - return this.funcsOffsetByIdentifier[name]; - } - - /** - * Labels - */ - addLabel(result) { - this.labels.unshift(result); - } - - hasLabel(index) { - return this.labels.length > index && index >= 0; - } - - getLabel(index) { - return this.labels[index]; - } - - popLabel() { - this.labels.shift(); - } - - /** - * Locals - */ - hasLocal(index) { - return typeof this.getLocal(index) !== "undefined"; - } - - getLocal(index) { - return this.locals[index]; - } - - addLocal(type) { - this.locals.push(type); - } - - /** - * Types - */ - addType(type) { - assert(type.functype.type === "Signature"); - this.types.push(type.functype); - } - - hasType(index) { - return this.types[index] !== undefined; - } - - getType(index) { - return this.types[index]; - } - - /** - * Globals - */ - hasGlobal(index) { - return this.globals.length > index && index >= 0; - } - - getGlobal(index) { - return this.globals[index].type; - } - - getGlobalOffsetByIdentifier(name) { - assert(typeof name === "string"); - - return this.globalsOffsetByIdentifier[name]; - } - - defineGlobal(global /*: Global*/) { - const type = global.globalType.valtype; - const mutability = global.globalType.mutability; - - this.globals.push({ type, mutability }); - - if (typeof global.name !== "undefined") { - this.globalsOffsetByIdentifier[global.name.value] = - this.globals.length - 1; - } - } - - importGlobal(type, mutability) { - this.globals.push({ type, mutability }); - } - - isMutableGlobal(index) { - return this.globals[index].mutability === "var"; - } - - isImmutableGlobal(index) { - return this.globals[index].mutability === "const"; - } - - /** - * Memories - */ - hasMemory(index) { - return this.mems.length > index && index >= 0; - } - - addMemory(min, max) { - this.mems.push({ min, max }); - } - - getMemory(index) { - return this.mems[index]; - } -} diff --git a/node_modules/@webassemblyjs/helper-module-context/test/index.js b/node_modules/@webassemblyjs/helper-module-context/test/index.js deleted file mode 100644 index 2fbf58c..0000000 --- a/node_modules/@webassemblyjs/helper-module-context/test/index.js +++ /dev/null @@ -1,100 +0,0 @@ -const { assert } = require("chai"); -const { parse } = require("@webassemblyjs/wast-parser"); - -const { moduleContextFromModuleAST } = require("../lib"); - -const contextFromWast = wast => moduleContextFromModuleAST(parse(wast).body[0]); - -describe("module context", () => { - describe("start segment", () => { - it("should return the start function offset", () => { - const context = contextFromWast(` - (module - (func) - (func) - (start 1) - ) - `); - - assert.isOk(context.getStart()); - assert.typeOf(context.getStart(), "number"); - assert.equal(context.getStart(), 1); - }); - - it("should return null if no start function", () => { - const context = contextFromWast(` - (module (func)) - `); - - assert.isNull(context.getStart()); - }); - - it("should retrive the type of implemented functions", () => { - const context = contextFromWast(` - (module - (func (param i32) (result i64)) - (func (param i64) (result i32)) - (func (result i64)) - (func) - ) - `); - - assert.deepEqual(context.getFunction(0), { - args: ["i32"], - result: ["i64"] - }); - assert.deepEqual(context.getFunction(1), { - args: ["i64"], - result: ["i32"] - }); - assert.deepEqual(context.getFunction(2), { args: [], result: ["i64"] }); - assert.deepEqual(context.getFunction(3), { args: [], result: [] }); - }); - - it("should retrive the type of imported functions", () => { - const context = contextFromWast(` - (module - (import "a" "a" (func (param i32) (result i32))) - (import "a" "b" (func (result i64))) - (import "a" "c" (func)) - (func (result f32)) - ) - `); - - assert.deepEqual(context.getFunction(0), { - args: ["i32"], - result: ["i32"] - }); - assert.deepEqual(context.getFunction(1), { - args: [], - result: ["i64"] - }); - assert.deepEqual(context.getFunction(2), { args: [], result: [] }); - assert.deepEqual(context.getFunction(3), { args: [], result: ["f32"] }); - }); - - it("should retrive the type of functions with type ref", () => { - const context = contextFromWast(` - (module - (type (func (param i32) (result i32))) - (type (func (result i64))) - (type (func)) - - (import "a" "a" (func (type 0))) - (import "a" "b" (func (type 1))) - (func (type 2)) - ) - `); - - assert.deepEqual(context.getFunction(0), { - args: ["i32"], - result: ["i32"] - }); - assert.deepEqual(context.getFunction(1), { - args: [], - result: ["i64"] - }); - assert.deepEqual(context.getFunction(2), { args: [], result: [] }); - }); - }); -}); diff --git a/node_modules/@webassemblyjs/helper-wasm-bytecode/LICENSE b/node_modules/@webassemblyjs/helper-wasm-bytecode/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-bytecode/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/helper-wasm-bytecode/esm/index.js b/node_modules/@webassemblyjs/helper-wasm-bytecode/esm/index.js deleted file mode 100644 index be0bc83..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-bytecode/esm/index.js +++ /dev/null @@ -1,324 +0,0 @@ -var illegalop = "illegal"; -var magicModuleHeader = [0x00, 0x61, 0x73, 0x6d]; -var moduleVersion = [0x01, 0x00, 0x00, 0x00]; - -function invertMap(obj) { - var keyModifierFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (k) { - return k; - }; - var result = {}; - var keys = Object.keys(obj); - - for (var i = 0, length = keys.length; i < length; i++) { - result[keyModifierFn(obj[keys[i]])] = keys[i]; - } - - return result; -} - -function createSymbolObject(name -/*: string */ -, object -/*: string */ -) -/*: Symbol*/ -{ - var numberOfArgs - /*: number*/ - = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - return { - name: name, - object: object, - numberOfArgs: numberOfArgs - }; -} - -function createSymbol(name -/*: string */ -) -/*: Symbol*/ -{ - var numberOfArgs - /*: number*/ - = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - return { - name: name, - numberOfArgs: numberOfArgs - }; -} - -var types = { - func: 0x60, - result: 0x40 -}; -var exportTypes = { - 0x00: "Func", - 0x01: "Table", - 0x02: "Mem", - 0x03: "Global" -}; -var exportTypesByName = invertMap(exportTypes); -var valtypes = { - 0x7f: "i32", - 0x7e: "i64", - 0x7d: "f32", - 0x7c: "f64", - 0x7b: "v128" -}; -var valtypesByString = invertMap(valtypes); -var tableTypes = { - 0x70: "anyfunc" -}; -var blockTypes = Object.assign({}, valtypes, { - // https://webassembly.github.io/spec/core/binary/types.html#binary-blocktype - 0x40: null, - // https://webassembly.github.io/spec/core/binary/types.html#binary-valtype - 0x7f: "i32", - 0x7e: "i64", - 0x7d: "f32", - 0x7c: "f64" -}); -var globalTypes = { - 0x00: "const", - 0x01: "var" -}; -var globalTypesByString = invertMap(globalTypes); -var importTypes = { - 0x00: "func", - 0x01: "table", - 0x02: "mem", - 0x03: "global" -}; -var sections = { - custom: 0, - type: 1, - import: 2, - func: 3, - table: 4, - memory: 5, - global: 6, - export: 7, - start: 8, - element: 9, - code: 10, - data: 11 -}; -var symbolsByByte = { - 0x00: createSymbol("unreachable"), - 0x01: createSymbol("nop"), - 0x02: createSymbol("block"), - 0x03: createSymbol("loop"), - 0x04: createSymbol("if"), - 0x05: createSymbol("else"), - 0x06: illegalop, - 0x07: illegalop, - 0x08: illegalop, - 0x09: illegalop, - 0x0a: illegalop, - 0x0b: createSymbol("end"), - 0x0c: createSymbol("br", 1), - 0x0d: createSymbol("br_if", 1), - 0x0e: createSymbol("br_table"), - 0x0f: createSymbol("return"), - 0x10: createSymbol("call", 1), - 0x11: createSymbol("call_indirect", 2), - 0x12: illegalop, - 0x13: illegalop, - 0x14: illegalop, - 0x15: illegalop, - 0x16: illegalop, - 0x17: illegalop, - 0x18: illegalop, - 0x19: illegalop, - 0x1a: createSymbol("drop"), - 0x1b: createSymbol("select"), - 0x1c: illegalop, - 0x1d: illegalop, - 0x1e: illegalop, - 0x1f: illegalop, - 0x20: createSymbol("get_local", 1), - 0x21: createSymbol("set_local", 1), - 0x22: createSymbol("tee_local", 1), - 0x23: createSymbol("get_global", 1), - 0x24: createSymbol("set_global", 1), - 0x25: illegalop, - 0x26: illegalop, - 0x27: illegalop, - 0x28: createSymbolObject("load", "u32", 1), - 0x29: createSymbolObject("load", "u64", 1), - 0x2a: createSymbolObject("load", "f32", 1), - 0x2b: createSymbolObject("load", "f64", 1), - 0x2c: createSymbolObject("load8_s", "u32", 1), - 0x2d: createSymbolObject("load8_u", "u32", 1), - 0x2e: createSymbolObject("load16_s", "u32", 1), - 0x2f: createSymbolObject("load16_u", "u32", 1), - 0x30: createSymbolObject("load8_s", "u64", 1), - 0x31: createSymbolObject("load8_u", "u64", 1), - 0x32: createSymbolObject("load16_s", "u64", 1), - 0x33: createSymbolObject("load16_u", "u64", 1), - 0x34: createSymbolObject("load32_s", "u64", 1), - 0x35: createSymbolObject("load32_u", "u64", 1), - 0x36: createSymbolObject("store", "u32", 1), - 0x37: createSymbolObject("store", "u64", 1), - 0x38: createSymbolObject("store", "f32", 1), - 0x39: createSymbolObject("store", "f64", 1), - 0x3a: createSymbolObject("store8", "u32", 1), - 0x3b: createSymbolObject("store16", "u32", 1), - 0x3c: createSymbolObject("store8", "u64", 1), - 0x3d: createSymbolObject("store16", "u64", 1), - 0x3e: createSymbolObject("store32", "u64", 1), - 0x3f: createSymbolObject("current_memory"), - 0x40: createSymbolObject("grow_memory"), - 0x41: createSymbolObject("const", "i32", 1), - 0x42: createSymbolObject("const", "i64", 1), - 0x43: createSymbolObject("const", "f32", 1), - 0x44: createSymbolObject("const", "f64", 1), - 0x45: createSymbolObject("eqz", "i32"), - 0x46: createSymbolObject("eq", "i32"), - 0x47: createSymbolObject("ne", "i32"), - 0x48: createSymbolObject("lt_s", "i32"), - 0x49: createSymbolObject("lt_u", "i32"), - 0x4a: createSymbolObject("gt_s", "i32"), - 0x4b: createSymbolObject("gt_u", "i32"), - 0x4c: createSymbolObject("le_s", "i32"), - 0x4d: createSymbolObject("le_u", "i32"), - 0x4e: createSymbolObject("ge_s", "i32"), - 0x4f: createSymbolObject("ge_u", "i32"), - 0x50: createSymbolObject("eqz", "i64"), - 0x51: createSymbolObject("eq", "i64"), - 0x52: createSymbolObject("ne", "i64"), - 0x53: createSymbolObject("lt_s", "i64"), - 0x54: createSymbolObject("lt_u", "i64"), - 0x55: createSymbolObject("gt_s", "i64"), - 0x56: createSymbolObject("gt_u", "i64"), - 0x57: createSymbolObject("le_s", "i64"), - 0x58: createSymbolObject("le_u", "i64"), - 0x59: createSymbolObject("ge_s", "i64"), - 0x5a: createSymbolObject("ge_u", "i64"), - 0x5b: createSymbolObject("eq", "f32"), - 0x5c: createSymbolObject("ne", "f32"), - 0x5d: createSymbolObject("lt", "f32"), - 0x5e: createSymbolObject("gt", "f32"), - 0x5f: createSymbolObject("le", "f32"), - 0x60: createSymbolObject("ge", "f32"), - 0x61: createSymbolObject("eq", "f64"), - 0x62: createSymbolObject("ne", "f64"), - 0x63: createSymbolObject("lt", "f64"), - 0x64: createSymbolObject("gt", "f64"), - 0x65: createSymbolObject("le", "f64"), - 0x66: createSymbolObject("ge", "f64"), - 0x67: createSymbolObject("clz", "i32"), - 0x68: createSymbolObject("ctz", "i32"), - 0x69: createSymbolObject("popcnt", "i32"), - 0x6a: createSymbolObject("add", "i32"), - 0x6b: createSymbolObject("sub", "i32"), - 0x6c: createSymbolObject("mul", "i32"), - 0x6d: createSymbolObject("div_s", "i32"), - 0x6e: createSymbolObject("div_u", "i32"), - 0x6f: createSymbolObject("rem_s", "i32"), - 0x70: createSymbolObject("rem_u", "i32"), - 0x71: createSymbolObject("and", "i32"), - 0x72: createSymbolObject("or", "i32"), - 0x73: createSymbolObject("xor", "i32"), - 0x74: createSymbolObject("shl", "i32"), - 0x75: createSymbolObject("shr_s", "i32"), - 0x76: createSymbolObject("shr_u", "i32"), - 0x77: createSymbolObject("rotl", "i32"), - 0x78: createSymbolObject("rotr", "i32"), - 0x79: createSymbolObject("clz", "i64"), - 0x7a: createSymbolObject("ctz", "i64"), - 0x7b: createSymbolObject("popcnt", "i64"), - 0x7c: createSymbolObject("add", "i64"), - 0x7d: createSymbolObject("sub", "i64"), - 0x7e: createSymbolObject("mul", "i64"), - 0x7f: createSymbolObject("div_s", "i64"), - 0x80: createSymbolObject("div_u", "i64"), - 0x81: createSymbolObject("rem_s", "i64"), - 0x82: createSymbolObject("rem_u", "i64"), - 0x83: createSymbolObject("and", "i64"), - 0x84: createSymbolObject("or", "i64"), - 0x85: createSymbolObject("xor", "i64"), - 0x86: createSymbolObject("shl", "i64"), - 0x87: createSymbolObject("shr_s", "i64"), - 0x88: createSymbolObject("shr_u", "i64"), - 0x89: createSymbolObject("rotl", "i64"), - 0x8a: createSymbolObject("rotr", "i64"), - 0x8b: createSymbolObject("abs", "f32"), - 0x8c: createSymbolObject("neg", "f32"), - 0x8d: createSymbolObject("ceil", "f32"), - 0x8e: createSymbolObject("floor", "f32"), - 0x8f: createSymbolObject("trunc", "f32"), - 0x90: createSymbolObject("nearest", "f32"), - 0x91: createSymbolObject("sqrt", "f32"), - 0x92: createSymbolObject("add", "f32"), - 0x93: createSymbolObject("sub", "f32"), - 0x94: createSymbolObject("mul", "f32"), - 0x95: createSymbolObject("div", "f32"), - 0x96: createSymbolObject("min", "f32"), - 0x97: createSymbolObject("max", "f32"), - 0x98: createSymbolObject("copysign", "f32"), - 0x99: createSymbolObject("abs", "f64"), - 0x9a: createSymbolObject("neg", "f64"), - 0x9b: createSymbolObject("ceil", "f64"), - 0x9c: createSymbolObject("floor", "f64"), - 0x9d: createSymbolObject("trunc", "f64"), - 0x9e: createSymbolObject("nearest", "f64"), - 0x9f: createSymbolObject("sqrt", "f64"), - 0xa0: createSymbolObject("add", "f64"), - 0xa1: createSymbolObject("sub", "f64"), - 0xa2: createSymbolObject("mul", "f64"), - 0xa3: createSymbolObject("div", "f64"), - 0xa4: createSymbolObject("min", "f64"), - 0xa5: createSymbolObject("max", "f64"), - 0xa6: createSymbolObject("copysign", "f64"), - 0xa7: createSymbolObject("wrap/i64", "i32"), - 0xa8: createSymbolObject("trunc_s/f32", "i32"), - 0xa9: createSymbolObject("trunc_u/f32", "i32"), - 0xaa: createSymbolObject("trunc_s/f64", "i32"), - 0xab: createSymbolObject("trunc_u/f64", "i32"), - 0xac: createSymbolObject("extend_s/i32", "i64"), - 0xad: createSymbolObject("extend_u/i32", "i64"), - 0xae: createSymbolObject("trunc_s/f32", "i64"), - 0xaf: createSymbolObject("trunc_u/f32", "i64"), - 0xb0: createSymbolObject("trunc_s/f64", "i64"), - 0xb1: createSymbolObject("trunc_u/f64", "i64"), - 0xb2: createSymbolObject("convert_s/i32", "f32"), - 0xb3: createSymbolObject("convert_u/i32", "f32"), - 0xb4: createSymbolObject("convert_s/i64", "f32"), - 0xb5: createSymbolObject("convert_u/i64", "f32"), - 0xb6: createSymbolObject("demote/f64", "f32"), - 0xb7: createSymbolObject("convert_s/i32", "f64"), - 0xb8: createSymbolObject("convert_u/i32", "f64"), - 0xb9: createSymbolObject("convert_s/i64", "f64"), - 0xba: createSymbolObject("convert_u/i64", "f64"), - 0xbb: createSymbolObject("promote/f32", "f64"), - 0xbc: createSymbolObject("reinterpret/f32", "i32"), - 0xbd: createSymbolObject("reinterpret/f64", "i64"), - 0xbe: createSymbolObject("reinterpret/i32", "f32"), - 0xbf: createSymbolObject("reinterpret/i64", "f64") -}; -var symbolsByName = invertMap(symbolsByByte, function (obj) { - if (typeof obj.object === "string") { - return "".concat(obj.object, ".").concat(obj.name); - } - - return obj.name; -}); -export default { - symbolsByByte: symbolsByByte, - sections: sections, - magicModuleHeader: magicModuleHeader, - moduleVersion: moduleVersion, - types: types, - valtypes: valtypes, - exportTypes: exportTypes, - blockTypes: blockTypes, - tableTypes: tableTypes, - globalTypes: globalTypes, - importTypes: importTypes, - valtypesByString: valtypesByString, - globalTypesByString: globalTypesByString, - exportTypesByName: exportTypesByName, - symbolsByName: symbolsByName -}; -export { getSectionForNode } from "./section";
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-wasm-bytecode/esm/section.js b/node_modules/@webassemblyjs/helper-wasm-bytecode/esm/section.js deleted file mode 100644 index abdc4cf..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-bytecode/esm/section.js +++ /dev/null @@ -1,31 +0,0 @@ -export function getSectionForNode(n) { - switch (n.type) { - case "ModuleImport": - return "import"; - - case "CallInstruction": - case "CallIndirectInstruction": - case "Func": - case "Instr": - return "code"; - - case "ModuleExport": - return "export"; - - case "Start": - return "start"; - - case "TypeInstruction": - return "type"; - - case "IndexInFuncSection": - return "func"; - - case "Global": - return "global"; - // No section - - default: - return; - } -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/index.js b/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/index.js deleted file mode 100644 index 7239e10..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/index.js +++ /dev/null @@ -1,339 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "getSectionForNode", { - enumerable: true, - get: function get() { - return _section.getSectionForNode; - } -}); -exports.default = void 0; - -var _section = require("./section"); - -var illegalop = "illegal"; -var magicModuleHeader = [0x00, 0x61, 0x73, 0x6d]; -var moduleVersion = [0x01, 0x00, 0x00, 0x00]; - -function invertMap(obj) { - var keyModifierFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (k) { - return k; - }; - var result = {}; - var keys = Object.keys(obj); - - for (var i = 0, length = keys.length; i < length; i++) { - result[keyModifierFn(obj[keys[i]])] = keys[i]; - } - - return result; -} - -function createSymbolObject(name -/*: string */ -, object -/*: string */ -) -/*: Symbol*/ -{ - var numberOfArgs - /*: number*/ - = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; - return { - name: name, - object: object, - numberOfArgs: numberOfArgs - }; -} - -function createSymbol(name -/*: string */ -) -/*: Symbol*/ -{ - var numberOfArgs - /*: number*/ - = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - return { - name: name, - numberOfArgs: numberOfArgs - }; -} - -var types = { - func: 0x60, - result: 0x40 -}; -var exportTypes = { - 0x00: "Func", - 0x01: "Table", - 0x02: "Mem", - 0x03: "Global" -}; -var exportTypesByName = invertMap(exportTypes); -var valtypes = { - 0x7f: "i32", - 0x7e: "i64", - 0x7d: "f32", - 0x7c: "f64", - 0x7b: "v128" -}; -var valtypesByString = invertMap(valtypes); -var tableTypes = { - 0x70: "anyfunc" -}; -var blockTypes = Object.assign({}, valtypes, { - // https://webassembly.github.io/spec/core/binary/types.html#binary-blocktype - 0x40: null, - // https://webassembly.github.io/spec/core/binary/types.html#binary-valtype - 0x7f: "i32", - 0x7e: "i64", - 0x7d: "f32", - 0x7c: "f64" -}); -var globalTypes = { - 0x00: "const", - 0x01: "var" -}; -var globalTypesByString = invertMap(globalTypes); -var importTypes = { - 0x00: "func", - 0x01: "table", - 0x02: "mem", - 0x03: "global" -}; -var sections = { - custom: 0, - type: 1, - import: 2, - func: 3, - table: 4, - memory: 5, - global: 6, - export: 7, - start: 8, - element: 9, - code: 10, - data: 11 -}; -var symbolsByByte = { - 0x00: createSymbol("unreachable"), - 0x01: createSymbol("nop"), - 0x02: createSymbol("block"), - 0x03: createSymbol("loop"), - 0x04: createSymbol("if"), - 0x05: createSymbol("else"), - 0x06: illegalop, - 0x07: illegalop, - 0x08: illegalop, - 0x09: illegalop, - 0x0a: illegalop, - 0x0b: createSymbol("end"), - 0x0c: createSymbol("br", 1), - 0x0d: createSymbol("br_if", 1), - 0x0e: createSymbol("br_table"), - 0x0f: createSymbol("return"), - 0x10: createSymbol("call", 1), - 0x11: createSymbol("call_indirect", 2), - 0x12: illegalop, - 0x13: illegalop, - 0x14: illegalop, - 0x15: illegalop, - 0x16: illegalop, - 0x17: illegalop, - 0x18: illegalop, - 0x19: illegalop, - 0x1a: createSymbol("drop"), - 0x1b: createSymbol("select"), - 0x1c: illegalop, - 0x1d: illegalop, - 0x1e: illegalop, - 0x1f: illegalop, - 0x20: createSymbol("get_local", 1), - 0x21: createSymbol("set_local", 1), - 0x22: createSymbol("tee_local", 1), - 0x23: createSymbol("get_global", 1), - 0x24: createSymbol("set_global", 1), - 0x25: illegalop, - 0x26: illegalop, - 0x27: illegalop, - 0x28: createSymbolObject("load", "u32", 1), - 0x29: createSymbolObject("load", "u64", 1), - 0x2a: createSymbolObject("load", "f32", 1), - 0x2b: createSymbolObject("load", "f64", 1), - 0x2c: createSymbolObject("load8_s", "u32", 1), - 0x2d: createSymbolObject("load8_u", "u32", 1), - 0x2e: createSymbolObject("load16_s", "u32", 1), - 0x2f: createSymbolObject("load16_u", "u32", 1), - 0x30: createSymbolObject("load8_s", "u64", 1), - 0x31: createSymbolObject("load8_u", "u64", 1), - 0x32: createSymbolObject("load16_s", "u64", 1), - 0x33: createSymbolObject("load16_u", "u64", 1), - 0x34: createSymbolObject("load32_s", "u64", 1), - 0x35: createSymbolObject("load32_u", "u64", 1), - 0x36: createSymbolObject("store", "u32", 1), - 0x37: createSymbolObject("store", "u64", 1), - 0x38: createSymbolObject("store", "f32", 1), - 0x39: createSymbolObject("store", "f64", 1), - 0x3a: createSymbolObject("store8", "u32", 1), - 0x3b: createSymbolObject("store16", "u32", 1), - 0x3c: createSymbolObject("store8", "u64", 1), - 0x3d: createSymbolObject("store16", "u64", 1), - 0x3e: createSymbolObject("store32", "u64", 1), - 0x3f: createSymbolObject("current_memory"), - 0x40: createSymbolObject("grow_memory"), - 0x41: createSymbolObject("const", "i32", 1), - 0x42: createSymbolObject("const", "i64", 1), - 0x43: createSymbolObject("const", "f32", 1), - 0x44: createSymbolObject("const", "f64", 1), - 0x45: createSymbolObject("eqz", "i32"), - 0x46: createSymbolObject("eq", "i32"), - 0x47: createSymbolObject("ne", "i32"), - 0x48: createSymbolObject("lt_s", "i32"), - 0x49: createSymbolObject("lt_u", "i32"), - 0x4a: createSymbolObject("gt_s", "i32"), - 0x4b: createSymbolObject("gt_u", "i32"), - 0x4c: createSymbolObject("le_s", "i32"), - 0x4d: createSymbolObject("le_u", "i32"), - 0x4e: createSymbolObject("ge_s", "i32"), - 0x4f: createSymbolObject("ge_u", "i32"), - 0x50: createSymbolObject("eqz", "i64"), - 0x51: createSymbolObject("eq", "i64"), - 0x52: createSymbolObject("ne", "i64"), - 0x53: createSymbolObject("lt_s", "i64"), - 0x54: createSymbolObject("lt_u", "i64"), - 0x55: createSymbolObject("gt_s", "i64"), - 0x56: createSymbolObject("gt_u", "i64"), - 0x57: createSymbolObject("le_s", "i64"), - 0x58: createSymbolObject("le_u", "i64"), - 0x59: createSymbolObject("ge_s", "i64"), - 0x5a: createSymbolObject("ge_u", "i64"), - 0x5b: createSymbolObject("eq", "f32"), - 0x5c: createSymbolObject("ne", "f32"), - 0x5d: createSymbolObject("lt", "f32"), - 0x5e: createSymbolObject("gt", "f32"), - 0x5f: createSymbolObject("le", "f32"), - 0x60: createSymbolObject("ge", "f32"), - 0x61: createSymbolObject("eq", "f64"), - 0x62: createSymbolObject("ne", "f64"), - 0x63: createSymbolObject("lt", "f64"), - 0x64: createSymbolObject("gt", "f64"), - 0x65: createSymbolObject("le", "f64"), - 0x66: createSymbolObject("ge", "f64"), - 0x67: createSymbolObject("clz", "i32"), - 0x68: createSymbolObject("ctz", "i32"), - 0x69: createSymbolObject("popcnt", "i32"), - 0x6a: createSymbolObject("add", "i32"), - 0x6b: createSymbolObject("sub", "i32"), - 0x6c: createSymbolObject("mul", "i32"), - 0x6d: createSymbolObject("div_s", "i32"), - 0x6e: createSymbolObject("div_u", "i32"), - 0x6f: createSymbolObject("rem_s", "i32"), - 0x70: createSymbolObject("rem_u", "i32"), - 0x71: createSymbolObject("and", "i32"), - 0x72: createSymbolObject("or", "i32"), - 0x73: createSymbolObject("xor", "i32"), - 0x74: createSymbolObject("shl", "i32"), - 0x75: createSymbolObject("shr_s", "i32"), - 0x76: createSymbolObject("shr_u", "i32"), - 0x77: createSymbolObject("rotl", "i32"), - 0x78: createSymbolObject("rotr", "i32"), - 0x79: createSymbolObject("clz", "i64"), - 0x7a: createSymbolObject("ctz", "i64"), - 0x7b: createSymbolObject("popcnt", "i64"), - 0x7c: createSymbolObject("add", "i64"), - 0x7d: createSymbolObject("sub", "i64"), - 0x7e: createSymbolObject("mul", "i64"), - 0x7f: createSymbolObject("div_s", "i64"), - 0x80: createSymbolObject("div_u", "i64"), - 0x81: createSymbolObject("rem_s", "i64"), - 0x82: createSymbolObject("rem_u", "i64"), - 0x83: createSymbolObject("and", "i64"), - 0x84: createSymbolObject("or", "i64"), - 0x85: createSymbolObject("xor", "i64"), - 0x86: createSymbolObject("shl", "i64"), - 0x87: createSymbolObject("shr_s", "i64"), - 0x88: createSymbolObject("shr_u", "i64"), - 0x89: createSymbolObject("rotl", "i64"), - 0x8a: createSymbolObject("rotr", "i64"), - 0x8b: createSymbolObject("abs", "f32"), - 0x8c: createSymbolObject("neg", "f32"), - 0x8d: createSymbolObject("ceil", "f32"), - 0x8e: createSymbolObject("floor", "f32"), - 0x8f: createSymbolObject("trunc", "f32"), - 0x90: createSymbolObject("nearest", "f32"), - 0x91: createSymbolObject("sqrt", "f32"), - 0x92: createSymbolObject("add", "f32"), - 0x93: createSymbolObject("sub", "f32"), - 0x94: createSymbolObject("mul", "f32"), - 0x95: createSymbolObject("div", "f32"), - 0x96: createSymbolObject("min", "f32"), - 0x97: createSymbolObject("max", "f32"), - 0x98: createSymbolObject("copysign", "f32"), - 0x99: createSymbolObject("abs", "f64"), - 0x9a: createSymbolObject("neg", "f64"), - 0x9b: createSymbolObject("ceil", "f64"), - 0x9c: createSymbolObject("floor", "f64"), - 0x9d: createSymbolObject("trunc", "f64"), - 0x9e: createSymbolObject("nearest", "f64"), - 0x9f: createSymbolObject("sqrt", "f64"), - 0xa0: createSymbolObject("add", "f64"), - 0xa1: createSymbolObject("sub", "f64"), - 0xa2: createSymbolObject("mul", "f64"), - 0xa3: createSymbolObject("div", "f64"), - 0xa4: createSymbolObject("min", "f64"), - 0xa5: createSymbolObject("max", "f64"), - 0xa6: createSymbolObject("copysign", "f64"), - 0xa7: createSymbolObject("wrap/i64", "i32"), - 0xa8: createSymbolObject("trunc_s/f32", "i32"), - 0xa9: createSymbolObject("trunc_u/f32", "i32"), - 0xaa: createSymbolObject("trunc_s/f64", "i32"), - 0xab: createSymbolObject("trunc_u/f64", "i32"), - 0xac: createSymbolObject("extend_s/i32", "i64"), - 0xad: createSymbolObject("extend_u/i32", "i64"), - 0xae: createSymbolObject("trunc_s/f32", "i64"), - 0xaf: createSymbolObject("trunc_u/f32", "i64"), - 0xb0: createSymbolObject("trunc_s/f64", "i64"), - 0xb1: createSymbolObject("trunc_u/f64", "i64"), - 0xb2: createSymbolObject("convert_s/i32", "f32"), - 0xb3: createSymbolObject("convert_u/i32", "f32"), - 0xb4: createSymbolObject("convert_s/i64", "f32"), - 0xb5: createSymbolObject("convert_u/i64", "f32"), - 0xb6: createSymbolObject("demote/f64", "f32"), - 0xb7: createSymbolObject("convert_s/i32", "f64"), - 0xb8: createSymbolObject("convert_u/i32", "f64"), - 0xb9: createSymbolObject("convert_s/i64", "f64"), - 0xba: createSymbolObject("convert_u/i64", "f64"), - 0xbb: createSymbolObject("promote/f32", "f64"), - 0xbc: createSymbolObject("reinterpret/f32", "i32"), - 0xbd: createSymbolObject("reinterpret/f64", "i64"), - 0xbe: createSymbolObject("reinterpret/i32", "f32"), - 0xbf: createSymbolObject("reinterpret/i64", "f64") -}; -var symbolsByName = invertMap(symbolsByByte, function (obj) { - if (typeof obj.object === "string") { - return "".concat(obj.object, ".").concat(obj.name); - } - - return obj.name; -}); -var _default = { - symbolsByByte: symbolsByByte, - sections: sections, - magicModuleHeader: magicModuleHeader, - moduleVersion: moduleVersion, - types: types, - valtypes: valtypes, - exportTypes: exportTypes, - blockTypes: blockTypes, - tableTypes: tableTypes, - globalTypes: globalTypes, - importTypes: importTypes, - valtypesByString: valtypesByString, - globalTypesByString: globalTypesByString, - exportTypesByName: exportTypesByName, - symbolsByName: symbolsByName -}; -exports.default = _default;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/section.js b/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/section.js deleted file mode 100644 index 23f6b2b..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-bytecode/lib/section.js +++ /dev/null @@ -1,38 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.getSectionForNode = getSectionForNode; - -function getSectionForNode(n) { - switch (n.type) { - case "ModuleImport": - return "import"; - - case "CallInstruction": - case "CallIndirectInstruction": - case "Func": - case "Instr": - return "code"; - - case "ModuleExport": - return "export"; - - case "Start": - return "start"; - - case "TypeInstruction": - return "type"; - - case "IndexInFuncSection": - return "func"; - - case "Global": - return "global"; - // No section - - default: - return; - } -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-wasm-bytecode/package.json b/node_modules/@webassemblyjs/helper-wasm-bytecode/package.json deleted file mode 100644 index da03565..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-bytecode/package.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "_from": "@webassemblyjs/helper-wasm-bytecode@1.9.0", - "_id": "@webassemblyjs/helper-wasm-bytecode@1.9.0", - "_inBundle": false, - "_integrity": "sha512-R7FStIzyNcd7xKxCZH5lE0Bqy+hGTwS3LJjuv1ZVxd9O7eHCedSdrId/hMOd20I+v8wDXEn+bjfKDLzTepoaUw==", - "_location": "/@webassemblyjs/helper-wasm-bytecode", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/helper-wasm-bytecode@1.9.0", - "name": "@webassemblyjs/helper-wasm-bytecode", - "escapedName": "@webassemblyjs%2fhelper-wasm-bytecode", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/ast", - "/@webassemblyjs/helper-wasm-section", - "/@webassemblyjs/wasm-edit", - "/@webassemblyjs/wasm-gen", - "/@webassemblyjs/wasm-parser" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.9.0.tgz", - "_shasum": "4fed8beac9b8c14f8c58b70d124d549dd1fe5790", - "_spec": "@webassemblyjs/helper-wasm-bytecode@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/ast", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "deprecated": false, - "description": "WASM's Bytecode constants", - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/helper-wasm-bytecode", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/helper-wasm-section/LICENSE b/node_modules/@webassemblyjs/helper-wasm-section/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-section/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/helper-wasm-section/esm/create.js b/node_modules/@webassemblyjs/helper-wasm-section/esm/create.js deleted file mode 100644 index 3797978..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-section/esm/create.js +++ /dev/null @@ -1,107 +0,0 @@ -function _typeof(obj) { 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); } - -import { encodeNode } from "@webassemblyjs/wasm-gen"; -import { overrideBytesInBuffer } from "@webassemblyjs/helper-buffer"; -import constants from "@webassemblyjs/helper-wasm-bytecode"; -import * as t from "@webassemblyjs/ast"; - -function findLastSection(ast, forSection) { - var targetSectionId = constants.sections[forSection]; // $FlowIgnore: metadata can not be empty - - var moduleSections = ast.body[0].metadata.sections; - var lastSection; - var lastId = 0; - - for (var i = 0, len = moduleSections.length; i < len; i++) { - var section = moduleSections[i]; // Ignore custom section since they can actually occur everywhere - - if (section.section === "custom") { - continue; - } - - var sectionId = constants.sections[section.section]; - - if (targetSectionId > lastId && targetSectionId < sectionId) { - return lastSection; - } - - lastId = sectionId; - lastSection = section; - } - - return lastSection; -} - -export function createEmptySection(ast, uint8Buffer, section) { - // previous section after which we are going to insert our section - var lastSection = findLastSection(ast, section); - var start, end; - /** - * It's the first section - */ - - if (lastSection == null || lastSection.section === "custom") { - start = 8 - /* wasm header size */ - ; - end = start; - } else { - start = lastSection.startOffset + lastSection.size.value + 1; - end = start; - } // section id - - - start += 1; - var sizeStartLoc = { - line: -1, - column: start - }; - var sizeEndLoc = { - line: -1, - column: start + 1 - }; // 1 byte for the empty vector - - var size = t.withLoc(t.numberLiteralFromRaw(1), sizeEndLoc, sizeStartLoc); - var vectorOfSizeStartLoc = { - line: -1, - column: sizeEndLoc.column - }; - var vectorOfSizeEndLoc = { - line: -1, - column: sizeEndLoc.column + 1 - }; - var vectorOfSize = t.withLoc(t.numberLiteralFromRaw(0), vectorOfSizeEndLoc, vectorOfSizeStartLoc); - var sectionMetadata = t.sectionMetadata(section, start, size, vectorOfSize); - var sectionBytes = encodeNode(sectionMetadata); - uint8Buffer = overrideBytesInBuffer(uint8Buffer, start - 1, end, sectionBytes); // Add section into the AST for later lookups - - if (_typeof(ast.body[0].metadata) === "object") { - // $FlowIgnore: metadata can not be empty - ast.body[0].metadata.sections.push(sectionMetadata); - t.sortSectionMetadata(ast.body[0]); - } - /** - * Update AST - */ - // Once we hit our section every that is after needs to be shifted by the delta - - - var deltaBytes = +sectionBytes.length; - var encounteredSection = false; - t.traverse(ast, { - SectionMetadata: function SectionMetadata(path) { - if (path.node.section === section) { - encounteredSection = true; - return; - } - - if (encounteredSection === true) { - t.shiftSection(ast, path.node, deltaBytes); - } - } - }); - return { - uint8Buffer: uint8Buffer, - sectionMetadata: sectionMetadata - }; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-wasm-section/esm/index.js b/node_modules/@webassemblyjs/helper-wasm-section/esm/index.js deleted file mode 100644 index 91afb0a..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-section/esm/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export { resizeSectionByteSize, resizeSectionVecSize } from "./resize"; -export { createEmptySection } from "./create"; -export { removeSections } from "./remove";
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-wasm-section/esm/remove.js b/node_modules/@webassemblyjs/helper-wasm-section/esm/remove.js deleted file mode 100644 index 3ed85a0..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-section/esm/remove.js +++ /dev/null @@ -1,36 +0,0 @@ -import { traverse, getSectionMetadatas, shiftSection } from "@webassemblyjs/ast"; -import { overrideBytesInBuffer } from "@webassemblyjs/helper-buffer"; -export function removeSections(ast, uint8Buffer, section) { - var sectionMetadatas = getSectionMetadatas(ast, section); - - if (sectionMetadatas.length === 0) { - throw new Error("Section metadata not found"); - } - - return sectionMetadatas.reverse().reduce(function (uint8Buffer, sectionMetadata) { - var startsIncludingId = sectionMetadata.startOffset - 1; - var ends = section === "start" ? sectionMetadata.size.loc.end.column + 1 : sectionMetadata.startOffset + sectionMetadata.size.value + 1; - var delta = -(ends - startsIncludingId); - /** - * update AST - */ - // Once we hit our section every that is after needs to be shifted by the delta - - var encounteredSection = false; - traverse(ast, { - SectionMetadata: function SectionMetadata(path) { - if (path.node.section === section) { - encounteredSection = true; - return path.remove(); - } - - if (encounteredSection === true) { - shiftSection(ast, path.node, delta); - } - } - }); // replacement is nothing - - var replacement = []; - return overrideBytesInBuffer(uint8Buffer, startsIncludingId, ends, replacement); - }, uint8Buffer); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-wasm-section/esm/resize.js b/node_modules/@webassemblyjs/helper-wasm-section/esm/resize.js deleted file mode 100644 index 9792078..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-section/esm/resize.js +++ /dev/null @@ -1,78 +0,0 @@ -import { encodeU32 } from "@webassemblyjs/wasm-gen"; -import { getSectionMetadata, traverse, shiftSection } from "@webassemblyjs/ast"; -import { overrideBytesInBuffer } from "@webassemblyjs/helper-buffer"; -export function resizeSectionByteSize(ast, uint8Buffer, section, deltaBytes) { - var sectionMetadata = getSectionMetadata(ast, section); - - if (typeof sectionMetadata === "undefined") { - throw new Error("Section metadata not found"); - } - - if (typeof sectionMetadata.size.loc === "undefined") { - throw new Error("SectionMetadata " + section + " has no loc"); - } // keep old node location to be overriden - - - var start = sectionMetadata.size.loc.start.column; - var end = sectionMetadata.size.loc.end.column; - var newSectionSize = sectionMetadata.size.value + deltaBytes; - var newBytes = encodeU32(newSectionSize); - /** - * update AST - */ - - sectionMetadata.size.value = newSectionSize; - var oldu32EncodedLen = end - start; - var newu32EncodedLen = newBytes.length; // the new u32 has a different encoded length - - if (newu32EncodedLen !== oldu32EncodedLen) { - var deltaInSizeEncoding = newu32EncodedLen - oldu32EncodedLen; - sectionMetadata.size.loc.end.column = start + newu32EncodedLen; - deltaBytes += deltaInSizeEncoding; // move the vec size pointer size the section size is now smaller - - sectionMetadata.vectorOfSize.loc.start.column += deltaInSizeEncoding; - sectionMetadata.vectorOfSize.loc.end.column += deltaInSizeEncoding; - } // Once we hit our section every that is after needs to be shifted by the delta - - - var encounteredSection = false; - traverse(ast, { - SectionMetadata: function SectionMetadata(path) { - if (path.node.section === section) { - encounteredSection = true; - return; - } - - if (encounteredSection === true) { - shiftSection(ast, path.node, deltaBytes); - } - } - }); - return overrideBytesInBuffer(uint8Buffer, start, end, newBytes); -} -export function resizeSectionVecSize(ast, uint8Buffer, section, deltaElements) { - var sectionMetadata = getSectionMetadata(ast, section); - - if (typeof sectionMetadata === "undefined") { - throw new Error("Section metadata not found"); - } - - if (typeof sectionMetadata.vectorOfSize.loc === "undefined") { - throw new Error("SectionMetadata " + section + " has no loc"); - } // Section has no vector - - - if (sectionMetadata.vectorOfSize.value === -1) { - return uint8Buffer; - } // keep old node location to be overriden - - - var start = sectionMetadata.vectorOfSize.loc.start.column; - var end = sectionMetadata.vectorOfSize.loc.end.column; - var newValue = sectionMetadata.vectorOfSize.value + deltaElements; - var newBytes = encodeU32(newValue); // Update AST - - sectionMetadata.vectorOfSize.value = newValue; - sectionMetadata.vectorOfSize.loc.end.column = start + newBytes.length; - return overrideBytesInBuffer(uint8Buffer, start, end, newBytes); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-wasm-section/lib/create.js b/node_modules/@webassemblyjs/helper-wasm-section/lib/create.js deleted file mode 100644 index 9506eac..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-section/lib/create.js +++ /dev/null @@ -1,121 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.createEmptySection = createEmptySection; - -var _wasmGen = require("@webassemblyjs/wasm-gen"); - -var _helperBuffer = require("@webassemblyjs/helper-buffer"); - -var _helperWasmBytecode = _interopRequireDefault(require("@webassemblyjs/helper-wasm-bytecode")); - -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; } } - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _typeof(obj) { 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); } - -function findLastSection(ast, forSection) { - var targetSectionId = _helperWasmBytecode.default.sections[forSection]; // $FlowIgnore: metadata can not be empty - - var moduleSections = ast.body[0].metadata.sections; - var lastSection; - var lastId = 0; - - for (var i = 0, len = moduleSections.length; i < len; i++) { - var section = moduleSections[i]; // Ignore custom section since they can actually occur everywhere - - if (section.section === "custom") { - continue; - } - - var sectionId = _helperWasmBytecode.default.sections[section.section]; - - if (targetSectionId > lastId && targetSectionId < sectionId) { - return lastSection; - } - - lastId = sectionId; - lastSection = section; - } - - return lastSection; -} - -function createEmptySection(ast, uint8Buffer, section) { - // previous section after which we are going to insert our section - var lastSection = findLastSection(ast, section); - var start, end; - /** - * It's the first section - */ - - if (lastSection == null || lastSection.section === "custom") { - start = 8 - /* wasm header size */ - ; - end = start; - } else { - start = lastSection.startOffset + lastSection.size.value + 1; - end = start; - } // section id - - - start += 1; - var sizeStartLoc = { - line: -1, - column: start - }; - var sizeEndLoc = { - line: -1, - column: start + 1 - }; // 1 byte for the empty vector - - var size = t.withLoc(t.numberLiteralFromRaw(1), sizeEndLoc, sizeStartLoc); - var vectorOfSizeStartLoc = { - line: -1, - column: sizeEndLoc.column - }; - var vectorOfSizeEndLoc = { - line: -1, - column: sizeEndLoc.column + 1 - }; - var vectorOfSize = t.withLoc(t.numberLiteralFromRaw(0), vectorOfSizeEndLoc, vectorOfSizeStartLoc); - var sectionMetadata = t.sectionMetadata(section, start, size, vectorOfSize); - var sectionBytes = (0, _wasmGen.encodeNode)(sectionMetadata); - uint8Buffer = (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, start - 1, end, sectionBytes); // Add section into the AST for later lookups - - if (_typeof(ast.body[0].metadata) === "object") { - // $FlowIgnore: metadata can not be empty - ast.body[0].metadata.sections.push(sectionMetadata); - t.sortSectionMetadata(ast.body[0]); - } - /** - * Update AST - */ - // Once we hit our section every that is after needs to be shifted by the delta - - - var deltaBytes = +sectionBytes.length; - var encounteredSection = false; - t.traverse(ast, { - SectionMetadata: function SectionMetadata(path) { - if (path.node.section === section) { - encounteredSection = true; - return; - } - - if (encounteredSection === true) { - t.shiftSection(ast, path.node, deltaBytes); - } - } - }); - return { - uint8Buffer: uint8Buffer, - sectionMetadata: sectionMetadata - }; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-wasm-section/lib/index.js b/node_modules/@webassemblyjs/helper-wasm-section/lib/index.js deleted file mode 100644 index 3c7963c..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-section/lib/index.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "resizeSectionByteSize", { - enumerable: true, - get: function get() { - return _resize.resizeSectionByteSize; - } -}); -Object.defineProperty(exports, "resizeSectionVecSize", { - enumerable: true, - get: function get() { - return _resize.resizeSectionVecSize; - } -}); -Object.defineProperty(exports, "createEmptySection", { - enumerable: true, - get: function get() { - return _create.createEmptySection; - } -}); -Object.defineProperty(exports, "removeSections", { - enumerable: true, - get: function get() { - return _remove.removeSections; - } -}); - -var _resize = require("./resize"); - -var _create = require("./create"); - -var _remove = require("./remove");
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js b/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js deleted file mode 100644 index 008f5d6..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-section/lib/remove.js +++ /dev/null @@ -1,45 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.removeSections = removeSections; - -var _ast = require("@webassemblyjs/ast"); - -var _helperBuffer = require("@webassemblyjs/helper-buffer"); - -function removeSections(ast, uint8Buffer, section) { - var sectionMetadatas = (0, _ast.getSectionMetadatas)(ast, section); - - if (sectionMetadatas.length === 0) { - throw new Error("Section metadata not found"); - } - - return sectionMetadatas.reverse().reduce(function (uint8Buffer, sectionMetadata) { - var startsIncludingId = sectionMetadata.startOffset - 1; - var ends = section === "start" ? sectionMetadata.size.loc.end.column + 1 : sectionMetadata.startOffset + sectionMetadata.size.value + 1; - var delta = -(ends - startsIncludingId); - /** - * update AST - */ - // Once we hit our section every that is after needs to be shifted by the delta - - var encounteredSection = false; - (0, _ast.traverse)(ast, { - SectionMetadata: function SectionMetadata(path) { - if (path.node.section === section) { - encounteredSection = true; - return path.remove(); - } - - if (encounteredSection === true) { - (0, _ast.shiftSection)(ast, path.node, delta); - } - } - }); // replacement is nothing - - var replacement = []; - return (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, startsIncludingId, ends, replacement); - }, uint8Buffer); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-wasm-section/lib/resize.js b/node_modules/@webassemblyjs/helper-wasm-section/lib/resize.js deleted file mode 100644 index 524cacb..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-section/lib/resize.js +++ /dev/null @@ -1,90 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.resizeSectionByteSize = resizeSectionByteSize; -exports.resizeSectionVecSize = resizeSectionVecSize; - -var _wasmGen = require("@webassemblyjs/wasm-gen"); - -var _ast = require("@webassemblyjs/ast"); - -var _helperBuffer = require("@webassemblyjs/helper-buffer"); - -function resizeSectionByteSize(ast, uint8Buffer, section, deltaBytes) { - var sectionMetadata = (0, _ast.getSectionMetadata)(ast, section); - - if (typeof sectionMetadata === "undefined") { - throw new Error("Section metadata not found"); - } - - if (typeof sectionMetadata.size.loc === "undefined") { - throw new Error("SectionMetadata " + section + " has no loc"); - } // keep old node location to be overriden - - - var start = sectionMetadata.size.loc.start.column; - var end = sectionMetadata.size.loc.end.column; - var newSectionSize = sectionMetadata.size.value + deltaBytes; - var newBytes = (0, _wasmGen.encodeU32)(newSectionSize); - /** - * update AST - */ - - sectionMetadata.size.value = newSectionSize; - var oldu32EncodedLen = end - start; - var newu32EncodedLen = newBytes.length; // the new u32 has a different encoded length - - if (newu32EncodedLen !== oldu32EncodedLen) { - var deltaInSizeEncoding = newu32EncodedLen - oldu32EncodedLen; - sectionMetadata.size.loc.end.column = start + newu32EncodedLen; - deltaBytes += deltaInSizeEncoding; // move the vec size pointer size the section size is now smaller - - sectionMetadata.vectorOfSize.loc.start.column += deltaInSizeEncoding; - sectionMetadata.vectorOfSize.loc.end.column += deltaInSizeEncoding; - } // Once we hit our section every that is after needs to be shifted by the delta - - - var encounteredSection = false; - (0, _ast.traverse)(ast, { - SectionMetadata: function SectionMetadata(path) { - if (path.node.section === section) { - encounteredSection = true; - return; - } - - if (encounteredSection === true) { - (0, _ast.shiftSection)(ast, path.node, deltaBytes); - } - } - }); - return (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, start, end, newBytes); -} - -function resizeSectionVecSize(ast, uint8Buffer, section, deltaElements) { - var sectionMetadata = (0, _ast.getSectionMetadata)(ast, section); - - if (typeof sectionMetadata === "undefined") { - throw new Error("Section metadata not found"); - } - - if (typeof sectionMetadata.vectorOfSize.loc === "undefined") { - throw new Error("SectionMetadata " + section + " has no loc"); - } // Section has no vector - - - if (sectionMetadata.vectorOfSize.value === -1) { - return uint8Buffer; - } // keep old node location to be overriden - - - var start = sectionMetadata.vectorOfSize.loc.start.column; - var end = sectionMetadata.vectorOfSize.loc.end.column; - var newValue = sectionMetadata.vectorOfSize.value + deltaElements; - var newBytes = (0, _wasmGen.encodeU32)(newValue); // Update AST - - sectionMetadata.vectorOfSize.value = newValue; - sectionMetadata.vectorOfSize.loc.end.column = start + newBytes.length; - return (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, start, end, newBytes); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/helper-wasm-section/package.json b/node_modules/@webassemblyjs/helper-wasm-section/package.json deleted file mode 100644 index 3997eec..0000000 --- a/node_modules/@webassemblyjs/helper-wasm-section/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "_from": "@webassemblyjs/helper-wasm-section@1.9.0", - "_id": "@webassemblyjs/helper-wasm-section@1.9.0", - "_inBundle": false, - "_integrity": "sha512-XnMB8l3ek4tvrKUUku+IVaXNHz2YsJyOOmz+MMkZvh8h1uSJpSen6vYnw3IoQ7WwEuAhL8Efjms1ZWjqh2agvw==", - "_location": "/@webassemblyjs/helper-wasm-section", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/helper-wasm-section@1.9.0", - "name": "@webassemblyjs/helper-wasm-section", - "escapedName": "@webassemblyjs%2fhelper-wasm-section", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/wasm-edit" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.9.0.tgz", - "_shasum": "5a4138d5a6292ba18b04c5ae49717e4167965346", - "_spec": "@webassemblyjs/helper-wasm-section@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/wasm-edit", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "dependencies": { - "@webassemblyjs/ast": "1.9.0", - "@webassemblyjs/helper-buffer": "1.9.0", - "@webassemblyjs/helper-wasm-bytecode": "1.9.0", - "@webassemblyjs/wasm-gen": "1.9.0" - }, - "deprecated": false, - "description": "", - "devDependencies": { - "@webassemblyjs/wasm-parser": "1.9.0" - }, - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/helper-wasm-section", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/ieee754/LICENSE b/node_modules/@webassemblyjs/ieee754/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/ieee754/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/ieee754/esm/index.js b/node_modules/@webassemblyjs/ieee754/esm/index.js deleted file mode 100644 index 88d9d4c..0000000 --- a/node_modules/@webassemblyjs/ieee754/esm/index.js +++ /dev/null @@ -1,33 +0,0 @@ -import { write, read } from "@xtuc/ieee754"; -/** - * According to https://webassembly.github.io/spec/binary/values.html#binary-float - * n = 32/8 - */ - -export var NUMBER_OF_BYTE_F32 = 4; -/** - * According to https://webassembly.github.io/spec/binary/values.html#binary-float - * n = 64/8 - */ - -export var NUMBER_OF_BYTE_F64 = 8; -export var SINGLE_PRECISION_MANTISSA = 23; -export var DOUBLE_PRECISION_MANTISSA = 52; -export function encodeF32(v) { - var buffer = []; - write(buffer, v, 0, true, SINGLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F32); - return buffer; -} -export function encodeF64(v) { - var buffer = []; - write(buffer, v, 0, true, DOUBLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F64); - return buffer; -} -export function decodeF32(bytes) { - var buffer = Buffer.from(bytes); - return read(buffer, 0, true, SINGLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F32); -} -export function decodeF64(bytes) { - var buffer = Buffer.from(bytes); - return read(buffer, 0, true, DOUBLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F64); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ieee754/lib/index.js b/node_modules/@webassemblyjs/ieee754/lib/index.js deleted file mode 100644 index 27b9e22..0000000 --- a/node_modules/@webassemblyjs/ieee754/lib/index.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.encodeF32 = encodeF32; -exports.encodeF64 = encodeF64; -exports.decodeF32 = decodeF32; -exports.decodeF64 = decodeF64; -exports.DOUBLE_PRECISION_MANTISSA = exports.SINGLE_PRECISION_MANTISSA = exports.NUMBER_OF_BYTE_F64 = exports.NUMBER_OF_BYTE_F32 = void 0; - -var _ieee = require("@xtuc/ieee754"); - -/** - * According to https://webassembly.github.io/spec/binary/values.html#binary-float - * n = 32/8 - */ -var NUMBER_OF_BYTE_F32 = 4; -/** - * According to https://webassembly.github.io/spec/binary/values.html#binary-float - * n = 64/8 - */ - -exports.NUMBER_OF_BYTE_F32 = NUMBER_OF_BYTE_F32; -var NUMBER_OF_BYTE_F64 = 8; -exports.NUMBER_OF_BYTE_F64 = NUMBER_OF_BYTE_F64; -var SINGLE_PRECISION_MANTISSA = 23; -exports.SINGLE_PRECISION_MANTISSA = SINGLE_PRECISION_MANTISSA; -var DOUBLE_PRECISION_MANTISSA = 52; -exports.DOUBLE_PRECISION_MANTISSA = DOUBLE_PRECISION_MANTISSA; - -function encodeF32(v) { - var buffer = []; - (0, _ieee.write)(buffer, v, 0, true, SINGLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F32); - return buffer; -} - -function encodeF64(v) { - var buffer = []; - (0, _ieee.write)(buffer, v, 0, true, DOUBLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F64); - return buffer; -} - -function decodeF32(bytes) { - var buffer = Buffer.from(bytes); - return (0, _ieee.read)(buffer, 0, true, SINGLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F32); -} - -function decodeF64(bytes) { - var buffer = Buffer.from(bytes); - return (0, _ieee.read)(buffer, 0, true, DOUBLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F64); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/ieee754/package.json b/node_modules/@webassemblyjs/ieee754/package.json deleted file mode 100644 index 46f6e06..0000000 --- a/node_modules/@webassemblyjs/ieee754/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "_from": "@webassemblyjs/ieee754@1.9.0", - "_id": "@webassemblyjs/ieee754@1.9.0", - "_inBundle": false, - "_integrity": "sha512-dcX8JuYU/gvymzIHc9DgxTzUUTLexWwt8uCTWP3otys596io0L5aW02Gb1RjYpx2+0Jus1h4ZFqjla7umFniTg==", - "_location": "/@webassemblyjs/ieee754", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/ieee754@1.9.0", - "name": "@webassemblyjs/ieee754", - "escapedName": "@webassemblyjs%2fieee754", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/wasm-gen", - "/@webassemblyjs/wasm-parser" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.9.0.tgz", - "_shasum": "15c7a0fbaae83fb26143bbacf6d6df1702ad39e4", - "_spec": "@webassemblyjs/ieee754@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/wasm-gen", - "bundleDependencies": false, - "dependencies": { - "@xtuc/ieee754": "^1.2.0" - }, - "deprecated": false, - "description": "IEEE754 decoder and encoder", - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/ieee754", - "publishConfig": { - "access": "public" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/ieee754/src/index.js b/node_modules/@webassemblyjs/ieee754/src/index.js deleted file mode 100644 index c8540a5..0000000 --- a/node_modules/@webassemblyjs/ieee754/src/index.js +++ /dev/null @@ -1,47 +0,0 @@ -// @flow - -import { write, read } from "@xtuc/ieee754"; - -/** - * According to https://webassembly.github.io/spec/binary/values.html#binary-float - * n = 32/8 - */ -export const NUMBER_OF_BYTE_F32 = 4; - -/** - * According to https://webassembly.github.io/spec/binary/values.html#binary-float - * n = 64/8 - */ -export const NUMBER_OF_BYTE_F64 = 8; - -export const SINGLE_PRECISION_MANTISSA = 23; - -export const DOUBLE_PRECISION_MANTISSA = 52; - -export function encodeF32(v: number): Array<number> { - const buffer = []; - - write(buffer, v, 0, true, SINGLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F32); - - return buffer; -} - -export function encodeF64(v: number): Array<number> { - const buffer = []; - - write(buffer, v, 0, true, DOUBLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F64); - - return buffer; -} - -export function decodeF32(bytes: Array<Byte>): number { - const buffer = Buffer.from(bytes); - - return read(buffer, 0, true, SINGLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F32); -} - -export function decodeF64(bytes: Array<Byte>): number { - const buffer = Buffer.from(bytes); - - return read(buffer, 0, true, DOUBLE_PRECISION_MANTISSA, NUMBER_OF_BYTE_F64); -} diff --git a/node_modules/@webassemblyjs/leb128/LICENSE.txt b/node_modules/@webassemblyjs/leb128/LICENSE.txt deleted file mode 100644 index 55e332a..0000000 --- a/node_modules/@webassemblyjs/leb128/LICENSE.txt +++ /dev/null @@ -1,194 +0,0 @@ -Copyright 2012 The Obvious Corporation. -http://obvious.com/ - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - - -------------------------------------------------------------------------- - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - -2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - -3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - -4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - -5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - -6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - -8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS diff --git a/node_modules/@webassemblyjs/leb128/esm/bits.js b/node_modules/@webassemblyjs/leb128/esm/bits.js deleted file mode 100644 index 4c763cd..0000000 --- a/node_modules/@webassemblyjs/leb128/esm/bits.js +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2012 The Obvious Corporation. - -/* - * bits: Bitwise buffer utilities. The utilities here treat a buffer - * as a little-endian bigint, so the lowest-order bit is bit #0 of - * `buffer[0]`, and the highest-order bit is bit #7 of - * `buffer[buffer.length - 1]`. - */ - -/* - * Modules used - */ -"use strict"; -/* - * Exported bindings - */ - -/** - * Extracts the given number of bits from the buffer at the indicated - * index, returning a simple number as the result. If bits are requested - * that aren't covered by the buffer, the `defaultBit` is used as their - * value. - * - * The `bitLength` must be no more than 32. The `defaultBit` if not - * specified is taken to be `0`. - */ - -export function extract(buffer, bitIndex, bitLength, defaultBit) { - if (bitLength < 0 || bitLength > 32) { - throw new Error("Bad value for bitLength."); - } - - if (defaultBit === undefined) { - defaultBit = 0; - } else if (defaultBit !== 0 && defaultBit !== 1) { - throw new Error("Bad value for defaultBit."); - } - - var defaultByte = defaultBit * 0xff; - var result = 0; // All starts are inclusive. The {endByte, endBit} pair is exclusive, but - // if endBit !== 0, then endByte is inclusive. - - var lastBit = bitIndex + bitLength; - var startByte = Math.floor(bitIndex / 8); - var startBit = bitIndex % 8; - var endByte = Math.floor(lastBit / 8); - var endBit = lastBit % 8; - - if (endBit !== 0) { - // `(1 << endBit) - 1` is the mask of all bits up to but not including - // the endBit. - result = get(endByte) & (1 << endBit) - 1; - } - - while (endByte > startByte) { - endByte--; - result = result << 8 | get(endByte); - } - - result >>>= startBit; - return result; - - function get(index) { - var result = buffer[index]; - return result === undefined ? defaultByte : result; - } -} -/** - * Injects the given bits into the given buffer at the given index. Any - * bits in the value beyond the length to set are ignored. - */ - -export function inject(buffer, bitIndex, bitLength, value) { - if (bitLength < 0 || bitLength > 32) { - throw new Error("Bad value for bitLength."); - } - - var lastByte = Math.floor((bitIndex + bitLength - 1) / 8); - - if (bitIndex < 0 || lastByte >= buffer.length) { - throw new Error("Index out of range."); - } // Just keeping it simple, until / unless profiling shows that this - // is a problem. - - - var atByte = Math.floor(bitIndex / 8); - var atBit = bitIndex % 8; - - while (bitLength > 0) { - if (value & 1) { - buffer[atByte] |= 1 << atBit; - } else { - buffer[atByte] &= ~(1 << atBit); - } - - value >>= 1; - bitLength--; - atBit = (atBit + 1) % 8; - - if (atBit === 0) { - atByte++; - } - } -} -/** - * Gets the sign bit of the given buffer. - */ - -export function getSign(buffer) { - return buffer[buffer.length - 1] >>> 7; -} -/** - * Gets the zero-based bit number of the highest-order bit with the - * given value in the given buffer. - * - * If the buffer consists entirely of the other bit value, then this returns - * `-1`. - */ - -export function highOrder(bit, buffer) { - var length = buffer.length; - var fullyWrongByte = (bit ^ 1) * 0xff; // the other-bit extended to a full byte - - while (length > 0 && buffer[length - 1] === fullyWrongByte) { - length--; - } - - if (length === 0) { - // Degenerate case. The buffer consists entirely of ~bit. - return -1; - } - - var byteToCheck = buffer[length - 1]; - var result = length * 8 - 1; - - for (var i = 7; i > 0; i--) { - if ((byteToCheck >> i & 1) === bit) { - break; - } - - result--; - } - - return result; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/leb128/esm/bufs.js b/node_modules/@webassemblyjs/leb128/esm/bufs.js deleted file mode 100644 index 7e2a2bf..0000000 --- a/node_modules/@webassemblyjs/leb128/esm/bufs.js +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright 2012 The Obvious Corporation. - -/* - * bufs: Buffer utilities. - */ - -/* - * Module variables - */ - -/** Pool of buffers, where `bufPool[x].length === x`. */ -var bufPool = []; -/** Maximum length of kept temporary buffers. */ - -var TEMP_BUF_MAXIMUM_LENGTH = 20; -/** Minimum exactly-representable 64-bit int. */ - -var MIN_EXACT_INT64 = -0x8000000000000000; -/** Maximum exactly-representable 64-bit int. */ - -var MAX_EXACT_INT64 = 0x7ffffffffffffc00; -/** Maximum exactly-representable 64-bit uint. */ - -var MAX_EXACT_UINT64 = 0xfffffffffffff800; -/** - * The int value consisting just of a 1 in bit #32 (that is, one more - * than the maximum 32-bit unsigned value). - */ - -var BIT_32 = 0x100000000; -/** - * The int value consisting just of a 1 in bit #64 (that is, one more - * than the maximum 64-bit unsigned value). - */ - -var BIT_64 = 0x10000000000000000; -/* - * Helper functions - */ - -/** - * Masks off all but the lowest bit set of the given number. - */ - -function lowestBit(num) { - return num & -num; -} -/** - * Gets whether trying to add the second number to the first is lossy - * (inexact). The first number is meant to be an accumulated result. - */ - - -function isLossyToAdd(accum, num) { - if (num === 0) { - return false; - } - - var lowBit = lowestBit(num); - var added = accum + lowBit; - - if (added === accum) { - return true; - } - - if (added - lowBit !== accum) { - return true; - } - - return false; -} -/* - * Exported functions - */ - -/** - * Allocates a buffer of the given length, which is initialized - * with all zeroes. This returns a buffer from the pool if it is - * available, or a freshly-allocated buffer if not. - */ - - -export function alloc(length) { - var result = bufPool[length]; - - if (result) { - bufPool[length] = undefined; - } else { - result = new Buffer(length); - } - - result.fill(0); - return result; -} -/** - * Releases a buffer back to the pool. - */ - -export function free(buffer) { - var length = buffer.length; - - if (length < TEMP_BUF_MAXIMUM_LENGTH) { - bufPool[length] = buffer; - } -} -/** - * Resizes a buffer, returning a new buffer. Returns the argument if - * the length wouldn't actually change. This function is only safe to - * use if the given buffer was allocated within this module (since - * otherwise the buffer might possibly be shared externally). - */ - -export function resize(buffer, length) { - if (length === buffer.length) { - return buffer; - } - - var newBuf = alloc(length); - buffer.copy(newBuf); - free(buffer); - return newBuf; -} -/** - * Reads an arbitrary signed int from a buffer. - */ - -export function readInt(buffer) { - var length = buffer.length; - var positive = buffer[length - 1] < 0x80; - var result = positive ? 0 : -1; - var lossy = false; // Note: We can't use bit manipulation here, since that stops - // working if the result won't fit in a 32-bit int. - - if (length < 7) { - // Common case which can't possibly be lossy (because the result has - // no more than 48 bits, and loss only happens with 54 or more). - for (var i = length - 1; i >= 0; i--) { - result = result * 0x100 + buffer[i]; - } - } else { - for (var _i = length - 1; _i >= 0; _i--) { - var one = buffer[_i]; - result *= 0x100; - - if (isLossyToAdd(result, one)) { - lossy = true; - } - - result += one; - } - } - - return { - value: result, - lossy: lossy - }; -} -/** - * Reads an arbitrary unsigned int from a buffer. - */ - -export function readUInt(buffer) { - var length = buffer.length; - var result = 0; - var lossy = false; // Note: See above in re bit manipulation. - - if (length < 7) { - // Common case which can't possibly be lossy (see above). - for (var i = length - 1; i >= 0; i--) { - result = result * 0x100 + buffer[i]; - } - } else { - for (var _i2 = length - 1; _i2 >= 0; _i2--) { - var one = buffer[_i2]; - result *= 0x100; - - if (isLossyToAdd(result, one)) { - lossy = true; - } - - result += one; - } - } - - return { - value: result, - lossy: lossy - }; -} -/** - * Writes a little-endian 64-bit signed int into a buffer. - */ - -export function writeInt64(value, buffer) { - if (value < MIN_EXACT_INT64 || value > MAX_EXACT_INT64) { - throw new Error("Value out of range."); - } - - if (value < 0) { - value += BIT_64; - } - - writeUInt64(value, buffer); -} -/** - * Writes a little-endian 64-bit unsigned int into a buffer. - */ - -export function writeUInt64(value, buffer) { - if (value < 0 || value > MAX_EXACT_UINT64) { - throw new Error("Value out of range."); - } - - var lowWord = value % BIT_32; - var highWord = Math.floor(value / BIT_32); - buffer.writeUInt32LE(lowWord, 0); - buffer.writeUInt32LE(highWord, 4); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/leb128/esm/index.js b/node_modules/@webassemblyjs/leb128/esm/index.js deleted file mode 100644 index 7ee23fa..0000000 --- a/node_modules/@webassemblyjs/leb128/esm/index.js +++ /dev/null @@ -1,34 +0,0 @@ -import leb from "./leb"; -/** - * According to https://webassembly.github.io/spec/core/binary/values.html#binary-int - * max = ceil(32/7) - */ - -export var MAX_NUMBER_OF_BYTE_U32 = 5; -/** - * According to https://webassembly.github.io/spec/core/binary/values.html#binary-int - * max = ceil(64/7) - */ - -export var MAX_NUMBER_OF_BYTE_U64 = 10; -export function decodeInt64(encodedBuffer, index) { - return leb.decodeInt64(encodedBuffer, index); -} -export function decodeUInt64(encodedBuffer, index) { - return leb.decodeUInt64(encodedBuffer, index); -} -export function decodeInt32(encodedBuffer, index) { - return leb.decodeInt32(encodedBuffer, index); -} -export function decodeUInt32(encodedBuffer, index) { - return leb.decodeUInt32(encodedBuffer, index); -} -export function encodeU32(v) { - return leb.encodeUInt32(v); -} -export function encodeI32(v) { - return leb.encodeInt32(v); -} -export function encodeI64(v) { - return leb.encodeInt64(v); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/leb128/esm/leb.js b/node_modules/@webassemblyjs/leb128/esm/leb.js deleted file mode 100644 index 1b6ee09..0000000 --- a/node_modules/@webassemblyjs/leb128/esm/leb.js +++ /dev/null @@ -1,316 +0,0 @@ -// Copyright 2012 The Obvious Corporation. - -/* - * leb: LEB128 utilities. - */ - -/* - * Modules used - */ -"use strict"; - -import Long from "@xtuc/long"; -import * as bits from "./bits"; -import * as bufs from "./bufs"; -/* - * Module variables - */ - -/** The minimum possible 32-bit signed int. */ - -var MIN_INT32 = -0x80000000; -/** The maximum possible 32-bit signed int. */ - -var MAX_INT32 = 0x7fffffff; -/** The maximum possible 32-bit unsigned int. */ - -var MAX_UINT32 = 0xffffffff; -/** The minimum possible 64-bit signed int. */ -// const MIN_INT64 = -0x8000000000000000; - -/** - * The maximum possible 64-bit signed int that is representable as a - * JavaScript number. - */ -// const MAX_INT64 = 0x7ffffffffffffc00; - -/** - * The maximum possible 64-bit unsigned int that is representable as a - * JavaScript number. - */ -// const MAX_UINT64 = 0xfffffffffffff800; - -/* - * Helper functions - */ - -/** - * Determines the number of bits required to encode the number - * represented in the given buffer as a signed value. The buffer is - * taken to represent a signed number in little-endian form. - * - * The number of bits to encode is the (zero-based) bit number of the - * highest-order non-sign-matching bit, plus two. For example: - * - * 11111011 01110101 - * high low - * - * The sign bit here is 1 (that is, it's a negative number). The highest - * bit number that doesn't match the sign is bit #10 (where the lowest-order - * bit is bit #0). So, we have to encode at least 12 bits total. - * - * As a special degenerate case, the numbers 0 and -1 each require just one bit. - */ - -function signedBitCount(buffer) { - return bits.highOrder(bits.getSign(buffer) ^ 1, buffer) + 2; -} -/** - * Determines the number of bits required to encode the number - * represented in the given buffer as an unsigned value. The buffer is - * taken to represent an unsigned number in little-endian form. - * - * The number of bits to encode is the (zero-based) bit number of the - * highest-order 1 bit, plus one. For example: - * - * 00011000 01010011 - * high low - * - * The highest-order 1 bit here is bit #12 (where the lowest-order bit - * is bit #0). So, we have to encode at least 13 bits total. - * - * As a special degenerate case, the number 0 requires 1 bit. - */ - - -function unsignedBitCount(buffer) { - var result = bits.highOrder(1, buffer) + 1; - return result ? result : 1; -} -/** - * Common encoder for both signed and unsigned ints. This takes a - * bigint-ish buffer, returning an LEB128-encoded buffer. - */ - - -function encodeBufferCommon(buffer, signed) { - var signBit; - var bitCount; - - if (signed) { - signBit = bits.getSign(buffer); - bitCount = signedBitCount(buffer); - } else { - signBit = 0; - bitCount = unsignedBitCount(buffer); - } - - var byteCount = Math.ceil(bitCount / 7); - var result = bufs.alloc(byteCount); - - for (var i = 0; i < byteCount; i++) { - var payload = bits.extract(buffer, i * 7, 7, signBit); - result[i] = payload | 0x80; - } // Mask off the top bit of the last byte, to indicate the end of the - // encoding. - - - result[byteCount - 1] &= 0x7f; - return result; -} -/** - * Gets the byte-length of the value encoded in the given buffer at - * the given index. - */ - - -function encodedLength(encodedBuffer, index) { - var result = 0; - - while (encodedBuffer[index + result] >= 0x80) { - result++; - } - - result++; // to account for the last byte - - if (index + result > encodedBuffer.length) {// FIXME(sven): seems to cause false positives - // throw new Error("integer representation too long"); - } - - return result; -} -/** - * Common decoder for both signed and unsigned ints. This takes an - * LEB128-encoded buffer, returning a bigint-ish buffer. - */ - - -function decodeBufferCommon(encodedBuffer, index, signed) { - index = index === undefined ? 0 : index; - var length = encodedLength(encodedBuffer, index); - var bitLength = length * 7; - var byteLength = Math.ceil(bitLength / 8); - var result = bufs.alloc(byteLength); - var outIndex = 0; - - while (length > 0) { - bits.inject(result, outIndex, 7, encodedBuffer[index]); - outIndex += 7; - index++; - length--; - } - - var signBit; - var signByte; - - if (signed) { - // Sign-extend the last byte. - var lastByte = result[byteLength - 1]; - var endBit = outIndex % 8; - - if (endBit !== 0) { - var shift = 32 - endBit; // 32 because JS bit ops work on 32-bit ints. - - lastByte = result[byteLength - 1] = lastByte << shift >> shift & 0xff; - } - - signBit = lastByte >> 7; - signByte = signBit * 0xff; - } else { - signBit = 0; - signByte = 0; - } // Slice off any superfluous bytes, that is, ones that add no meaningful - // bits (because the value would be the same if they were removed). - - - while (byteLength > 1 && result[byteLength - 1] === signByte && (!signed || result[byteLength - 2] >> 7 === signBit)) { - byteLength--; - } - - result = bufs.resize(result, byteLength); - return { - value: result, - nextIndex: index - }; -} -/* - * Exported bindings - */ - - -function encodeIntBuffer(buffer) { - return encodeBufferCommon(buffer, true); -} - -function decodeIntBuffer(encodedBuffer, index) { - return decodeBufferCommon(encodedBuffer, index, true); -} - -function encodeInt32(num) { - var buf = bufs.alloc(4); - buf.writeInt32LE(num, 0); - var result = encodeIntBuffer(buf); - bufs.free(buf); - return result; -} - -function decodeInt32(encodedBuffer, index) { - var result = decodeIntBuffer(encodedBuffer, index); - var parsed = bufs.readInt(result.value); - var value = parsed.value; - bufs.free(result.value); - - if (value < MIN_INT32 || value > MAX_INT32) { - throw new Error("integer too large"); - } - - return { - value: value, - nextIndex: result.nextIndex - }; -} - -function encodeInt64(num) { - var buf = bufs.alloc(8); - bufs.writeInt64(num, buf); - var result = encodeIntBuffer(buf); - bufs.free(buf); - return result; -} - -function decodeInt64(encodedBuffer, index) { - var result = decodeIntBuffer(encodedBuffer, index); - var value = Long.fromBytesLE(result.value, false); - bufs.free(result.value); - return { - value: value, - nextIndex: result.nextIndex, - lossy: false - }; -} - -function encodeUIntBuffer(buffer) { - return encodeBufferCommon(buffer, false); -} - -function decodeUIntBuffer(encodedBuffer, index) { - return decodeBufferCommon(encodedBuffer, index, false); -} - -function encodeUInt32(num) { - var buf = bufs.alloc(4); - buf.writeUInt32LE(num, 0); - var result = encodeUIntBuffer(buf); - bufs.free(buf); - return result; -} - -function decodeUInt32(encodedBuffer, index) { - var result = decodeUIntBuffer(encodedBuffer, index); - var parsed = bufs.readUInt(result.value); - var value = parsed.value; - bufs.free(result.value); - - if (value > MAX_UINT32) { - throw new Error("integer too large"); - } - - return { - value: value, - nextIndex: result.nextIndex - }; -} - -function encodeUInt64(num) { - var buf = bufs.alloc(8); - bufs.writeUInt64(num, buf); - var result = encodeUIntBuffer(buf); - bufs.free(buf); - return result; -} - -function decodeUInt64(encodedBuffer, index) { - var result = decodeUIntBuffer(encodedBuffer, index); - var value = Long.fromBytesLE(result.value, true); - bufs.free(result.value); - return { - value: value, - nextIndex: result.nextIndex, - lossy: false - }; -} - -export default { - decodeInt32: decodeInt32, - decodeInt64: decodeInt64, - decodeIntBuffer: decodeIntBuffer, - decodeUInt32: decodeUInt32, - decodeUInt64: decodeUInt64, - decodeUIntBuffer: decodeUIntBuffer, - encodeInt32: encodeInt32, - encodeInt64: encodeInt64, - encodeIntBuffer: encodeIntBuffer, - encodeUInt32: encodeUInt32, - encodeUInt64: encodeUInt64, - encodeUIntBuffer: encodeUIntBuffer -};
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/leb128/lib/bits.js b/node_modules/@webassemblyjs/leb128/lib/bits.js deleted file mode 100644 index 5acf246..0000000 --- a/node_modules/@webassemblyjs/leb128/lib/bits.js +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2012 The Obvious Corporation. - -/* - * bits: Bitwise buffer utilities. The utilities here treat a buffer - * as a little-endian bigint, so the lowest-order bit is bit #0 of - * `buffer[0]`, and the highest-order bit is bit #7 of - * `buffer[buffer.length - 1]`. - */ - -/* - * Modules used - */ -"use strict"; -/* - * Exported bindings - */ - -/** - * Extracts the given number of bits from the buffer at the indicated - * index, returning a simple number as the result. If bits are requested - * that aren't covered by the buffer, the `defaultBit` is used as their - * value. - * - * The `bitLength` must be no more than 32. The `defaultBit` if not - * specified is taken to be `0`. - */ - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.extract = extract; -exports.inject = inject; -exports.getSign = getSign; -exports.highOrder = highOrder; - -function extract(buffer, bitIndex, bitLength, defaultBit) { - if (bitLength < 0 || bitLength > 32) { - throw new Error("Bad value for bitLength."); - } - - if (defaultBit === undefined) { - defaultBit = 0; - } else if (defaultBit !== 0 && defaultBit !== 1) { - throw new Error("Bad value for defaultBit."); - } - - var defaultByte = defaultBit * 0xff; - var result = 0; // All starts are inclusive. The {endByte, endBit} pair is exclusive, but - // if endBit !== 0, then endByte is inclusive. - - var lastBit = bitIndex + bitLength; - var startByte = Math.floor(bitIndex / 8); - var startBit = bitIndex % 8; - var endByte = Math.floor(lastBit / 8); - var endBit = lastBit % 8; - - if (endBit !== 0) { - // `(1 << endBit) - 1` is the mask of all bits up to but not including - // the endBit. - result = get(endByte) & (1 << endBit) - 1; - } - - while (endByte > startByte) { - endByte--; - result = result << 8 | get(endByte); - } - - result >>>= startBit; - return result; - - function get(index) { - var result = buffer[index]; - return result === undefined ? defaultByte : result; - } -} -/** - * Injects the given bits into the given buffer at the given index. Any - * bits in the value beyond the length to set are ignored. - */ - - -function inject(buffer, bitIndex, bitLength, value) { - if (bitLength < 0 || bitLength > 32) { - throw new Error("Bad value for bitLength."); - } - - var lastByte = Math.floor((bitIndex + bitLength - 1) / 8); - - if (bitIndex < 0 || lastByte >= buffer.length) { - throw new Error("Index out of range."); - } // Just keeping it simple, until / unless profiling shows that this - // is a problem. - - - var atByte = Math.floor(bitIndex / 8); - var atBit = bitIndex % 8; - - while (bitLength > 0) { - if (value & 1) { - buffer[atByte] |= 1 << atBit; - } else { - buffer[atByte] &= ~(1 << atBit); - } - - value >>= 1; - bitLength--; - atBit = (atBit + 1) % 8; - - if (atBit === 0) { - atByte++; - } - } -} -/** - * Gets the sign bit of the given buffer. - */ - - -function getSign(buffer) { - return buffer[buffer.length - 1] >>> 7; -} -/** - * Gets the zero-based bit number of the highest-order bit with the - * given value in the given buffer. - * - * If the buffer consists entirely of the other bit value, then this returns - * `-1`. - */ - - -function highOrder(bit, buffer) { - var length = buffer.length; - var fullyWrongByte = (bit ^ 1) * 0xff; // the other-bit extended to a full byte - - while (length > 0 && buffer[length - 1] === fullyWrongByte) { - length--; - } - - if (length === 0) { - // Degenerate case. The buffer consists entirely of ~bit. - return -1; - } - - var byteToCheck = buffer[length - 1]; - var result = length * 8 - 1; - - for (var i = 7; i > 0; i--) { - if ((byteToCheck >> i & 1) === bit) { - break; - } - - result--; - } - - return result; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/leb128/lib/bufs.js b/node_modules/@webassemblyjs/leb128/lib/bufs.js deleted file mode 100644 index f9a176e..0000000 --- a/node_modules/@webassemblyjs/leb128/lib/bufs.js +++ /dev/null @@ -1,236 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.alloc = alloc; -exports.free = free; -exports.resize = resize; -exports.readInt = readInt; -exports.readUInt = readUInt; -exports.writeInt64 = writeInt64; -exports.writeUInt64 = writeUInt64; -// Copyright 2012 The Obvious Corporation. - -/* - * bufs: Buffer utilities. - */ - -/* - * Module variables - */ - -/** Pool of buffers, where `bufPool[x].length === x`. */ -var bufPool = []; -/** Maximum length of kept temporary buffers. */ - -var TEMP_BUF_MAXIMUM_LENGTH = 20; -/** Minimum exactly-representable 64-bit int. */ - -var MIN_EXACT_INT64 = -0x8000000000000000; -/** Maximum exactly-representable 64-bit int. */ - -var MAX_EXACT_INT64 = 0x7ffffffffffffc00; -/** Maximum exactly-representable 64-bit uint. */ - -var MAX_EXACT_UINT64 = 0xfffffffffffff800; -/** - * The int value consisting just of a 1 in bit #32 (that is, one more - * than the maximum 32-bit unsigned value). - */ - -var BIT_32 = 0x100000000; -/** - * The int value consisting just of a 1 in bit #64 (that is, one more - * than the maximum 64-bit unsigned value). - */ - -var BIT_64 = 0x10000000000000000; -/* - * Helper functions - */ - -/** - * Masks off all but the lowest bit set of the given number. - */ - -function lowestBit(num) { - return num & -num; -} -/** - * Gets whether trying to add the second number to the first is lossy - * (inexact). The first number is meant to be an accumulated result. - */ - - -function isLossyToAdd(accum, num) { - if (num === 0) { - return false; - } - - var lowBit = lowestBit(num); - var added = accum + lowBit; - - if (added === accum) { - return true; - } - - if (added - lowBit !== accum) { - return true; - } - - return false; -} -/* - * Exported functions - */ - -/** - * Allocates a buffer of the given length, which is initialized - * with all zeroes. This returns a buffer from the pool if it is - * available, or a freshly-allocated buffer if not. - */ - - -function alloc(length) { - var result = bufPool[length]; - - if (result) { - bufPool[length] = undefined; - } else { - result = new Buffer(length); - } - - result.fill(0); - return result; -} -/** - * Releases a buffer back to the pool. - */ - - -function free(buffer) { - var length = buffer.length; - - if (length < TEMP_BUF_MAXIMUM_LENGTH) { - bufPool[length] = buffer; - } -} -/** - * Resizes a buffer, returning a new buffer. Returns the argument if - * the length wouldn't actually change. This function is only safe to - * use if the given buffer was allocated within this module (since - * otherwise the buffer might possibly be shared externally). - */ - - -function resize(buffer, length) { - if (length === buffer.length) { - return buffer; - } - - var newBuf = alloc(length); - buffer.copy(newBuf); - free(buffer); - return newBuf; -} -/** - * Reads an arbitrary signed int from a buffer. - */ - - -function readInt(buffer) { - var length = buffer.length; - var positive = buffer[length - 1] < 0x80; - var result = positive ? 0 : -1; - var lossy = false; // Note: We can't use bit manipulation here, since that stops - // working if the result won't fit in a 32-bit int. - - if (length < 7) { - // Common case which can't possibly be lossy (because the result has - // no more than 48 bits, and loss only happens with 54 or more). - for (var i = length - 1; i >= 0; i--) { - result = result * 0x100 + buffer[i]; - } - } else { - for (var _i = length - 1; _i >= 0; _i--) { - var one = buffer[_i]; - result *= 0x100; - - if (isLossyToAdd(result, one)) { - lossy = true; - } - - result += one; - } - } - - return { - value: result, - lossy: lossy - }; -} -/** - * Reads an arbitrary unsigned int from a buffer. - */ - - -function readUInt(buffer) { - var length = buffer.length; - var result = 0; - var lossy = false; // Note: See above in re bit manipulation. - - if (length < 7) { - // Common case which can't possibly be lossy (see above). - for (var i = length - 1; i >= 0; i--) { - result = result * 0x100 + buffer[i]; - } - } else { - for (var _i2 = length - 1; _i2 >= 0; _i2--) { - var one = buffer[_i2]; - result *= 0x100; - - if (isLossyToAdd(result, one)) { - lossy = true; - } - - result += one; - } - } - - return { - value: result, - lossy: lossy - }; -} -/** - * Writes a little-endian 64-bit signed int into a buffer. - */ - - -function writeInt64(value, buffer) { - if (value < MIN_EXACT_INT64 || value > MAX_EXACT_INT64) { - throw new Error("Value out of range."); - } - - if (value < 0) { - value += BIT_64; - } - - writeUInt64(value, buffer); -} -/** - * Writes a little-endian 64-bit unsigned int into a buffer. - */ - - -function writeUInt64(value, buffer) { - if (value < 0 || value > MAX_EXACT_UINT64) { - throw new Error("Value out of range."); - } - - var lowWord = value % BIT_32; - var highWord = Math.floor(value / BIT_32); - buffer.writeUInt32LE(lowWord, 0); - buffer.writeUInt32LE(highWord, 4); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/leb128/lib/index.js b/node_modules/@webassemblyjs/leb128/lib/index.js deleted file mode 100644 index 6687537..0000000 --- a/node_modules/@webassemblyjs/leb128/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.decodeInt64 = decodeInt64; -exports.decodeUInt64 = decodeUInt64; -exports.decodeInt32 = decodeInt32; -exports.decodeUInt32 = decodeUInt32; -exports.encodeU32 = encodeU32; -exports.encodeI32 = encodeI32; -exports.encodeI64 = encodeI64; -exports.MAX_NUMBER_OF_BYTE_U64 = exports.MAX_NUMBER_OF_BYTE_U32 = void 0; - -var _leb = _interopRequireDefault(require("./leb")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * According to https://webassembly.github.io/spec/core/binary/values.html#binary-int - * max = ceil(32/7) - */ -var MAX_NUMBER_OF_BYTE_U32 = 5; -/** - * According to https://webassembly.github.io/spec/core/binary/values.html#binary-int - * max = ceil(64/7) - */ - -exports.MAX_NUMBER_OF_BYTE_U32 = MAX_NUMBER_OF_BYTE_U32; -var MAX_NUMBER_OF_BYTE_U64 = 10; -exports.MAX_NUMBER_OF_BYTE_U64 = MAX_NUMBER_OF_BYTE_U64; - -function decodeInt64(encodedBuffer, index) { - return _leb.default.decodeInt64(encodedBuffer, index); -} - -function decodeUInt64(encodedBuffer, index) { - return _leb.default.decodeUInt64(encodedBuffer, index); -} - -function decodeInt32(encodedBuffer, index) { - return _leb.default.decodeInt32(encodedBuffer, index); -} - -function decodeUInt32(encodedBuffer, index) { - return _leb.default.decodeUInt32(encodedBuffer, index); -} - -function encodeU32(v) { - return _leb.default.encodeUInt32(v); -} - -function encodeI32(v) { - return _leb.default.encodeInt32(v); -} - -function encodeI64(v) { - return _leb.default.encodeInt64(v); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/leb128/lib/leb.js b/node_modules/@webassemblyjs/leb128/lib/leb.js deleted file mode 100644 index 3c1d4aa..0000000 --- a/node_modules/@webassemblyjs/leb128/lib/leb.js +++ /dev/null @@ -1,332 +0,0 @@ -// Copyright 2012 The Obvious Corporation. - -/* - * leb: LEB128 utilities. - */ - -/* - * Modules used - */ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; - -var _long = _interopRequireDefault(require("@xtuc/long")); - -var bits = _interopRequireWildcard(require("./bits")); - -var bufs = _interopRequireWildcard(require("./bufs")); - -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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/* - * Module variables - */ - -/** The minimum possible 32-bit signed int. */ -var MIN_INT32 = -0x80000000; -/** The maximum possible 32-bit signed int. */ - -var MAX_INT32 = 0x7fffffff; -/** The maximum possible 32-bit unsigned int. */ - -var MAX_UINT32 = 0xffffffff; -/** The minimum possible 64-bit signed int. */ -// const MIN_INT64 = -0x8000000000000000; - -/** - * The maximum possible 64-bit signed int that is representable as a - * JavaScript number. - */ -// const MAX_INT64 = 0x7ffffffffffffc00; - -/** - * The maximum possible 64-bit unsigned int that is representable as a - * JavaScript number. - */ -// const MAX_UINT64 = 0xfffffffffffff800; - -/* - * Helper functions - */ - -/** - * Determines the number of bits required to encode the number - * represented in the given buffer as a signed value. The buffer is - * taken to represent a signed number in little-endian form. - * - * The number of bits to encode is the (zero-based) bit number of the - * highest-order non-sign-matching bit, plus two. For example: - * - * 11111011 01110101 - * high low - * - * The sign bit here is 1 (that is, it's a negative number). The highest - * bit number that doesn't match the sign is bit #10 (where the lowest-order - * bit is bit #0). So, we have to encode at least 12 bits total. - * - * As a special degenerate case, the numbers 0 and -1 each require just one bit. - */ - -function signedBitCount(buffer) { - return bits.highOrder(bits.getSign(buffer) ^ 1, buffer) + 2; -} -/** - * Determines the number of bits required to encode the number - * represented in the given buffer as an unsigned value. The buffer is - * taken to represent an unsigned number in little-endian form. - * - * The number of bits to encode is the (zero-based) bit number of the - * highest-order 1 bit, plus one. For example: - * - * 00011000 01010011 - * high low - * - * The highest-order 1 bit here is bit #12 (where the lowest-order bit - * is bit #0). So, we have to encode at least 13 bits total. - * - * As a special degenerate case, the number 0 requires 1 bit. - */ - - -function unsignedBitCount(buffer) { - var result = bits.highOrder(1, buffer) + 1; - return result ? result : 1; -} -/** - * Common encoder for both signed and unsigned ints. This takes a - * bigint-ish buffer, returning an LEB128-encoded buffer. - */ - - -function encodeBufferCommon(buffer, signed) { - var signBit; - var bitCount; - - if (signed) { - signBit = bits.getSign(buffer); - bitCount = signedBitCount(buffer); - } else { - signBit = 0; - bitCount = unsignedBitCount(buffer); - } - - var byteCount = Math.ceil(bitCount / 7); - var result = bufs.alloc(byteCount); - - for (var i = 0; i < byteCount; i++) { - var payload = bits.extract(buffer, i * 7, 7, signBit); - result[i] = payload | 0x80; - } // Mask off the top bit of the last byte, to indicate the end of the - // encoding. - - - result[byteCount - 1] &= 0x7f; - return result; -} -/** - * Gets the byte-length of the value encoded in the given buffer at - * the given index. - */ - - -function encodedLength(encodedBuffer, index) { - var result = 0; - - while (encodedBuffer[index + result] >= 0x80) { - result++; - } - - result++; // to account for the last byte - - if (index + result > encodedBuffer.length) {// FIXME(sven): seems to cause false positives - // throw new Error("integer representation too long"); - } - - return result; -} -/** - * Common decoder for both signed and unsigned ints. This takes an - * LEB128-encoded buffer, returning a bigint-ish buffer. - */ - - -function decodeBufferCommon(encodedBuffer, index, signed) { - index = index === undefined ? 0 : index; - var length = encodedLength(encodedBuffer, index); - var bitLength = length * 7; - var byteLength = Math.ceil(bitLength / 8); - var result = bufs.alloc(byteLength); - var outIndex = 0; - - while (length > 0) { - bits.inject(result, outIndex, 7, encodedBuffer[index]); - outIndex += 7; - index++; - length--; - } - - var signBit; - var signByte; - - if (signed) { - // Sign-extend the last byte. - var lastByte = result[byteLength - 1]; - var endBit = outIndex % 8; - - if (endBit !== 0) { - var shift = 32 - endBit; // 32 because JS bit ops work on 32-bit ints. - - lastByte = result[byteLength - 1] = lastByte << shift >> shift & 0xff; - } - - signBit = lastByte >> 7; - signByte = signBit * 0xff; - } else { - signBit = 0; - signByte = 0; - } // Slice off any superfluous bytes, that is, ones that add no meaningful - // bits (because the value would be the same if they were removed). - - - while (byteLength > 1 && result[byteLength - 1] === signByte && (!signed || result[byteLength - 2] >> 7 === signBit)) { - byteLength--; - } - - result = bufs.resize(result, byteLength); - return { - value: result, - nextIndex: index - }; -} -/* - * Exported bindings - */ - - -function encodeIntBuffer(buffer) { - return encodeBufferCommon(buffer, true); -} - -function decodeIntBuffer(encodedBuffer, index) { - return decodeBufferCommon(encodedBuffer, index, true); -} - -function encodeInt32(num) { - var buf = bufs.alloc(4); - buf.writeInt32LE(num, 0); - var result = encodeIntBuffer(buf); - bufs.free(buf); - return result; -} - -function decodeInt32(encodedBuffer, index) { - var result = decodeIntBuffer(encodedBuffer, index); - var parsed = bufs.readInt(result.value); - var value = parsed.value; - bufs.free(result.value); - - if (value < MIN_INT32 || value > MAX_INT32) { - throw new Error("integer too large"); - } - - return { - value: value, - nextIndex: result.nextIndex - }; -} - -function encodeInt64(num) { - var buf = bufs.alloc(8); - bufs.writeInt64(num, buf); - var result = encodeIntBuffer(buf); - bufs.free(buf); - return result; -} - -function decodeInt64(encodedBuffer, index) { - var result = decodeIntBuffer(encodedBuffer, index); - - var value = _long.default.fromBytesLE(result.value, false); - - bufs.free(result.value); - return { - value: value, - nextIndex: result.nextIndex, - lossy: false - }; -} - -function encodeUIntBuffer(buffer) { - return encodeBufferCommon(buffer, false); -} - -function decodeUIntBuffer(encodedBuffer, index) { - return decodeBufferCommon(encodedBuffer, index, false); -} - -function encodeUInt32(num) { - var buf = bufs.alloc(4); - buf.writeUInt32LE(num, 0); - var result = encodeUIntBuffer(buf); - bufs.free(buf); - return result; -} - -function decodeUInt32(encodedBuffer, index) { - var result = decodeUIntBuffer(encodedBuffer, index); - var parsed = bufs.readUInt(result.value); - var value = parsed.value; - bufs.free(result.value); - - if (value > MAX_UINT32) { - throw new Error("integer too large"); - } - - return { - value: value, - nextIndex: result.nextIndex - }; -} - -function encodeUInt64(num) { - var buf = bufs.alloc(8); - bufs.writeUInt64(num, buf); - var result = encodeUIntBuffer(buf); - bufs.free(buf); - return result; -} - -function decodeUInt64(encodedBuffer, index) { - var result = decodeUIntBuffer(encodedBuffer, index); - - var value = _long.default.fromBytesLE(result.value, true); - - bufs.free(result.value); - return { - value: value, - nextIndex: result.nextIndex, - lossy: false - }; -} - -var _default = { - decodeInt32: decodeInt32, - decodeInt64: decodeInt64, - decodeIntBuffer: decodeIntBuffer, - decodeUInt32: decodeUInt32, - decodeUInt64: decodeUInt64, - decodeUIntBuffer: decodeUIntBuffer, - encodeInt32: encodeInt32, - encodeInt64: encodeInt64, - encodeIntBuffer: encodeIntBuffer, - encodeUInt32: encodeUInt32, - encodeUInt64: encodeUInt64, - encodeUIntBuffer: encodeUIntBuffer -}; -exports.default = _default;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/leb128/package.json b/node_modules/@webassemblyjs/leb128/package.json deleted file mode 100644 index 5a5c2e3..0000000 --- a/node_modules/@webassemblyjs/leb128/package.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "_from": "@webassemblyjs/leb128@1.9.0", - "_id": "@webassemblyjs/leb128@1.9.0", - "_inBundle": false, - "_integrity": "sha512-ENVzM5VwV1ojs9jam6vPys97B/S65YQtv/aanqnU7D8aSoHFX8GyhGg0CMfyKNIHBuAVjy3tlzd5QMMINa7wpw==", - "_location": "/@webassemblyjs/leb128", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/leb128@1.9.0", - "name": "@webassemblyjs/leb128", - "escapedName": "@webassemblyjs%2fleb128", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/wasm-gen", - "/@webassemblyjs/wasm-parser" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.9.0.tgz", - "_shasum": "f19ca0b76a6dc55623a09cffa769e838fa1e1c95", - "_spec": "@webassemblyjs/leb128@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/wasm-gen", - "bundleDependencies": false, - "dependencies": { - "@xtuc/long": "4.2.2" - }, - "deprecated": false, - "description": "LEB128 decoder and encoder", - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/leb128", - "publishConfig": { - "access": "public" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/utf8/LICENSE b/node_modules/@webassemblyjs/utf8/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/utf8/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/utf8/esm/decoder.js b/node_modules/@webassemblyjs/utf8/esm/decoder.js deleted file mode 100644 index 12d88eb..0000000 --- a/node_modules/@webassemblyjs/utf8/esm/decoder.js +++ /dev/null @@ -1,95 +0,0 @@ -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 _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); } - -function con(b) { - if ((b & 0xc0) === 0x80) { - return b & 0x3f; - } else { - throw new Error("invalid UTF-8 encoding"); - } -} - -function code(min, n) { - if (n < min || 0xd800 <= n && n < 0xe000 || n >= 0x10000) { - throw new Error("invalid UTF-8 encoding"); - } else { - return n; - } -} - -export function decode(bytes) { - return _decode(bytes).map(function (x) { - return String.fromCharCode(x); - }).join(""); -} - -function _decode(bytes) { - if (bytes.length === 0) { - return []; - } - /** - * 1 byte - */ - - - { - var _bytes = _toArray(bytes), - b1 = _bytes[0], - bs = _bytes.slice(1); - - if (b1 < 0x80) { - return [code(0x0, b1)].concat(_toConsumableArray(_decode(bs))); - } - - if (b1 < 0xc0) { - throw new Error("invalid UTF-8 encoding"); - } - } - /** - * 2 bytes - */ - - { - var _bytes2 = _toArray(bytes), - _b = _bytes2[0], - b2 = _bytes2[1], - _bs = _bytes2.slice(2); - - if (_b < 0xe0) { - return [code(0x80, ((_b & 0x1f) << 6) + con(b2))].concat(_toConsumableArray(_decode(_bs))); - } - } - /** - * 3 bytes - */ - - { - var _bytes3 = _toArray(bytes), - _b2 = _bytes3[0], - _b3 = _bytes3[1], - b3 = _bytes3[2], - _bs2 = _bytes3.slice(3); - - if (_b2 < 0xf0) { - return [code(0x800, ((_b2 & 0x0f) << 12) + (con(_b3) << 6) + con(b3))].concat(_toConsumableArray(_decode(_bs2))); - } - } - /** - * 4 bytes - */ - - { - var _bytes4 = _toArray(bytes), - _b4 = _bytes4[0], - _b5 = _bytes4[1], - _b6 = _bytes4[2], - b4 = _bytes4[3], - _bs3 = _bytes4.slice(4); - - if (_b4 < 0xf8) { - return [code(0x10000, (((_b4 & 0x07) << 18) + con(_b5) << 12) + (con(_b6) << 6) + con(b4))].concat(_toConsumableArray(_decode(_bs3))); - } - } - throw new Error("invalid UTF-8 encoding"); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/utf8/esm/encoder.js b/node_modules/@webassemblyjs/utf8/esm/encoder.js deleted file mode 100644 index 6d5e4de..0000000 --- a/node_modules/@webassemblyjs/utf8/esm/encoder.js +++ /dev/null @@ -1,46 +0,0 @@ -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 _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); } - -function con(n) { - return 0x80 | n & 0x3f; -} - -export function encode(str) { - var arr = str.split("").map(function (x) { - return x.charCodeAt(0); - }); - return _encode(arr); -} - -function _encode(arr) { - if (arr.length === 0) { - return []; - } - - var _arr = _toArray(arr), - n = _arr[0], - ns = _arr.slice(1); - - if (n < 0) { - throw new Error("utf8"); - } - - if (n < 0x80) { - return [n].concat(_toConsumableArray(_encode(ns))); - } - - if (n < 0x800) { - return [0xc0 | n >>> 6, con(n)].concat(_toConsumableArray(_encode(ns))); - } - - if (n < 0x10000) { - return [0xe0 | n >>> 12, con(n >>> 6), con(n)].concat(_toConsumableArray(_encode(ns))); - } - - if (n < 0x110000) { - return [0xf0 | n >>> 18, con(n >>> 12), con(n >>> 6), con(n)].concat(_toConsumableArray(_encode(ns))); - } - - throw new Error("utf8"); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/utf8/esm/index.js b/node_modules/@webassemblyjs/utf8/esm/index.js deleted file mode 100644 index 2e31357..0000000 --- a/node_modules/@webassemblyjs/utf8/esm/index.js +++ /dev/null @@ -1,2 +0,0 @@ -export { decode } from "./decoder"; -export { encode } from "./encoder";
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/utf8/lib/decoder.js b/node_modules/@webassemblyjs/utf8/lib/decoder.js deleted file mode 100644 index 824c843..0000000 --- a/node_modules/@webassemblyjs/utf8/lib/decoder.js +++ /dev/null @@ -1,102 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.decode = decode; - -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 _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); } - -function con(b) { - if ((b & 0xc0) === 0x80) { - return b & 0x3f; - } else { - throw new Error("invalid UTF-8 encoding"); - } -} - -function code(min, n) { - if (n < min || 0xd800 <= n && n < 0xe000 || n >= 0x10000) { - throw new Error("invalid UTF-8 encoding"); - } else { - return n; - } -} - -function decode(bytes) { - return _decode(bytes).map(function (x) { - return String.fromCharCode(x); - }).join(""); -} - -function _decode(bytes) { - if (bytes.length === 0) { - return []; - } - /** - * 1 byte - */ - - - { - var _bytes = _toArray(bytes), - b1 = _bytes[0], - bs = _bytes.slice(1); - - if (b1 < 0x80) { - return [code(0x0, b1)].concat(_toConsumableArray(_decode(bs))); - } - - if (b1 < 0xc0) { - throw new Error("invalid UTF-8 encoding"); - } - } - /** - * 2 bytes - */ - - { - var _bytes2 = _toArray(bytes), - _b = _bytes2[0], - b2 = _bytes2[1], - _bs = _bytes2.slice(2); - - if (_b < 0xe0) { - return [code(0x80, ((_b & 0x1f) << 6) + con(b2))].concat(_toConsumableArray(_decode(_bs))); - } - } - /** - * 3 bytes - */ - - { - var _bytes3 = _toArray(bytes), - _b2 = _bytes3[0], - _b3 = _bytes3[1], - b3 = _bytes3[2], - _bs2 = _bytes3.slice(3); - - if (_b2 < 0xf0) { - return [code(0x800, ((_b2 & 0x0f) << 12) + (con(_b3) << 6) + con(b3))].concat(_toConsumableArray(_decode(_bs2))); - } - } - /** - * 4 bytes - */ - - { - var _bytes4 = _toArray(bytes), - _b4 = _bytes4[0], - _b5 = _bytes4[1], - _b6 = _bytes4[2], - b4 = _bytes4[3], - _bs3 = _bytes4.slice(4); - - if (_b4 < 0xf8) { - return [code(0x10000, (((_b4 & 0x07) << 18) + con(_b5) << 12) + (con(_b6) << 6) + con(b4))].concat(_toConsumableArray(_decode(_bs3))); - } - } - throw new Error("invalid UTF-8 encoding"); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/utf8/lib/encoder.js b/node_modules/@webassemblyjs/utf8/lib/encoder.js deleted file mode 100644 index 0606b56..0000000 --- a/node_modules/@webassemblyjs/utf8/lib/encoder.js +++ /dev/null @@ -1,53 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.encode = encode; - -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 _toArray(arr) { return Array.isArray(arr) ? arr : Array.from(arr); } - -function con(n) { - return 0x80 | n & 0x3f; -} - -function encode(str) { - var arr = str.split("").map(function (x) { - return x.charCodeAt(0); - }); - return _encode(arr); -} - -function _encode(arr) { - if (arr.length === 0) { - return []; - } - - var _arr = _toArray(arr), - n = _arr[0], - ns = _arr.slice(1); - - if (n < 0) { - throw new Error("utf8"); - } - - if (n < 0x80) { - return [n].concat(_toConsumableArray(_encode(ns))); - } - - if (n < 0x800) { - return [0xc0 | n >>> 6, con(n)].concat(_toConsumableArray(_encode(ns))); - } - - if (n < 0x10000) { - return [0xe0 | n >>> 12, con(n >>> 6), con(n)].concat(_toConsumableArray(_encode(ns))); - } - - if (n < 0x110000) { - return [0xf0 | n >>> 18, con(n >>> 12), con(n >>> 6), con(n)].concat(_toConsumableArray(_encode(ns))); - } - - throw new Error("utf8"); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/utf8/lib/index.js b/node_modules/@webassemblyjs/utf8/lib/index.js deleted file mode 100644 index fef9470..0000000 --- a/node_modules/@webassemblyjs/utf8/lib/index.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -Object.defineProperty(exports, "decode", { - enumerable: true, - get: function get() { - return _decoder.decode; - } -}); -Object.defineProperty(exports, "encode", { - enumerable: true, - get: function get() { - return _encoder.encode; - } -}); - -var _decoder = require("./decoder"); - -var _encoder = require("./encoder");
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/utf8/package.json b/node_modules/@webassemblyjs/utf8/package.json deleted file mode 100644 index 0a322dc..0000000 --- a/node_modules/@webassemblyjs/utf8/package.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "_from": "@webassemblyjs/utf8@1.9.0", - "_id": "@webassemblyjs/utf8@1.9.0", - "_inBundle": false, - "_integrity": "sha512-GZbQlWtopBTP0u7cHrEx+73yZKrQoBMpwkGEIqlacljhXCkVM1kMQge/Mf+csMJAjEdSwhOyLAS0AoR3AG5P8w==", - "_location": "/@webassemblyjs/utf8", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/utf8@1.9.0", - "name": "@webassemblyjs/utf8", - "escapedName": "@webassemblyjs%2futf8", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/wasm-gen", - "/@webassemblyjs/wasm-parser" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.9.0.tgz", - "_shasum": "04d33b636f78e6a6813227e82402f7637b6229ab", - "_spec": "@webassemblyjs/utf8@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/wasm-gen", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "deprecated": false, - "description": "UTF8 encoder/decoder for WASM", - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/utf8", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/utf8/src/decoder.js b/node_modules/@webassemblyjs/utf8/src/decoder.js deleted file mode 100644 index 227ba3a..0000000 --- a/node_modules/@webassemblyjs/utf8/src/decoder.js +++ /dev/null @@ -1,86 +0,0 @@ -function con(b) { - if ((b & 0xc0) === 0x80) { - return b & 0x3f; - } else { - throw new Error("invalid UTF-8 encoding"); - } -} - -function code(min, n) { - if (n < min || (0xd800 <= n && n < 0xe000) || n >= 0x10000) { - throw new Error("invalid UTF-8 encoding"); - } else { - return n; - } -} - -export function decode(bytes) { - return _decode(bytes) - .map(x => String.fromCharCode(x)) - .join(""); -} - -function _decode(bytes) { - if (bytes.length === 0) { - return []; - } - - /** - * 1 byte - */ - { - const [b1, ...bs] = bytes; - - if (b1 < 0x80) { - return [code(0x0, b1), ..._decode(bs)]; - } - - if (b1 < 0xc0) { - throw new Error("invalid UTF-8 encoding"); - } - } - - /** - * 2 bytes - */ - { - const [b1, b2, ...bs] = bytes; - - if (b1 < 0xe0) { - return [code(0x80, ((b1 & 0x1f) << 6) + con(b2)), ..._decode(bs)]; - } - } - - /** - * 3 bytes - */ - { - const [b1, b2, b3, ...bs] = bytes; - - if (b1 < 0xf0) { - return [ - code(0x800, ((b1 & 0x0f) << 12) + (con(b2) << 6) + con(b3)), - ..._decode(bs) - ]; - } - } - - /** - * 4 bytes - */ - { - const [b1, b2, b3, b4, ...bs] = bytes; - - if (b1 < 0xf8) { - return [ - code( - 0x10000, - ((((b1 & 0x07) << 18) + con(b2)) << 12) + (con(b3) << 6) + con(b4) - ), - ..._decode(bs) - ]; - } - } - - throw new Error("invalid UTF-8 encoding"); -} diff --git a/node_modules/@webassemblyjs/utf8/src/encoder.js b/node_modules/@webassemblyjs/utf8/src/encoder.js deleted file mode 100644 index 1c482f0..0000000 --- a/node_modules/@webassemblyjs/utf8/src/encoder.js +++ /dev/null @@ -1,44 +0,0 @@ -function con(n) { - return 0x80 | (n & 0x3f); -} - -export function encode(str) { - const arr = str.split("").map(x => x.charCodeAt(0)); - return _encode(arr); -} - -function _encode(arr) { - if (arr.length === 0) { - return []; - } - - const [n, ...ns] = arr; - - if (n < 0) { - throw new Error("utf8"); - } - - if (n < 0x80) { - return [n, ..._encode(ns)]; - } - - if (n < 0x800) { - return [0xc0 | (n >>> 6), con(n), ..._encode(ns)]; - } - - if (n < 0x10000) { - return [0xe0 | (n >>> 12), con(n >>> 6), con(n), ..._encode(ns)]; - } - - if (n < 0x110000) { - return [ - 0xf0 | (n >>> 18), - con(n >>> 12), - con(n >>> 6), - con(n), - ..._encode(ns) - ]; - } - - throw new Error("utf8"); -} diff --git a/node_modules/@webassemblyjs/utf8/src/index.js b/node_modules/@webassemblyjs/utf8/src/index.js deleted file mode 100644 index 82cf9a7..0000000 --- a/node_modules/@webassemblyjs/utf8/src/index.js +++ /dev/null @@ -1,4 +0,0 @@ -// @flow - -export { decode } from "./decoder"; -export { encode } from "./encoder"; diff --git a/node_modules/@webassemblyjs/utf8/test/index.js b/node_modules/@webassemblyjs/utf8/test/index.js deleted file mode 100644 index dabdc6c..0000000 --- a/node_modules/@webassemblyjs/utf8/test/index.js +++ /dev/null @@ -1,13 +0,0 @@ -const { assert } = require("chai"); - -const { decode, encode } = require("../lib"); - -describe("UTF8", () => { - it("should f-1(f(x)) = x", () => { - assert.equal(decode(encode("foo")), "foo"); - assert.equal(decode(encode("éé")), "éé"); - - // TODO(sven): utf8 encoder fails here - // assert.equal(decode(encode("🤣见見")), "🤣见見"); - }); -}); diff --git a/node_modules/@webassemblyjs/wasm-edit/LICENSE b/node_modules/@webassemblyjs/wasm-edit/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/wasm-edit/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/wasm-edit/README.md b/node_modules/@webassemblyjs/wasm-edit/README.md deleted file mode 100644 index f03462f..0000000 --- a/node_modules/@webassemblyjs/wasm-edit/README.md +++ /dev/null @@ -1,86 +0,0 @@ -# @webassemblyjs/wasm-edit - -> Rewrite a WASM binary - -Replace in-place an AST node in the binary. - -## Installation - -```sh -yarn add @webassemblyjs/wasm-edit -``` - -## Usage - -Update: - -```js -import { edit } from "@webassemblyjs/wasm-edit"; - -const binary = [/*...*/]; - -const visitors = { - ModuleImport({ node }) { - node.module = "foo"; - node.name = "bar"; - } -}; - -const newBinary = edit(binary, visitors); -``` - -Replace: - -```js -import { edit } from "@webassemblyjs/wasm-edit"; - -const binary = [/*...*/]; - -const visitors = { - Instr(path) { - const newNode = t.callInstruction(t.indexLiteral(0)); - path.replaceWith(newNode); - } -}; - -const newBinary = edit(binary, visitors); -``` - -Remove: - -```js -import { edit } from "@webassemblyjs/wasm-edit"; - -const binary = [/*...*/]; - -const visitors = { - ModuleExport({ node }) { - path.remove() - } -}; - -const newBinary = edit(binary, visitors); -``` - -Insert: - -```js -import { add } from "@webassemblyjs/wasm-edit"; - -const binary = [/*...*/]; - -const newBinary = add(actualBinary, [ - t.moduleImport("env", "mem", t.memory(t.limit(1))) -]); -``` - -## Providing the AST - -Providing an AST allows you to handle the decoding yourself, here is the API: - -```js -addWithAST(Program, ArrayBuffer, Array<Node>): ArrayBuffer; -editWithAST(Program, ArrayBuffer, visitors): ArrayBuffer; -``` - -Note that the AST will be updated in-place. diff --git a/node_modules/@webassemblyjs/wasm-edit/esm/apply.js b/node_modules/@webassemblyjs/wasm-edit/esm/apply.js deleted file mode 100644 index 4c21569..0000000 --- a/node_modules/@webassemblyjs/wasm-edit/esm/apply.js +++ /dev/null @@ -1,299 +0,0 @@ -function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - -function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } } - -import { encodeNode } from "@webassemblyjs/wasm-gen"; -import { encodeU32 } from "@webassemblyjs/wasm-gen/lib/encoder"; -import { isFunc, isGlobal, assertHasLoc, orderedInsertNode, getSectionMetadata, traverse, getEndOfSection } from "@webassemblyjs/ast"; -import { resizeSectionByteSize, resizeSectionVecSize, createEmptySection, removeSections } from "@webassemblyjs/helper-wasm-section"; -import { overrideBytesInBuffer } from "@webassemblyjs/helper-buffer"; -import { getSectionForNode } from "@webassemblyjs/helper-wasm-bytecode"; - -function shiftLocNodeByDelta(node, delta) { - assertHasLoc(node); // $FlowIgnore: assertHasLoc ensures that - - node.loc.start.column += delta; // $FlowIgnore: assertHasLoc ensures that - - node.loc.end.column += delta; -} - -function applyUpdate(ast, uint8Buffer, _ref) { - var _ref2 = _slicedToArray(_ref, 2), - oldNode = _ref2[0], - newNode = _ref2[1]; - - var deltaElements = 0; - assertHasLoc(oldNode); - var sectionName = getSectionForNode(newNode); - var replacementByteArray = encodeNode(newNode); - /** - * Replace new node as bytes - */ - - uint8Buffer = overrideBytesInBuffer(uint8Buffer, // $FlowIgnore: assertHasLoc ensures that - oldNode.loc.start.column, // $FlowIgnore: assertHasLoc ensures that - oldNode.loc.end.column, replacementByteArray); - /** - * Update function body size if needed - */ - - if (sectionName === "code") { - // Find the parent func - traverse(ast, { - Func: function Func(_ref3) { - var node = _ref3.node; - var funcHasThisIntr = node.body.find(function (n) { - return n === newNode; - }) !== undefined; // Update func's body size if needed - - if (funcHasThisIntr === true) { - // These are the old functions locations informations - assertHasLoc(node); - var oldNodeSize = encodeNode(oldNode).length; - var bodySizeDeltaBytes = replacementByteArray.length - oldNodeSize; - - if (bodySizeDeltaBytes !== 0) { - var newValue = node.metadata.bodySize + bodySizeDeltaBytes; - var newByteArray = encodeU32(newValue); // function body size byte - // FIXME(sven): only handles one byte u32 - - var start = node.loc.start.column; - var end = start + 1; - uint8Buffer = overrideBytesInBuffer(uint8Buffer, start, end, newByteArray); - } - } - } - }); - } - /** - * Update section size - */ - - - var deltaBytes = replacementByteArray.length - ( // $FlowIgnore: assertHasLoc ensures that - oldNode.loc.end.column - oldNode.loc.start.column); // Init location informations - - newNode.loc = { - start: { - line: -1, - column: -1 - }, - end: { - line: -1, - column: -1 - } - }; // Update new node end position - // $FlowIgnore: assertHasLoc ensures that - - newNode.loc.start.column = oldNode.loc.start.column; // $FlowIgnore: assertHasLoc ensures that - - newNode.loc.end.column = // $FlowIgnore: assertHasLoc ensures that - oldNode.loc.start.column + replacementByteArray.length; - return { - uint8Buffer: uint8Buffer, - deltaBytes: deltaBytes, - deltaElements: deltaElements - }; -} - -function applyDelete(ast, uint8Buffer, node) { - var deltaElements = -1; // since we removed an element - - assertHasLoc(node); - var sectionName = getSectionForNode(node); - - if (sectionName === "start") { - var sectionMetadata = getSectionMetadata(ast, "start"); - /** - * The start section only contains one element, - * we need to remove the whole section - */ - - uint8Buffer = removeSections(ast, uint8Buffer, "start"); - - var _deltaBytes = -(sectionMetadata.size.value + 1); - /* section id */ - - - return { - uint8Buffer: uint8Buffer, - deltaBytes: _deltaBytes, - deltaElements: deltaElements - }; - } // replacement is nothing - - - var replacement = []; - uint8Buffer = overrideBytesInBuffer(uint8Buffer, // $FlowIgnore: assertHasLoc ensures that - node.loc.start.column, // $FlowIgnore: assertHasLoc ensures that - node.loc.end.column, replacement); - /** - * Update section - */ - // $FlowIgnore: assertHasLoc ensures that - - var deltaBytes = -(node.loc.end.column - node.loc.start.column); - return { - uint8Buffer: uint8Buffer, - deltaBytes: deltaBytes, - deltaElements: deltaElements - }; -} - -function applyAdd(ast, uint8Buffer, node) { - var deltaElements = +1; // since we added an element - - var sectionName = getSectionForNode(node); - var sectionMetadata = getSectionMetadata(ast, sectionName); // Section doesn't exists, we create an empty one - - if (typeof sectionMetadata === "undefined") { - var res = createEmptySection(ast, uint8Buffer, sectionName); - uint8Buffer = res.uint8Buffer; - sectionMetadata = res.sectionMetadata; - } - /** - * check that the expressions were ended - */ - - - if (isFunc(node)) { - // $FlowIgnore - var body = node.body; - - if (body.length === 0 || body[body.length - 1].id !== "end") { - throw new Error("expressions must be ended"); - } - } - - if (isGlobal(node)) { - // $FlowIgnore - var body = node.init; - - if (body.length === 0 || body[body.length - 1].id !== "end") { - throw new Error("expressions must be ended"); - } - } - /** - * Add nodes - */ - - - var newByteArray = encodeNode(node); // The size of the section doesn't include the storage of the size itself - // we need to manually add it here - - var start = getEndOfSection(sectionMetadata); - var end = start; - /** - * Update section - */ - - var deltaBytes = newByteArray.length; - uint8Buffer = overrideBytesInBuffer(uint8Buffer, start, end, newByteArray); - node.loc = { - start: { - line: -1, - column: start - }, - end: { - line: -1, - column: start + deltaBytes - } - }; // for func add the additional metadata in the AST - - if (node.type === "Func") { - // the size is the first byte - // FIXME(sven): handle LEB128 correctly here - var bodySize = newByteArray[0]; - node.metadata = { - bodySize: bodySize - }; - } - - if (node.type !== "IndexInFuncSection") { - orderedInsertNode(ast.body[0], node); - } - - return { - uint8Buffer: uint8Buffer, - deltaBytes: deltaBytes, - deltaElements: deltaElements - }; -} - -export function applyOperations(ast, uint8Buffer, ops) { - ops.forEach(function (op) { - var state; - var sectionName; - - switch (op.kind) { - case "update": - state = applyUpdate(ast, uint8Buffer, [op.oldNode, op.node]); - sectionName = getSectionForNode(op.node); - break; - - case "delete": - state = applyDelete(ast, uint8Buffer, op.node); - sectionName = getSectionForNode(op.node); - break; - - case "add": - state = applyAdd(ast, uint8Buffer, op.node); - sectionName = getSectionForNode(op.node); - break; - - default: - throw new Error("Unknown operation"); - } - /** - * Resize section vec size. - * If the length of the LEB-encoded size changes, this can change - * the byte length of the section and the offset for nodes in the - * section. So we do this first before resizing section byte size - * or shifting following operations' nodes. - */ - - - if (state.deltaElements !== 0 && sectionName !== "start") { - var oldBufferLength = state.uint8Buffer.length; - state.uint8Buffer = resizeSectionVecSize(ast, state.uint8Buffer, sectionName, state.deltaElements); // Infer bytes added/removed by comparing buffer lengths - - state.deltaBytes += state.uint8Buffer.length - oldBufferLength; - } - /** - * Resize section byte size. - * If the length of the LEB-encoded size changes, this can change - * the offset for nodes in the section. So we do this before - * shifting following operations' nodes. - */ - - - if (state.deltaBytes !== 0 && sectionName !== "start") { - var _oldBufferLength = state.uint8Buffer.length; - state.uint8Buffer = resizeSectionByteSize(ast, state.uint8Buffer, sectionName, state.deltaBytes); // Infer bytes added/removed by comparing buffer lengths - - state.deltaBytes += state.uint8Buffer.length - _oldBufferLength; - } - /** - * Shift following operation's nodes - */ - - - if (state.deltaBytes !== 0) { - ops.forEach(function (op) { - // We don't need to handle add ops, they are positioning independent - switch (op.kind) { - case "update": - shiftLocNodeByDelta(op.oldNode, state.deltaBytes); - break; - - case "delete": - shiftLocNodeByDelta(op.node, state.deltaBytes); - break; - } - }); - } - - uint8Buffer = state.uint8Buffer; - }); - return uint8Buffer; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-edit/esm/index.js b/node_modules/@webassemblyjs/wasm-edit/esm/index.js deleted file mode 100644 index 6ed9d53..0000000 --- a/node_modules/@webassemblyjs/wasm-edit/esm/index.js +++ /dev/null @@ -1,114 +0,0 @@ -import { decode } from "@webassemblyjs/wasm-parser"; -import { traverse } from "@webassemblyjs/ast"; -import { cloneNode } from "@webassemblyjs/ast/lib/clone"; -import { shrinkPaddedLEB128 } from "@webassemblyjs/wasm-opt"; -import { getSectionForNode } from "@webassemblyjs/helper-wasm-bytecode"; -import constants from "@webassemblyjs/helper-wasm-bytecode"; -import { applyOperations } from "./apply"; - -function hashNode(node) { - return JSON.stringify(node); -} - -function preprocess(ab) { - var optBin = shrinkPaddedLEB128(new Uint8Array(ab)); - return optBin.buffer; -} - -function sortBySectionOrder(nodes) { - var originalOrder = new Map(); - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var _node = _step.value; - originalOrder.set(_node, originalOrder.size); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return != null) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - nodes.sort(function (a, b) { - var sectionA = getSectionForNode(a); - var sectionB = getSectionForNode(b); - var aId = constants.sections[sectionA]; - var bId = constants.sections[sectionB]; - - if (typeof aId !== "number" || typeof bId !== "number") { - throw new Error("Section id not found"); - } - - if (aId === bId) { - // $FlowIgnore originalOrder is filled for all nodes - return originalOrder.get(a) - originalOrder.get(b); - } - - return aId - bId; - }); -} - -export function edit(ab, visitors) { - ab = preprocess(ab); - var ast = decode(ab); - return editWithAST(ast, ab, visitors); -} -export function editWithAST(ast, ab, visitors) { - var operations = []; - var uint8Buffer = new Uint8Array(ab); - var nodeBefore; - - function before(type, path) { - nodeBefore = cloneNode(path.node); - } - - function after(type, path) { - if (path.node._deleted === true) { - operations.push({ - kind: "delete", - node: path.node - }); // $FlowIgnore - } else if (hashNode(nodeBefore) !== hashNode(path.node)) { - operations.push({ - kind: "update", - oldNode: nodeBefore, - node: path.node - }); - } - } - - traverse(ast, visitors, before, after); - uint8Buffer = applyOperations(ast, uint8Buffer, operations); - return uint8Buffer.buffer; -} -export function add(ab, newNodes) { - ab = preprocess(ab); - var ast = decode(ab); - return addWithAST(ast, ab, newNodes); -} -export function addWithAST(ast, ab, newNodes) { - // Sort nodes by insertion order - sortBySectionOrder(newNodes); - var uint8Buffer = new Uint8Array(ab); // Map node into operations - - var operations = newNodes.map(function (n) { - return { - kind: "add", - node: n - }; - }); - uint8Buffer = applyOperations(ast, uint8Buffer, operations); - return uint8Buffer.buffer; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-edit/lib/apply.js b/node_modules/@webassemblyjs/wasm-edit/lib/apply.js deleted file mode 100644 index e9cb38f..0000000 --- a/node_modules/@webassemblyjs/wasm-edit/lib/apply.js +++ /dev/null @@ -1,311 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.applyOperations = applyOperations; - -var _wasmGen = require("@webassemblyjs/wasm-gen"); - -var _encoder = require("@webassemblyjs/wasm-gen/lib/encoder"); - -var _ast = require("@webassemblyjs/ast"); - -var _helperWasmSection = require("@webassemblyjs/helper-wasm-section"); - -var _helperBuffer = require("@webassemblyjs/helper-buffer"); - -var _helperWasmBytecode = require("@webassemblyjs/helper-wasm-bytecode"); - -function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - -function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } } - -function shiftLocNodeByDelta(node, delta) { - (0, _ast.assertHasLoc)(node); // $FlowIgnore: assertHasLoc ensures that - - node.loc.start.column += delta; // $FlowIgnore: assertHasLoc ensures that - - node.loc.end.column += delta; -} - -function applyUpdate(ast, uint8Buffer, _ref) { - var _ref2 = _slicedToArray(_ref, 2), - oldNode = _ref2[0], - newNode = _ref2[1]; - - var deltaElements = 0; - (0, _ast.assertHasLoc)(oldNode); - var sectionName = (0, _helperWasmBytecode.getSectionForNode)(newNode); - var replacementByteArray = (0, _wasmGen.encodeNode)(newNode); - /** - * Replace new node as bytes - */ - - uint8Buffer = (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, // $FlowIgnore: assertHasLoc ensures that - oldNode.loc.start.column, // $FlowIgnore: assertHasLoc ensures that - oldNode.loc.end.column, replacementByteArray); - /** - * Update function body size if needed - */ - - if (sectionName === "code") { - // Find the parent func - (0, _ast.traverse)(ast, { - Func: function Func(_ref3) { - var node = _ref3.node; - var funcHasThisIntr = node.body.find(function (n) { - return n === newNode; - }) !== undefined; // Update func's body size if needed - - if (funcHasThisIntr === true) { - // These are the old functions locations informations - (0, _ast.assertHasLoc)(node); - var oldNodeSize = (0, _wasmGen.encodeNode)(oldNode).length; - var bodySizeDeltaBytes = replacementByteArray.length - oldNodeSize; - - if (bodySizeDeltaBytes !== 0) { - var newValue = node.metadata.bodySize + bodySizeDeltaBytes; - var newByteArray = (0, _encoder.encodeU32)(newValue); // function body size byte - // FIXME(sven): only handles one byte u32 - - var start = node.loc.start.column; - var end = start + 1; - uint8Buffer = (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, start, end, newByteArray); - } - } - } - }); - } - /** - * Update section size - */ - - - var deltaBytes = replacementByteArray.length - ( // $FlowIgnore: assertHasLoc ensures that - oldNode.loc.end.column - oldNode.loc.start.column); // Init location informations - - newNode.loc = { - start: { - line: -1, - column: -1 - }, - end: { - line: -1, - column: -1 - } - }; // Update new node end position - // $FlowIgnore: assertHasLoc ensures that - - newNode.loc.start.column = oldNode.loc.start.column; // $FlowIgnore: assertHasLoc ensures that - - newNode.loc.end.column = // $FlowIgnore: assertHasLoc ensures that - oldNode.loc.start.column + replacementByteArray.length; - return { - uint8Buffer: uint8Buffer, - deltaBytes: deltaBytes, - deltaElements: deltaElements - }; -} - -function applyDelete(ast, uint8Buffer, node) { - var deltaElements = -1; // since we removed an element - - (0, _ast.assertHasLoc)(node); - var sectionName = (0, _helperWasmBytecode.getSectionForNode)(node); - - if (sectionName === "start") { - var sectionMetadata = (0, _ast.getSectionMetadata)(ast, "start"); - /** - * The start section only contains one element, - * we need to remove the whole section - */ - - uint8Buffer = (0, _helperWasmSection.removeSections)(ast, uint8Buffer, "start"); - - var _deltaBytes = -(sectionMetadata.size.value + 1); - /* section id */ - - - return { - uint8Buffer: uint8Buffer, - deltaBytes: _deltaBytes, - deltaElements: deltaElements - }; - } // replacement is nothing - - - var replacement = []; - uint8Buffer = (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, // $FlowIgnore: assertHasLoc ensures that - node.loc.start.column, // $FlowIgnore: assertHasLoc ensures that - node.loc.end.column, replacement); - /** - * Update section - */ - // $FlowIgnore: assertHasLoc ensures that - - var deltaBytes = -(node.loc.end.column - node.loc.start.column); - return { - uint8Buffer: uint8Buffer, - deltaBytes: deltaBytes, - deltaElements: deltaElements - }; -} - -function applyAdd(ast, uint8Buffer, node) { - var deltaElements = +1; // since we added an element - - var sectionName = (0, _helperWasmBytecode.getSectionForNode)(node); - var sectionMetadata = (0, _ast.getSectionMetadata)(ast, sectionName); // Section doesn't exists, we create an empty one - - if (typeof sectionMetadata === "undefined") { - var res = (0, _helperWasmSection.createEmptySection)(ast, uint8Buffer, sectionName); - uint8Buffer = res.uint8Buffer; - sectionMetadata = res.sectionMetadata; - } - /** - * check that the expressions were ended - */ - - - if ((0, _ast.isFunc)(node)) { - // $FlowIgnore - var body = node.body; - - if (body.length === 0 || body[body.length - 1].id !== "end") { - throw new Error("expressions must be ended"); - } - } - - if ((0, _ast.isGlobal)(node)) { - // $FlowIgnore - var body = node.init; - - if (body.length === 0 || body[body.length - 1].id !== "end") { - throw new Error("expressions must be ended"); - } - } - /** - * Add nodes - */ - - - var newByteArray = (0, _wasmGen.encodeNode)(node); // The size of the section doesn't include the storage of the size itself - // we need to manually add it here - - var start = (0, _ast.getEndOfSection)(sectionMetadata); - var end = start; - /** - * Update section - */ - - var deltaBytes = newByteArray.length; - uint8Buffer = (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, start, end, newByteArray); - node.loc = { - start: { - line: -1, - column: start - }, - end: { - line: -1, - column: start + deltaBytes - } - }; // for func add the additional metadata in the AST - - if (node.type === "Func") { - // the size is the first byte - // FIXME(sven): handle LEB128 correctly here - var bodySize = newByteArray[0]; - node.metadata = { - bodySize: bodySize - }; - } - - if (node.type !== "IndexInFuncSection") { - (0, _ast.orderedInsertNode)(ast.body[0], node); - } - - return { - uint8Buffer: uint8Buffer, - deltaBytes: deltaBytes, - deltaElements: deltaElements - }; -} - -function applyOperations(ast, uint8Buffer, ops) { - ops.forEach(function (op) { - var state; - var sectionName; - - switch (op.kind) { - case "update": - state = applyUpdate(ast, uint8Buffer, [op.oldNode, op.node]); - sectionName = (0, _helperWasmBytecode.getSectionForNode)(op.node); - break; - - case "delete": - state = applyDelete(ast, uint8Buffer, op.node); - sectionName = (0, _helperWasmBytecode.getSectionForNode)(op.node); - break; - - case "add": - state = applyAdd(ast, uint8Buffer, op.node); - sectionName = (0, _helperWasmBytecode.getSectionForNode)(op.node); - break; - - default: - throw new Error("Unknown operation"); - } - /** - * Resize section vec size. - * If the length of the LEB-encoded size changes, this can change - * the byte length of the section and the offset for nodes in the - * section. So we do this first before resizing section byte size - * or shifting following operations' nodes. - */ - - - if (state.deltaElements !== 0 && sectionName !== "start") { - var oldBufferLength = state.uint8Buffer.length; - state.uint8Buffer = (0, _helperWasmSection.resizeSectionVecSize)(ast, state.uint8Buffer, sectionName, state.deltaElements); // Infer bytes added/removed by comparing buffer lengths - - state.deltaBytes += state.uint8Buffer.length - oldBufferLength; - } - /** - * Resize section byte size. - * If the length of the LEB-encoded size changes, this can change - * the offset for nodes in the section. So we do this before - * shifting following operations' nodes. - */ - - - if (state.deltaBytes !== 0 && sectionName !== "start") { - var _oldBufferLength = state.uint8Buffer.length; - state.uint8Buffer = (0, _helperWasmSection.resizeSectionByteSize)(ast, state.uint8Buffer, sectionName, state.deltaBytes); // Infer bytes added/removed by comparing buffer lengths - - state.deltaBytes += state.uint8Buffer.length - _oldBufferLength; - } - /** - * Shift following operation's nodes - */ - - - if (state.deltaBytes !== 0) { - ops.forEach(function (op) { - // We don't need to handle add ops, they are positioning independent - switch (op.kind) { - case "update": - shiftLocNodeByDelta(op.oldNode, state.deltaBytes); - break; - - case "delete": - shiftLocNodeByDelta(op.node, state.deltaBytes); - break; - } - }); - } - - uint8Buffer = state.uint8Buffer; - }); - return uint8Buffer; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-edit/lib/index.js b/node_modules/@webassemblyjs/wasm-edit/lib/index.js deleted file mode 100644 index 3f9b295..0000000 --- a/node_modules/@webassemblyjs/wasm-edit/lib/index.js +++ /dev/null @@ -1,133 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.edit = edit; -exports.editWithAST = editWithAST; -exports.add = add; -exports.addWithAST = addWithAST; - -var _wasmParser = require("@webassemblyjs/wasm-parser"); - -var _ast = require("@webassemblyjs/ast"); - -var _clone = require("@webassemblyjs/ast/lib/clone"); - -var _wasmOpt = require("@webassemblyjs/wasm-opt"); - -var _helperWasmBytecode = _interopRequireWildcard(require("@webassemblyjs/helper-wasm-bytecode")); - -var _apply = require("./apply"); - -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 hashNode(node) { - return JSON.stringify(node); -} - -function preprocess(ab) { - var optBin = (0, _wasmOpt.shrinkPaddedLEB128)(new Uint8Array(ab)); - return optBin.buffer; -} - -function sortBySectionOrder(nodes) { - var originalOrder = new Map(); - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var _node = _step.value; - originalOrder.set(_node, originalOrder.size); - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return != null) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - nodes.sort(function (a, b) { - var sectionA = (0, _helperWasmBytecode.getSectionForNode)(a); - var sectionB = (0, _helperWasmBytecode.getSectionForNode)(b); - var aId = _helperWasmBytecode.default.sections[sectionA]; - var bId = _helperWasmBytecode.default.sections[sectionB]; - - if (typeof aId !== "number" || typeof bId !== "number") { - throw new Error("Section id not found"); - } - - if (aId === bId) { - // $FlowIgnore originalOrder is filled for all nodes - return originalOrder.get(a) - originalOrder.get(b); - } - - return aId - bId; - }); -} - -function edit(ab, visitors) { - ab = preprocess(ab); - var ast = (0, _wasmParser.decode)(ab); - return editWithAST(ast, ab, visitors); -} - -function editWithAST(ast, ab, visitors) { - var operations = []; - var uint8Buffer = new Uint8Array(ab); - var nodeBefore; - - function before(type, path) { - nodeBefore = (0, _clone.cloneNode)(path.node); - } - - function after(type, path) { - if (path.node._deleted === true) { - operations.push({ - kind: "delete", - node: path.node - }); // $FlowIgnore - } else if (hashNode(nodeBefore) !== hashNode(path.node)) { - operations.push({ - kind: "update", - oldNode: nodeBefore, - node: path.node - }); - } - } - - (0, _ast.traverse)(ast, visitors, before, after); - uint8Buffer = (0, _apply.applyOperations)(ast, uint8Buffer, operations); - return uint8Buffer.buffer; -} - -function add(ab, newNodes) { - ab = preprocess(ab); - var ast = (0, _wasmParser.decode)(ab); - return addWithAST(ast, ab, newNodes); -} - -function addWithAST(ast, ab, newNodes) { - // Sort nodes by insertion order - sortBySectionOrder(newNodes); - var uint8Buffer = new Uint8Array(ab); // Map node into operations - - var operations = newNodes.map(function (n) { - return { - kind: "add", - node: n - }; - }); - uint8Buffer = (0, _apply.applyOperations)(ast, uint8Buffer, operations); - return uint8Buffer.buffer; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-edit/package.json b/node_modules/@webassemblyjs/wasm-edit/package.json deleted file mode 100644 index d6d5cbc..0000000 --- a/node_modules/@webassemblyjs/wasm-edit/package.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "_from": "@webassemblyjs/wasm-edit@1.9.0", - "_id": "@webassemblyjs/wasm-edit@1.9.0", - "_inBundle": false, - "_integrity": "sha512-FgHzBm80uwz5M8WKnMTn6j/sVbqilPdQXTWraSjBwFXSYGirpkSWE2R9Qvz9tNiTKQvoKILpCuTjBKzOIm0nxw==", - "_location": "/@webassemblyjs/wasm-edit", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/wasm-edit@1.9.0", - "name": "@webassemblyjs/wasm-edit", - "escapedName": "@webassemblyjs%2fwasm-edit", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/webpack" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.9.0.tgz", - "_shasum": "3fe6d79d3f0f922183aa86002c42dd256cfee9cf", - "_spec": "@webassemblyjs/wasm-edit@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/webpack", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "dependencies": { - "@webassemblyjs/ast": "1.9.0", - "@webassemblyjs/helper-buffer": "1.9.0", - "@webassemblyjs/helper-wasm-bytecode": "1.9.0", - "@webassemblyjs/helper-wasm-section": "1.9.0", - "@webassemblyjs/wasm-gen": "1.9.0", - "@webassemblyjs/wasm-opt": "1.9.0", - "@webassemblyjs/wasm-parser": "1.9.0", - "@webassemblyjs/wast-printer": "1.9.0" - }, - "deprecated": false, - "description": "> Rewrite a WASM binary", - "devDependencies": { - "@webassemblyjs/helper-test-framework": "1.9.0" - }, - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/wasm-edit", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/wasm-gen/LICENSE b/node_modules/@webassemblyjs/wasm-gen/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/wasm-gen/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/wasm-gen/esm/encoder/index.js b/node_modules/@webassemblyjs/wasm-gen/esm/encoder/index.js deleted file mode 100644 index ec31249..0000000 --- a/node_modules/@webassemblyjs/wasm-gen/esm/encoder/index.js +++ /dev/null @@ -1,301 +0,0 @@ -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 leb from "@webassemblyjs/leb128"; -import * as ieee754 from "@webassemblyjs/ieee754"; -import * as utf8 from "@webassemblyjs/utf8"; -import constants from "@webassemblyjs/helper-wasm-bytecode"; -import { encodeNode } from "../index"; - -function assertNotIdentifierNode(n) { - if (n.type === "Identifier") { - throw new Error("Unsupported node Identifier"); - } -} - -export function encodeVersion(v) { - var bytes = constants.moduleVersion; - bytes[0] = v; - return bytes; -} -export function encodeHeader() { - return constants.magicModuleHeader; -} -export function encodeU32(v) { - var uint8view = new Uint8Array(leb.encodeU32(v)); - - var array = _toConsumableArray(uint8view); - - return array; -} -export function encodeI32(v) { - var uint8view = new Uint8Array(leb.encodeI32(v)); - - var array = _toConsumableArray(uint8view); - - return array; -} -export function encodeI64(v) { - var uint8view = new Uint8Array(leb.encodeI64(v)); - - var array = _toConsumableArray(uint8view); - - return array; -} -export function encodeVec(elements) { - var size = encodeU32(elements.length); - return _toConsumableArray(size).concat(_toConsumableArray(elements)); -} -export function encodeValtype(v) { - var byte = constants.valtypesByString[v]; - - if (typeof byte === "undefined") { - throw new Error("Unknown valtype: " + v); - } - - return parseInt(byte, 10); -} -export function encodeMutability(v) { - var byte = constants.globalTypesByString[v]; - - if (typeof byte === "undefined") { - throw new Error("Unknown mutability: " + v); - } - - return parseInt(byte, 10); -} -export function encodeUTF8Vec(str) { - return encodeVec(utf8.encode(str)); -} -export function encodeLimits(n) { - var out = []; - - if (typeof n.max === "number") { - out.push(0x01); - out.push.apply(out, _toConsumableArray(encodeU32(n.min))); // $FlowIgnore: ensured by the typeof - - out.push.apply(out, _toConsumableArray(encodeU32(n.max))); - } else { - out.push(0x00); - out.push.apply(out, _toConsumableArray(encodeU32(n.min))); - } - - return out; -} -export function encodeModuleImport(n) { - var out = []; - out.push.apply(out, _toConsumableArray(encodeUTF8Vec(n.module))); - out.push.apply(out, _toConsumableArray(encodeUTF8Vec(n.name))); - - switch (n.descr.type) { - case "GlobalType": - { - out.push(0x03); // $FlowIgnore: GlobalType ensure that these props exists - - out.push(encodeValtype(n.descr.valtype)); // $FlowIgnore: GlobalType ensure that these props exists - - out.push(encodeMutability(n.descr.mutability)); - break; - } - - case "Memory": - { - out.push(0x02); // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeLimits(n.descr.limits))); - break; - } - - case "Table": - { - out.push(0x01); - out.push(0x70); // element type - // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeLimits(n.descr.limits))); - break; - } - - case "FuncImportDescr": - { - out.push(0x00); // $FlowIgnore - - assertNotIdentifierNode(n.descr.id); // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeU32(n.descr.id.value))); - break; - } - - default: - throw new Error("Unsupport operation: encode module import of type: " + n.descr.type); - } - - return out; -} -export function encodeSectionMetadata(n) { - var out = []; - var sectionId = constants.sections[n.section]; - - if (typeof sectionId === "undefined") { - throw new Error("Unknown section: " + n.section); - } - - if (n.section === "start") { - /** - * This is not implemented yet because it's a special case which - * doesn't have a vector in its section. - */ - throw new Error("Unsupported section encoding of type start"); - } - - out.push(sectionId); - out.push.apply(out, _toConsumableArray(encodeU32(n.size.value))); - out.push.apply(out, _toConsumableArray(encodeU32(n.vectorOfSize.value))); - return out; -} -export function encodeCallInstruction(n) { - var out = []; - assertNotIdentifierNode(n.index); - out.push(0x10); // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeU32(n.index.value))); - return out; -} -export function encodeCallIndirectInstruction(n) { - var out = []; // $FlowIgnore - - assertNotIdentifierNode(n.index); - out.push(0x11); // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeU32(n.index.value))); // add a reserved byte - - out.push(0x00); - return out; -} -export function encodeModuleExport(n) { - var out = []; - assertNotIdentifierNode(n.descr.id); - var exportTypeByteString = constants.exportTypesByName[n.descr.exportType]; - - if (typeof exportTypeByteString === "undefined") { - throw new Error("Unknown export of type: " + n.descr.exportType); - } - - var exportTypeByte = parseInt(exportTypeByteString, 10); - out.push.apply(out, _toConsumableArray(encodeUTF8Vec(n.name))); - out.push(exportTypeByte); // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeU32(n.descr.id.value))); - return out; -} -export function encodeTypeInstruction(n) { - var out = [0x60]; - var params = n.functype.params.map(function (x) { - return x.valtype; - }).map(encodeValtype); - var results = n.functype.results.map(encodeValtype); - out.push.apply(out, _toConsumableArray(encodeVec(params))); - out.push.apply(out, _toConsumableArray(encodeVec(results))); - return out; -} -export function encodeInstr(n) { - var out = []; - var instructionName = n.id; - - if (typeof n.object === "string") { - instructionName = "".concat(n.object, ".").concat(String(n.id)); - } - - var byteString = constants.symbolsByName[instructionName]; - - if (typeof byteString === "undefined") { - throw new Error("encodeInstr: unknown instruction " + JSON.stringify(instructionName)); - } - - var byte = parseInt(byteString, 10); - out.push(byte); - - if (n.args) { - n.args.forEach(function (arg) { - var encoder = encodeU32; // find correct encoder - - if (n.object === "i32") { - encoder = encodeI32; - } - - if (n.object === "i64") { - encoder = encodeI64; - } - - if (n.object === "f32") { - encoder = ieee754.encodeF32; - } - - if (n.object === "f64") { - encoder = ieee754.encodeF64; - } - - if (arg.type === "NumberLiteral" || arg.type === "FloatLiteral" || arg.type === "LongNumberLiteral") { - // $FlowIgnore - out.push.apply(out, _toConsumableArray(encoder(arg.value))); - } else { - throw new Error("Unsupported instruction argument encoding " + JSON.stringify(arg.type)); - } - }); - } - - return out; -} - -function encodeExpr(instrs) { - var out = []; - instrs.forEach(function (instr) { - // $FlowIgnore - var n = encodeNode(instr); - out.push.apply(out, _toConsumableArray(n)); - }); - return out; -} - -export function encodeStringLiteral(n) { - return encodeUTF8Vec(n.value); -} -export function encodeGlobal(n) { - var out = []; - var _n$globalType = n.globalType, - valtype = _n$globalType.valtype, - mutability = _n$globalType.mutability; - out.push(encodeValtype(valtype)); - out.push(encodeMutability(mutability)); - out.push.apply(out, _toConsumableArray(encodeExpr(n.init))); - return out; -} -export function encodeFuncBody(n) { - var out = []; - out.push(-1); // temporary function body size - // FIXME(sven): get the func locals? - - var localBytes = encodeVec([]); - out.push.apply(out, _toConsumableArray(localBytes)); - var funcBodyBytes = encodeExpr(n.body); - out[0] = funcBodyBytes.length + localBytes.length; - out.push.apply(out, _toConsumableArray(funcBodyBytes)); - return out; -} -export function encodeIndexInFuncSection(n) { - assertNotIdentifierNode(n.index); // $FlowIgnore - - return encodeU32(n.index.value); -} -export function encodeElem(n) { - var out = []; - assertNotIdentifierNode(n.table); // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeU32(n.table.value))); - out.push.apply(out, _toConsumableArray(encodeExpr(n.offset))); // $FlowIgnore - - var funcs = n.funcs.reduce(function (acc, x) { - return _toConsumableArray(acc).concat(_toConsumableArray(encodeU32(x.value))); - }, []); - out.push.apply(out, _toConsumableArray(encodeVec(funcs))); - return out; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-gen/esm/index.js b/node_modules/@webassemblyjs/wasm-gen/esm/index.js deleted file mode 100644 index 83bc19f..0000000 --- a/node_modules/@webassemblyjs/wasm-gen/esm/index.js +++ /dev/null @@ -1,51 +0,0 @@ -import * as encoder from "./encoder"; -export function encodeNode(n) { - switch (n.type) { - case "ModuleImport": - // $FlowIgnore: ModuleImport ensure that the node is well formated - return encoder.encodeModuleImport(n); - - case "SectionMetadata": - // $FlowIgnore: SectionMetadata ensure that the node is well formated - return encoder.encodeSectionMetadata(n); - - case "CallInstruction": - // $FlowIgnore: SectionMetadata ensure that the node is well formated - return encoder.encodeCallInstruction(n); - - case "CallIndirectInstruction": - // $FlowIgnore: SectionMetadata ensure that the node is well formated - return encoder.encodeCallIndirectInstruction(n); - - case "TypeInstruction": - return encoder.encodeTypeInstruction(n); - - case "Instr": - // $FlowIgnore - return encoder.encodeInstr(n); - - case "ModuleExport": - // $FlowIgnore: SectionMetadata ensure that the node is well formated - return encoder.encodeModuleExport(n); - - case "Global": - // $FlowIgnore - return encoder.encodeGlobal(n); - - case "Func": - return encoder.encodeFuncBody(n); - - case "IndexInFuncSection": - return encoder.encodeIndexInFuncSection(n); - - case "StringLiteral": - return encoder.encodeStringLiteral(n); - - case "Elem": - return encoder.encodeElem(n); - - default: - throw new Error("Unsupported encoding for node of type: " + JSON.stringify(n.type)); - } -} -export var encodeU32 = encoder.encodeU32;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-gen/lib/encoder/index.js b/node_modules/@webassemblyjs/wasm-gen/lib/encoder/index.js deleted file mode 100644 index a77bff7..0000000 --- a/node_modules/@webassemblyjs/wasm-gen/lib/encoder/index.js +++ /dev/null @@ -1,357 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.encodeVersion = encodeVersion; -exports.encodeHeader = encodeHeader; -exports.encodeU32 = encodeU32; -exports.encodeI32 = encodeI32; -exports.encodeI64 = encodeI64; -exports.encodeVec = encodeVec; -exports.encodeValtype = encodeValtype; -exports.encodeMutability = encodeMutability; -exports.encodeUTF8Vec = encodeUTF8Vec; -exports.encodeLimits = encodeLimits; -exports.encodeModuleImport = encodeModuleImport; -exports.encodeSectionMetadata = encodeSectionMetadata; -exports.encodeCallInstruction = encodeCallInstruction; -exports.encodeCallIndirectInstruction = encodeCallIndirectInstruction; -exports.encodeModuleExport = encodeModuleExport; -exports.encodeTypeInstruction = encodeTypeInstruction; -exports.encodeInstr = encodeInstr; -exports.encodeStringLiteral = encodeStringLiteral; -exports.encodeGlobal = encodeGlobal; -exports.encodeFuncBody = encodeFuncBody; -exports.encodeIndexInFuncSection = encodeIndexInFuncSection; -exports.encodeElem = encodeElem; - -var leb = _interopRequireWildcard(require("@webassemblyjs/leb128")); - -var ieee754 = _interopRequireWildcard(require("@webassemblyjs/ieee754")); - -var utf8 = _interopRequireWildcard(require("@webassemblyjs/utf8")); - -var _helperWasmBytecode = _interopRequireDefault(require("@webassemblyjs/helper-wasm-bytecode")); - -var _index = require("../index"); - -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 _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 assertNotIdentifierNode(n) { - if (n.type === "Identifier") { - throw new Error("Unsupported node Identifier"); - } -} - -function encodeVersion(v) { - var bytes = _helperWasmBytecode.default.moduleVersion; - bytes[0] = v; - return bytes; -} - -function encodeHeader() { - return _helperWasmBytecode.default.magicModuleHeader; -} - -function encodeU32(v) { - var uint8view = new Uint8Array(leb.encodeU32(v)); - - var array = _toConsumableArray(uint8view); - - return array; -} - -function encodeI32(v) { - var uint8view = new Uint8Array(leb.encodeI32(v)); - - var array = _toConsumableArray(uint8view); - - return array; -} - -function encodeI64(v) { - var uint8view = new Uint8Array(leb.encodeI64(v)); - - var array = _toConsumableArray(uint8view); - - return array; -} - -function encodeVec(elements) { - var size = encodeU32(elements.length); - return _toConsumableArray(size).concat(_toConsumableArray(elements)); -} - -function encodeValtype(v) { - var byte = _helperWasmBytecode.default.valtypesByString[v]; - - if (typeof byte === "undefined") { - throw new Error("Unknown valtype: " + v); - } - - return parseInt(byte, 10); -} - -function encodeMutability(v) { - var byte = _helperWasmBytecode.default.globalTypesByString[v]; - - if (typeof byte === "undefined") { - throw new Error("Unknown mutability: " + v); - } - - return parseInt(byte, 10); -} - -function encodeUTF8Vec(str) { - return encodeVec(utf8.encode(str)); -} - -function encodeLimits(n) { - var out = []; - - if (typeof n.max === "number") { - out.push(0x01); - out.push.apply(out, _toConsumableArray(encodeU32(n.min))); // $FlowIgnore: ensured by the typeof - - out.push.apply(out, _toConsumableArray(encodeU32(n.max))); - } else { - out.push(0x00); - out.push.apply(out, _toConsumableArray(encodeU32(n.min))); - } - - return out; -} - -function encodeModuleImport(n) { - var out = []; - out.push.apply(out, _toConsumableArray(encodeUTF8Vec(n.module))); - out.push.apply(out, _toConsumableArray(encodeUTF8Vec(n.name))); - - switch (n.descr.type) { - case "GlobalType": - { - out.push(0x03); // $FlowIgnore: GlobalType ensure that these props exists - - out.push(encodeValtype(n.descr.valtype)); // $FlowIgnore: GlobalType ensure that these props exists - - out.push(encodeMutability(n.descr.mutability)); - break; - } - - case "Memory": - { - out.push(0x02); // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeLimits(n.descr.limits))); - break; - } - - case "Table": - { - out.push(0x01); - out.push(0x70); // element type - // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeLimits(n.descr.limits))); - break; - } - - case "FuncImportDescr": - { - out.push(0x00); // $FlowIgnore - - assertNotIdentifierNode(n.descr.id); // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeU32(n.descr.id.value))); - break; - } - - default: - throw new Error("Unsupport operation: encode module import of type: " + n.descr.type); - } - - return out; -} - -function encodeSectionMetadata(n) { - var out = []; - var sectionId = _helperWasmBytecode.default.sections[n.section]; - - if (typeof sectionId === "undefined") { - throw new Error("Unknown section: " + n.section); - } - - if (n.section === "start") { - /** - * This is not implemented yet because it's a special case which - * doesn't have a vector in its section. - */ - throw new Error("Unsupported section encoding of type start"); - } - - out.push(sectionId); - out.push.apply(out, _toConsumableArray(encodeU32(n.size.value))); - out.push.apply(out, _toConsumableArray(encodeU32(n.vectorOfSize.value))); - return out; -} - -function encodeCallInstruction(n) { - var out = []; - assertNotIdentifierNode(n.index); - out.push(0x10); // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeU32(n.index.value))); - return out; -} - -function encodeCallIndirectInstruction(n) { - var out = []; // $FlowIgnore - - assertNotIdentifierNode(n.index); - out.push(0x11); // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeU32(n.index.value))); // add a reserved byte - - out.push(0x00); - return out; -} - -function encodeModuleExport(n) { - var out = []; - assertNotIdentifierNode(n.descr.id); - var exportTypeByteString = _helperWasmBytecode.default.exportTypesByName[n.descr.exportType]; - - if (typeof exportTypeByteString === "undefined") { - throw new Error("Unknown export of type: " + n.descr.exportType); - } - - var exportTypeByte = parseInt(exportTypeByteString, 10); - out.push.apply(out, _toConsumableArray(encodeUTF8Vec(n.name))); - out.push(exportTypeByte); // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeU32(n.descr.id.value))); - return out; -} - -function encodeTypeInstruction(n) { - var out = [0x60]; - var params = n.functype.params.map(function (x) { - return x.valtype; - }).map(encodeValtype); - var results = n.functype.results.map(encodeValtype); - out.push.apply(out, _toConsumableArray(encodeVec(params))); - out.push.apply(out, _toConsumableArray(encodeVec(results))); - return out; -} - -function encodeInstr(n) { - var out = []; - var instructionName = n.id; - - if (typeof n.object === "string") { - instructionName = "".concat(n.object, ".").concat(String(n.id)); - } - - var byteString = _helperWasmBytecode.default.symbolsByName[instructionName]; - - if (typeof byteString === "undefined") { - throw new Error("encodeInstr: unknown instruction " + JSON.stringify(instructionName)); - } - - var byte = parseInt(byteString, 10); - out.push(byte); - - if (n.args) { - n.args.forEach(function (arg) { - var encoder = encodeU32; // find correct encoder - - if (n.object === "i32") { - encoder = encodeI32; - } - - if (n.object === "i64") { - encoder = encodeI64; - } - - if (n.object === "f32") { - encoder = ieee754.encodeF32; - } - - if (n.object === "f64") { - encoder = ieee754.encodeF64; - } - - if (arg.type === "NumberLiteral" || arg.type === "FloatLiteral" || arg.type === "LongNumberLiteral") { - // $FlowIgnore - out.push.apply(out, _toConsumableArray(encoder(arg.value))); - } else { - throw new Error("Unsupported instruction argument encoding " + JSON.stringify(arg.type)); - } - }); - } - - return out; -} - -function encodeExpr(instrs) { - var out = []; - instrs.forEach(function (instr) { - // $FlowIgnore - var n = (0, _index.encodeNode)(instr); - out.push.apply(out, _toConsumableArray(n)); - }); - return out; -} - -function encodeStringLiteral(n) { - return encodeUTF8Vec(n.value); -} - -function encodeGlobal(n) { - var out = []; - var _n$globalType = n.globalType, - valtype = _n$globalType.valtype, - mutability = _n$globalType.mutability; - out.push(encodeValtype(valtype)); - out.push(encodeMutability(mutability)); - out.push.apply(out, _toConsumableArray(encodeExpr(n.init))); - return out; -} - -function encodeFuncBody(n) { - var out = []; - out.push(-1); // temporary function body size - // FIXME(sven): get the func locals? - - var localBytes = encodeVec([]); - out.push.apply(out, _toConsumableArray(localBytes)); - var funcBodyBytes = encodeExpr(n.body); - out[0] = funcBodyBytes.length + localBytes.length; - out.push.apply(out, _toConsumableArray(funcBodyBytes)); - return out; -} - -function encodeIndexInFuncSection(n) { - assertNotIdentifierNode(n.index); // $FlowIgnore - - return encodeU32(n.index.value); -} - -function encodeElem(n) { - var out = []; - assertNotIdentifierNode(n.table); // $FlowIgnore - - out.push.apply(out, _toConsumableArray(encodeU32(n.table.value))); - out.push.apply(out, _toConsumableArray(encodeExpr(n.offset))); // $FlowIgnore - - var funcs = n.funcs.reduce(function (acc, x) { - return _toConsumableArray(acc).concat(_toConsumableArray(encodeU32(x.value))); - }, []); - out.push.apply(out, _toConsumableArray(encodeVec(funcs))); - return out; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-gen/lib/index.js b/node_modules/@webassemblyjs/wasm-gen/lib/index.js deleted file mode 100644 index f5095b1..0000000 --- a/node_modules/@webassemblyjs/wasm-gen/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.encodeNode = encodeNode; -exports.encodeU32 = void 0; - -var encoder = _interopRequireWildcard(require("./encoder")); - -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 encodeNode(n) { - switch (n.type) { - case "ModuleImport": - // $FlowIgnore: ModuleImport ensure that the node is well formated - return encoder.encodeModuleImport(n); - - case "SectionMetadata": - // $FlowIgnore: SectionMetadata ensure that the node is well formated - return encoder.encodeSectionMetadata(n); - - case "CallInstruction": - // $FlowIgnore: SectionMetadata ensure that the node is well formated - return encoder.encodeCallInstruction(n); - - case "CallIndirectInstruction": - // $FlowIgnore: SectionMetadata ensure that the node is well formated - return encoder.encodeCallIndirectInstruction(n); - - case "TypeInstruction": - return encoder.encodeTypeInstruction(n); - - case "Instr": - // $FlowIgnore - return encoder.encodeInstr(n); - - case "ModuleExport": - // $FlowIgnore: SectionMetadata ensure that the node is well formated - return encoder.encodeModuleExport(n); - - case "Global": - // $FlowIgnore - return encoder.encodeGlobal(n); - - case "Func": - return encoder.encodeFuncBody(n); - - case "IndexInFuncSection": - return encoder.encodeIndexInFuncSection(n); - - case "StringLiteral": - return encoder.encodeStringLiteral(n); - - case "Elem": - return encoder.encodeElem(n); - - default: - throw new Error("Unsupported encoding for node of type: " + JSON.stringify(n.type)); - } -} - -var encodeU32 = encoder.encodeU32; -exports.encodeU32 = encodeU32;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-gen/package.json b/node_modules/@webassemblyjs/wasm-gen/package.json deleted file mode 100644 index af91ebd..0000000 --- a/node_modules/@webassemblyjs/wasm-gen/package.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "_from": "@webassemblyjs/wasm-gen@1.9.0", - "_id": "@webassemblyjs/wasm-gen@1.9.0", - "_inBundle": false, - "_integrity": "sha512-cPE3o44YzOOHvlsb4+E9qSqjc9Qf9Na1OO/BHFy4OI91XDE14MjFN4lTMezzaIWdPqHnsTodGGNP+iRSYfGkjA==", - "_location": "/@webassemblyjs/wasm-gen", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/wasm-gen@1.9.0", - "name": "@webassemblyjs/wasm-gen", - "escapedName": "@webassemblyjs%2fwasm-gen", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/helper-wasm-section", - "/@webassemblyjs/wasm-edit", - "/@webassemblyjs/wasm-opt" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.9.0.tgz", - "_shasum": "50bc70ec68ded8e2763b01a1418bf43491a7a49c", - "_spec": "@webassemblyjs/wasm-gen@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/wasm-edit", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "dependencies": { - "@webassemblyjs/ast": "1.9.0", - "@webassemblyjs/helper-wasm-bytecode": "1.9.0", - "@webassemblyjs/ieee754": "1.9.0", - "@webassemblyjs/leb128": "1.9.0", - "@webassemblyjs/utf8": "1.9.0" - }, - "deprecated": false, - "description": "WebAssembly binary format printer", - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/wasm-gen", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/wasm-opt/LICENSE b/node_modules/@webassemblyjs/wasm-opt/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/wasm-opt/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/wasm-opt/esm/index.js b/node_modules/@webassemblyjs/wasm-opt/esm/index.js deleted file mode 100644 index f9d9232..0000000 --- a/node_modules/@webassemblyjs/wasm-opt/esm/index.js +++ /dev/null @@ -1,41 +0,0 @@ -function _typeof(obj) { 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); } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -import { decode } from "@webassemblyjs/wasm-parser"; -import { shrinkPaddedLEB128 as makeShrinkPaddedLEB128 } from "./leb128.js"; - -var OptimizerError = -/*#__PURE__*/ -function (_Error) { - _inherits(OptimizerError, _Error); - - function OptimizerError(name, initalError) { - var _this; - - _classCallCheck(this, OptimizerError); - - _this = _possibleConstructorReturn(this, (OptimizerError.__proto__ || Object.getPrototypeOf(OptimizerError)).call(this, "Error while optimizing: " + name + ": " + initalError.message)); - _this.stack = initalError.stack; - return _this; - } - - return OptimizerError; -}(Error); - -var decoderOpts = { - ignoreCodeSection: true, - ignoreDataSection: true -}; -export function shrinkPaddedLEB128(uint8Buffer) { - try { - var ast = decode(uint8Buffer.buffer, decoderOpts); - return makeShrinkPaddedLEB128(ast, uint8Buffer); - } catch (e) { - throw new OptimizerError("shrinkPaddedLEB128", e); - } -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-opt/esm/leb128.js b/node_modules/@webassemblyjs/wasm-opt/esm/leb128.js deleted file mode 100644 index 3150c9e..0000000 --- a/node_modules/@webassemblyjs/wasm-opt/esm/leb128.js +++ /dev/null @@ -1,47 +0,0 @@ -import { traverse, shiftSection } from "@webassemblyjs/ast"; -import { encodeU32 } from "@webassemblyjs/wasm-gen/lib/encoder"; -import { overrideBytesInBuffer } from "@webassemblyjs/helper-buffer"; - -function shiftFollowingSections(ast, _ref, deltaInSizeEncoding) { - var section = _ref.section; - // Once we hit our section every that is after needs to be shifted by the delta - var encounteredSection = false; - traverse(ast, { - SectionMetadata: function SectionMetadata(path) { - if (path.node.section === section) { - encounteredSection = true; - return; - } - - if (encounteredSection === true) { - shiftSection(ast, path.node, deltaInSizeEncoding); - } - } - }); -} - -export function shrinkPaddedLEB128(ast, uint8Buffer) { - traverse(ast, { - SectionMetadata: function SectionMetadata(_ref2) { - var node = _ref2.node; - - /** - * Section size - */ - { - var newu32Encoded = encodeU32(node.size.value); - var newu32EncodedLen = newu32Encoded.length; - var start = node.size.loc.start.column; - var end = node.size.loc.end.column; - var oldu32EncodedLen = end - start; - - if (newu32EncodedLen !== oldu32EncodedLen) { - var deltaInSizeEncoding = oldu32EncodedLen - newu32EncodedLen; - uint8Buffer = overrideBytesInBuffer(uint8Buffer, start, end, newu32Encoded); - shiftFollowingSections(ast, node, -deltaInSizeEncoding); - } - } - } - }); - return uint8Buffer; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-opt/lib/index.js b/node_modules/@webassemblyjs/wasm-opt/lib/index.js deleted file mode 100644 index 4355961..0000000 --- a/node_modules/@webassemblyjs/wasm-opt/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.shrinkPaddedLEB128 = shrinkPaddedLEB128; - -var _wasmParser = require("@webassemblyjs/wasm-parser"); - -var _leb = require("./leb128.js"); - -function _typeof(obj) { 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); } - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -var OptimizerError = -/*#__PURE__*/ -function (_Error) { - _inherits(OptimizerError, _Error); - - function OptimizerError(name, initalError) { - var _this; - - _classCallCheck(this, OptimizerError); - - _this = _possibleConstructorReturn(this, (OptimizerError.__proto__ || Object.getPrototypeOf(OptimizerError)).call(this, "Error while optimizing: " + name + ": " + initalError.message)); - _this.stack = initalError.stack; - return _this; - } - - return OptimizerError; -}(Error); - -var decoderOpts = { - ignoreCodeSection: true, - ignoreDataSection: true -}; - -function shrinkPaddedLEB128(uint8Buffer) { - try { - var ast = (0, _wasmParser.decode)(uint8Buffer.buffer, decoderOpts); - return (0, _leb.shrinkPaddedLEB128)(ast, uint8Buffer); - } catch (e) { - throw new OptimizerError("shrinkPaddedLEB128", e); - } -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js b/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js deleted file mode 100644 index e4a0e85..0000000 --- a/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.shrinkPaddedLEB128 = shrinkPaddedLEB128; - -var _ast = require("@webassemblyjs/ast"); - -var _encoder = require("@webassemblyjs/wasm-gen/lib/encoder"); - -var _helperBuffer = require("@webassemblyjs/helper-buffer"); - -function shiftFollowingSections(ast, _ref, deltaInSizeEncoding) { - var section = _ref.section; - // Once we hit our section every that is after needs to be shifted by the delta - var encounteredSection = false; - (0, _ast.traverse)(ast, { - SectionMetadata: function SectionMetadata(path) { - if (path.node.section === section) { - encounteredSection = true; - return; - } - - if (encounteredSection === true) { - (0, _ast.shiftSection)(ast, path.node, deltaInSizeEncoding); - } - } - }); -} - -function shrinkPaddedLEB128(ast, uint8Buffer) { - (0, _ast.traverse)(ast, { - SectionMetadata: function SectionMetadata(_ref2) { - var node = _ref2.node; - - /** - * Section size - */ - { - var newu32Encoded = (0, _encoder.encodeU32)(node.size.value); - var newu32EncodedLen = newu32Encoded.length; - var start = node.size.loc.start.column; - var end = node.size.loc.end.column; - var oldu32EncodedLen = end - start; - - if (newu32EncodedLen !== oldu32EncodedLen) { - var deltaInSizeEncoding = oldu32EncodedLen - newu32EncodedLen; - uint8Buffer = (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, start, end, newu32Encoded); - shiftFollowingSections(ast, node, -deltaInSizeEncoding); - } - } - } - }); - return uint8Buffer; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-opt/package.json b/node_modules/@webassemblyjs/wasm-opt/package.json deleted file mode 100644 index b22e943..0000000 --- a/node_modules/@webassemblyjs/wasm-opt/package.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "_from": "@webassemblyjs/wasm-opt@1.9.0", - "_id": "@webassemblyjs/wasm-opt@1.9.0", - "_inBundle": false, - "_integrity": "sha512-Qkjgm6Anhm+OMbIL0iokO7meajkzQD71ioelnfPEj6r4eOFuqm4YC3VBPqXjFyyNwowzbMD+hizmprP/Fwkl2A==", - "_location": "/@webassemblyjs/wasm-opt", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/wasm-opt@1.9.0", - "name": "@webassemblyjs/wasm-opt", - "escapedName": "@webassemblyjs%2fwasm-opt", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/wasm-edit" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.9.0.tgz", - "_shasum": "2211181e5b31326443cc8112eb9f0b9028721a61", - "_spec": "@webassemblyjs/wasm-opt@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/wasm-edit", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "dependencies": { - "@webassemblyjs/ast": "1.9.0", - "@webassemblyjs/helper-buffer": "1.9.0", - "@webassemblyjs/wasm-gen": "1.9.0", - "@webassemblyjs/wasm-parser": "1.9.0" - }, - "deprecated": false, - "description": "", - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/wasm-opt", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/wasm-parser/LICENSE b/node_modules/@webassemblyjs/wasm-parser/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/wasm-parser/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/wasm-parser/README.md b/node_modules/@webassemblyjs/wasm-parser/README.md deleted file mode 100644 index 19058d7..0000000 --- a/node_modules/@webassemblyjs/wasm-parser/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# @webassemblyjs/wasm-parser - -> WebAssembly binary format parser - -## Installation - -```sh -yarn add @webassemblyjs/wasm-parser -``` - -## Usage - -```js -import { decode } from "@webassemblyjs/wasm-parser"; - -const decoderOpts = {}; - -const ast = decode(binary, decoderOpts); -``` - -### Decoder options - -- `dump`: print dump information while decoding (default `false`) -- `ignoreCodeSection`: ignore the code section (default `false`) -- `ignoreDataSection`: ignore the data section (default `false`) - diff --git a/node_modules/@webassemblyjs/wasm-parser/esm/decoder.js b/node_modules/@webassemblyjs/wasm-parser/esm/decoder.js deleted file mode 100644 index 0e48f8c..0000000 --- a/node_modules/@webassemblyjs/wasm-parser/esm/decoder.js +++ /dev/null @@ -1,1760 +0,0 @@ -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 { CompileError } from "@webassemblyjs/helper-api-error"; -import * as ieee754 from "@webassemblyjs/ieee754"; -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"; - -function toHex(n) { - return "0x" + Number(n).toString(16); -} - -function byteArrayEq(l, r) { - if (l.length !== r.length) { - return false; - } - - for (var i = 0; i < l.length; i++) { - if (l[i] !== r[i]) { - return false; - } - } - - return true; -} - -export function decode(ab, opts) { - var buf = new Uint8Array(ab); - var getUniqueName = t.getUniqueNameGenerator(); - var offset = 0; - - function getPosition() { - return { - line: -1, - column: offset - }; - } - - function dump(b, msg) { - if (opts.dump === false) return; - var pad = "\t\t\t\t\t\t\t\t\t\t"; - var str = ""; - - if (b.length < 5) { - str = b.map(toHex).join(" "); - } else { - str = "..."; - } - - console.log(toHex(offset) + ":\t", str, pad, ";", msg); - } - - function dumpSep(msg) { - if (opts.dump === false) return; - console.log(";", msg); - } - /** - * TODO(sven): we can atually use a same structure - * we are adding incrementally new features - */ - - - var state = { - elementsInFuncSection: [], - elementsInExportSection: [], - elementsInCodeSection: [], - - /** - * Decode memory from: - * - Memory section - */ - memoriesInModule: [], - - /** - * Decoded types from: - * - Type section - */ - typesInModule: [], - - /** - * Decoded functions from: - * - Function section - * - Import section - */ - functionsInModule: [], - - /** - * Decoded tables from: - * - Table section - */ - tablesInModule: [], - - /** - * Decoded globals from: - * - Global section - */ - globalsInModule: [] - }; - - function isEOF() { - return offset >= buf.length; - } - - function eatBytes(n) { - offset = offset + n; - } - - function readBytesAtOffset(_offset, numberOfBytes) { - var arr = []; - - for (var i = 0; i < numberOfBytes; i++) { - arr.push(buf[_offset + i]); - } - - return arr; - } - - function readBytes(numberOfBytes) { - return readBytesAtOffset(offset, numberOfBytes); - } - - function readF64() { - var bytes = readBytes(ieee754.NUMBER_OF_BYTE_F64); - var value = ieee754.decodeF64(bytes); - - if (Math.sign(value) * value === Infinity) { - return { - value: Math.sign(value), - inf: true, - nextIndex: ieee754.NUMBER_OF_BYTE_F64 - }; - } - - if (isNaN(value)) { - var sign = bytes[bytes.length - 1] >> 7 ? -1 : 1; - var mantissa = 0; - - for (var i = 0; i < bytes.length - 2; ++i) { - mantissa += bytes[i] * Math.pow(256, i); - } - - mantissa += bytes[bytes.length - 2] % 16 * Math.pow(256, bytes.length - 2); - return { - value: sign * mantissa, - nan: true, - nextIndex: ieee754.NUMBER_OF_BYTE_F64 - }; - } - - return { - value: value, - nextIndex: ieee754.NUMBER_OF_BYTE_F64 - }; - } - - function readF32() { - var bytes = readBytes(ieee754.NUMBER_OF_BYTE_F32); - var value = ieee754.decodeF32(bytes); - - if (Math.sign(value) * value === Infinity) { - return { - value: Math.sign(value), - inf: true, - nextIndex: ieee754.NUMBER_OF_BYTE_F32 - }; - } - - if (isNaN(value)) { - var sign = bytes[bytes.length - 1] >> 7 ? -1 : 1; - var mantissa = 0; - - for (var i = 0; i < bytes.length - 2; ++i) { - mantissa += bytes[i] * Math.pow(256, i); - } - - mantissa += bytes[bytes.length - 2] % 128 * Math.pow(256, bytes.length - 2); - return { - value: sign * mantissa, - nan: true, - nextIndex: ieee754.NUMBER_OF_BYTE_F32 - }; - } - - return { - value: value, - nextIndex: ieee754.NUMBER_OF_BYTE_F32 - }; - } - - function readUTF8String() { - var lenu32 = readU32(); // Don't eat any bytes. Instead, peek ahead of the current offset using - // readBytesAtOffset below. This keeps readUTF8String neutral with respect - // to the current offset, just like the other readX functions. - - var strlen = lenu32.value; - dump([strlen], "string length"); - var bytes = readBytesAtOffset(offset + lenu32.nextIndex, strlen); - var value = utf8.decode(bytes); - return { - value: value, - nextIndex: strlen + lenu32.nextIndex - }; - } - /** - * Decode an unsigned 32bits integer - * - * The length will be handled by the leb librairy, we pass the max number of - * byte. - */ - - - function readU32() { - var bytes = readBytes(MAX_NUMBER_OF_BYTE_U32); - var buffer = Buffer.from(bytes); - return decodeUInt32(buffer); - } - - function readVaruint32() { - // where 32 bits = max 4 bytes - var bytes = readBytes(4); - var buffer = Buffer.from(bytes); - return decodeUInt32(buffer); - } - - function readVaruint7() { - // where 7 bits = max 1 bytes - var bytes = readBytes(1); - var buffer = Buffer.from(bytes); - return decodeUInt32(buffer); - } - /** - * Decode a signed 32bits interger - */ - - - function read32() { - var bytes = readBytes(MAX_NUMBER_OF_BYTE_U32); - var buffer = Buffer.from(bytes); - return decodeInt32(buffer); - } - /** - * Decode a signed 64bits integer - */ - - - function read64() { - var bytes = readBytes(MAX_NUMBER_OF_BYTE_U64); - var buffer = Buffer.from(bytes); - return decodeInt64(buffer); - } - - function readU64() { - var bytes = readBytes(MAX_NUMBER_OF_BYTE_U64); - var buffer = Buffer.from(bytes); - return decodeUInt64(buffer); - } - - function readByte() { - return readBytes(1)[0]; - } - - function parseModuleHeader() { - if (isEOF() === true || offset + 4 > buf.length) { - throw new Error("unexpected end"); - } - - var header = readBytes(4); - - if (byteArrayEq(constants.magicModuleHeader, header) === false) { - throw new CompileError("magic header not detected"); - } - - dump(header, "wasm magic header"); - eatBytes(4); - } - - function parseVersion() { - if (isEOF() === true || offset + 4 > buf.length) { - throw new Error("unexpected end"); - } - - var version = readBytes(4); - - if (byteArrayEq(constants.moduleVersion, version) === false) { - throw new CompileError("unknown binary version"); - } - - dump(version, "wasm version"); - eatBytes(4); - } - - function parseVec(cast) { - var u32 = readU32(); - var length = u32.value; - eatBytes(u32.nextIndex); - dump([length], "number"); - - if (length === 0) { - return []; - } - - var elements = []; - - for (var i = 0; i < length; i++) { - var byte = readByte(); - eatBytes(1); - var value = cast(byte); - dump([byte], value); - - if (typeof value === "undefined") { - throw new CompileError("Internal failure: parseVec could not cast the value"); - } - - elements.push(value); - } - - return elements; - } // Type section - // https://webassembly.github.io/spec/binary/modules.html#binary-typesec - - - function parseTypeSection(numberOfTypes) { - var typeInstructionNodes = []; - dump([numberOfTypes], "num types"); - - for (var i = 0; i < numberOfTypes; i++) { - var _startLoc = getPosition(); - - dumpSep("type " + i); - var type = readByte(); - eatBytes(1); - - if (type == constants.types.func) { - dump([type], "func"); - var paramValtypes = parseVec(function (b) { - return constants.valtypes[b]; - }); - var params = paramValtypes.map(function (v) { - return t.funcParam( - /*valtype*/ - v); - }); - var result = parseVec(function (b) { - return constants.valtypes[b]; - }); - typeInstructionNodes.push(function () { - var endLoc = getPosition(); - return t.withLoc(t.typeInstruction(undefined, t.signature(params, result)), endLoc, _startLoc); - }()); - state.typesInModule.push({ - params: params, - result: result - }); - } else { - throw new Error("Unsupported type: " + toHex(type)); - } - } - - return typeInstructionNodes; - } // Import section - // https://webassembly.github.io/spec/binary/modules.html#binary-importsec - - - function parseImportSection(numberOfImports) { - var imports = []; - - for (var i = 0; i < numberOfImports; i++) { - dumpSep("import header " + i); - - var _startLoc2 = getPosition(); - /** - * Module name - */ - - - var moduleName = readUTF8String(); - 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") { - throw new CompileError("function signature not found (".concat(typeindex, ")")); - } - - var id = getUniqueName("func"); - importDescr = t.funcImportDescr(id, t.signature(signature.params, signature.result)); - state.functionsInModule.push({ - id: t.identifier(name.value), - signature: signature, - isExternal: true - }); - } else if (descrType === "global") { - importDescr = parseGlobalType(); - var globalNode = t.global(importDescr, []); - state.globalsInModule.push(globalNode); - } else if (descrType === "table") { - importDescr = parseTableType(i); - } else if (descrType === "mem") { - var memoryNode = parseMemoryType(0); - state.memoriesInModule.push(memoryNode); - importDescr = memoryNode; - } else { - throw new CompileError("Unsupported import of type: " + descrType); - } - - imports.push(function () { - var endLoc = getPosition(); - return t.withLoc(t.moduleImport(moduleName.value, name.value, importDescr), endLoc, _startLoc2); - }()); - } - - return imports; - } // Function section - // https://webassembly.github.io/spec/binary/modules.html#function-section - - - function parseFuncSection(numberOfFunctions) { - dump([numberOfFunctions], "num funcs"); - - for (var i = 0; i < numberOfFunctions; i++) { - var indexU32 = readU32(); - var typeindex = indexU32.value; - eatBytes(indexU32.nextIndex); - dump([typeindex], "type index"); - var signature = state.typesInModule[typeindex]; - - if (typeof signature === "undefined") { - throw new CompileError("function signature not found (".concat(typeindex, ")")); - } // preserve anonymous, a name might be resolved later - - - var id = t.withRaw(t.identifier(getUniqueName("func")), ""); - state.functionsInModule.push({ - id: id, - signature: signature, - isExternal: false - }); - } - } // Export section - // https://webassembly.github.io/spec/binary/modules.html#export-section - - - function parseExportSection(numberOfExport) { - dump([numberOfExport], "num exports"); // Parse vector of exports - - for (var i = 0; i < numberOfExport; i++) { - var _startLoc3 = getPosition(); - /** - * Name - */ - - - var name = readUTF8String(); - eatBytes(name.nextIndex); - dump([], "export name (".concat(name.value, ")")); - /** - * exportdescr - */ - - var typeIndex = readByte(); - eatBytes(1); - dump([typeIndex], "export kind"); - var indexu32 = readU32(); - var index = indexu32.value; - eatBytes(indexu32.nextIndex); - dump([index], "export index"); - var id = void 0, - signature = void 0; - - if (constants.exportTypes[typeIndex] === "Func") { - var func = state.functionsInModule[index]; - - if (typeof func === "undefined") { - throw new CompileError("unknown function (".concat(index, ")")); - } - - id = t.numberLiteralFromRaw(index, String(index)); - signature = func.signature; - } else if (constants.exportTypes[typeIndex] === "Table") { - var table = state.tablesInModule[index]; - - if (typeof table === "undefined") { - throw new CompileError("unknown table ".concat(index)); - } - - id = t.numberLiteralFromRaw(index, String(index)); - signature = null; - } else if (constants.exportTypes[typeIndex] === "Mem") { - var memNode = state.memoriesInModule[index]; - - if (typeof memNode === "undefined") { - throw new CompileError("unknown memory ".concat(index)); - } - - id = t.numberLiteralFromRaw(index, String(index)); - signature = null; - } else if (constants.exportTypes[typeIndex] === "Global") { - var global = state.globalsInModule[index]; - - if (typeof global === "undefined") { - throw new CompileError("unknown global ".concat(index)); - } - - id = t.numberLiteralFromRaw(index, String(index)); - signature = null; - } else { - console.warn("Unsupported export type: " + toHex(typeIndex)); - return; - } - - var endLoc = getPosition(); - state.elementsInExportSection.push({ - name: name.value, - type: constants.exportTypes[typeIndex], - signature: signature, - id: id, - index: index, - endLoc: endLoc, - startLoc: _startLoc3 - }); - } - } // Code section - // https://webassembly.github.io/spec/binary/modules.html#code-section - - - function parseCodeSection(numberOfFuncs) { - dump([numberOfFuncs], "number functions"); // Parse vector of function - - for (var i = 0; i < numberOfFuncs; i++) { - var _startLoc4 = getPosition(); - - dumpSep("function body " + i); // the u32 size of the function code in bytes - // Ignore it for now - - var bodySizeU32 = readU32(); - eatBytes(bodySizeU32.nextIndex); - dump([bodySizeU32.value], "function body size"); - var code = []; - /** - * Parse locals - */ - - var funcLocalNumU32 = readU32(); - var funcLocalNum = funcLocalNumU32.value; - eatBytes(funcLocalNumU32.nextIndex); - dump([funcLocalNum], "num locals"); - var locals = []; - - for (var _i = 0; _i < funcLocalNum; _i++) { - var _startLoc5 = getPosition(); - - var localCountU32 = readU32(); - var localCount = localCountU32.value; - eatBytes(localCountU32.nextIndex); - dump([localCount], "num local"); - var valtypeByte = readByte(); - eatBytes(1); - var type = constants.valtypes[valtypeByte]; - var args = []; - - for (var _i2 = 0; _i2 < localCount; _i2++) { - args.push(t.valtypeLiteral(type)); - } - - var localNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.instruction("local", args), endLoc, _startLoc5); - }(); - - locals.push(localNode); - dump([valtypeByte], type); - - if (typeof type === "undefined") { - throw new CompileError("Unexpected valtype: " + toHex(valtypeByte)); - } - } - - code.push.apply(code, locals); // Decode instructions until the end - - parseInstructionBlock(code); - var endLoc = getPosition(); - state.elementsInCodeSection.push({ - code: code, - locals: locals, - endLoc: endLoc, - startLoc: _startLoc4, - bodySize: bodySizeU32.value - }); - } - } - - function parseInstructionBlock(code) { - while (true) { - var _startLoc6 = getPosition(); - - var instructionAlreadyCreated = false; - var instructionByte = readByte(); - eatBytes(1); - - if (instructionByte === 0xfe) { - throw new CompileError("Atomic instructions are not implemented"); - } - - var instruction = constants.symbolsByByte[instructionByte]; - - if (typeof instruction === "undefined") { - throw new CompileError("Unexpected instruction: " + toHex(instructionByte)); - } - - if (typeof instruction.object === "string") { - dump([instructionByte], "".concat(instruction.object, ".").concat(instruction.name)); - } else { - dump([instructionByte], instruction.name); - } - /** - * End of the function - */ - - - if (instruction.name === "end") { - var node = function () { - var endLoc = getPosition(); - return t.withLoc(t.instruction(instruction.name), endLoc, _startLoc6); - }(); - - code.push(node); - break; - } - - var args = []; - - if (instruction.name === "loop") { - var _startLoc7 = getPosition(); - - var blocktypeByte = readByte(); - eatBytes(1); - var blocktype = constants.blockTypes[blocktypeByte]; - dump([blocktypeByte], "blocktype"); - - if (typeof blocktype === "undefined") { - throw new CompileError("Unexpected blocktype: " + toHex(blocktypeByte)); - } - - var instr = []; - parseInstructionBlock(instr); // preserve anonymous - - var label = t.withRaw(t.identifier(getUniqueName("loop")), ""); - - var loopNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.loopInstruction(label, blocktype, instr), endLoc, _startLoc7); - }(); - - code.push(loopNode); - instructionAlreadyCreated = true; - } else if (instruction.name === "if") { - var _startLoc8 = getPosition(); - - var _blocktypeByte = readByte(); - - eatBytes(1); - var _blocktype = constants.blockTypes[_blocktypeByte]; - dump([_blocktypeByte], "blocktype"); - - if (typeof _blocktype === "undefined") { - throw new CompileError("Unexpected blocktype: " + toHex(_blocktypeByte)); - } - - var testIndex = t.withRaw(t.identifier(getUniqueName("if")), ""); - var ifBody = []; - parseInstructionBlock(ifBody); // Defaults to no alternate - - var elseIndex = 0; - - for (elseIndex = 0; elseIndex < ifBody.length; ++elseIndex) { - var _instr = ifBody[elseIndex]; - - if (_instr.type === "Instr" && _instr.id === "else") { - break; - } - } - - var consequentInstr = ifBody.slice(0, elseIndex); - var alternate = ifBody.slice(elseIndex + 1); // wast sugar - - var testInstrs = []; - - var ifNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.ifInstruction(testIndex, testInstrs, _blocktype, consequentInstr, alternate), endLoc, _startLoc8); - }(); - - code.push(ifNode); - instructionAlreadyCreated = true; - } else if (instruction.name === "block") { - var _startLoc9 = getPosition(); - - var _blocktypeByte2 = readByte(); - - eatBytes(1); - var _blocktype2 = constants.blockTypes[_blocktypeByte2]; - dump([_blocktypeByte2], "blocktype"); - - if (typeof _blocktype2 === "undefined") { - throw new CompileError("Unexpected blocktype: " + toHex(_blocktypeByte2)); - } - - var _instr2 = []; - parseInstructionBlock(_instr2); // preserve anonymous - - var _label = t.withRaw(t.identifier(getUniqueName("block")), ""); - - var blockNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.blockInstruction(_label, _instr2, _blocktype2), endLoc, _startLoc9); - }(); - - code.push(blockNode); - instructionAlreadyCreated = true; - } else if (instruction.name === "call") { - var indexu32 = readU32(); - var index = indexu32.value; - eatBytes(indexu32.nextIndex); - dump([index], "index"); - - var callNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.callInstruction(t.indexLiteral(index)), endLoc, _startLoc6); - }(); - - code.push(callNode); - instructionAlreadyCreated = true; - } else if (instruction.name === "call_indirect") { - var _startLoc10 = getPosition(); - - var indexU32 = readU32(); - var typeindex = indexU32.value; - eatBytes(indexU32.nextIndex); - dump([typeindex], "type index"); - var signature = state.typesInModule[typeindex]; - - if (typeof signature === "undefined") { - throw new CompileError("call_indirect signature not found (".concat(typeindex, ")")); - } - - var _callNode = t.callIndirectInstruction(t.signature(signature.params, signature.result), []); - - var flagU32 = readU32(); - var flag = flagU32.value; // 0x00 - reserved byte - - eatBytes(flagU32.nextIndex); - - if (flag !== 0) { - throw new CompileError("zero flag expected"); - } - - code.push(function () { - var endLoc = getPosition(); - return t.withLoc(_callNode, endLoc, _startLoc10); - }()); - instructionAlreadyCreated = true; - } else if (instruction.name === "br_table") { - var indicesu32 = readU32(); - var indices = indicesu32.value; - eatBytes(indicesu32.nextIndex); - dump([indices], "num indices"); - - for (var i = 0; i <= indices; i++) { - var _indexu = readU32(); - - var _index = _indexu.value; - eatBytes(_indexu.nextIndex); - dump([_index], "index"); - args.push(t.numberLiteralFromRaw(_indexu.value.toString(), "u32")); - } - } else if (instructionByte >= 0x28 && instructionByte <= 0x40) { - /** - * Memory instructions - */ - if (instruction.name === "grow_memory" || instruction.name === "current_memory") { - var _indexU = readU32(); - - var _index2 = _indexU.value; - eatBytes(_indexU.nextIndex); - - if (_index2 !== 0) { - throw new Error("zero flag expected"); - } - - dump([_index2], "index"); - } else { - var aligun32 = readU32(); - var align = aligun32.value; - eatBytes(aligun32.nextIndex); - dump([align], "align"); - var offsetu32 = readU32(); - var _offset2 = offsetu32.value; - eatBytes(offsetu32.nextIndex); - dump([_offset2], "offset"); - } - } else if (instructionByte >= 0x41 && instructionByte <= 0x44) { - /** - * Numeric instructions - */ - if (instruction.object === "i32") { - var value32 = read32(); - var value = value32.value; - eatBytes(value32.nextIndex); - dump([value], "i32 value"); - args.push(t.numberLiteralFromRaw(value)); - } - - if (instruction.object === "u32") { - var valueu32 = readU32(); - var _value = valueu32.value; - eatBytes(valueu32.nextIndex); - dump([_value], "u32 value"); - args.push(t.numberLiteralFromRaw(_value)); - } - - if (instruction.object === "i64") { - var value64 = read64(); - var _value2 = value64.value; - eatBytes(value64.nextIndex); - dump([Number(_value2.toString())], "i64 value"); - var high = _value2.high, - low = _value2.low; - var _node = { - type: "LongNumberLiteral", - value: { - high: high, - low: low - } - }; - args.push(_node); - } - - if (instruction.object === "u64") { - var valueu64 = readU64(); - var _value3 = valueu64.value; - eatBytes(valueu64.nextIndex); - dump([Number(_value3.toString())], "u64 value"); - var _high = _value3.high, - _low = _value3.low; - var _node2 = { - type: "LongNumberLiteral", - value: { - high: _high, - low: _low - } - }; - args.push(_node2); - } - - if (instruction.object === "f32") { - var valuef32 = readF32(); - var _value4 = valuef32.value; - eatBytes(valuef32.nextIndex); - dump([_value4], "f32 value"); - args.push( // $FlowIgnore - t.floatLiteral(_value4, valuef32.nan, valuef32.inf, String(_value4))); - } - - if (instruction.object === "f64") { - var valuef64 = readF64(); - var _value5 = valuef64.value; - eatBytes(valuef64.nextIndex); - dump([_value5], "f64 value"); - args.push( // $FlowIgnore - t.floatLiteral(_value5, valuef64.nan, valuef64.inf, String(_value5))); - } - } else { - for (var _i3 = 0; _i3 < instruction.numberOfArgs; _i3++) { - var u32 = readU32(); - eatBytes(u32.nextIndex); - dump([u32.value], "argument " + _i3); - args.push(t.numberLiteralFromRaw(u32.value)); - } - } - - if (instructionAlreadyCreated === false) { - if (typeof instruction.object === "string") { - var _node3 = function () { - var endLoc = getPosition(); - return t.withLoc(t.objectInstruction(instruction.name, instruction.object, args), endLoc, _startLoc6); - }(); - - code.push(_node3); - } else { - var _node4 = function () { - var endLoc = getPosition(); - return t.withLoc(t.instruction(instruction.name, args), endLoc, _startLoc6); - }(); - - code.push(_node4); - } - } - } - } // https://webassembly.github.io/spec/core/binary/types.html#limits - - - function parseLimits() { - var limitType = readByte(); - eatBytes(1); - dump([limitType], "limit type"); - var min, max; - - if (limitType === 0x01 || limitType === 0x03 // shared limits - ) { - 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"); - } - - if (limitType === 0x00) { - var _u32min = readU32(); - - min = parseInt(_u32min.value); - eatBytes(_u32min.nextIndex); - dump([min], "min"); - } - - return t.limit(min, max); - } // https://webassembly.github.io/spec/core/binary/types.html#binary-tabletype - - - function parseTableType(index) { - var name = t.withRaw(t.identifier(getUniqueName("table")), String(index)); - var elementTypeByte = readByte(); - eatBytes(1); - dump([elementTypeByte], "element type"); - var elementType = constants.tableTypes[elementTypeByte]; - - if (typeof elementType === "undefined") { - throw new CompileError("Unknown element type in table: " + toHex(elementType)); - } - - var limits = parseLimits(); - return t.table(elementType, limits, name); - } // https://webassembly.github.io/spec/binary/types.html#global-types - - - function parseGlobalType() { - var valtypeByte = readByte(); - eatBytes(1); - var type = constants.valtypes[valtypeByte]; - dump([valtypeByte], type); - - if (typeof type === "undefined") { - throw new CompileError("Unknown valtype: " + toHex(valtypeByte)); - } - - var globalTypeByte = readByte(); - eatBytes(1); - var globalType = constants.globalTypes[globalTypeByte]; - dump([globalTypeByte], "global type (".concat(globalType, ")")); - - if (typeof globalType === "undefined") { - throw new CompileError("Invalid mutability: " + toHex(globalTypeByte)); - } - - return t.globalType(type, globalType); - } // function parseNameModule() { - // const lenu32 = readVaruint32(); - // eatBytes(lenu32.nextIndex); - // console.log("len", lenu32); - // const strlen = lenu32.value; - // dump([strlen], "string length"); - // const bytes = readBytes(strlen); - // eatBytes(strlen); - // const value = utf8.decode(bytes); - // return [t.moduleNameMetadata(value)]; - // } - // this section contains an array of function names and indices - - - function parseNameSectionFunctions() { - var functionNames = []; - var numberOfFunctionsu32 = readU32(); - var numbeOfFunctions = numberOfFunctionsu32.value; - eatBytes(numberOfFunctionsu32.nextIndex); - - for (var i = 0; i < numbeOfFunctions; i++) { - var indexu32 = readU32(); - var index = indexu32.value; - eatBytes(indexu32.nextIndex); - var name = readUTF8String(); - eatBytes(name.nextIndex); - functionNames.push(t.functionNameMetadata(name.value, index)); - } - - return functionNames; - } - - function parseNameSectionLocals() { - var localNames = []; - var numbeOfFunctionsu32 = readU32(); - var numbeOfFunctions = numbeOfFunctionsu32.value; - eatBytes(numbeOfFunctionsu32.nextIndex); - - for (var i = 0; i < numbeOfFunctions; i++) { - var functionIndexu32 = readU32(); - var functionIndex = functionIndexu32.value; - eatBytes(functionIndexu32.nextIndex); - var numLocalsu32 = readU32(); - var numLocals = numLocalsu32.value; - eatBytes(numLocalsu32.nextIndex); - - for (var _i4 = 0; _i4 < numLocals; _i4++) { - var localIndexu32 = readU32(); - var localIndex = localIndexu32.value; - eatBytes(localIndexu32.nextIndex); - var name = readUTF8String(); - eatBytes(name.nextIndex); - localNames.push(t.localNameMetadata(name.value, localIndex, functionIndex)); - } - } - - return localNames; - } // this is a custom section used for name resolution - // https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#name-section - - - function parseNameSection(remainingBytes) { - var nameMetadata = []; - var initialOffset = offset; - - while (offset - initialOffset < remainingBytes) { - // name_type - var sectionTypeByte = readVaruint7(); - eatBytes(sectionTypeByte.nextIndex); // name_payload_len - - var subSectionSizeInBytesu32 = readVaruint32(); - 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 1: - { - nameMetadata.push.apply(nameMetadata, _toConsumableArray(parseNameSectionFunctions())); - break; - } - - case 2: - { - nameMetadata.push.apply(nameMetadata, _toConsumableArray(parseNameSectionLocals())); - break; - } - - default: - { - // skip unknown subsection - eatBytes(subSectionSizeInBytesu32.value); - } - } - } - - return nameMetadata; - } // this is a custom section used for information about the producers - // https://github.com/WebAssembly/tool-conventions/blob/master/ProducersSection.md - - - function parseProducersSection() { - var metadata = t.producersSectionMetadata([]); // field_count - - var sectionTypeByte = readVaruint32(); - eatBytes(sectionTypeByte.nextIndex); - dump([sectionTypeByte.value], "num of producers"); - var fields = { - language: [], - "processed-by": [], - sdk: [] - }; // fields - - for (var fieldI = 0; fieldI < sectionTypeByte.value; fieldI++) { - // field_name - var fieldName = readUTF8String(); - eatBytes(fieldName.nextIndex); // field_value_count - - var valueCount = readVaruint32(); - eatBytes(valueCount.nextIndex); // field_values - - for (var producerI = 0; producerI < valueCount.value; producerI++) { - var producerName = readUTF8String(); - eatBytes(producerName.nextIndex); - var producerVersion = readUTF8String(); - eatBytes(producerVersion.nextIndex); - fields[fieldName.value].push(t.producerMetadataVersionedName(producerName.value, producerVersion.value)); - } - - metadata.producers.push(fields[fieldName.value]); - } - - return metadata; - } - - function parseGlobalSection(numberOfGlobals) { - var globals = []; - dump([numberOfGlobals], "num globals"); - - for (var i = 0; i < numberOfGlobals; i++) { - var _startLoc11 = getPosition(); - - var globalType = parseGlobalType(); - /** - * Global expressions - */ - - var init = []; - parseInstructionBlock(init); - - var node = function () { - var endLoc = getPosition(); - return t.withLoc(t.global(globalType, init), endLoc, _startLoc11); - }(); - - globals.push(node); - state.globalsInModule.push(node); - } - - return globals; - } - - function parseElemSection(numberOfElements) { - var elems = []; - dump([numberOfElements], "num elements"); - - for (var i = 0; i < numberOfElements; i++) { - var _startLoc12 = getPosition(); - - var tableindexu32 = readU32(); - var tableindex = tableindexu32.value; - eatBytes(tableindexu32.nextIndex); - dump([tableindex], "table index"); - /** - * Parse instructions - */ - - var instr = []; - parseInstructionBlock(instr); - /** - * Parse ( vector function index ) * - */ - - var indicesu32 = readU32(); - var indices = indicesu32.value; - eatBytes(indicesu32.nextIndex); - dump([indices], "num indices"); - var indexValues = []; - - for (var _i5 = 0; _i5 < indices; _i5++) { - var indexu32 = readU32(); - var index = indexu32.value; - eatBytes(indexu32.nextIndex); - dump([index], "index"); - indexValues.push(t.indexLiteral(index)); - } - - var elemNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.elem(t.indexLiteral(tableindex), instr, indexValues), endLoc, _startLoc12); - }(); - - elems.push(elemNode); - } - - return elems; - } // https://webassembly.github.io/spec/core/binary/types.html#memory-types - - - function parseMemoryType(i) { - var limits = parseLimits(); - return t.memory(limits, t.indexLiteral(i)); - } // https://webassembly.github.io/spec/binary/modules.html#table-section - - - function parseTableSection(numberOfElements) { - var tables = []; - dump([numberOfElements], "num elements"); - - for (var i = 0; i < numberOfElements; i++) { - var tablesNode = parseTableType(i); - state.tablesInModule.push(tablesNode); - tables.push(tablesNode); - } - - return tables; - } // https://webassembly.github.io/spec/binary/modules.html#memory-section - - - function parseMemorySection(numberOfElements) { - var memories = []; - dump([numberOfElements], "num elements"); - - for (var i = 0; i < numberOfElements; i++) { - var memoryNode = parseMemoryType(i); - state.memoriesInModule.push(memoryNode); - memories.push(memoryNode); - } - - return memories; - } // https://webassembly.github.io/spec/binary/modules.html#binary-startsec - - - function parseStartSection() { - var startLoc = getPosition(); - var u32 = readU32(); - var startFuncIndex = u32.value; - eatBytes(u32.nextIndex); - dump([startFuncIndex], "index"); - return function () { - var endLoc = getPosition(); - return t.withLoc(t.start(t.indexLiteral(startFuncIndex)), endLoc, startLoc); - }(); - } // https://webassembly.github.io/spec/binary/modules.html#data-section - - - function parseDataSection(numberOfElements) { - var dataEntries = []; - dump([numberOfElements], "num elements"); - - for (var i = 0; i < numberOfElements; i++) { - var memoryIndexu32 = readU32(); - var memoryIndex = memoryIndexu32.value; - eatBytes(memoryIndexu32.nextIndex); - dump([memoryIndex], "memory index"); - var instrs = []; - parseInstructionBlock(instrs); - var hasExtraInstrs = instrs.filter(function (i) { - return i.id !== "end"; - }).length !== 1; - - if (hasExtraInstrs) { - throw new CompileError("data section offset must be a single instruction"); - } - - var bytes = parseVec(function (b) { - return b; - }); - dump([], "init"); - dataEntries.push(t.data(t.memIndexLiteral(memoryIndex), instrs[0], t.byteArray(bytes))); - } - - return dataEntries; - } // https://webassembly.github.io/spec/binary/modules.html#binary-section - - - function parseSection(sectionIndex) { - var sectionId = readByte(); - eatBytes(1); - - if (sectionId >= sectionIndex || sectionIndex === constants.sections.custom) { - sectionIndex = sectionId + 1; - } else { - if (sectionId !== constants.sections.custom) throw new CompileError("Unexpected section: " + toHex(sectionId)); - } - - var nextSectionIndex = sectionIndex; - var startOffset = offset; - var startLoc = getPosition(); - var u32 = readU32(); - var sectionSizeInBytes = u32.value; - eatBytes(u32.nextIndex); - - var sectionSizeInBytesNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(sectionSizeInBytes), endLoc, startLoc); - }(); - - switch (sectionId) { - case constants.sections.type: - { - dumpSep("section Type"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc13 = getPosition(); - - var _u = readU32(); - - var numberOfTypes = _u.value; - eatBytes(_u.nextIndex); - - var _metadata = t.sectionMetadata("type", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfTypes), endLoc, _startLoc13); - }()); - - var _nodes = parseTypeSection(numberOfTypes); - - return { - nodes: _nodes, - metadata: _metadata, - nextSectionIndex: nextSectionIndex - }; - } - - case constants.sections.table: - { - dumpSep("section Table"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc14 = getPosition(); - - var _u2 = readU32(); - - var numberOfTable = _u2.value; - eatBytes(_u2.nextIndex); - dump([numberOfTable], "num tables"); - - var _metadata2 = t.sectionMetadata("table", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfTable), endLoc, _startLoc14); - }()); - - var _nodes2 = parseTableSection(numberOfTable); - - return { - nodes: _nodes2, - metadata: _metadata2, - nextSectionIndex: nextSectionIndex - }; - } - - case constants.sections.import: - { - dumpSep("section Import"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc15 = getPosition(); - - var numberOfImportsu32 = readU32(); - var numberOfImports = numberOfImportsu32.value; - eatBytes(numberOfImportsu32.nextIndex); - dump([numberOfImports], "number of imports"); - - var _metadata3 = t.sectionMetadata("import", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfImports), endLoc, _startLoc15); - }()); - - var _nodes3 = parseImportSection(numberOfImports); - - return { - nodes: _nodes3, - metadata: _metadata3, - nextSectionIndex: nextSectionIndex - }; - } - - case constants.sections.func: - { - dumpSep("section Function"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc16 = getPosition(); - - var numberOfFunctionsu32 = readU32(); - var numberOfFunctions = numberOfFunctionsu32.value; - eatBytes(numberOfFunctionsu32.nextIndex); - - var _metadata4 = t.sectionMetadata("func", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfFunctions), endLoc, _startLoc16); - }()); - - parseFuncSection(numberOfFunctions); - var _nodes4 = []; - return { - nodes: _nodes4, - metadata: _metadata4, - nextSectionIndex: nextSectionIndex - }; - } - - case constants.sections.export: - { - dumpSep("section Export"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc17 = getPosition(); - - var _u3 = readU32(); - - var numberOfExport = _u3.value; - eatBytes(_u3.nextIndex); - - var _metadata5 = t.sectionMetadata("export", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfExport), endLoc, _startLoc17); - }()); - - parseExportSection(numberOfExport); - var _nodes5 = []; - return { - nodes: _nodes5, - metadata: _metadata5, - nextSectionIndex: nextSectionIndex - }; - } - - case constants.sections.code: - { - dumpSep("section Code"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc18 = getPosition(); - - var _u4 = readU32(); - - var numberOfFuncs = _u4.value; - eatBytes(_u4.nextIndex); - - var _metadata6 = t.sectionMetadata("code", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfFuncs), endLoc, _startLoc18); - }()); - - if (opts.ignoreCodeSection === true) { - var remainingBytes = sectionSizeInBytes - _u4.nextIndex; - eatBytes(remainingBytes); // eat the entire section - } else { - parseCodeSection(numberOfFuncs); - } - - var _nodes6 = []; - return { - nodes: _nodes6, - metadata: _metadata6, - nextSectionIndex: nextSectionIndex - }; - } - - case constants.sections.start: - { - dumpSep("section Start"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _metadata7 = t.sectionMetadata("start", startOffset, sectionSizeInBytesNode); - - var _nodes7 = [parseStartSection()]; - return { - nodes: _nodes7, - metadata: _metadata7, - nextSectionIndex: nextSectionIndex - }; - } - - case constants.sections.element: - { - dumpSep("section Element"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc19 = getPosition(); - - var numberOfElementsu32 = readU32(); - var numberOfElements = numberOfElementsu32.value; - eatBytes(numberOfElementsu32.nextIndex); - - var _metadata8 = t.sectionMetadata("element", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfElements), endLoc, _startLoc19); - }()); - - var _nodes8 = parseElemSection(numberOfElements); - - return { - nodes: _nodes8, - metadata: _metadata8, - nextSectionIndex: nextSectionIndex - }; - } - - case constants.sections.global: - { - dumpSep("section Global"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc20 = getPosition(); - - var numberOfGlobalsu32 = readU32(); - var numberOfGlobals = numberOfGlobalsu32.value; - eatBytes(numberOfGlobalsu32.nextIndex); - - var _metadata9 = t.sectionMetadata("global", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfGlobals), endLoc, _startLoc20); - }()); - - var _nodes9 = parseGlobalSection(numberOfGlobals); - - return { - nodes: _nodes9, - metadata: _metadata9, - nextSectionIndex: nextSectionIndex - }; - } - - case constants.sections.memory: - { - dumpSep("section Memory"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc21 = getPosition(); - - var _numberOfElementsu = readU32(); - - var _numberOfElements = _numberOfElementsu.value; - eatBytes(_numberOfElementsu.nextIndex); - - var _metadata10 = t.sectionMetadata("memory", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(_numberOfElements), endLoc, _startLoc21); - }()); - - var _nodes10 = parseMemorySection(_numberOfElements); - - return { - nodes: _nodes10, - metadata: _metadata10, - nextSectionIndex: nextSectionIndex - }; - } - - case constants.sections.data: - { - dumpSep("section Data"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _metadata11 = t.sectionMetadata("data", startOffset, sectionSizeInBytesNode); - - var _startLoc22 = getPosition(); - - var _numberOfElementsu2 = readU32(); - - var _numberOfElements2 = _numberOfElementsu2.value; - eatBytes(_numberOfElementsu2.nextIndex); - - _metadata11.vectorOfSize = function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(_numberOfElements2), endLoc, _startLoc22); - }(); - - if (opts.ignoreDataSection === true) { - var _remainingBytes = sectionSizeInBytes - _numberOfElementsu2.nextIndex; - - eatBytes(_remainingBytes); // eat the entire section - - dumpSep("ignore data (" + sectionSizeInBytes + " bytes)"); - return { - nodes: [], - metadata: _metadata11, - nextSectionIndex: nextSectionIndex - }; - } else { - var _nodes11 = parseDataSection(_numberOfElements2); - - return { - nodes: _nodes11, - metadata: _metadata11, - nextSectionIndex: nextSectionIndex - }; - } - } - - case constants.sections.custom: - { - dumpSep("section Custom"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - var _metadata12 = [t.sectionMetadata("custom", startOffset, sectionSizeInBytesNode)]; - var sectionName = readUTF8String(); - eatBytes(sectionName.nextIndex); - dump([], "section name (".concat(sectionName.value, ")")); - - var _remainingBytes2 = sectionSizeInBytes - sectionName.nextIndex; - - if (sectionName.value === "name") { - var initialOffset = offset; - - 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(offset - (initialOffset + _remainingBytes2)); - } - } else if (sectionName.value === "producers") { - var _initialOffset = offset; - - try { - _metadata12.push(parseProducersSection()); - } catch (e) { - console.warn("Failed to decode custom \"producers\" section @".concat(offset, "; ignoring (").concat(e.message, ").")); - eatBytes(offset - (_initialOffset + _remainingBytes2)); - } - } else { - // We don't parse the custom section - eatBytes(_remainingBytes2); - dumpSep("ignore custom " + JSON.stringify(sectionName.value) + " section (" + _remainingBytes2 + " bytes)"); - } - - return { - nodes: [], - metadata: _metadata12, - nextSectionIndex: nextSectionIndex - }; - } - } - - throw new CompileError("Unexpected section: " + toHex(sectionId)); - } - - parseModuleHeader(); - parseVersion(); - var moduleFields = []; - var sectionIndex = 0; - var moduleMetadata = { - sections: [], - functionNames: [], - localNames: [], - producers: [] - }; - /** - * All the generate declaration are going to be stored in our state - */ - - while (offset < buf.length) { - var _parseSection = parseSection(sectionIndex), - _nodes12 = _parseSection.nodes, - _metadata13 = _parseSection.metadata, - nextSectionIndex = _parseSection.nextSectionIndex; - - moduleFields.push.apply(moduleFields, _toConsumableArray(_nodes12)); - var metadataArray = Array.isArray(_metadata13) ? _metadata13 : [_metadata13]; - metadataArray.forEach(function (metadataItem) { - if (metadataItem.type === "FunctionNameMetadata") { - moduleMetadata.functionNames.push(metadataItem); - } else if (metadataItem.type === "LocalNameMetadata") { - moduleMetadata.localNames.push(metadataItem); - } else if (metadataItem.type === "ProducersSectionMetadata") { - moduleMetadata.producers.push(metadataItem); - } else { - moduleMetadata.sections.push(metadataItem); - } - }); // Ignore custom section - - if (nextSectionIndex) { - sectionIndex = nextSectionIndex; - } - } - /** - * Transform the state into AST nodes - */ - - - var funcIndex = 0; - state.functionsInModule.forEach(function (func) { - var params = func.signature.params; - var result = func.signature.result; - var body = []; // External functions doesn't provide any code, can skip it here - - if (func.isExternal === true) { - return; - } - - var decodedElementInCodeSection = state.elementsInCodeSection[funcIndex]; - - if (opts.ignoreCodeSection === false) { - if (typeof decodedElementInCodeSection === "undefined") { - throw new CompileError("func " + toHex(funcIndex) + " code not found"); - } - - body = decodedElementInCodeSection.code; - } - - funcIndex++; - var funcNode = t.func(func.id, t.signature(params, result), body); - - if (func.isExternal === true) { - funcNode.isExternal = func.isExternal; - } // Add function position in the binary if possible - - - if (opts.ignoreCodeSection === false) { - var _startLoc23 = decodedElementInCodeSection.startLoc, - endLoc = decodedElementInCodeSection.endLoc, - bodySize = decodedElementInCodeSection.bodySize; - funcNode = t.withLoc(funcNode, endLoc, _startLoc23); - funcNode.metadata = { - bodySize: bodySize - }; - } - - moduleFields.push(funcNode); - }); - state.elementsInExportSection.forEach(function (moduleExport) { - /** - * If the export has no id, we won't be able to call it from the outside - * so we can omit it - */ - if (moduleExport.id != null) { - moduleFields.push(t.withLoc(t.moduleExport(moduleExport.name, t.moduleExportDescr(moduleExport.type, moduleExport.id)), moduleExport.endLoc, moduleExport.startLoc)); - } - }); - dumpSep("end of program"); - var module = t.module(null, moduleFields, t.moduleMetadata(moduleMetadata.sections, moduleMetadata.functionNames, moduleMetadata.localNames, moduleMetadata.producers)); - return t.program([module]); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-parser/esm/index.js b/node_modules/@webassemblyjs/wasm-parser/esm/index.js deleted file mode 100644 index a5844d6..0000000 --- a/node_modules/@webassemblyjs/wasm-parser/esm/index.js +++ /dev/null @@ -1,247 +0,0 @@ -import * as decoder from "./decoder"; -import * as t from "@webassemblyjs/ast"; -/** - * TODO(sven): I added initial props, but we should rather fix - * https://github.com/xtuc/webassemblyjs/issues/405 - */ - -var defaultDecoderOpts = { - dump: false, - ignoreCodeSection: false, - ignoreDataSection: false, - ignoreCustomNameSection: false -}; // traverses the AST, locating function name metadata, which is then -// used to update index-based identifiers with function names - -function restoreFunctionNames(ast) { - var functionNames = []; - t.traverse(ast, { - FunctionNameMetadata: function FunctionNameMetadata(_ref) { - var node = _ref.node; - functionNames.push({ - name: node.value, - index: node.index - }); - } - }); - - if (functionNames.length === 0) { - return; - } - - t.traverse(ast, { - Func: function (_Func) { - function Func(_x) { - return _Func.apply(this, arguments); - } - - Func.toString = function () { - return _Func.toString(); - }; - - return Func; - }(function (_ref2) { - var node = _ref2.node; - // $FlowIgnore - var nodeName = node.name; - var indexBasedFunctionName = nodeName.value; - var index = Number(indexBasedFunctionName.replace("func_", "")); - var functionName = functionNames.find(function (f) { - return f.index === index; - }); - - if (functionName) { - var oldValue = nodeName.value; - nodeName.value = functionName.name; - nodeName.numeric = oldValue; // $FlowIgnore - - delete nodeName.raw; - } - }), - // Also update the reference in the export - ModuleExport: function (_ModuleExport) { - function ModuleExport(_x2) { - return _ModuleExport.apply(this, arguments); - } - - ModuleExport.toString = function () { - return _ModuleExport.toString(); - }; - - return ModuleExport; - }(function (_ref3) { - var node = _ref3.node; - - if (node.descr.exportType === "Func") { - // $FlowIgnore - var nodeName = node.descr.id; - var index = nodeName.value; - var functionName = functionNames.find(function (f) { - return f.index === index; - }); - - if (functionName) { - node.descr.id = t.identifier(functionName.name); - } - } - }), - ModuleImport: function (_ModuleImport) { - function ModuleImport(_x3) { - return _ModuleImport.apply(this, arguments); - } - - ModuleImport.toString = function () { - return _ModuleImport.toString(); - }; - - return ModuleImport; - }(function (_ref4) { - var node = _ref4.node; - - if (node.descr.type === "FuncImportDescr") { - // $FlowIgnore - var indexBasedFunctionName = node.descr.id; - var index = Number(indexBasedFunctionName.replace("func_", "")); - var functionName = functionNames.find(function (f) { - return f.index === index; - }); - - if (functionName) { - // $FlowIgnore - node.descr.id = t.identifier(functionName.name); - } - } - }), - CallInstruction: function (_CallInstruction) { - function CallInstruction(_x4) { - return _CallInstruction.apply(this, arguments); - } - - CallInstruction.toString = function () { - return _CallInstruction.toString(); - }; - - return CallInstruction; - }(function (nodePath) { - var node = nodePath.node; - var index = node.index.value; - var functionName = functionNames.find(function (f) { - return f.index === index; - }); - - if (functionName) { - var oldValue = node.index; - node.index = t.identifier(functionName.name); - node.numeric = oldValue; // $FlowIgnore - - delete node.raw; - } - }) - }); -} - -function restoreLocalNames(ast) { - var localNames = []; - t.traverse(ast, { - LocalNameMetadata: function LocalNameMetadata(_ref5) { - var node = _ref5.node; - localNames.push({ - name: node.value, - localIndex: node.localIndex, - functionIndex: node.functionIndex - }); - } - }); - - if (localNames.length === 0) { - return; - } - - t.traverse(ast, { - Func: function (_Func2) { - function Func(_x5) { - return _Func2.apply(this, arguments); - } - - Func.toString = function () { - return _Func2.toString(); - }; - - return Func; - }(function (_ref6) { - var node = _ref6.node; - var signature = node.signature; - - if (signature.type !== "Signature") { - return; - } // $FlowIgnore - - - var nodeName = node.name; - var indexBasedFunctionName = nodeName.value; - var functionIndex = Number(indexBasedFunctionName.replace("func_", "")); - signature.params.forEach(function (param, paramIndex) { - var paramName = localNames.find(function (f) { - return f.localIndex === paramIndex && f.functionIndex === functionIndex; - }); - - if (paramName && paramName.name !== "") { - param.id = paramName.name; - } - }); - }) - }); -} - -function restoreModuleName(ast) { - t.traverse(ast, { - ModuleNameMetadata: function (_ModuleNameMetadata) { - function ModuleNameMetadata(_x6) { - return _ModuleNameMetadata.apply(this, arguments); - } - - ModuleNameMetadata.toString = function () { - return _ModuleNameMetadata.toString(); - }; - - return ModuleNameMetadata; - }(function (moduleNameMetadataPath) { - // update module - t.traverse(ast, { - Module: function (_Module) { - function Module(_x7) { - return _Module.apply(this, arguments); - } - - Module.toString = function () { - return _Module.toString(); - }; - - return Module; - }(function (_ref7) { - var node = _ref7.node; - var name = moduleNameMetadataPath.node.value; // compatiblity with wast-parser - - if (name === "") { - name = null; - } - - node.id = name; - }) - }); - }) - }); -} - -export function decode(buf, customOpts) { - var opts = Object.assign({}, defaultDecoderOpts, customOpts); - var ast = decoder.decode(buf, opts); - - if (opts.ignoreCustomNameSection === false) { - restoreFunctionNames(ast); - restoreLocalNames(ast); - restoreModuleName(ast); - } - - return ast; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-parser/esm/types/decoder.js b/node_modules/@webassemblyjs/wasm-parser/esm/types/decoder.js deleted file mode 100644 index e69de29..0000000 --- a/node_modules/@webassemblyjs/wasm-parser/esm/types/decoder.js +++ /dev/null diff --git a/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js b/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js deleted file mode 100644 index f218d38..0000000 --- a/node_modules/@webassemblyjs/wasm-parser/lib/decoder.js +++ /dev/null @@ -1,1776 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.decode = decode; - -var _helperApiError = require("@webassemblyjs/helper-api-error"); - -var ieee754 = _interopRequireWildcard(require("@webassemblyjs/ieee754")); - -var utf8 = _interopRequireWildcard(require("@webassemblyjs/utf8")); - -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; } } - -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 toHex(n) { - return "0x" + Number(n).toString(16); -} - -function byteArrayEq(l, r) { - if (l.length !== r.length) { - return false; - } - - for (var i = 0; i < l.length; i++) { - if (l[i] !== r[i]) { - return false; - } - } - - return true; -} - -function decode(ab, opts) { - var buf = new Uint8Array(ab); - var getUniqueName = t.getUniqueNameGenerator(); - var offset = 0; - - function getPosition() { - return { - line: -1, - column: offset - }; - } - - function dump(b, msg) { - if (opts.dump === false) return; - var pad = "\t\t\t\t\t\t\t\t\t\t"; - var str = ""; - - if (b.length < 5) { - str = b.map(toHex).join(" "); - } else { - str = "..."; - } - - console.log(toHex(offset) + ":\t", str, pad, ";", msg); - } - - function dumpSep(msg) { - if (opts.dump === false) return; - console.log(";", msg); - } - /** - * TODO(sven): we can atually use a same structure - * we are adding incrementally new features - */ - - - var state = { - elementsInFuncSection: [], - elementsInExportSection: [], - elementsInCodeSection: [], - - /** - * Decode memory from: - * - Memory section - */ - memoriesInModule: [], - - /** - * Decoded types from: - * - Type section - */ - typesInModule: [], - - /** - * Decoded functions from: - * - Function section - * - Import section - */ - functionsInModule: [], - - /** - * Decoded tables from: - * - Table section - */ - tablesInModule: [], - - /** - * Decoded globals from: - * - Global section - */ - globalsInModule: [] - }; - - function isEOF() { - return offset >= buf.length; - } - - function eatBytes(n) { - offset = offset + n; - } - - function readBytesAtOffset(_offset, numberOfBytes) { - var arr = []; - - for (var i = 0; i < numberOfBytes; i++) { - arr.push(buf[_offset + i]); - } - - return arr; - } - - function readBytes(numberOfBytes) { - return readBytesAtOffset(offset, numberOfBytes); - } - - function readF64() { - var bytes = readBytes(ieee754.NUMBER_OF_BYTE_F64); - var value = ieee754.decodeF64(bytes); - - if (Math.sign(value) * value === Infinity) { - return { - value: Math.sign(value), - inf: true, - nextIndex: ieee754.NUMBER_OF_BYTE_F64 - }; - } - - if (isNaN(value)) { - var sign = bytes[bytes.length - 1] >> 7 ? -1 : 1; - var mantissa = 0; - - for (var i = 0; i < bytes.length - 2; ++i) { - mantissa += bytes[i] * Math.pow(256, i); - } - - mantissa += bytes[bytes.length - 2] % 16 * Math.pow(256, bytes.length - 2); - return { - value: sign * mantissa, - nan: true, - nextIndex: ieee754.NUMBER_OF_BYTE_F64 - }; - } - - return { - value: value, - nextIndex: ieee754.NUMBER_OF_BYTE_F64 - }; - } - - function readF32() { - var bytes = readBytes(ieee754.NUMBER_OF_BYTE_F32); - var value = ieee754.decodeF32(bytes); - - if (Math.sign(value) * value === Infinity) { - return { - value: Math.sign(value), - inf: true, - nextIndex: ieee754.NUMBER_OF_BYTE_F32 - }; - } - - if (isNaN(value)) { - var sign = bytes[bytes.length - 1] >> 7 ? -1 : 1; - var mantissa = 0; - - for (var i = 0; i < bytes.length - 2; ++i) { - mantissa += bytes[i] * Math.pow(256, i); - } - - mantissa += bytes[bytes.length - 2] % 128 * Math.pow(256, bytes.length - 2); - return { - value: sign * mantissa, - nan: true, - nextIndex: ieee754.NUMBER_OF_BYTE_F32 - }; - } - - return { - value: value, - nextIndex: ieee754.NUMBER_OF_BYTE_F32 - }; - } - - function readUTF8String() { - var lenu32 = readU32(); // Don't eat any bytes. Instead, peek ahead of the current offset using - // readBytesAtOffset below. This keeps readUTF8String neutral with respect - // to the current offset, just like the other readX functions. - - var strlen = lenu32.value; - dump([strlen], "string length"); - var bytes = readBytesAtOffset(offset + lenu32.nextIndex, strlen); - var value = utf8.decode(bytes); - return { - value: value, - nextIndex: strlen + lenu32.nextIndex - }; - } - /** - * Decode an unsigned 32bits integer - * - * The length will be handled by the leb librairy, we pass the max number of - * byte. - */ - - - function readU32() { - var bytes = readBytes(_leb.MAX_NUMBER_OF_BYTE_U32); - var buffer = Buffer.from(bytes); - return (0, _leb.decodeUInt32)(buffer); - } - - 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); - } - /** - * Decode a signed 32bits interger - */ - - - function read32() { - var bytes = readBytes(_leb.MAX_NUMBER_OF_BYTE_U32); - var buffer = Buffer.from(bytes); - return (0, _leb.decodeInt32)(buffer); - } - /** - * Decode a signed 64bits integer - */ - - - function read64() { - var bytes = readBytes(_leb.MAX_NUMBER_OF_BYTE_U64); - var buffer = Buffer.from(bytes); - return (0, _leb.decodeInt64)(buffer); - } - - function readU64() { - var bytes = readBytes(_leb.MAX_NUMBER_OF_BYTE_U64); - var buffer = Buffer.from(bytes); - return (0, _leb.decodeUInt64)(buffer); - } - - function readByte() { - return readBytes(1)[0]; - } - - function parseModuleHeader() { - if (isEOF() === true || offset + 4 > buf.length) { - throw new Error("unexpected end"); - } - - var header = readBytes(4); - - if (byteArrayEq(_helperWasmBytecode.default.magicModuleHeader, header) === false) { - throw new _helperApiError.CompileError("magic header not detected"); - } - - dump(header, "wasm magic header"); - eatBytes(4); - } - - function parseVersion() { - if (isEOF() === true || offset + 4 > buf.length) { - throw new Error("unexpected end"); - } - - var version = readBytes(4); - - if (byteArrayEq(_helperWasmBytecode.default.moduleVersion, version) === false) { - throw new _helperApiError.CompileError("unknown binary version"); - } - - dump(version, "wasm version"); - eatBytes(4); - } - - function parseVec(cast) { - var u32 = readU32(); - var length = u32.value; - eatBytes(u32.nextIndex); - dump([length], "number"); - - if (length === 0) { - return []; - } - - var elements = []; - - for (var i = 0; i < length; i++) { - var byte = readByte(); - eatBytes(1); - var value = cast(byte); - dump([byte], value); - - if (typeof value === "undefined") { - throw new _helperApiError.CompileError("Internal failure: parseVec could not cast the value"); - } - - elements.push(value); - } - - return elements; - } // Type section - // https://webassembly.github.io/spec/binary/modules.html#binary-typesec - - - function parseTypeSection(numberOfTypes) { - var typeInstructionNodes = []; - dump([numberOfTypes], "num types"); - - for (var i = 0; i < numberOfTypes; i++) { - var _startLoc = getPosition(); - - dumpSep("type " + i); - var type = readByte(); - eatBytes(1); - - if (type == _helperWasmBytecode.default.types.func) { - dump([type], "func"); - var paramValtypes = parseVec(function (b) { - return _helperWasmBytecode.default.valtypes[b]; - }); - var params = paramValtypes.map(function (v) { - return t.funcParam( - /*valtype*/ - v); - }); - var result = parseVec(function (b) { - return _helperWasmBytecode.default.valtypes[b]; - }); - typeInstructionNodes.push(function () { - var endLoc = getPosition(); - return t.withLoc(t.typeInstruction(undefined, t.signature(params, result)), endLoc, _startLoc); - }()); - state.typesInModule.push({ - params: params, - result: result - }); - } else { - throw new Error("Unsupported type: " + toHex(type)); - } - } - - return typeInstructionNodes; - } // Import section - // https://webassembly.github.io/spec/binary/modules.html#binary-importsec - - - function parseImportSection(numberOfImports) { - var imports = []; - - for (var i = 0; i < numberOfImports; i++) { - dumpSep("import header " + i); - - var _startLoc2 = getPosition(); - /** - * Module name - */ - - - var moduleName = readUTF8String(); - 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 = _helperWasmBytecode.default.importTypes[descrTypeByte]; - dump([descrTypeByte], "import kind"); - - if (typeof descrType === "undefined") { - throw new _helperApiError.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") { - throw new _helperApiError.CompileError("function signature not found (".concat(typeindex, ")")); - } - - var id = getUniqueName("func"); - importDescr = t.funcImportDescr(id, t.signature(signature.params, signature.result)); - state.functionsInModule.push({ - id: t.identifier(name.value), - signature: signature, - isExternal: true - }); - } else if (descrType === "global") { - importDescr = parseGlobalType(); - var globalNode = t.global(importDescr, []); - state.globalsInModule.push(globalNode); - } else if (descrType === "table") { - importDescr = parseTableType(i); - } else if (descrType === "mem") { - var memoryNode = parseMemoryType(0); - state.memoriesInModule.push(memoryNode); - importDescr = memoryNode; - } else { - throw new _helperApiError.CompileError("Unsupported import of type: " + descrType); - } - - imports.push(function () { - var endLoc = getPosition(); - return t.withLoc(t.moduleImport(moduleName.value, name.value, importDescr), endLoc, _startLoc2); - }()); - } - - return imports; - } // Function section - // https://webassembly.github.io/spec/binary/modules.html#function-section - - - function parseFuncSection(numberOfFunctions) { - dump([numberOfFunctions], "num funcs"); - - for (var i = 0; i < numberOfFunctions; i++) { - var indexU32 = readU32(); - var typeindex = indexU32.value; - eatBytes(indexU32.nextIndex); - dump([typeindex], "type index"); - var signature = state.typesInModule[typeindex]; - - if (typeof signature === "undefined") { - throw new _helperApiError.CompileError("function signature not found (".concat(typeindex, ")")); - } // preserve anonymous, a name might be resolved later - - - var id = t.withRaw(t.identifier(getUniqueName("func")), ""); - state.functionsInModule.push({ - id: id, - signature: signature, - isExternal: false - }); - } - } // Export section - // https://webassembly.github.io/spec/binary/modules.html#export-section - - - function parseExportSection(numberOfExport) { - dump([numberOfExport], "num exports"); // Parse vector of exports - - for (var i = 0; i < numberOfExport; i++) { - var _startLoc3 = getPosition(); - /** - * Name - */ - - - var name = readUTF8String(); - eatBytes(name.nextIndex); - dump([], "export name (".concat(name.value, ")")); - /** - * exportdescr - */ - - var typeIndex = readByte(); - eatBytes(1); - dump([typeIndex], "export kind"); - var indexu32 = readU32(); - var index = indexu32.value; - eatBytes(indexu32.nextIndex); - dump([index], "export index"); - var id = void 0, - signature = void 0; - - if (_helperWasmBytecode.default.exportTypes[typeIndex] === "Func") { - var func = state.functionsInModule[index]; - - if (typeof func === "undefined") { - throw new _helperApiError.CompileError("unknown function (".concat(index, ")")); - } - - id = t.numberLiteralFromRaw(index, String(index)); - signature = func.signature; - } else if (_helperWasmBytecode.default.exportTypes[typeIndex] === "Table") { - var table = state.tablesInModule[index]; - - if (typeof table === "undefined") { - throw new _helperApiError.CompileError("unknown table ".concat(index)); - } - - id = t.numberLiteralFromRaw(index, String(index)); - signature = null; - } else if (_helperWasmBytecode.default.exportTypes[typeIndex] === "Mem") { - var memNode = state.memoriesInModule[index]; - - if (typeof memNode === "undefined") { - throw new _helperApiError.CompileError("unknown memory ".concat(index)); - } - - id = t.numberLiteralFromRaw(index, String(index)); - signature = null; - } else if (_helperWasmBytecode.default.exportTypes[typeIndex] === "Global") { - var global = state.globalsInModule[index]; - - if (typeof global === "undefined") { - throw new _helperApiError.CompileError("unknown global ".concat(index)); - } - - id = t.numberLiteralFromRaw(index, String(index)); - signature = null; - } else { - console.warn("Unsupported export type: " + toHex(typeIndex)); - return; - } - - var endLoc = getPosition(); - state.elementsInExportSection.push({ - name: name.value, - type: _helperWasmBytecode.default.exportTypes[typeIndex], - signature: signature, - id: id, - index: index, - endLoc: endLoc, - startLoc: _startLoc3 - }); - } - } // Code section - // https://webassembly.github.io/spec/binary/modules.html#code-section - - - function parseCodeSection(numberOfFuncs) { - dump([numberOfFuncs], "number functions"); // Parse vector of function - - for (var i = 0; i < numberOfFuncs; i++) { - var _startLoc4 = getPosition(); - - dumpSep("function body " + i); // the u32 size of the function code in bytes - // Ignore it for now - - var bodySizeU32 = readU32(); - eatBytes(bodySizeU32.nextIndex); - dump([bodySizeU32.value], "function body size"); - var code = []; - /** - * Parse locals - */ - - var funcLocalNumU32 = readU32(); - var funcLocalNum = funcLocalNumU32.value; - eatBytes(funcLocalNumU32.nextIndex); - dump([funcLocalNum], "num locals"); - var locals = []; - - for (var _i = 0; _i < funcLocalNum; _i++) { - var _startLoc5 = getPosition(); - - var localCountU32 = readU32(); - var localCount = localCountU32.value; - eatBytes(localCountU32.nextIndex); - dump([localCount], "num local"); - var valtypeByte = readByte(); - eatBytes(1); - var type = _helperWasmBytecode.default.valtypes[valtypeByte]; - var args = []; - - for (var _i2 = 0; _i2 < localCount; _i2++) { - args.push(t.valtypeLiteral(type)); - } - - var localNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.instruction("local", args), endLoc, _startLoc5); - }(); - - locals.push(localNode); - dump([valtypeByte], type); - - if (typeof type === "undefined") { - throw new _helperApiError.CompileError("Unexpected valtype: " + toHex(valtypeByte)); - } - } - - code.push.apply(code, locals); // Decode instructions until the end - - parseInstructionBlock(code); - var endLoc = getPosition(); - state.elementsInCodeSection.push({ - code: code, - locals: locals, - endLoc: endLoc, - startLoc: _startLoc4, - bodySize: bodySizeU32.value - }); - } - } - - function parseInstructionBlock(code) { - while (true) { - var _startLoc6 = getPosition(); - - var instructionAlreadyCreated = false; - var instructionByte = readByte(); - eatBytes(1); - - if (instructionByte === 0xfe) { - throw new _helperApiError.CompileError("Atomic instructions are not implemented"); - } - - var instruction = _helperWasmBytecode.default.symbolsByByte[instructionByte]; - - if (typeof instruction === "undefined") { - throw new _helperApiError.CompileError("Unexpected instruction: " + toHex(instructionByte)); - } - - if (typeof instruction.object === "string") { - dump([instructionByte], "".concat(instruction.object, ".").concat(instruction.name)); - } else { - dump([instructionByte], instruction.name); - } - /** - * End of the function - */ - - - if (instruction.name === "end") { - var node = function () { - var endLoc = getPosition(); - return t.withLoc(t.instruction(instruction.name), endLoc, _startLoc6); - }(); - - code.push(node); - break; - } - - var args = []; - - if (instruction.name === "loop") { - var _startLoc7 = getPosition(); - - var blocktypeByte = readByte(); - eatBytes(1); - var blocktype = _helperWasmBytecode.default.blockTypes[blocktypeByte]; - dump([blocktypeByte], "blocktype"); - - if (typeof blocktype === "undefined") { - throw new _helperApiError.CompileError("Unexpected blocktype: " + toHex(blocktypeByte)); - } - - var instr = []; - parseInstructionBlock(instr); // preserve anonymous - - var label = t.withRaw(t.identifier(getUniqueName("loop")), ""); - - var loopNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.loopInstruction(label, blocktype, instr), endLoc, _startLoc7); - }(); - - code.push(loopNode); - instructionAlreadyCreated = true; - } else if (instruction.name === "if") { - var _startLoc8 = getPosition(); - - var _blocktypeByte = readByte(); - - eatBytes(1); - var _blocktype = _helperWasmBytecode.default.blockTypes[_blocktypeByte]; - dump([_blocktypeByte], "blocktype"); - - if (typeof _blocktype === "undefined") { - throw new _helperApiError.CompileError("Unexpected blocktype: " + toHex(_blocktypeByte)); - } - - var testIndex = t.withRaw(t.identifier(getUniqueName("if")), ""); - var ifBody = []; - parseInstructionBlock(ifBody); // Defaults to no alternate - - var elseIndex = 0; - - for (elseIndex = 0; elseIndex < ifBody.length; ++elseIndex) { - var _instr = ifBody[elseIndex]; - - if (_instr.type === "Instr" && _instr.id === "else") { - break; - } - } - - var consequentInstr = ifBody.slice(0, elseIndex); - var alternate = ifBody.slice(elseIndex + 1); // wast sugar - - var testInstrs = []; - - var ifNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.ifInstruction(testIndex, testInstrs, _blocktype, consequentInstr, alternate), endLoc, _startLoc8); - }(); - - code.push(ifNode); - instructionAlreadyCreated = true; - } else if (instruction.name === "block") { - var _startLoc9 = getPosition(); - - var _blocktypeByte2 = readByte(); - - eatBytes(1); - var _blocktype2 = _helperWasmBytecode.default.blockTypes[_blocktypeByte2]; - dump([_blocktypeByte2], "blocktype"); - - if (typeof _blocktype2 === "undefined") { - throw new _helperApiError.CompileError("Unexpected blocktype: " + toHex(_blocktypeByte2)); - } - - var _instr2 = []; - parseInstructionBlock(_instr2); // preserve anonymous - - var _label = t.withRaw(t.identifier(getUniqueName("block")), ""); - - var blockNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.blockInstruction(_label, _instr2, _blocktype2), endLoc, _startLoc9); - }(); - - code.push(blockNode); - instructionAlreadyCreated = true; - } else if (instruction.name === "call") { - var indexu32 = readU32(); - var index = indexu32.value; - eatBytes(indexu32.nextIndex); - dump([index], "index"); - - var callNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.callInstruction(t.indexLiteral(index)), endLoc, _startLoc6); - }(); - - code.push(callNode); - instructionAlreadyCreated = true; - } else if (instruction.name === "call_indirect") { - var _startLoc10 = getPosition(); - - var indexU32 = readU32(); - var typeindex = indexU32.value; - eatBytes(indexU32.nextIndex); - dump([typeindex], "type index"); - var signature = state.typesInModule[typeindex]; - - if (typeof signature === "undefined") { - throw new _helperApiError.CompileError("call_indirect signature not found (".concat(typeindex, ")")); - } - - var _callNode = t.callIndirectInstruction(t.signature(signature.params, signature.result), []); - - var flagU32 = readU32(); - var flag = flagU32.value; // 0x00 - reserved byte - - eatBytes(flagU32.nextIndex); - - if (flag !== 0) { - throw new _helperApiError.CompileError("zero flag expected"); - } - - code.push(function () { - var endLoc = getPosition(); - return t.withLoc(_callNode, endLoc, _startLoc10); - }()); - instructionAlreadyCreated = true; - } else if (instruction.name === "br_table") { - var indicesu32 = readU32(); - var indices = indicesu32.value; - eatBytes(indicesu32.nextIndex); - dump([indices], "num indices"); - - for (var i = 0; i <= indices; i++) { - var _indexu = readU32(); - - var _index = _indexu.value; - eatBytes(_indexu.nextIndex); - dump([_index], "index"); - args.push(t.numberLiteralFromRaw(_indexu.value.toString(), "u32")); - } - } else if (instructionByte >= 0x28 && instructionByte <= 0x40) { - /** - * Memory instructions - */ - if (instruction.name === "grow_memory" || instruction.name === "current_memory") { - var _indexU = readU32(); - - var _index2 = _indexU.value; - eatBytes(_indexU.nextIndex); - - if (_index2 !== 0) { - throw new Error("zero flag expected"); - } - - dump([_index2], "index"); - } else { - var aligun32 = readU32(); - var align = aligun32.value; - eatBytes(aligun32.nextIndex); - dump([align], "align"); - var offsetu32 = readU32(); - var _offset2 = offsetu32.value; - eatBytes(offsetu32.nextIndex); - dump([_offset2], "offset"); - } - } else if (instructionByte >= 0x41 && instructionByte <= 0x44) { - /** - * Numeric instructions - */ - if (instruction.object === "i32") { - var value32 = read32(); - var value = value32.value; - eatBytes(value32.nextIndex); - dump([value], "i32 value"); - args.push(t.numberLiteralFromRaw(value)); - } - - if (instruction.object === "u32") { - var valueu32 = readU32(); - var _value = valueu32.value; - eatBytes(valueu32.nextIndex); - dump([_value], "u32 value"); - args.push(t.numberLiteralFromRaw(_value)); - } - - if (instruction.object === "i64") { - var value64 = read64(); - var _value2 = value64.value; - eatBytes(value64.nextIndex); - dump([Number(_value2.toString())], "i64 value"); - var high = _value2.high, - low = _value2.low; - var _node = { - type: "LongNumberLiteral", - value: { - high: high, - low: low - } - }; - args.push(_node); - } - - if (instruction.object === "u64") { - var valueu64 = readU64(); - var _value3 = valueu64.value; - eatBytes(valueu64.nextIndex); - dump([Number(_value3.toString())], "u64 value"); - var _high = _value3.high, - _low = _value3.low; - var _node2 = { - type: "LongNumberLiteral", - value: { - high: _high, - low: _low - } - }; - args.push(_node2); - } - - if (instruction.object === "f32") { - var valuef32 = readF32(); - var _value4 = valuef32.value; - eatBytes(valuef32.nextIndex); - dump([_value4], "f32 value"); - args.push( // $FlowIgnore - t.floatLiteral(_value4, valuef32.nan, valuef32.inf, String(_value4))); - } - - if (instruction.object === "f64") { - var valuef64 = readF64(); - var _value5 = valuef64.value; - eatBytes(valuef64.nextIndex); - dump([_value5], "f64 value"); - args.push( // $FlowIgnore - t.floatLiteral(_value5, valuef64.nan, valuef64.inf, String(_value5))); - } - } else { - for (var _i3 = 0; _i3 < instruction.numberOfArgs; _i3++) { - var u32 = readU32(); - eatBytes(u32.nextIndex); - dump([u32.value], "argument " + _i3); - args.push(t.numberLiteralFromRaw(u32.value)); - } - } - - if (instructionAlreadyCreated === false) { - if (typeof instruction.object === "string") { - var _node3 = function () { - var endLoc = getPosition(); - return t.withLoc(t.objectInstruction(instruction.name, instruction.object, args), endLoc, _startLoc6); - }(); - - code.push(_node3); - } else { - var _node4 = function () { - var endLoc = getPosition(); - return t.withLoc(t.instruction(instruction.name, args), endLoc, _startLoc6); - }(); - - code.push(_node4); - } - } - } - } // https://webassembly.github.io/spec/core/binary/types.html#limits - - - function parseLimits() { - var limitType = readByte(); - eatBytes(1); - dump([limitType], "limit type"); - var min, max; - - if (limitType === 0x01 || limitType === 0x03 // shared limits - ) { - 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"); - } - - if (limitType === 0x00) { - var _u32min = readU32(); - - min = parseInt(_u32min.value); - eatBytes(_u32min.nextIndex); - dump([min], "min"); - } - - return t.limit(min, max); - } // https://webassembly.github.io/spec/core/binary/types.html#binary-tabletype - - - function parseTableType(index) { - var name = t.withRaw(t.identifier(getUniqueName("table")), String(index)); - var elementTypeByte = readByte(); - eatBytes(1); - dump([elementTypeByte], "element type"); - var elementType = _helperWasmBytecode.default.tableTypes[elementTypeByte]; - - if (typeof elementType === "undefined") { - throw new _helperApiError.CompileError("Unknown element type in table: " + toHex(elementType)); - } - - var limits = parseLimits(); - return t.table(elementType, limits, name); - } // https://webassembly.github.io/spec/binary/types.html#global-types - - - function parseGlobalType() { - var valtypeByte = readByte(); - eatBytes(1); - var type = _helperWasmBytecode.default.valtypes[valtypeByte]; - dump([valtypeByte], type); - - if (typeof type === "undefined") { - throw new _helperApiError.CompileError("Unknown valtype: " + toHex(valtypeByte)); - } - - var globalTypeByte = readByte(); - eatBytes(1); - var globalType = _helperWasmBytecode.default.globalTypes[globalTypeByte]; - dump([globalTypeByte], "global type (".concat(globalType, ")")); - - if (typeof globalType === "undefined") { - throw new _helperApiError.CompileError("Invalid mutability: " + toHex(globalTypeByte)); - } - - return t.globalType(type, globalType); - } // function parseNameModule() { - // const lenu32 = readVaruint32(); - // eatBytes(lenu32.nextIndex); - // console.log("len", lenu32); - // const strlen = lenu32.value; - // dump([strlen], "string length"); - // const bytes = readBytes(strlen); - // eatBytes(strlen); - // const value = utf8.decode(bytes); - // return [t.moduleNameMetadata(value)]; - // } - // this section contains an array of function names and indices - - - function parseNameSectionFunctions() { - var functionNames = []; - var numberOfFunctionsu32 = readU32(); - var numbeOfFunctions = numberOfFunctionsu32.value; - eatBytes(numberOfFunctionsu32.nextIndex); - - for (var i = 0; i < numbeOfFunctions; i++) { - var indexu32 = readU32(); - var index = indexu32.value; - eatBytes(indexu32.nextIndex); - var name = readUTF8String(); - eatBytes(name.nextIndex); - functionNames.push(t.functionNameMetadata(name.value, index)); - } - - return functionNames; - } - - function parseNameSectionLocals() { - var localNames = []; - var numbeOfFunctionsu32 = readU32(); - var numbeOfFunctions = numbeOfFunctionsu32.value; - eatBytes(numbeOfFunctionsu32.nextIndex); - - for (var i = 0; i < numbeOfFunctions; i++) { - var functionIndexu32 = readU32(); - var functionIndex = functionIndexu32.value; - eatBytes(functionIndexu32.nextIndex); - var numLocalsu32 = readU32(); - var numLocals = numLocalsu32.value; - eatBytes(numLocalsu32.nextIndex); - - for (var _i4 = 0; _i4 < numLocals; _i4++) { - var localIndexu32 = readU32(); - var localIndex = localIndexu32.value; - eatBytes(localIndexu32.nextIndex); - var name = readUTF8String(); - eatBytes(name.nextIndex); - localNames.push(t.localNameMetadata(name.value, localIndex, functionIndex)); - } - } - - return localNames; - } // this is a custom section used for name resolution - // https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#name-section - - - function parseNameSection(remainingBytes) { - var nameMetadata = []; - var initialOffset = offset; - - while (offset - initialOffset < remainingBytes) { - // name_type - var sectionTypeByte = readVaruint7(); - eatBytes(sectionTypeByte.nextIndex); // name_payload_len - - var subSectionSizeInBytesu32 = readVaruint32(); - 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 1: - { - nameMetadata.push.apply(nameMetadata, _toConsumableArray(parseNameSectionFunctions())); - break; - } - - case 2: - { - nameMetadata.push.apply(nameMetadata, _toConsumableArray(parseNameSectionLocals())); - break; - } - - default: - { - // skip unknown subsection - eatBytes(subSectionSizeInBytesu32.value); - } - } - } - - return nameMetadata; - } // this is a custom section used for information about the producers - // https://github.com/WebAssembly/tool-conventions/blob/master/ProducersSection.md - - - function parseProducersSection() { - var metadata = t.producersSectionMetadata([]); // field_count - - var sectionTypeByte = readVaruint32(); - eatBytes(sectionTypeByte.nextIndex); - dump([sectionTypeByte.value], "num of producers"); - var fields = { - language: [], - "processed-by": [], - sdk: [] - }; // fields - - for (var fieldI = 0; fieldI < sectionTypeByte.value; fieldI++) { - // field_name - var fieldName = readUTF8String(); - eatBytes(fieldName.nextIndex); // field_value_count - - var valueCount = readVaruint32(); - eatBytes(valueCount.nextIndex); // field_values - - for (var producerI = 0; producerI < valueCount.value; producerI++) { - var producerName = readUTF8String(); - eatBytes(producerName.nextIndex); - var producerVersion = readUTF8String(); - eatBytes(producerVersion.nextIndex); - fields[fieldName.value].push(t.producerMetadataVersionedName(producerName.value, producerVersion.value)); - } - - metadata.producers.push(fields[fieldName.value]); - } - - return metadata; - } - - function parseGlobalSection(numberOfGlobals) { - var globals = []; - dump([numberOfGlobals], "num globals"); - - for (var i = 0; i < numberOfGlobals; i++) { - var _startLoc11 = getPosition(); - - var globalType = parseGlobalType(); - /** - * Global expressions - */ - - var init = []; - parseInstructionBlock(init); - - var node = function () { - var endLoc = getPosition(); - return t.withLoc(t.global(globalType, init), endLoc, _startLoc11); - }(); - - globals.push(node); - state.globalsInModule.push(node); - } - - return globals; - } - - function parseElemSection(numberOfElements) { - var elems = []; - dump([numberOfElements], "num elements"); - - for (var i = 0; i < numberOfElements; i++) { - var _startLoc12 = getPosition(); - - var tableindexu32 = readU32(); - var tableindex = tableindexu32.value; - eatBytes(tableindexu32.nextIndex); - dump([tableindex], "table index"); - /** - * Parse instructions - */ - - var instr = []; - parseInstructionBlock(instr); - /** - * Parse ( vector function index ) * - */ - - var indicesu32 = readU32(); - var indices = indicesu32.value; - eatBytes(indicesu32.nextIndex); - dump([indices], "num indices"); - var indexValues = []; - - for (var _i5 = 0; _i5 < indices; _i5++) { - var indexu32 = readU32(); - var index = indexu32.value; - eatBytes(indexu32.nextIndex); - dump([index], "index"); - indexValues.push(t.indexLiteral(index)); - } - - var elemNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.elem(t.indexLiteral(tableindex), instr, indexValues), endLoc, _startLoc12); - }(); - - elems.push(elemNode); - } - - return elems; - } // https://webassembly.github.io/spec/core/binary/types.html#memory-types - - - function parseMemoryType(i) { - var limits = parseLimits(); - return t.memory(limits, t.indexLiteral(i)); - } // https://webassembly.github.io/spec/binary/modules.html#table-section - - - function parseTableSection(numberOfElements) { - var tables = []; - dump([numberOfElements], "num elements"); - - for (var i = 0; i < numberOfElements; i++) { - var tablesNode = parseTableType(i); - state.tablesInModule.push(tablesNode); - tables.push(tablesNode); - } - - return tables; - } // https://webassembly.github.io/spec/binary/modules.html#memory-section - - - function parseMemorySection(numberOfElements) { - var memories = []; - dump([numberOfElements], "num elements"); - - for (var i = 0; i < numberOfElements; i++) { - var memoryNode = parseMemoryType(i); - state.memoriesInModule.push(memoryNode); - memories.push(memoryNode); - } - - return memories; - } // https://webassembly.github.io/spec/binary/modules.html#binary-startsec - - - function parseStartSection() { - var startLoc = getPosition(); - var u32 = readU32(); - var startFuncIndex = u32.value; - eatBytes(u32.nextIndex); - dump([startFuncIndex], "index"); - return function () { - var endLoc = getPosition(); - return t.withLoc(t.start(t.indexLiteral(startFuncIndex)), endLoc, startLoc); - }(); - } // https://webassembly.github.io/spec/binary/modules.html#data-section - - - function parseDataSection(numberOfElements) { - var dataEntries = []; - dump([numberOfElements], "num elements"); - - for (var i = 0; i < numberOfElements; i++) { - var memoryIndexu32 = readU32(); - var memoryIndex = memoryIndexu32.value; - eatBytes(memoryIndexu32.nextIndex); - dump([memoryIndex], "memory index"); - var instrs = []; - parseInstructionBlock(instrs); - var hasExtraInstrs = instrs.filter(function (i) { - return i.id !== "end"; - }).length !== 1; - - if (hasExtraInstrs) { - throw new _helperApiError.CompileError("data section offset must be a single instruction"); - } - - var bytes = parseVec(function (b) { - return b; - }); - dump([], "init"); - dataEntries.push(t.data(t.memIndexLiteral(memoryIndex), instrs[0], t.byteArray(bytes))); - } - - return dataEntries; - } // https://webassembly.github.io/spec/binary/modules.html#binary-section - - - function parseSection(sectionIndex) { - var sectionId = readByte(); - eatBytes(1); - - 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)); - } - - var nextSectionIndex = sectionIndex; - var startOffset = offset; - var startLoc = getPosition(); - var u32 = readU32(); - var sectionSizeInBytes = u32.value; - eatBytes(u32.nextIndex); - - var sectionSizeInBytesNode = function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(sectionSizeInBytes), endLoc, startLoc); - }(); - - switch (sectionId) { - case _helperWasmBytecode.default.sections.type: - { - dumpSep("section Type"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc13 = getPosition(); - - var _u = readU32(); - - var numberOfTypes = _u.value; - eatBytes(_u.nextIndex); - - var _metadata = t.sectionMetadata("type", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfTypes), endLoc, _startLoc13); - }()); - - var _nodes = parseTypeSection(numberOfTypes); - - return { - nodes: _nodes, - metadata: _metadata, - nextSectionIndex: nextSectionIndex - }; - } - - case _helperWasmBytecode.default.sections.table: - { - dumpSep("section Table"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc14 = getPosition(); - - var _u2 = readU32(); - - var numberOfTable = _u2.value; - eatBytes(_u2.nextIndex); - dump([numberOfTable], "num tables"); - - var _metadata2 = t.sectionMetadata("table", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfTable), endLoc, _startLoc14); - }()); - - var _nodes2 = parseTableSection(numberOfTable); - - return { - nodes: _nodes2, - metadata: _metadata2, - nextSectionIndex: nextSectionIndex - }; - } - - case _helperWasmBytecode.default.sections.import: - { - dumpSep("section Import"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc15 = getPosition(); - - var numberOfImportsu32 = readU32(); - var numberOfImports = numberOfImportsu32.value; - eatBytes(numberOfImportsu32.nextIndex); - dump([numberOfImports], "number of imports"); - - var _metadata3 = t.sectionMetadata("import", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfImports), endLoc, _startLoc15); - }()); - - var _nodes3 = parseImportSection(numberOfImports); - - return { - nodes: _nodes3, - metadata: _metadata3, - nextSectionIndex: nextSectionIndex - }; - } - - case _helperWasmBytecode.default.sections.func: - { - dumpSep("section Function"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc16 = getPosition(); - - var numberOfFunctionsu32 = readU32(); - var numberOfFunctions = numberOfFunctionsu32.value; - eatBytes(numberOfFunctionsu32.nextIndex); - - var _metadata4 = t.sectionMetadata("func", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfFunctions), endLoc, _startLoc16); - }()); - - parseFuncSection(numberOfFunctions); - var _nodes4 = []; - return { - nodes: _nodes4, - metadata: _metadata4, - nextSectionIndex: nextSectionIndex - }; - } - - case _helperWasmBytecode.default.sections.export: - { - dumpSep("section Export"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc17 = getPosition(); - - var _u3 = readU32(); - - var numberOfExport = _u3.value; - eatBytes(_u3.nextIndex); - - var _metadata5 = t.sectionMetadata("export", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfExport), endLoc, _startLoc17); - }()); - - parseExportSection(numberOfExport); - var _nodes5 = []; - return { - nodes: _nodes5, - metadata: _metadata5, - nextSectionIndex: nextSectionIndex - }; - } - - case _helperWasmBytecode.default.sections.code: - { - dumpSep("section Code"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc18 = getPosition(); - - var _u4 = readU32(); - - var numberOfFuncs = _u4.value; - eatBytes(_u4.nextIndex); - - var _metadata6 = t.sectionMetadata("code", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfFuncs), endLoc, _startLoc18); - }()); - - if (opts.ignoreCodeSection === true) { - var remainingBytes = sectionSizeInBytes - _u4.nextIndex; - eatBytes(remainingBytes); // eat the entire section - } else { - parseCodeSection(numberOfFuncs); - } - - var _nodes6 = []; - return { - nodes: _nodes6, - metadata: _metadata6, - nextSectionIndex: nextSectionIndex - }; - } - - case _helperWasmBytecode.default.sections.start: - { - dumpSep("section Start"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _metadata7 = t.sectionMetadata("start", startOffset, sectionSizeInBytesNode); - - var _nodes7 = [parseStartSection()]; - return { - nodes: _nodes7, - metadata: _metadata7, - nextSectionIndex: nextSectionIndex - }; - } - - case _helperWasmBytecode.default.sections.element: - { - dumpSep("section Element"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc19 = getPosition(); - - var numberOfElementsu32 = readU32(); - var numberOfElements = numberOfElementsu32.value; - eatBytes(numberOfElementsu32.nextIndex); - - var _metadata8 = t.sectionMetadata("element", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfElements), endLoc, _startLoc19); - }()); - - var _nodes8 = parseElemSection(numberOfElements); - - return { - nodes: _nodes8, - metadata: _metadata8, - nextSectionIndex: nextSectionIndex - }; - } - - case _helperWasmBytecode.default.sections.global: - { - dumpSep("section Global"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc20 = getPosition(); - - var numberOfGlobalsu32 = readU32(); - var numberOfGlobals = numberOfGlobalsu32.value; - eatBytes(numberOfGlobalsu32.nextIndex); - - var _metadata9 = t.sectionMetadata("global", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(numberOfGlobals), endLoc, _startLoc20); - }()); - - var _nodes9 = parseGlobalSection(numberOfGlobals); - - return { - nodes: _nodes9, - metadata: _metadata9, - nextSectionIndex: nextSectionIndex - }; - } - - case _helperWasmBytecode.default.sections.memory: - { - dumpSep("section Memory"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _startLoc21 = getPosition(); - - var _numberOfElementsu = readU32(); - - var _numberOfElements = _numberOfElementsu.value; - eatBytes(_numberOfElementsu.nextIndex); - - var _metadata10 = t.sectionMetadata("memory", startOffset, sectionSizeInBytesNode, function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(_numberOfElements), endLoc, _startLoc21); - }()); - - var _nodes10 = parseMemorySection(_numberOfElements); - - return { - nodes: _nodes10, - metadata: _metadata10, - nextSectionIndex: nextSectionIndex - }; - } - - case _helperWasmBytecode.default.sections.data: - { - dumpSep("section Data"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - - var _metadata11 = t.sectionMetadata("data", startOffset, sectionSizeInBytesNode); - - var _startLoc22 = getPosition(); - - var _numberOfElementsu2 = readU32(); - - var _numberOfElements2 = _numberOfElementsu2.value; - eatBytes(_numberOfElementsu2.nextIndex); - - _metadata11.vectorOfSize = function () { - var endLoc = getPosition(); - return t.withLoc(t.numberLiteralFromRaw(_numberOfElements2), endLoc, _startLoc22); - }(); - - if (opts.ignoreDataSection === true) { - var _remainingBytes = sectionSizeInBytes - _numberOfElementsu2.nextIndex; - - eatBytes(_remainingBytes); // eat the entire section - - dumpSep("ignore data (" + sectionSizeInBytes + " bytes)"); - return { - nodes: [], - metadata: _metadata11, - nextSectionIndex: nextSectionIndex - }; - } else { - var _nodes11 = parseDataSection(_numberOfElements2); - - return { - nodes: _nodes11, - metadata: _metadata11, - nextSectionIndex: nextSectionIndex - }; - } - } - - case _helperWasmBytecode.default.sections.custom: - { - dumpSep("section Custom"); - dump([sectionId], "section code"); - dump([sectionSizeInBytes], "section size"); - var _metadata12 = [t.sectionMetadata("custom", startOffset, sectionSizeInBytesNode)]; - var sectionName = readUTF8String(); - eatBytes(sectionName.nextIndex); - dump([], "section name (".concat(sectionName.value, ")")); - - var _remainingBytes2 = sectionSizeInBytes - sectionName.nextIndex; - - if (sectionName.value === "name") { - var initialOffset = offset; - - 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(offset - (initialOffset + _remainingBytes2)); - } - } else if (sectionName.value === "producers") { - var _initialOffset = offset; - - try { - _metadata12.push(parseProducersSection()); - } catch (e) { - console.warn("Failed to decode custom \"producers\" section @".concat(offset, "; ignoring (").concat(e.message, ").")); - eatBytes(offset - (_initialOffset + _remainingBytes2)); - } - } else { - // We don't parse the custom section - eatBytes(_remainingBytes2); - dumpSep("ignore custom " + JSON.stringify(sectionName.value) + " section (" + _remainingBytes2 + " bytes)"); - } - - return { - nodes: [], - metadata: _metadata12, - nextSectionIndex: nextSectionIndex - }; - } - } - - throw new _helperApiError.CompileError("Unexpected section: " + toHex(sectionId)); - } - - parseModuleHeader(); - parseVersion(); - var moduleFields = []; - var sectionIndex = 0; - var moduleMetadata = { - sections: [], - functionNames: [], - localNames: [], - producers: [] - }; - /** - * All the generate declaration are going to be stored in our state - */ - - while (offset < buf.length) { - var _parseSection = parseSection(sectionIndex), - _nodes12 = _parseSection.nodes, - _metadata13 = _parseSection.metadata, - nextSectionIndex = _parseSection.nextSectionIndex; - - moduleFields.push.apply(moduleFields, _toConsumableArray(_nodes12)); - var metadataArray = Array.isArray(_metadata13) ? _metadata13 : [_metadata13]; - metadataArray.forEach(function (metadataItem) { - if (metadataItem.type === "FunctionNameMetadata") { - moduleMetadata.functionNames.push(metadataItem); - } else if (metadataItem.type === "LocalNameMetadata") { - moduleMetadata.localNames.push(metadataItem); - } else if (metadataItem.type === "ProducersSectionMetadata") { - moduleMetadata.producers.push(metadataItem); - } else { - moduleMetadata.sections.push(metadataItem); - } - }); // Ignore custom section - - if (nextSectionIndex) { - sectionIndex = nextSectionIndex; - } - } - /** - * Transform the state into AST nodes - */ - - - var funcIndex = 0; - state.functionsInModule.forEach(function (func) { - var params = func.signature.params; - var result = func.signature.result; - var body = []; // External functions doesn't provide any code, can skip it here - - if (func.isExternal === true) { - return; - } - - var decodedElementInCodeSection = state.elementsInCodeSection[funcIndex]; - - if (opts.ignoreCodeSection === false) { - if (typeof decodedElementInCodeSection === "undefined") { - throw new _helperApiError.CompileError("func " + toHex(funcIndex) + " code not found"); - } - - body = decodedElementInCodeSection.code; - } - - funcIndex++; - var funcNode = t.func(func.id, t.signature(params, result), body); - - if (func.isExternal === true) { - funcNode.isExternal = func.isExternal; - } // Add function position in the binary if possible - - - if (opts.ignoreCodeSection === false) { - var _startLoc23 = decodedElementInCodeSection.startLoc, - endLoc = decodedElementInCodeSection.endLoc, - bodySize = decodedElementInCodeSection.bodySize; - funcNode = t.withLoc(funcNode, endLoc, _startLoc23); - funcNode.metadata = { - bodySize: bodySize - }; - } - - moduleFields.push(funcNode); - }); - state.elementsInExportSection.forEach(function (moduleExport) { - /** - * If the export has no id, we won't be able to call it from the outside - * so we can omit it - */ - if (moduleExport.id != null) { - moduleFields.push(t.withLoc(t.moduleExport(moduleExport.name, t.moduleExportDescr(moduleExport.type, moduleExport.id)), moduleExport.endLoc, moduleExport.startLoc)); - } - }); - dumpSep("end of program"); - var module = t.module(null, moduleFields, t.moduleMetadata(moduleMetadata.sections, moduleMetadata.functionNames, moduleMetadata.localNames, moduleMetadata.producers)); - return t.program([module]); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-parser/lib/index.js b/node_modules/@webassemblyjs/wasm-parser/lib/index.js deleted file mode 100644 index abd442a..0000000 --- a/node_modules/@webassemblyjs/wasm-parser/lib/index.js +++ /dev/null @@ -1,257 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.decode = decode; - -var decoder = _interopRequireWildcard(require("./decoder")); - -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; } } - -/** - * TODO(sven): I added initial props, but we should rather fix - * https://github.com/xtuc/webassemblyjs/issues/405 - */ -var defaultDecoderOpts = { - dump: false, - ignoreCodeSection: false, - ignoreDataSection: false, - ignoreCustomNameSection: false -}; // traverses the AST, locating function name metadata, which is then -// used to update index-based identifiers with function names - -function restoreFunctionNames(ast) { - var functionNames = []; - t.traverse(ast, { - FunctionNameMetadata: function FunctionNameMetadata(_ref) { - var node = _ref.node; - functionNames.push({ - name: node.value, - index: node.index - }); - } - }); - - if (functionNames.length === 0) { - return; - } - - t.traverse(ast, { - Func: function (_Func) { - function Func(_x) { - return _Func.apply(this, arguments); - } - - Func.toString = function () { - return _Func.toString(); - }; - - return Func; - }(function (_ref2) { - var node = _ref2.node; - // $FlowIgnore - var nodeName = node.name; - var indexBasedFunctionName = nodeName.value; - var index = Number(indexBasedFunctionName.replace("func_", "")); - var functionName = functionNames.find(function (f) { - return f.index === index; - }); - - if (functionName) { - var oldValue = nodeName.value; - nodeName.value = functionName.name; - nodeName.numeric = oldValue; // $FlowIgnore - - delete nodeName.raw; - } - }), - // Also update the reference in the export - ModuleExport: function (_ModuleExport) { - function ModuleExport(_x2) { - return _ModuleExport.apply(this, arguments); - } - - ModuleExport.toString = function () { - return _ModuleExport.toString(); - }; - - return ModuleExport; - }(function (_ref3) { - var node = _ref3.node; - - if (node.descr.exportType === "Func") { - // $FlowIgnore - var nodeName = node.descr.id; - var index = nodeName.value; - var functionName = functionNames.find(function (f) { - return f.index === index; - }); - - if (functionName) { - node.descr.id = t.identifier(functionName.name); - } - } - }), - ModuleImport: function (_ModuleImport) { - function ModuleImport(_x3) { - return _ModuleImport.apply(this, arguments); - } - - ModuleImport.toString = function () { - return _ModuleImport.toString(); - }; - - return ModuleImport; - }(function (_ref4) { - var node = _ref4.node; - - if (node.descr.type === "FuncImportDescr") { - // $FlowIgnore - var indexBasedFunctionName = node.descr.id; - var index = Number(indexBasedFunctionName.replace("func_", "")); - var functionName = functionNames.find(function (f) { - return f.index === index; - }); - - if (functionName) { - // $FlowIgnore - node.descr.id = t.identifier(functionName.name); - } - } - }), - CallInstruction: function (_CallInstruction) { - function CallInstruction(_x4) { - return _CallInstruction.apply(this, arguments); - } - - CallInstruction.toString = function () { - return _CallInstruction.toString(); - }; - - return CallInstruction; - }(function (nodePath) { - var node = nodePath.node; - var index = node.index.value; - var functionName = functionNames.find(function (f) { - return f.index === index; - }); - - if (functionName) { - var oldValue = node.index; - node.index = t.identifier(functionName.name); - node.numeric = oldValue; // $FlowIgnore - - delete node.raw; - } - }) - }); -} - -function restoreLocalNames(ast) { - var localNames = []; - t.traverse(ast, { - LocalNameMetadata: function LocalNameMetadata(_ref5) { - var node = _ref5.node; - localNames.push({ - name: node.value, - localIndex: node.localIndex, - functionIndex: node.functionIndex - }); - } - }); - - if (localNames.length === 0) { - return; - } - - t.traverse(ast, { - Func: function (_Func2) { - function Func(_x5) { - return _Func2.apply(this, arguments); - } - - Func.toString = function () { - return _Func2.toString(); - }; - - return Func; - }(function (_ref6) { - var node = _ref6.node; - var signature = node.signature; - - if (signature.type !== "Signature") { - return; - } // $FlowIgnore - - - var nodeName = node.name; - var indexBasedFunctionName = nodeName.value; - var functionIndex = Number(indexBasedFunctionName.replace("func_", "")); - signature.params.forEach(function (param, paramIndex) { - var paramName = localNames.find(function (f) { - return f.localIndex === paramIndex && f.functionIndex === functionIndex; - }); - - if (paramName && paramName.name !== "") { - param.id = paramName.name; - } - }); - }) - }); -} - -function restoreModuleName(ast) { - t.traverse(ast, { - ModuleNameMetadata: function (_ModuleNameMetadata) { - function ModuleNameMetadata(_x6) { - return _ModuleNameMetadata.apply(this, arguments); - } - - ModuleNameMetadata.toString = function () { - return _ModuleNameMetadata.toString(); - }; - - return ModuleNameMetadata; - }(function (moduleNameMetadataPath) { - // update module - t.traverse(ast, { - Module: function (_Module) { - function Module(_x7) { - return _Module.apply(this, arguments); - } - - Module.toString = function () { - return _Module.toString(); - }; - - return Module; - }(function (_ref7) { - var node = _ref7.node; - var name = moduleNameMetadataPath.node.value; // compatiblity with wast-parser - - if (name === "") { - name = null; - } - - node.id = name; - }) - }); - }) - }); -} - -function decode(buf, customOpts) { - var opts = Object.assign({}, defaultDecoderOpts, customOpts); - var ast = decoder.decode(buf, opts); - - if (opts.ignoreCustomNameSection === false) { - restoreFunctionNames(ast); - restoreLocalNames(ast); - restoreModuleName(ast); - } - - return ast; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wasm-parser/lib/types/decoder.js b/node_modules/@webassemblyjs/wasm-parser/lib/types/decoder.js deleted file mode 100644 index e69de29..0000000 --- a/node_modules/@webassemblyjs/wasm-parser/lib/types/decoder.js +++ /dev/null diff --git a/node_modules/@webassemblyjs/wasm-parser/package.json b/node_modules/@webassemblyjs/wasm-parser/package.json deleted file mode 100644 index 77e7387..0000000 --- a/node_modules/@webassemblyjs/wasm-parser/package.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "_from": "@webassemblyjs/wasm-parser@1.9.0", - "_id": "@webassemblyjs/wasm-parser@1.9.0", - "_inBundle": false, - "_integrity": "sha512-9+wkMowR2AmdSWQzsPEjFU7njh8HTO5MqO8vjwEHuM+AMHioNqSBONRdr0NQQ3dVQrzp0s8lTcYqzUdb7YgELA==", - "_location": "/@webassemblyjs/wasm-parser", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/wasm-parser@1.9.0", - "name": "@webassemblyjs/wasm-parser", - "escapedName": "@webassemblyjs%2fwasm-parser", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/wasm-edit", - "/@webassemblyjs/wasm-opt", - "/webpack" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.9.0.tgz", - "_shasum": "9d48e44826df4a6598294aa6c87469d642fff65e", - "_spec": "@webassemblyjs/wasm-parser@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/webpack", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "dependencies": { - "@webassemblyjs/ast": "1.9.0", - "@webassemblyjs/helper-api-error": "1.9.0", - "@webassemblyjs/helper-wasm-bytecode": "1.9.0", - "@webassemblyjs/ieee754": "1.9.0", - "@webassemblyjs/leb128": "1.9.0", - "@webassemblyjs/utf8": "1.9.0" - }, - "deprecated": false, - "description": "WebAssembly binary format parser", - "devDependencies": { - "@webassemblyjs/helper-buffer": "1.9.0", - "@webassemblyjs/helper-test-framework": "1.9.0", - "@webassemblyjs/helper-wasm-bytecode": "1.7.7", - "@webassemblyjs/wasm-gen": "1.9.0", - "@webassemblyjs/wast-parser": "1.9.0", - "mamacro": "^0.0.7", - "wabt": "1.0.12" - }, - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "keywords": [ - "webassembly", - "javascript", - "ast", - "parser", - "wasm" - ], - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/wasm-parser", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "scripts": { - "test": "mocha" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/wast-parser/LICENSE b/node_modules/@webassemblyjs/wast-parser/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/wast-parser/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/wast-parser/README.md b/node_modules/@webassemblyjs/wast-parser/README.md deleted file mode 100644 index 345f0d7..0000000 --- a/node_modules/@webassemblyjs/wast-parser/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# @webassemblyjs/wast-parser - -> WebAssembly text format parser - -## Installation - -```sh -yarn add @webassemblyjs/wast-parser -``` - -## Usage - -```js -import { parse } from "@webassemblyjs/wast-parser"; - -const ast = parse(source); -``` diff --git a/node_modules/@webassemblyjs/wast-parser/esm/grammar.js b/node_modules/@webassemblyjs/wast-parser/esm/grammar.js deleted file mode 100644 index aa92e55..0000000 --- a/node_modules/@webassemblyjs/wast-parser/esm/grammar.js +++ /dev/null @@ -1,1756 +0,0 @@ -function _typeof(obj) { 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); } - -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 { codeFrameFromSource } from "@webassemblyjs/helper-code-frame"; -import * as t from "@webassemblyjs/ast"; -import { parse32I } from "./number-literals"; -import { parseString } from "./string-literals"; -import { tokens, keywords } from "./tokenizer"; - -function hasPlugin(name) { - if (name !== "wast") throw new Error("unknow plugin"); - return true; -} - -function isKeyword(token, id) { - return token.type === tokens.keyword && token.value === id; -} - -function tokenToString(token) { - if (token.type === "keyword") { - return "keyword (".concat(token.value, ")"); - } - - return token.type; -} - -function identifierFromToken(token) { - var _token$loc = token.loc, - end = _token$loc.end, - start = _token$loc.start; - return t.withLoc(t.identifier(token.value), end, start); -} - -export function parse(tokensList, source) { - var current = 0; - var getUniqueName = t.getUniqueNameGenerator(); - var state = { - registredExportedElements: [] - }; // But this time we're going to use recursion instead of a `while` loop. So we - // define a `walk` function. - - function walk() { - var token = tokensList[current]; - - function eatToken() { - token = tokensList[++current]; - } - - function getEndLoc() { - var currentToken = token; - - if (typeof currentToken === "undefined") { - var lastToken = tokensList[tokensList.length - 1]; - currentToken = lastToken; - } - - return currentToken.loc.end; - } - - function getStartLoc() { - return token.loc.start; - } - - function eatTokenOfType(type) { - if (token.type !== type) { - throw new Error("\n" + codeFrameFromSource(source, token.loc) + "Assertion error: expected token of type " + type + ", given " + tokenToString(token)); - } - - eatToken(); - } - - function parseExportIndex(token) { - if (token.type === tokens.identifier) { - var index = identifierFromToken(token); - eatToken(); - return index; - } else if (token.type === tokens.number) { - var _index = t.numberLiteralFromRaw(token.value); - - eatToken(); - return _index; - } else { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "unknown export index" + ", given " + tokenToString(token)); - }(); - } - } - - function lookaheadAndCheck() { - var len = arguments.length; - - for (var i = 0; i < len; i++) { - var tokenAhead = tokensList[current + i]; - var expectedToken = i < 0 || arguments.length <= i ? undefined : arguments[i]; - - if (tokenAhead.type === "keyword") { - if (isKeyword(tokenAhead, expectedToken) === false) { - return false; - } - } else if (expectedToken !== tokenAhead.type) { - return false; - } - } - - return true; - } // TODO(sven): there is probably a better way to do this - // can refactor it if it get out of hands - - - function maybeIgnoreComment() { - if (typeof token === "undefined") { - // Ignore - return; - } - - while (token.type === tokens.comment) { - eatToken(); - - if (typeof token === "undefined") { - // Hit the end - break; - } - } - } - /** - * Parses a memory instruction - * - * WAST: - * - * memory: ( memory <name>? <memory_sig> ) - * ( memory <name>? ( export <string> ) <...> ) - * ( memory <name>? ( import <string> <string> ) <memory_sig> ) - * ( memory <name>? ( export <string> )* ( data <string>* ) - * memory_sig: <nat> <nat>? - * - */ - - - function parseMemory() { - var id = t.identifier(getUniqueName("memory")); - var limits = t.limit(0); - - if (token.type === tokens.string || token.type === tokens.identifier) { - id = t.identifier(token.value); - eatToken(); - } else { - id = t.withRaw(id, ""); // preserve anonymous - } - /** - * Maybe data - */ - - - if (lookaheadAndCheck(tokens.openParen, keywords.data)) { - eatToken(); // ( - - eatToken(); // data - // TODO(sven): do something with the data collected here - - var stringInitializer = token.value; - eatTokenOfType(tokens.string); // Update limits accordingly - - limits = t.limit(stringInitializer.length); - eatTokenOfType(tokens.closeParen); - } - /** - * Maybe export - */ - - - if (lookaheadAndCheck(tokens.openParen, keywords.export)) { - eatToken(); // ( - - eatToken(); // export - - if (token.type !== tokens.string) { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Expected string in export" + ", given " + tokenToString(token)); - }(); - } - - var _name = token.value; - eatToken(); - state.registredExportedElements.push({ - exportType: "Memory", - name: _name, - id: id - }); - eatTokenOfType(tokens.closeParen); - } - /** - * Memory signature - */ - - - if (token.type === tokens.number) { - limits = t.limit(parse32I(token.value)); - eatToken(); - - if (token.type === tokens.number) { - limits.max = parse32I(token.value); - eatToken(); - } - } - - return t.memory(limits, id); - } - /** - * Parses a data section - * https://webassembly.github.io/spec/core/text/modules.html#data-segments - * - * WAST: - * - * data: ( data <index>? <offset> <string> ) - */ - - - function parseData() { - // optional memory index - var memidx = 0; - - if (token.type === tokens.number) { - memidx = token.value; - eatTokenOfType(tokens.number); // . - } - - eatTokenOfType(tokens.openParen); - var offset; - - if (token.type === tokens.valtype) { - eatTokenOfType(tokens.valtype); // i32 - - eatTokenOfType(tokens.dot); // . - - if (token.value !== "const") { - throw new Error("constant expression required"); - } - - eatTokenOfType(tokens.name); // const - - var numberLiteral = t.numberLiteralFromRaw(token.value, "i32"); - offset = t.objectInstruction("const", "i32", [numberLiteral]); - eatToken(); - eatTokenOfType(tokens.closeParen); - } else { - eatTokenOfType(tokens.name); // get_global - - var _numberLiteral = t.numberLiteralFromRaw(token.value, "i32"); - - offset = t.instruction("get_global", [_numberLiteral]); - eatToken(); - eatTokenOfType(tokens.closeParen); - } - - var byteArray = parseString(token.value); - eatToken(); // "string" - - return t.data(t.memIndexLiteral(memidx), offset, t.byteArray(byteArray)); - } - /** - * Parses a table instruction - * - * WAST: - * - * table: ( table <name>? <table_type> ) - * ( table <name>? ( export <string> ) <...> ) - * ( table <name>? ( import <string> <string> ) <table_type> ) - * ( table <name>? ( export <string> )* <elem_type> ( elem <var>* ) ) - * - * table_type: <nat> <nat>? <elem_type> - * elem_type: anyfunc - * - * elem: ( elem <var>? (offset <instr>* ) <var>* ) - * ( elem <var>? <expr> <var>* ) - */ - - - function parseTable() { - var name = t.identifier(getUniqueName("table")); - var limit = t.limit(0); - var elemIndices = []; - var elemType = "anyfunc"; - - if (token.type === tokens.string || token.type === tokens.identifier) { - name = identifierFromToken(token); - eatToken(); - } else { - name = t.withRaw(name, ""); // preserve anonymous - } - - while (token.type !== tokens.closeParen) { - /** - * Maybe export - */ - if (lookaheadAndCheck(tokens.openParen, keywords.elem)) { - eatToken(); // ( - - eatToken(); // elem - - while (token.type === tokens.identifier) { - elemIndices.push(t.identifier(token.value)); - eatToken(); - } - - eatTokenOfType(tokens.closeParen); - } else if (lookaheadAndCheck(tokens.openParen, keywords.export)) { - eatToken(); // ( - - eatToken(); // export - - if (token.type !== tokens.string) { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Expected string in export" + ", given " + tokenToString(token)); - }(); - } - - var exportName = token.value; - eatToken(); - state.registredExportedElements.push({ - exportType: "Table", - name: exportName, - id: name - }); - eatTokenOfType(tokens.closeParen); - } else if (isKeyword(token, keywords.anyfunc)) { - // It's the default value, we can ignore it - eatToken(); // anyfunc - } else if (token.type === tokens.number) { - /** - * Table type - */ - var min = parseInt(token.value); - eatToken(); - - if (token.type === tokens.number) { - var max = parseInt(token.value); - eatToken(); - limit = t.limit(min, max); - } else { - limit = t.limit(min); - } - - eatToken(); - } else { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected token" + ", given " + tokenToString(token)); - }(); - } - } - - if (elemIndices.length > 0) { - return t.table(elemType, limit, name, elemIndices); - } else { - return t.table(elemType, limit, name); - } - } - /** - * Parses an import statement - * - * WAST: - * - * import: ( import <string> <string> <imkind> ) - * imkind: ( func <name>? <func_sig> ) - * ( global <name>? <global_sig> ) - * ( table <name>? <table_sig> ) - * ( memory <name>? <memory_sig> ) - * - * global_sig: <type> | ( mut <type> ) - */ - - - function parseImport() { - if (token.type !== tokens.string) { - throw new Error("Expected a string, " + token.type + " given."); - } - - var moduleName = token.value; - eatToken(); - - if (token.type !== tokens.string) { - throw new Error("Expected a string, " + token.type + " given."); - } - - var name = token.value; - eatToken(); - eatTokenOfType(tokens.openParen); - var descr; - - if (isKeyword(token, keywords.func)) { - eatToken(); // keyword - - var fnParams = []; - var fnResult = []; - var typeRef; - var fnName = t.identifier(getUniqueName("func")); - - if (token.type === tokens.identifier) { - fnName = identifierFromToken(token); - eatToken(); - } - - while (token.type === tokens.openParen) { - eatToken(); - - if (lookaheadAndCheck(keywords.type) === true) { - eatToken(); - typeRef = parseTypeReference(); - } else if (lookaheadAndCheck(keywords.param) === true) { - eatToken(); - fnParams.push.apply(fnParams, _toConsumableArray(parseFuncParam())); - } else if (lookaheadAndCheck(keywords.result) === true) { - eatToken(); - fnResult.push.apply(fnResult, _toConsumableArray(parseFuncResult())); - } else { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected token in import of type" + ", given " + tokenToString(token)); - }(); - } - - eatTokenOfType(tokens.closeParen); - } - - if (typeof fnName === "undefined") { - throw new Error("Imported function must have a name"); - } - - descr = t.funcImportDescr(fnName, typeRef !== undefined ? typeRef : t.signature(fnParams, fnResult)); - } else if (isKeyword(token, keywords.global)) { - eatToken(); // keyword - - if (token.type === tokens.openParen) { - eatToken(); // ( - - eatTokenOfType(tokens.keyword); // mut keyword - - var valtype = token.value; - eatToken(); - descr = t.globalType(valtype, "var"); - eatTokenOfType(tokens.closeParen); - } else { - var _valtype = token.value; - eatTokenOfType(tokens.valtype); - descr = t.globalType(_valtype, "const"); - } - } else if (isKeyword(token, keywords.memory) === true) { - eatToken(); // Keyword - - descr = parseMemory(); - } else if (isKeyword(token, keywords.table) === true) { - eatToken(); // Keyword - - descr = parseTable(); - } else { - throw new Error("Unsupported import type: " + tokenToString(token)); - } - - eatTokenOfType(tokens.closeParen); - return t.moduleImport(moduleName, name, descr); - } - /** - * Parses a block instruction - * - * WAST: - * - * expr: ( block <name>? <block_sig> <instr>* ) - * instr: block <name>? <block_sig> <instr>* end <name>? - * block_sig : ( result <type>* )* - * - */ - - - function parseBlock() { - var label = t.identifier(getUniqueName("block")); - var blockResult = null; - var instr = []; - - if (token.type === tokens.identifier) { - label = identifierFromToken(token); - eatToken(); - } else { - label = t.withRaw(label, ""); // preserve anonymous - } - - while (token.type === tokens.openParen) { - eatToken(); - - if (lookaheadAndCheck(keywords.result) === true) { - eatToken(); - blockResult = token.value; - eatToken(); - } else if (lookaheadAndCheck(tokens.name) === true || lookaheadAndCheck(tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - // Instruction - instr.push(parseFuncInstr()); - } else { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected token in block body of type" + ", given " + tokenToString(token)); - }(); - } - - maybeIgnoreComment(); - eatTokenOfType(tokens.closeParen); - } - - return t.blockInstruction(label, instr, blockResult); - } - /** - * Parses a if instruction - * - * WAST: - * - * expr: - * ( if <name>? <block_sig> ( then <instr>* ) ( else <instr>* )? ) - * ( if <name>? <block_sig> <expr>+ ( then <instr>* ) ( else <instr>* )? ) - * - * instr: - * if <name>? <block_sig> <instr>* end <name>? - * if <name>? <block_sig> <instr>* else <name>? <instr>* end <name>? - * - * block_sig : ( result <type>* )* - * - */ - - - function parseIf() { - var blockResult = null; - var label = t.identifier(getUniqueName("if")); - var testInstrs = []; - var consequent = []; - var alternate = []; - - if (token.type === tokens.identifier) { - label = identifierFromToken(token); - eatToken(); - } else { - label = t.withRaw(label, ""); // preserve anonymous - } - - while (token.type === tokens.openParen) { - eatToken(); // ( - - /** - * Block signature - */ - - if (isKeyword(token, keywords.result) === true) { - eatToken(); - blockResult = token.value; - eatTokenOfType(tokens.valtype); - eatTokenOfType(tokens.closeParen); - continue; - } - /** - * Then - */ - - - if (isKeyword(token, keywords.then) === true) { - eatToken(); // then - - while (token.type === tokens.openParen) { - eatToken(); // Instruction - - if (lookaheadAndCheck(tokens.name) === true || lookaheadAndCheck(tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - consequent.push(parseFuncInstr()); - } else { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected token in consequent body of type" + ", given " + tokenToString(token)); - }(); - } - - eatTokenOfType(tokens.closeParen); - } - - eatTokenOfType(tokens.closeParen); - continue; - } - /** - * Alternate - */ - - - if (isKeyword(token, keywords.else)) { - eatToken(); // else - - while (token.type === tokens.openParen) { - eatToken(); // Instruction - - if (lookaheadAndCheck(tokens.name) === true || lookaheadAndCheck(tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - alternate.push(parseFuncInstr()); - } else { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected token in alternate body of type" + ", given " + tokenToString(token)); - }(); - } - - eatTokenOfType(tokens.closeParen); - } - - eatTokenOfType(tokens.closeParen); - continue; - } - /** - * Test instruction - */ - - - if (lookaheadAndCheck(tokens.name) === true || lookaheadAndCheck(tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - testInstrs.push(parseFuncInstr()); - eatTokenOfType(tokens.closeParen); - continue; - } - - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected token in if body" + ", given " + tokenToString(token)); - }(); - } - - return t.ifInstruction(label, testInstrs, blockResult, consequent, alternate); - } - /** - * Parses a loop instruction - * - * WAT: - * - * blockinstr :: 'loop' I:label rt:resulttype (in:instr*) 'end' id? - * - * WAST: - * - * instr :: loop <name>? <block_sig> <instr>* end <name>? - * expr :: ( loop <name>? <block_sig> <instr>* ) - * block_sig :: ( result <type>* )* - * - */ - - - function parseLoop() { - var label = t.identifier(getUniqueName("loop")); - var blockResult; - var instr = []; - - if (token.type === tokens.identifier) { - label = identifierFromToken(token); - eatToken(); - } else { - label = t.withRaw(label, ""); // preserve anonymous - } - - while (token.type === tokens.openParen) { - eatToken(); - - if (lookaheadAndCheck(keywords.result) === true) { - eatToken(); - blockResult = token.value; - eatToken(); - } else if (lookaheadAndCheck(tokens.name) === true || lookaheadAndCheck(tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - // Instruction - instr.push(parseFuncInstr()); - } else { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected token in loop body" + ", given " + tokenToString(token)); - }(); - } - - eatTokenOfType(tokens.closeParen); - } - - return t.loopInstruction(label, blockResult, instr); - } - - function parseCallIndirect() { - var typeRef; - var params = []; - var results = []; - var instrs = []; - - while (token.type !== tokens.closeParen) { - if (lookaheadAndCheck(tokens.openParen, keywords.type)) { - eatToken(); // ( - - eatToken(); // type - - typeRef = parseTypeReference(); - } else if (lookaheadAndCheck(tokens.openParen, keywords.param)) { - eatToken(); // ( - - eatToken(); // param - - /** - * Params can be empty: - * (params)` - */ - - if (token.type !== tokens.closeParen) { - params.push.apply(params, _toConsumableArray(parseFuncParam())); - } - } else if (lookaheadAndCheck(tokens.openParen, keywords.result)) { - eatToken(); // ( - - eatToken(); // result - - /** - * Results can be empty: - * (result)` - */ - - if (token.type !== tokens.closeParen) { - results.push.apply(results, _toConsumableArray(parseFuncResult())); - } - } else { - eatTokenOfType(tokens.openParen); - instrs.push(parseFuncInstr()); - } - - eatTokenOfType(tokens.closeParen); - } - - return t.callIndirectInstruction(typeRef !== undefined ? typeRef : t.signature(params, results), instrs); - } - /** - * Parses an export instruction - * - * WAT: - * - * export: ( export <string> <exkind> ) - * exkind: ( func <var> ) - * ( global <var> ) - * ( table <var> ) - * ( memory <var> ) - * var: <nat> | <name> - * - */ - - - function parseExport() { - if (token.type !== tokens.string) { - throw new Error("Expected string after export, got: " + token.type); - } - - var name = token.value; - eatToken(); - var moduleExportDescr = parseModuleExportDescr(); - return t.moduleExport(name, moduleExportDescr); - } - - function parseModuleExportDescr() { - var startLoc = getStartLoc(); - var type = ""; - var index; - eatTokenOfType(tokens.openParen); - - while (token.type !== tokens.closeParen) { - if (isKeyword(token, keywords.func)) { - type = "Func"; - eatToken(); - index = parseExportIndex(token); - } else if (isKeyword(token, keywords.table)) { - type = "Table"; - eatToken(); - index = parseExportIndex(token); - } else if (isKeyword(token, keywords.global)) { - type = "Global"; - eatToken(); - index = parseExportIndex(token); - } else if (isKeyword(token, keywords.memory)) { - type = "Memory"; - eatToken(); - index = parseExportIndex(token); - } - - eatToken(); - } - - if (type === "") { - throw new Error("Unknown export type"); - } - - if (index === undefined) { - throw new Error("Exported function must have a name"); - } - - var node = t.moduleExportDescr(type, index); - var endLoc = getEndLoc(); - eatTokenOfType(tokens.closeParen); - return t.withLoc(node, endLoc, startLoc); - } - - function parseModule() { - var name = null; - var isBinary = false; - var isQuote = false; - var moduleFields = []; - - if (token.type === tokens.identifier) { - name = token.value; - eatToken(); - } - - if (hasPlugin("wast") && token.type === tokens.name && token.value === "binary") { - eatToken(); - isBinary = true; - } - - if (hasPlugin("wast") && token.type === tokens.name && token.value === "quote") { - eatToken(); - isQuote = true; - } - - if (isBinary === true) { - var blob = []; - - while (token.type === tokens.string) { - blob.push(token.value); - eatToken(); - maybeIgnoreComment(); - } - - eatTokenOfType(tokens.closeParen); - return t.binaryModule(name, blob); - } - - if (isQuote === true) { - var string = []; - - while (token.type === tokens.string) { - string.push(token.value); - eatToken(); - } - - eatTokenOfType(tokens.closeParen); - return t.quoteModule(name, string); - } - - while (token.type !== tokens.closeParen) { - moduleFields.push(walk()); - - if (state.registredExportedElements.length > 0) { - state.registredExportedElements.forEach(function (decl) { - moduleFields.push(t.moduleExport(decl.name, t.moduleExportDescr(decl.exportType, decl.id))); - }); - state.registredExportedElements = []; - } - - token = tokensList[current]; - } - - eatTokenOfType(tokens.closeParen); - return t.module(name, moduleFields); - } - /** - * Parses the arguments of an instruction - */ - - - function parseFuncInstrArguments(signature) { - var args = []; - var namedArgs = {}; - var signaturePtr = 0; - - while (token.type === tokens.name || isKeyword(token, keywords.offset)) { - var key = token.value; - eatToken(); - eatTokenOfType(tokens.equal); - var value = void 0; - - if (token.type === tokens.number) { - value = t.numberLiteralFromRaw(token.value); - } else { - throw new Error("Unexpected type for argument: " + token.type); - } - - namedArgs[key] = value; - eatToken(); - } // $FlowIgnore - - - var signatureLength = signature.vector ? Infinity : signature.length; - - while (token.type !== tokens.closeParen && ( // $FlowIgnore - token.type === tokens.openParen || signaturePtr < signatureLength)) { - if (token.type === tokens.identifier) { - args.push(t.identifier(token.value)); - eatToken(); - } else if (token.type === tokens.valtype) { - // Handle locals - args.push(t.valtypeLiteral(token.value)); - eatToken(); - } else if (token.type === tokens.string) { - args.push(t.stringLiteral(token.value)); - eatToken(); - } else if (token.type === tokens.number) { - args.push( // TODO(sven): refactor the type signature handling - // https://github.com/xtuc/webassemblyjs/pull/129 is a good start - t.numberLiteralFromRaw(token.value, // $FlowIgnore - signature[signaturePtr] || "f64")); // $FlowIgnore - - if (!signature.vector) { - ++signaturePtr; - } - - eatToken(); - } else if (token.type === tokens.openParen) { - /** - * Maybe some nested instructions - */ - eatToken(); // Instruction - - if (lookaheadAndCheck(tokens.name) === true || lookaheadAndCheck(tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - // $FlowIgnore - args.push(parseFuncInstr()); - } else { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected token in nested instruction" + ", given " + tokenToString(token)); - }(); - } - - if (token.type === tokens.closeParen) { - eatToken(); - } - } else { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected token in instruction argument" + ", given " + tokenToString(token)); - }(); - } - } - - return { - args: args, - namedArgs: namedArgs - }; - } - /** - * Parses an instruction - * - * WAT: - * - * instr :: plaininst - * blockinstr - * - * blockinstr :: 'block' I:label rt:resulttype (in:instr*) 'end' id? - * 'loop' I:label rt:resulttype (in:instr*) 'end' id? - * 'if' I:label rt:resulttype (in:instr*) 'else' id? (in2:intr*) 'end' id? - * - * plaininst :: 'unreachable' - * 'nop' - * 'br' l:labelidx - * 'br_if' l:labelidx - * 'br_table' l*:vec(labelidx) ln:labelidx - * 'return' - * 'call' x:funcidx - * 'call_indirect' x, I:typeuse - * - * WAST: - * - * instr: - * <expr> - * <op> - * block <name>? <block_sig> <instr>* end <name>? - * loop <name>? <block_sig> <instr>* end <name>? - * if <name>? <block_sig> <instr>* end <name>? - * if <name>? <block_sig> <instr>* else <name>? <instr>* end <name>? - * - * expr: - * ( <op> ) - * ( <op> <expr>+ ) - * ( block <name>? <block_sig> <instr>* ) - * ( loop <name>? <block_sig> <instr>* ) - * ( if <name>? <block_sig> ( then <instr>* ) ( else <instr>* )? ) - * ( if <name>? <block_sig> <expr>+ ( then <instr>* ) ( else <instr>* )? ) - * - * op: - * unreachable - * nop - * br <var> - * br_if <var> - * br_table <var>+ - * return - * call <var> - * call_indirect <func_sig> - * drop - * select - * get_local <var> - * set_local <var> - * tee_local <var> - * get_global <var> - * set_global <var> - * <type>.load((8|16|32)_<sign>)? <offset>? <align>? - * <type>.store(8|16|32)? <offset>? <align>? - * current_memory - * grow_memory - * <type>.const <value> - * <type>.<unop> - * <type>.<binop> - * <type>.<testop> - * <type>.<relop> - * <type>.<cvtop>/<type> - * - * func_type: ( type <var> )? <param>* <result>* - */ - - - function parseFuncInstr() { - var startLoc = getStartLoc(); - maybeIgnoreComment(); - /** - * A simple instruction - */ - - if (token.type === tokens.name || token.type === tokens.valtype) { - var _name2 = token.value; - var object; - eatToken(); - - if (token.type === tokens.dot) { - object = _name2; - eatToken(); - - if (token.type !== tokens.name) { - throw new TypeError("Unknown token: " + token.type + ", name expected"); - } - - _name2 = token.value; - eatToken(); - } - - if (token.type === tokens.closeParen) { - var _endLoc = token.loc.end; - - if (typeof object === "undefined") { - return t.withLoc(t.instruction(_name2), _endLoc, startLoc); - } else { - return t.withLoc(t.objectInstruction(_name2, object, []), _endLoc, startLoc); - } - } - - var signature = t.signatureForOpcode(object || "", _name2); - - var _parseFuncInstrArgume = parseFuncInstrArguments(signature), - _args = _parseFuncInstrArgume.args, - _namedArgs = _parseFuncInstrArgume.namedArgs; - - var endLoc = token.loc.end; - - if (typeof object === "undefined") { - return t.withLoc(t.instruction(_name2, _args, _namedArgs), endLoc, startLoc); - } else { - return t.withLoc(t.objectInstruction(_name2, object, _args, _namedArgs), endLoc, startLoc); - } - } else if (isKeyword(token, keywords.loop)) { - /** - * Else a instruction with a keyword (loop or block) - */ - eatToken(); // keyword - - return parseLoop(); - } else if (isKeyword(token, keywords.block)) { - eatToken(); // keyword - - return parseBlock(); - } else if (isKeyword(token, keywords.call_indirect)) { - eatToken(); // keyword - - return parseCallIndirect(); - } else if (isKeyword(token, keywords.call)) { - eatToken(); // keyword - - var index; - - if (token.type === tokens.identifier) { - index = identifierFromToken(token); - eatToken(); - } else if (token.type === tokens.number) { - index = t.indexLiteral(token.value); - eatToken(); - } - - var instrArgs = []; // Nested instruction - - while (token.type === tokens.openParen) { - eatToken(); - instrArgs.push(parseFuncInstr()); - eatTokenOfType(tokens.closeParen); - } - - if (typeof index === "undefined") { - throw new Error("Missing argument in call instruciton"); - } - - if (instrArgs.length > 0) { - return t.callInstruction(index, instrArgs); - } else { - return t.callInstruction(index); - } - } else if (isKeyword(token, keywords.if)) { - eatToken(); // Keyword - - return parseIf(); - } else if (isKeyword(token, keywords.module) && hasPlugin("wast")) { - eatToken(); // In WAST you can have a module as an instruction's argument - // we will cast it into a instruction to not break the flow - // $FlowIgnore - - var module = parseModule(); - return module; - } else { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected instruction in function body" + ", given " + tokenToString(token)); - }(); - } - } - /* - * Parses a function - * - * WAT: - * - * functype :: ( 'func' t1:vec(param) t2:vec(result) ) - * param :: ( 'param' id? t:valtype ) - * result :: ( 'result' t:valtype ) - * - * WAST: - * - * func :: ( func <name>? <func_sig> <local>* <instr>* ) - * ( func <name>? ( export <string> ) <...> ) - * ( func <name>? ( import <string> <string> ) <func_sig> ) - * func_sig :: ( type <var> )? <param>* <result>* - * param :: ( param <type>* ) | ( param <name> <type> ) - * result :: ( result <type>* ) - * local :: ( local <type>* ) | ( local <name> <type> ) - * - */ - - - function parseFunc() { - var fnName = t.identifier(getUniqueName("func")); - var typeRef; - var fnBody = []; - var fnParams = []; - var fnResult = []; // name - - if (token.type === tokens.identifier) { - fnName = identifierFromToken(token); - eatToken(); - } else { - fnName = t.withRaw(fnName, ""); // preserve anonymous - } - - maybeIgnoreComment(); - - while (token.type === tokens.openParen || token.type === tokens.name || token.type === tokens.valtype) { - // Instructions without parens - if (token.type === tokens.name || token.type === tokens.valtype) { - fnBody.push(parseFuncInstr()); - continue; - } - - eatToken(); - - if (lookaheadAndCheck(keywords.param) === true) { - eatToken(); - fnParams.push.apply(fnParams, _toConsumableArray(parseFuncParam())); - } else if (lookaheadAndCheck(keywords.result) === true) { - eatToken(); - fnResult.push.apply(fnResult, _toConsumableArray(parseFuncResult())); - } else if (lookaheadAndCheck(keywords.export) === true) { - eatToken(); - parseFuncExport(fnName); - } else if (lookaheadAndCheck(keywords.type) === true) { - eatToken(); - typeRef = parseTypeReference(); - } else if (lookaheadAndCheck(tokens.name) === true || lookaheadAndCheck(tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - // Instruction - fnBody.push(parseFuncInstr()); - } else { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected token in func body" + ", given " + tokenToString(token)); - }(); - } - - eatTokenOfType(tokens.closeParen); - } - - return t.func(fnName, typeRef !== undefined ? typeRef : t.signature(fnParams, fnResult), fnBody); - } - /** - * Parses shorthand export in func - * - * export :: ( export <string> ) - */ - - - function parseFuncExport(funcId) { - if (token.type !== tokens.string) { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Function export expected a string" + ", given " + tokenToString(token)); - }(); - } - - var name = token.value; - eatToken(); - /** - * Func export shorthand, we trait it as a syntaxic sugar. - * A export ModuleField will be added later. - * - * We give the anonymous function a generated name and export it. - */ - - var id = t.identifier(funcId.value); - state.registredExportedElements.push({ - exportType: "Func", - name: name, - id: id - }); - } - /** - * Parses a type instruction - * - * WAST: - * - * typedef: ( type <name>? ( func <param>* <result>* ) ) - */ - - - function parseType() { - var id; - var params = []; - var result = []; - - if (token.type === tokens.identifier) { - id = identifierFromToken(token); - eatToken(); - } - - if (lookaheadAndCheck(tokens.openParen, keywords.func)) { - eatToken(); // ( - - eatToken(); // func - - if (token.type === tokens.closeParen) { - eatToken(); // function with an empty signature, we can abort here - - return t.typeInstruction(id, t.signature([], [])); - } - - if (lookaheadAndCheck(tokens.openParen, keywords.param)) { - eatToken(); // ( - - eatToken(); // param - - params = parseFuncParam(); - eatTokenOfType(tokens.closeParen); - } - - if (lookaheadAndCheck(tokens.openParen, keywords.result)) { - eatToken(); // ( - - eatToken(); // result - - result = parseFuncResult(); - eatTokenOfType(tokens.closeParen); - } - - eatTokenOfType(tokens.closeParen); - } - - return t.typeInstruction(id, t.signature(params, result)); - } - /** - * Parses a function result - * - * WAST: - * - * result :: ( result <type>* ) - */ - - - function parseFuncResult() { - var results = []; - - while (token.type !== tokens.closeParen) { - if (token.type !== tokens.valtype) { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unexpected token in func result" + ", given " + tokenToString(token)); - }(); - } - - var valtype = token.value; - eatToken(); - results.push(valtype); - } - - return results; - } - /** - * Parses a type reference - * - */ - - - function parseTypeReference() { - var ref; - - if (token.type === tokens.identifier) { - ref = identifierFromToken(token); - eatToken(); - } else if (token.type === tokens.number) { - ref = t.numberLiteralFromRaw(token.value); - eatToken(); - } - - return ref; - } - /** - * Parses a global instruction - * - * WAST: - * - * global: ( global <name>? <global_sig> <instr>* ) - * ( global <name>? ( export <string> ) <...> ) - * ( global <name>? ( import <string> <string> ) <global_sig> ) - * - * global_sig: <type> | ( mut <type> ) - * - */ - - - function parseGlobal() { - var name = t.identifier(getUniqueName("global")); - var type; // Keep informations in case of a shorthand import - - var importing = null; - maybeIgnoreComment(); - - if (token.type === tokens.identifier) { - name = identifierFromToken(token); - eatToken(); - } else { - name = t.withRaw(name, ""); // preserve anonymous - } - /** - * maybe export - */ - - - if (lookaheadAndCheck(tokens.openParen, keywords.export)) { - eatToken(); // ( - - eatToken(); // export - - var exportName = token.value; - eatTokenOfType(tokens.string); - state.registredExportedElements.push({ - exportType: "Global", - name: exportName, - id: name - }); - eatTokenOfType(tokens.closeParen); - } - /** - * maybe import - */ - - - if (lookaheadAndCheck(tokens.openParen, keywords.import)) { - eatToken(); // ( - - eatToken(); // import - - var moduleName = token.value; - eatTokenOfType(tokens.string); - var _name3 = token.value; - eatTokenOfType(tokens.string); - importing = { - module: moduleName, - name: _name3, - descr: undefined - }; - eatTokenOfType(tokens.closeParen); - } - /** - * global_sig - */ - - - if (token.type === tokens.valtype) { - type = t.globalType(token.value, "const"); - eatToken(); - } else if (token.type === tokens.openParen) { - eatToken(); // ( - - if (isKeyword(token, keywords.mut) === false) { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unsupported global type, expected mut" + ", given " + tokenToString(token)); - }(); - } - - eatToken(); // mut - - type = t.globalType(token.value, "var"); - eatToken(); - eatTokenOfType(tokens.closeParen); - } - - if (type === undefined) { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Could not determine global type" + ", given " + tokenToString(token)); - }(); - } - - maybeIgnoreComment(); - var init = []; - - if (importing != null) { - importing.descr = type; - init.push(t.moduleImport(importing.module, importing.name, importing.descr)); - } - /** - * instr* - */ - - - while (token.type === tokens.openParen) { - eatToken(); - init.push(parseFuncInstr()); - eatTokenOfType(tokens.closeParen); - } - - return t.global(type, init, name); - } - /** - * Parses a function param - * - * WAST: - * - * param :: ( param <type>* ) | ( param <name> <type> ) - */ - - - function parseFuncParam() { - var params = []; - var id; - var valtype; - - if (token.type === tokens.identifier) { - id = token.value; - eatToken(); - } - - if (token.type === tokens.valtype) { - valtype = token.value; - eatToken(); - params.push({ - id: id, - valtype: valtype - }); - /** - * Shorthand notation for multiple anonymous parameters - * @see https://webassembly.github.io/spec/core/text/types.html#function-types - * @see https://github.com/xtuc/webassemblyjs/issues/6 - */ - - if (id === undefined) { - while (token.type === tokens.valtype) { - valtype = token.value; - eatToken(); - params.push({ - id: undefined, - valtype: valtype - }); - } - } - } else {// ignore - } - - return params; - } - /** - * Parses an element segments instruction - * - * WAST: - * - * elem: ( elem <var>? (offset <instr>* ) <var>* ) - * ( elem <var>? <expr> <var>* ) - * - * var: <nat> | <name> - */ - - - function parseElem() { - var tableIndex = t.indexLiteral(0); - var offset = []; - var funcs = []; - - if (token.type === tokens.identifier) { - tableIndex = identifierFromToken(token); - eatToken(); - } - - if (token.type === tokens.number) { - tableIndex = t.indexLiteral(token.value); - eatToken(); - } - - while (token.type !== tokens.closeParen) { - if (lookaheadAndCheck(tokens.openParen, keywords.offset)) { - eatToken(); // ( - - eatToken(); // offset - - while (token.type !== tokens.closeParen) { - eatTokenOfType(tokens.openParen); - offset.push(parseFuncInstr()); - eatTokenOfType(tokens.closeParen); - } - - eatTokenOfType(tokens.closeParen); - } else if (token.type === tokens.identifier) { - funcs.push(t.identifier(token.value)); - eatToken(); - } else if (token.type === tokens.number) { - funcs.push(t.indexLiteral(token.value)); - eatToken(); - } else if (token.type === tokens.openParen) { - eatToken(); // ( - - offset.push(parseFuncInstr()); - eatTokenOfType(tokens.closeParen); - } else { - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unsupported token in elem" + ", given " + tokenToString(token)); - }(); - } - } - - return t.elem(tableIndex, offset, funcs); - } - /** - * Parses the start instruction in a module - * - * WAST: - * - * start: ( start <var> ) - * var: <nat> | <name> - * - * WAT: - * start ::= ‘(’ ‘start’ x:funcidx ‘)’ - */ - - - function parseStart() { - if (token.type === tokens.identifier) { - var index = identifierFromToken(token); - eatToken(); - return t.start(index); - } - - if (token.type === tokens.number) { - var _index2 = t.indexLiteral(token.value); - - eatToken(); - return t.start(_index2); - } - - throw new Error("Unknown start, token: " + tokenToString(token)); - } - - if (token.type === tokens.openParen) { - eatToken(); - var startLoc = getStartLoc(); - - if (isKeyword(token, keywords.export)) { - eatToken(); - var node = parseExport(); - - var _endLoc2 = getEndLoc(); - - return t.withLoc(node, _endLoc2, startLoc); - } - - if (isKeyword(token, keywords.loop)) { - eatToken(); - - var _node = parseLoop(); - - var _endLoc3 = getEndLoc(); - - return t.withLoc(_node, _endLoc3, startLoc); - } - - if (isKeyword(token, keywords.func)) { - eatToken(); - - var _node2 = parseFunc(); - - var _endLoc4 = getEndLoc(); - - maybeIgnoreComment(); - eatTokenOfType(tokens.closeParen); - return t.withLoc(_node2, _endLoc4, startLoc); - } - - if (isKeyword(token, keywords.module)) { - eatToken(); - - var _node3 = parseModule(); - - var _endLoc5 = getEndLoc(); - - return t.withLoc(_node3, _endLoc5, startLoc); - } - - if (isKeyword(token, keywords.import)) { - eatToken(); - - var _node4 = parseImport(); - - var _endLoc6 = getEndLoc(); - - eatTokenOfType(tokens.closeParen); - return t.withLoc(_node4, _endLoc6, startLoc); - } - - if (isKeyword(token, keywords.block)) { - eatToken(); - - var _node5 = parseBlock(); - - var _endLoc7 = getEndLoc(); - - eatTokenOfType(tokens.closeParen); - return t.withLoc(_node5, _endLoc7, startLoc); - } - - if (isKeyword(token, keywords.memory)) { - eatToken(); - - var _node6 = parseMemory(); - - var _endLoc8 = getEndLoc(); - - eatTokenOfType(tokens.closeParen); - return t.withLoc(_node6, _endLoc8, startLoc); - } - - if (isKeyword(token, keywords.data)) { - eatToken(); - - var _node7 = parseData(); - - var _endLoc9 = getEndLoc(); - - eatTokenOfType(tokens.closeParen); - return t.withLoc(_node7, _endLoc9, startLoc); - } - - if (isKeyword(token, keywords.table)) { - eatToken(); - - var _node8 = parseTable(); - - var _endLoc10 = getEndLoc(); - - eatTokenOfType(tokens.closeParen); - return t.withLoc(_node8, _endLoc10, startLoc); - } - - if (isKeyword(token, keywords.global)) { - eatToken(); - - var _node9 = parseGlobal(); - - var _endLoc11 = getEndLoc(); - - eatTokenOfType(tokens.closeParen); - return t.withLoc(_node9, _endLoc11, startLoc); - } - - if (isKeyword(token, keywords.type)) { - eatToken(); - - var _node10 = parseType(); - - var _endLoc12 = getEndLoc(); - - eatTokenOfType(tokens.closeParen); - return t.withLoc(_node10, _endLoc12, startLoc); - } - - if (isKeyword(token, keywords.start)) { - eatToken(); - - var _node11 = parseStart(); - - var _endLoc13 = getEndLoc(); - - eatTokenOfType(tokens.closeParen); - return t.withLoc(_node11, _endLoc13, startLoc); - } - - if (isKeyword(token, keywords.elem)) { - eatToken(); - - var _node12 = parseElem(); - - var _endLoc14 = getEndLoc(); - - eatTokenOfType(tokens.closeParen); - return t.withLoc(_node12, _endLoc14, startLoc); - } - - var instruction = parseFuncInstr(); - var endLoc = getEndLoc(); - maybeIgnoreComment(); - - if (_typeof(instruction) === "object") { - if (typeof token !== "undefined") { - eatTokenOfType(tokens.closeParen); - } - - return t.withLoc(instruction, endLoc, startLoc); - } - } - - if (token.type === tokens.comment) { - var _startLoc = getStartLoc(); - - var builder = token.opts.type === "leading" ? t.leadingComment : t.blockComment; - - var _node13 = builder(token.value); - - eatToken(); // comment - - var _endLoc15 = getEndLoc(); - - return t.withLoc(_node13, _endLoc15, _startLoc); - } - - throw function () { - return new Error("\n" + codeFrameFromSource(source, token.loc) + "\n" + "Unknown token" + ", given " + tokenToString(token)); - }(); - } - - var body = []; - - while (current < tokensList.length) { - body.push(walk()); - } - - return t.program(body); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wast-parser/esm/index.js b/node_modules/@webassemblyjs/wast-parser/esm/index.js deleted file mode 100644 index 70cda38..0000000 --- a/node_modules/@webassemblyjs/wast-parser/esm/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import * as parser from "./grammar"; -import { tokenize } from "./tokenizer"; -export function parse(source) { - var tokens = tokenize(source); // We pass the source here to show code frames - - var ast = parser.parse(tokens, source); - return ast; -} -export * from "./number-literals";
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wast-parser/esm/number-literals.js b/node_modules/@webassemblyjs/wast-parser/esm/number-literals.js deleted file mode 100644 index 98b8996..0000000 --- a/node_modules/@webassemblyjs/wast-parser/esm/number-literals.js +++ /dev/null @@ -1,91 +0,0 @@ -import Long from "@xtuc/long"; -import parseHexFloat from "@webassemblyjs/floating-point-hex-parser"; -import { CompileError } from "@webassemblyjs/helper-api-error"; -export function parse32F(sourceString) { - if (isHexLiteral(sourceString)) { - return parseHexFloat(sourceString); - } - - if (isInfLiteral(sourceString)) { - return sourceString[0] === "-" ? -1 : 1; - } - - if (isNanLiteral(sourceString)) { - return (sourceString[0] === "-" ? -1 : 1) * (sourceString.includes(":") ? parseInt(sourceString.substring(sourceString.indexOf(":") + 1), 16) : 0x400000); - } - - return parseFloat(sourceString); -} -export function parse64F(sourceString) { - if (isHexLiteral(sourceString)) { - return parseHexFloat(sourceString); - } - - if (isInfLiteral(sourceString)) { - return sourceString[0] === "-" ? -1 : 1; - } - - if (isNanLiteral(sourceString)) { - return (sourceString[0] === "-" ? -1 : 1) * (sourceString.includes(":") ? parseInt(sourceString.substring(sourceString.indexOf(":") + 1), 16) : 0x8000000000000); - } - - if (isHexLiteral(sourceString)) { - return parseHexFloat(sourceString); - } - - return parseFloat(sourceString); -} -export function parse32I(sourceString) { - var value = 0; - - if (isHexLiteral(sourceString)) { - value = ~~parseInt(sourceString, 16); - } else if (isDecimalExponentLiteral(sourceString)) { - throw new Error("This number literal format is yet to be implemented."); - } else { - value = parseInt(sourceString, 10); - } - - return value; -} -export function parseU32(sourceString) { - var value = parse32I(sourceString); - - if (value < 0) { - throw new CompileError("Illegal value for u32: " + sourceString); - } - - return value; -} -export function parse64I(sourceString) { - var long; - - if (isHexLiteral(sourceString)) { - long = Long.fromString(sourceString, false, 16); - } else if (isDecimalExponentLiteral(sourceString)) { - throw new Error("This number literal format is yet to be implemented."); - } else { - long = Long.fromString(sourceString); - } - - return { - high: long.high, - low: long.low - }; -} -var NAN_WORD = /^\+?-?nan/; -var INF_WORD = /^\+?-?inf/; -export function isInfLiteral(sourceString) { - return INF_WORD.test(sourceString.toLowerCase()); -} -export function isNanLiteral(sourceString) { - return NAN_WORD.test(sourceString.toLowerCase()); -} - -function isDecimalExponentLiteral(sourceString) { - return !isHexLiteral(sourceString) && sourceString.toUpperCase().includes("E"); -} - -function isHexLiteral(sourceString) { - return sourceString.substring(0, 2).toUpperCase() === "0X" || sourceString.substring(0, 3).toUpperCase() === "-0X"; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wast-parser/esm/string-literals.js b/node_modules/@webassemblyjs/wast-parser/esm/string-literals.js deleted file mode 100644 index 3f55e82..0000000 --- a/node_modules/@webassemblyjs/wast-parser/esm/string-literals.js +++ /dev/null @@ -1,88 +0,0 @@ -// string literal characters cannot contain control codes -var CONTROL_CODES = [0, // null -7, // bell -8, // backspace -9, // horizontal -10, // line feed -11, // vertical tab -12, // form feed -13, // carriage return -26, // Control-Z -27, // escape -127 // delete -]; // escaped sequences can either be a two character hex value, or one of the -// following single character codes - -function decodeControlCharacter(char) { - switch (char) { - case "t": - return 0x09; - - case "n": - return 0x0a; - - case "r": - return 0x0d; - - case '"': - return 0x22; - - case "′": - return 0x27; - - case "\\": - return 0x5c; - } - - return -1; -} - -var ESCAPE_CHAR = 92; // backslash - -var QUOTE_CHAR = 34; // backslash -// parse string as per the spec: -// https://webassembly.github.io/spec/core/multipage/text/values.html#text-string - -export function parseString(value) { - var byteArray = []; - var index = 0; - - while (index < value.length) { - var charCode = value.charCodeAt(index); - - if (CONTROL_CODES.indexOf(charCode) !== -1) { - throw new Error("ASCII control characters are not permitted within string literals"); - } - - if (charCode === QUOTE_CHAR) { - throw new Error("quotes are not permitted within string literals"); - } - - if (charCode === ESCAPE_CHAR) { - var firstChar = value.substr(index + 1, 1); - var decodedControlChar = decodeControlCharacter(firstChar); - - if (decodedControlChar !== -1) { - // single character escaped values, e.g. \r - byteArray.push(decodedControlChar); - index += 2; - } else { - // hex escaped values, e.g. \2a - var hexValue = value.substr(index + 1, 2); - - if (!/^[0-9A-F]{2}$/i.test(hexValue)) { - throw new Error("invalid character encoding"); - } - - byteArray.push(parseInt(hexValue, 16)); - index += 3; - } - } else { - // ASCII encoded values - byteArray.push(charCode); - index++; - } - } - - return byteArray; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wast-parser/esm/tokenizer.js b/node_modules/@webassemblyjs/wast-parser/esm/tokenizer.js deleted file mode 100644 index 30f9098..0000000 --- a/node_modules/@webassemblyjs/wast-parser/esm/tokenizer.js +++ /dev/null @@ -1,434 +0,0 @@ -import { FSM, makeTransition } from "@webassemblyjs/helper-fsm"; -import { codeFrameFromSource } from "@webassemblyjs/helper-code-frame"; - -// eslint-disable-next-line -function getCodeFrame(source, line, column) { - var loc = { - start: { - line: line, - column: column - } - }; - return "\n" + codeFrameFromSource(source, loc) + "\n"; -} - -var WHITESPACE = /\s/; -var PARENS = /\(|\)/; -var LETTERS = /[a-z0-9_/]/i; -var idchar = /[a-z0-9!#$%&*+./:<=>?@\\[\]^_`|~-]/i; -var valtypes = ["i32", "i64", "f32", "f64"]; -var NUMBERS = /[0-9|.|_]/; -var NUMBER_KEYWORDS = /nan|inf/; - -function isNewLine(char) { - return char.charCodeAt(0) === 10 || char.charCodeAt(0) === 13; -} - -function Token(type, value, start, end) { - var opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; - var token = { - type: type, - value: value, - loc: { - start: start, - end: end - } - }; - - if (Object.keys(opts).length > 0) { - // $FlowIgnore - token["opts"] = opts; - } - - return token; -} - -var tokenTypes = { - openParen: "openParen", - closeParen: "closeParen", - number: "number", - string: "string", - name: "name", - identifier: "identifier", - valtype: "valtype", - dot: "dot", - comment: "comment", - equal: "equal", - keyword: "keyword" -}; -export var keywords = { - module: "module", - func: "func", - param: "param", - result: "result", - export: "export", - loop: "loop", - block: "block", - if: "if", - then: "then", - else: "else", - call: "call", - call_indirect: "call_indirect", - import: "import", - memory: "memory", - table: "table", - global: "global", - anyfunc: "anyfunc", - mut: "mut", - data: "data", - type: "type", - elem: "elem", - start: "start", - offset: "offset" -}; -var NUMERIC_SEPARATOR = "_"; -/** - * Build the FSM for number literals - */ - -var numberLiteralFSM = new FSM({ - START: [makeTransition(/-|\+/, "AFTER_SIGN"), makeTransition(/nan:0x/, "NAN_HEX", { - n: 6 - }), makeTransition(/nan|inf/, "STOP", { - n: 3 - }), makeTransition(/0x/, "HEX", { - n: 2 - }), makeTransition(/[0-9]/, "DEC"), makeTransition(/\./, "DEC_FRAC")], - AFTER_SIGN: [makeTransition(/nan:0x/, "NAN_HEX", { - n: 6 - }), makeTransition(/nan|inf/, "STOP", { - n: 3 - }), makeTransition(/0x/, "HEX", { - n: 2 - }), makeTransition(/[0-9]/, "DEC"), makeTransition(/\./, "DEC_FRAC")], - DEC_FRAC: [makeTransition(/[0-9]/, "DEC_FRAC", { - allowedSeparator: NUMERIC_SEPARATOR - }), makeTransition(/e|E/, "DEC_SIGNED_EXP")], - DEC: [makeTransition(/[0-9]/, "DEC", { - allowedSeparator: NUMERIC_SEPARATOR - }), makeTransition(/\./, "DEC_FRAC"), makeTransition(/e|E/, "DEC_SIGNED_EXP")], - DEC_SIGNED_EXP: [makeTransition(/\+|-/, "DEC_EXP"), makeTransition(/[0-9]/, "DEC_EXP")], - DEC_EXP: [makeTransition(/[0-9]/, "DEC_EXP", { - allowedSeparator: NUMERIC_SEPARATOR - })], - HEX: [makeTransition(/[0-9|A-F|a-f]/, "HEX", { - allowedSeparator: NUMERIC_SEPARATOR - }), makeTransition(/\./, "HEX_FRAC"), makeTransition(/p|P/, "HEX_SIGNED_EXP")], - HEX_FRAC: [makeTransition(/[0-9|A-F|a-f]/, "HEX_FRAC", { - allowedSeparator: NUMERIC_SEPARATOR - }), makeTransition(/p|P|/, "HEX_SIGNED_EXP")], - HEX_SIGNED_EXP: [makeTransition(/[0-9|+|-]/, "HEX_EXP")], - HEX_EXP: [makeTransition(/[0-9]/, "HEX_EXP", { - allowedSeparator: NUMERIC_SEPARATOR - })], - NAN_HEX: [makeTransition(/[0-9|A-F|a-f]/, "NAN_HEX", { - allowedSeparator: NUMERIC_SEPARATOR - })], - STOP: [] -}, "START", "STOP"); -export function tokenize(input) { - var current = 0; - var char = input[current]; // Used by SourceLocation - - var column = 1; - var line = 1; - var tokens = []; - /** - * Creates a pushToken function for a given type - */ - - function pushToken(type) { - return function (v) { - var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var startColumn = opts.startColumn || column - String(v).length; - delete opts.startColumn; - var endColumn = opts.endColumn || startColumn + String(v).length - 1; - delete opts.endColumn; - var start = { - line: line, - column: startColumn - }; - var end = { - line: line, - column: endColumn - }; - tokens.push(Token(type, v, start, end, opts)); - }; - } - /** - * Functions to save newly encountered tokens - */ - - - var pushCloseParenToken = pushToken(tokenTypes.closeParen); - var pushOpenParenToken = pushToken(tokenTypes.openParen); - var pushNumberToken = pushToken(tokenTypes.number); - var pushValtypeToken = pushToken(tokenTypes.valtype); - var pushNameToken = pushToken(tokenTypes.name); - var pushIdentifierToken = pushToken(tokenTypes.identifier); - var pushKeywordToken = pushToken(tokenTypes.keyword); - var pushDotToken = pushToken(tokenTypes.dot); - var pushStringToken = pushToken(tokenTypes.string); - var pushCommentToken = pushToken(tokenTypes.comment); - var pushEqualToken = pushToken(tokenTypes.equal); - /** - * Can be used to look at the next character(s). - * - * The default behavior `lookahead()` simply returns the next character without consuming it. - * Letters are always returned in lowercase. - * - * @param {number} length How many characters to query. Default = 1 - * @param {number} offset How many characters to skip forward from current one. Default = 1 - * - */ - - function lookahead() { - var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; - var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; - return input.substring(current + offset, current + offset + length).toLowerCase(); - } - /** - * Advances the cursor in the input by a certain amount - * - * @param {number} amount How many characters to consume. Default = 1 - */ - - - function eatCharacter() { - var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; - column += amount; - current += amount; - char = input[current]; - } - - while (current < input.length) { - // ;; - if (char === ";" && lookahead() === ";") { - var startColumn = column; - eatCharacter(2); - var text = ""; - - while (!isNewLine(char)) { - text += char; - eatCharacter(); - - if (char === undefined) { - break; - } - } - - var endColumn = column; - pushCommentToken(text, { - type: "leading", - startColumn: startColumn, - endColumn: endColumn - }); - continue; - } // (; - - - if (char === "(" && lookahead() === ";") { - var _startColumn = column; - eatCharacter(2); - var _text = ""; // ;) - - while (true) { - char = input[current]; - - if (char === ";" && lookahead() === ")") { - eatCharacter(2); - break; - } - - _text += char; - eatCharacter(); - - if (isNewLine(char)) { - line++; - column = 0; - } - } - - var _endColumn = column; - pushCommentToken(_text, { - type: "block", - startColumn: _startColumn, - endColumn: _endColumn - }); - continue; - } - - if (char === "(") { - pushOpenParenToken(char); - eatCharacter(); - continue; - } - - if (char === "=") { - pushEqualToken(char); - eatCharacter(); - continue; - } - - if (char === ")") { - pushCloseParenToken(char); - eatCharacter(); - continue; - } - - if (isNewLine(char)) { - line++; - eatCharacter(); - column = 0; - continue; - } - - if (WHITESPACE.test(char)) { - eatCharacter(); - continue; - } - - if (char === "$") { - var _startColumn2 = column; - eatCharacter(); - var value = ""; - - while (idchar.test(char)) { - value += char; - eatCharacter(); - } - - var _endColumn2 = column; - pushIdentifierToken(value, { - startColumn: _startColumn2, - endColumn: _endColumn2 - }); - continue; - } - - if (NUMBERS.test(char) || NUMBER_KEYWORDS.test(lookahead(3, 0)) || char === "-" || char === "+") { - var _startColumn3 = column; - - var _value = numberLiteralFSM.run(input.slice(current)); - - if (_value === "") { - throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char)); - } - - pushNumberToken(_value, { - startColumn: _startColumn3 - }); - eatCharacter(_value.length); - - if (char && !PARENS.test(char) && !WHITESPACE.test(char)) { - throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char)); - } - - continue; - } - - if (char === '"') { - var _startColumn4 = column; - var _value2 = ""; - eatCharacter(); // " - - while (char !== '"') { - if (isNewLine(char)) { - throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char)); - } - - _value2 += char; - eatCharacter(); // char - } - - eatCharacter(); // " - - var _endColumn3 = column; - pushStringToken(_value2, { - startColumn: _startColumn4, - endColumn: _endColumn3 - }); - continue; - } - - if (LETTERS.test(char)) { - var _value3 = ""; - var _startColumn5 = column; - - while (char && LETTERS.test(char)) { - _value3 += char; - eatCharacter(); - } - /* - * Handle MemberAccess - */ - - - if (char === ".") { - var dotStartColumn = column; - - if (valtypes.indexOf(_value3) !== -1) { - pushValtypeToken(_value3, { - startColumn: _startColumn5 - }); - } else { - pushNameToken(_value3); - } - - eatCharacter(); - _value3 = ""; - var nameStartColumn = column; - - while (LETTERS.test(char)) { - _value3 += char; - eatCharacter(); - } - - pushDotToken(".", { - startColumn: dotStartColumn - }); - pushNameToken(_value3, { - startColumn: nameStartColumn - }); - continue; - } - /* - * Handle keywords - */ - // $FlowIgnore - - - if (typeof keywords[_value3] === "string") { - pushKeywordToken(_value3, { - startColumn: _startColumn5 - }); - continue; - } - /* - * Handle types - */ - - - if (valtypes.indexOf(_value3) !== -1) { - pushValtypeToken(_value3, { - startColumn: _startColumn5 - }); - continue; - } - /* - * Handle literals - */ - - - pushNameToken(_value3, { - startColumn: _startColumn5 - }); - continue; - } - - throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char)); - } - - return tokens; -} -export var tokens = tokenTypes;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wast-parser/lib/grammar.js b/node_modules/@webassemblyjs/wast-parser/lib/grammar.js deleted file mode 100644 index ddde33a..0000000 --- a/node_modules/@webassemblyjs/wast-parser/lib/grammar.js +++ /dev/null @@ -1,1769 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.parse = parse; - -var _helperCodeFrame = require("@webassemblyjs/helper-code-frame"); - -var t = _interopRequireWildcard(require("@webassemblyjs/ast")); - -var _numberLiterals = require("./number-literals"); - -var _stringLiterals = require("./string-literals"); - -var _tokenizer = require("./tokenizer"); - -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 _typeof(obj) { 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); } - -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 hasPlugin(name) { - if (name !== "wast") throw new Error("unknow plugin"); - return true; -} - -function isKeyword(token, id) { - return token.type === _tokenizer.tokens.keyword && token.value === id; -} - -function tokenToString(token) { - if (token.type === "keyword") { - return "keyword (".concat(token.value, ")"); - } - - return token.type; -} - -function identifierFromToken(token) { - var _token$loc = token.loc, - end = _token$loc.end, - start = _token$loc.start; - return t.withLoc(t.identifier(token.value), end, start); -} - -function parse(tokensList, source) { - var current = 0; - var getUniqueName = t.getUniqueNameGenerator(); - var state = { - registredExportedElements: [] - }; // But this time we're going to use recursion instead of a `while` loop. So we - // define a `walk` function. - - function walk() { - var token = tokensList[current]; - - function eatToken() { - token = tokensList[++current]; - } - - function getEndLoc() { - var currentToken = token; - - if (typeof currentToken === "undefined") { - var lastToken = tokensList[tokensList.length - 1]; - currentToken = lastToken; - } - - return currentToken.loc.end; - } - - function getStartLoc() { - return token.loc.start; - } - - function eatTokenOfType(type) { - if (token.type !== type) { - throw new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "Assertion error: expected token of type " + type + ", given " + tokenToString(token)); - } - - eatToken(); - } - - function parseExportIndex(token) { - if (token.type === _tokenizer.tokens.identifier) { - var index = identifierFromToken(token); - eatToken(); - return index; - } else if (token.type === _tokenizer.tokens.number) { - var _index = t.numberLiteralFromRaw(token.value); - - eatToken(); - return _index; - } else { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "unknown export index" + ", given " + tokenToString(token)); - }(); - } - } - - function lookaheadAndCheck() { - var len = arguments.length; - - for (var i = 0; i < len; i++) { - var tokenAhead = tokensList[current + i]; - var expectedToken = i < 0 || arguments.length <= i ? undefined : arguments[i]; - - if (tokenAhead.type === "keyword") { - if (isKeyword(tokenAhead, expectedToken) === false) { - return false; - } - } else if (expectedToken !== tokenAhead.type) { - return false; - } - } - - return true; - } // TODO(sven): there is probably a better way to do this - // can refactor it if it get out of hands - - - function maybeIgnoreComment() { - if (typeof token === "undefined") { - // Ignore - return; - } - - while (token.type === _tokenizer.tokens.comment) { - eatToken(); - - if (typeof token === "undefined") { - // Hit the end - break; - } - } - } - /** - * Parses a memory instruction - * - * WAST: - * - * memory: ( memory <name>? <memory_sig> ) - * ( memory <name>? ( export <string> ) <...> ) - * ( memory <name>? ( import <string> <string> ) <memory_sig> ) - * ( memory <name>? ( export <string> )* ( data <string>* ) - * memory_sig: <nat> <nat>? - * - */ - - - function parseMemory() { - var id = t.identifier(getUniqueName("memory")); - var limits = t.limit(0); - - if (token.type === _tokenizer.tokens.string || token.type === _tokenizer.tokens.identifier) { - id = t.identifier(token.value); - eatToken(); - } else { - id = t.withRaw(id, ""); // preserve anonymous - } - /** - * Maybe data - */ - - - if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.data)) { - eatToken(); // ( - - eatToken(); // data - // TODO(sven): do something with the data collected here - - var stringInitializer = token.value; - eatTokenOfType(_tokenizer.tokens.string); // Update limits accordingly - - limits = t.limit(stringInitializer.length); - eatTokenOfType(_tokenizer.tokens.closeParen); - } - /** - * Maybe export - */ - - - if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.export)) { - eatToken(); // ( - - eatToken(); // export - - if (token.type !== _tokenizer.tokens.string) { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Expected string in export" + ", given " + tokenToString(token)); - }(); - } - - var _name = token.value; - eatToken(); - state.registredExportedElements.push({ - exportType: "Memory", - name: _name, - id: id - }); - eatTokenOfType(_tokenizer.tokens.closeParen); - } - /** - * Memory signature - */ - - - if (token.type === _tokenizer.tokens.number) { - limits = t.limit((0, _numberLiterals.parse32I)(token.value)); - eatToken(); - - if (token.type === _tokenizer.tokens.number) { - limits.max = (0, _numberLiterals.parse32I)(token.value); - eatToken(); - } - } - - return t.memory(limits, id); - } - /** - * Parses a data section - * https://webassembly.github.io/spec/core/text/modules.html#data-segments - * - * WAST: - * - * data: ( data <index>? <offset> <string> ) - */ - - - function parseData() { - // optional memory index - var memidx = 0; - - if (token.type === _tokenizer.tokens.number) { - memidx = token.value; - eatTokenOfType(_tokenizer.tokens.number); // . - } - - eatTokenOfType(_tokenizer.tokens.openParen); - var offset; - - if (token.type === _tokenizer.tokens.valtype) { - eatTokenOfType(_tokenizer.tokens.valtype); // i32 - - eatTokenOfType(_tokenizer.tokens.dot); // . - - if (token.value !== "const") { - throw new Error("constant expression required"); - } - - eatTokenOfType(_tokenizer.tokens.name); // const - - var numberLiteral = t.numberLiteralFromRaw(token.value, "i32"); - offset = t.objectInstruction("const", "i32", [numberLiteral]); - eatToken(); - eatTokenOfType(_tokenizer.tokens.closeParen); - } else { - eatTokenOfType(_tokenizer.tokens.name); // get_global - - var _numberLiteral = t.numberLiteralFromRaw(token.value, "i32"); - - offset = t.instruction("get_global", [_numberLiteral]); - eatToken(); - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - var byteArray = (0, _stringLiterals.parseString)(token.value); - eatToken(); // "string" - - return t.data(t.memIndexLiteral(memidx), offset, t.byteArray(byteArray)); - } - /** - * Parses a table instruction - * - * WAST: - * - * table: ( table <name>? <table_type> ) - * ( table <name>? ( export <string> ) <...> ) - * ( table <name>? ( import <string> <string> ) <table_type> ) - * ( table <name>? ( export <string> )* <elem_type> ( elem <var>* ) ) - * - * table_type: <nat> <nat>? <elem_type> - * elem_type: anyfunc - * - * elem: ( elem <var>? (offset <instr>* ) <var>* ) - * ( elem <var>? <expr> <var>* ) - */ - - - function parseTable() { - var name = t.identifier(getUniqueName("table")); - var limit = t.limit(0); - var elemIndices = []; - var elemType = "anyfunc"; - - if (token.type === _tokenizer.tokens.string || token.type === _tokenizer.tokens.identifier) { - name = identifierFromToken(token); - eatToken(); - } else { - name = t.withRaw(name, ""); // preserve anonymous - } - - while (token.type !== _tokenizer.tokens.closeParen) { - /** - * Maybe export - */ - if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.elem)) { - eatToken(); // ( - - eatToken(); // elem - - while (token.type === _tokenizer.tokens.identifier) { - elemIndices.push(t.identifier(token.value)); - eatToken(); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - } else if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.export)) { - eatToken(); // ( - - eatToken(); // export - - if (token.type !== _tokenizer.tokens.string) { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Expected string in export" + ", given " + tokenToString(token)); - }(); - } - - var exportName = token.value; - eatToken(); - state.registredExportedElements.push({ - exportType: "Table", - name: exportName, - id: name - }); - eatTokenOfType(_tokenizer.tokens.closeParen); - } else if (isKeyword(token, _tokenizer.keywords.anyfunc)) { - // It's the default value, we can ignore it - eatToken(); // anyfunc - } else if (token.type === _tokenizer.tokens.number) { - /** - * Table type - */ - var min = parseInt(token.value); - eatToken(); - - if (token.type === _tokenizer.tokens.number) { - var max = parseInt(token.value); - eatToken(); - limit = t.limit(min, max); - } else { - limit = t.limit(min); - } - - eatToken(); - } else { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected token" + ", given " + tokenToString(token)); - }(); - } - } - - if (elemIndices.length > 0) { - return t.table(elemType, limit, name, elemIndices); - } else { - return t.table(elemType, limit, name); - } - } - /** - * Parses an import statement - * - * WAST: - * - * import: ( import <string> <string> <imkind> ) - * imkind: ( func <name>? <func_sig> ) - * ( global <name>? <global_sig> ) - * ( table <name>? <table_sig> ) - * ( memory <name>? <memory_sig> ) - * - * global_sig: <type> | ( mut <type> ) - */ - - - function parseImport() { - if (token.type !== _tokenizer.tokens.string) { - throw new Error("Expected a string, " + token.type + " given."); - } - - var moduleName = token.value; - eatToken(); - - if (token.type !== _tokenizer.tokens.string) { - throw new Error("Expected a string, " + token.type + " given."); - } - - var name = token.value; - eatToken(); - eatTokenOfType(_tokenizer.tokens.openParen); - var descr; - - if (isKeyword(token, _tokenizer.keywords.func)) { - eatToken(); // keyword - - var fnParams = []; - var fnResult = []; - var typeRef; - var fnName = t.identifier(getUniqueName("func")); - - if (token.type === _tokenizer.tokens.identifier) { - fnName = identifierFromToken(token); - eatToken(); - } - - while (token.type === _tokenizer.tokens.openParen) { - eatToken(); - - if (lookaheadAndCheck(_tokenizer.keywords.type) === true) { - eatToken(); - typeRef = parseTypeReference(); - } else if (lookaheadAndCheck(_tokenizer.keywords.param) === true) { - eatToken(); - fnParams.push.apply(fnParams, _toConsumableArray(parseFuncParam())); - } else if (lookaheadAndCheck(_tokenizer.keywords.result) === true) { - eatToken(); - fnResult.push.apply(fnResult, _toConsumableArray(parseFuncResult())); - } else { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected token in import of type" + ", given " + tokenToString(token)); - }(); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - if (typeof fnName === "undefined") { - throw new Error("Imported function must have a name"); - } - - descr = t.funcImportDescr(fnName, typeRef !== undefined ? typeRef : t.signature(fnParams, fnResult)); - } else if (isKeyword(token, _tokenizer.keywords.global)) { - eatToken(); // keyword - - if (token.type === _tokenizer.tokens.openParen) { - eatToken(); // ( - - eatTokenOfType(_tokenizer.tokens.keyword); // mut keyword - - var valtype = token.value; - eatToken(); - descr = t.globalType(valtype, "var"); - eatTokenOfType(_tokenizer.tokens.closeParen); - } else { - var _valtype = token.value; - eatTokenOfType(_tokenizer.tokens.valtype); - descr = t.globalType(_valtype, "const"); - } - } else if (isKeyword(token, _tokenizer.keywords.memory) === true) { - eatToken(); // Keyword - - descr = parseMemory(); - } else if (isKeyword(token, _tokenizer.keywords.table) === true) { - eatToken(); // Keyword - - descr = parseTable(); - } else { - throw new Error("Unsupported import type: " + tokenToString(token)); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.moduleImport(moduleName, name, descr); - } - /** - * Parses a block instruction - * - * WAST: - * - * expr: ( block <name>? <block_sig> <instr>* ) - * instr: block <name>? <block_sig> <instr>* end <name>? - * block_sig : ( result <type>* )* - * - */ - - - function parseBlock() { - var label = t.identifier(getUniqueName("block")); - var blockResult = null; - var instr = []; - - if (token.type === _tokenizer.tokens.identifier) { - label = identifierFromToken(token); - eatToken(); - } else { - label = t.withRaw(label, ""); // preserve anonymous - } - - while (token.type === _tokenizer.tokens.openParen) { - eatToken(); - - if (lookaheadAndCheck(_tokenizer.keywords.result) === true) { - eatToken(); - blockResult = token.value; - eatToken(); - } else if (lookaheadAndCheck(_tokenizer.tokens.name) === true || lookaheadAndCheck(_tokenizer.tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - // Instruction - instr.push(parseFuncInstr()); - } else { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected token in block body of type" + ", given " + tokenToString(token)); - }(); - } - - maybeIgnoreComment(); - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - return t.blockInstruction(label, instr, blockResult); - } - /** - * Parses a if instruction - * - * WAST: - * - * expr: - * ( if <name>? <block_sig> ( then <instr>* ) ( else <instr>* )? ) - * ( if <name>? <block_sig> <expr>+ ( then <instr>* ) ( else <instr>* )? ) - * - * instr: - * if <name>? <block_sig> <instr>* end <name>? - * if <name>? <block_sig> <instr>* else <name>? <instr>* end <name>? - * - * block_sig : ( result <type>* )* - * - */ - - - function parseIf() { - var blockResult = null; - var label = t.identifier(getUniqueName("if")); - var testInstrs = []; - var consequent = []; - var alternate = []; - - if (token.type === _tokenizer.tokens.identifier) { - label = identifierFromToken(token); - eatToken(); - } else { - label = t.withRaw(label, ""); // preserve anonymous - } - - while (token.type === _tokenizer.tokens.openParen) { - eatToken(); // ( - - /** - * Block signature - */ - - if (isKeyword(token, _tokenizer.keywords.result) === true) { - eatToken(); - blockResult = token.value; - eatTokenOfType(_tokenizer.tokens.valtype); - eatTokenOfType(_tokenizer.tokens.closeParen); - continue; - } - /** - * Then - */ - - - if (isKeyword(token, _tokenizer.keywords.then) === true) { - eatToken(); // then - - while (token.type === _tokenizer.tokens.openParen) { - eatToken(); // Instruction - - if (lookaheadAndCheck(_tokenizer.tokens.name) === true || lookaheadAndCheck(_tokenizer.tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - consequent.push(parseFuncInstr()); - } else { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected token in consequent body of type" + ", given " + tokenToString(token)); - }(); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - continue; - } - /** - * Alternate - */ - - - if (isKeyword(token, _tokenizer.keywords.else)) { - eatToken(); // else - - while (token.type === _tokenizer.tokens.openParen) { - eatToken(); // Instruction - - if (lookaheadAndCheck(_tokenizer.tokens.name) === true || lookaheadAndCheck(_tokenizer.tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - alternate.push(parseFuncInstr()); - } else { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected token in alternate body of type" + ", given " + tokenToString(token)); - }(); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - continue; - } - /** - * Test instruction - */ - - - if (lookaheadAndCheck(_tokenizer.tokens.name) === true || lookaheadAndCheck(_tokenizer.tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - testInstrs.push(parseFuncInstr()); - eatTokenOfType(_tokenizer.tokens.closeParen); - continue; - } - - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected token in if body" + ", given " + tokenToString(token)); - }(); - } - - return t.ifInstruction(label, testInstrs, blockResult, consequent, alternate); - } - /** - * Parses a loop instruction - * - * WAT: - * - * blockinstr :: 'loop' I:label rt:resulttype (in:instr*) 'end' id? - * - * WAST: - * - * instr :: loop <name>? <block_sig> <instr>* end <name>? - * expr :: ( loop <name>? <block_sig> <instr>* ) - * block_sig :: ( result <type>* )* - * - */ - - - function parseLoop() { - var label = t.identifier(getUniqueName("loop")); - var blockResult; - var instr = []; - - if (token.type === _tokenizer.tokens.identifier) { - label = identifierFromToken(token); - eatToken(); - } else { - label = t.withRaw(label, ""); // preserve anonymous - } - - while (token.type === _tokenizer.tokens.openParen) { - eatToken(); - - if (lookaheadAndCheck(_tokenizer.keywords.result) === true) { - eatToken(); - blockResult = token.value; - eatToken(); - } else if (lookaheadAndCheck(_tokenizer.tokens.name) === true || lookaheadAndCheck(_tokenizer.tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - // Instruction - instr.push(parseFuncInstr()); - } else { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected token in loop body" + ", given " + tokenToString(token)); - }(); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - return t.loopInstruction(label, blockResult, instr); - } - - function parseCallIndirect() { - var typeRef; - var params = []; - var results = []; - var instrs = []; - - while (token.type !== _tokenizer.tokens.closeParen) { - if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.type)) { - eatToken(); // ( - - eatToken(); // type - - typeRef = parseTypeReference(); - } else if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.param)) { - eatToken(); // ( - - eatToken(); // param - - /** - * Params can be empty: - * (params)` - */ - - if (token.type !== _tokenizer.tokens.closeParen) { - params.push.apply(params, _toConsumableArray(parseFuncParam())); - } - } else if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.result)) { - eatToken(); // ( - - eatToken(); // result - - /** - * Results can be empty: - * (result)` - */ - - if (token.type !== _tokenizer.tokens.closeParen) { - results.push.apply(results, _toConsumableArray(parseFuncResult())); - } - } else { - eatTokenOfType(_tokenizer.tokens.openParen); - instrs.push(parseFuncInstr()); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - return t.callIndirectInstruction(typeRef !== undefined ? typeRef : t.signature(params, results), instrs); - } - /** - * Parses an export instruction - * - * WAT: - * - * export: ( export <string> <exkind> ) - * exkind: ( func <var> ) - * ( global <var> ) - * ( table <var> ) - * ( memory <var> ) - * var: <nat> | <name> - * - */ - - - function parseExport() { - if (token.type !== _tokenizer.tokens.string) { - throw new Error("Expected string after export, got: " + token.type); - } - - var name = token.value; - eatToken(); - var moduleExportDescr = parseModuleExportDescr(); - return t.moduleExport(name, moduleExportDescr); - } - - function parseModuleExportDescr() { - var startLoc = getStartLoc(); - var type = ""; - var index; - eatTokenOfType(_tokenizer.tokens.openParen); - - while (token.type !== _tokenizer.tokens.closeParen) { - if (isKeyword(token, _tokenizer.keywords.func)) { - type = "Func"; - eatToken(); - index = parseExportIndex(token); - } else if (isKeyword(token, _tokenizer.keywords.table)) { - type = "Table"; - eatToken(); - index = parseExportIndex(token); - } else if (isKeyword(token, _tokenizer.keywords.global)) { - type = "Global"; - eatToken(); - index = parseExportIndex(token); - } else if (isKeyword(token, _tokenizer.keywords.memory)) { - type = "Memory"; - eatToken(); - index = parseExportIndex(token); - } - - eatToken(); - } - - if (type === "") { - throw new Error("Unknown export type"); - } - - if (index === undefined) { - throw new Error("Exported function must have a name"); - } - - var node = t.moduleExportDescr(type, index); - var endLoc = getEndLoc(); - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.withLoc(node, endLoc, startLoc); - } - - function parseModule() { - var name = null; - var isBinary = false; - var isQuote = false; - var moduleFields = []; - - if (token.type === _tokenizer.tokens.identifier) { - name = token.value; - eatToken(); - } - - if (hasPlugin("wast") && token.type === _tokenizer.tokens.name && token.value === "binary") { - eatToken(); - isBinary = true; - } - - if (hasPlugin("wast") && token.type === _tokenizer.tokens.name && token.value === "quote") { - eatToken(); - isQuote = true; - } - - if (isBinary === true) { - var blob = []; - - while (token.type === _tokenizer.tokens.string) { - blob.push(token.value); - eatToken(); - maybeIgnoreComment(); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.binaryModule(name, blob); - } - - if (isQuote === true) { - var string = []; - - while (token.type === _tokenizer.tokens.string) { - string.push(token.value); - eatToken(); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.quoteModule(name, string); - } - - while (token.type !== _tokenizer.tokens.closeParen) { - moduleFields.push(walk()); - - if (state.registredExportedElements.length > 0) { - state.registredExportedElements.forEach(function (decl) { - moduleFields.push(t.moduleExport(decl.name, t.moduleExportDescr(decl.exportType, decl.id))); - }); - state.registredExportedElements = []; - } - - token = tokensList[current]; - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.module(name, moduleFields); - } - /** - * Parses the arguments of an instruction - */ - - - function parseFuncInstrArguments(signature) { - var args = []; - var namedArgs = {}; - var signaturePtr = 0; - - while (token.type === _tokenizer.tokens.name || isKeyword(token, _tokenizer.keywords.offset)) { - var key = token.value; - eatToken(); - eatTokenOfType(_tokenizer.tokens.equal); - var value = void 0; - - if (token.type === _tokenizer.tokens.number) { - value = t.numberLiteralFromRaw(token.value); - } else { - throw new Error("Unexpected type for argument: " + token.type); - } - - namedArgs[key] = value; - eatToken(); - } // $FlowIgnore - - - var signatureLength = signature.vector ? Infinity : signature.length; - - while (token.type !== _tokenizer.tokens.closeParen && ( // $FlowIgnore - token.type === _tokenizer.tokens.openParen || signaturePtr < signatureLength)) { - if (token.type === _tokenizer.tokens.identifier) { - args.push(t.identifier(token.value)); - eatToken(); - } else if (token.type === _tokenizer.tokens.valtype) { - // Handle locals - args.push(t.valtypeLiteral(token.value)); - eatToken(); - } else if (token.type === _tokenizer.tokens.string) { - args.push(t.stringLiteral(token.value)); - eatToken(); - } else if (token.type === _tokenizer.tokens.number) { - args.push( // TODO(sven): refactor the type signature handling - // https://github.com/xtuc/webassemblyjs/pull/129 is a good start - t.numberLiteralFromRaw(token.value, // $FlowIgnore - signature[signaturePtr] || "f64")); // $FlowIgnore - - if (!signature.vector) { - ++signaturePtr; - } - - eatToken(); - } else if (token.type === _tokenizer.tokens.openParen) { - /** - * Maybe some nested instructions - */ - eatToken(); // Instruction - - if (lookaheadAndCheck(_tokenizer.tokens.name) === true || lookaheadAndCheck(_tokenizer.tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - // $FlowIgnore - args.push(parseFuncInstr()); - } else { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected token in nested instruction" + ", given " + tokenToString(token)); - }(); - } - - if (token.type === _tokenizer.tokens.closeParen) { - eatToken(); - } - } else { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected token in instruction argument" + ", given " + tokenToString(token)); - }(); - } - } - - return { - args: args, - namedArgs: namedArgs - }; - } - /** - * Parses an instruction - * - * WAT: - * - * instr :: plaininst - * blockinstr - * - * blockinstr :: 'block' I:label rt:resulttype (in:instr*) 'end' id? - * 'loop' I:label rt:resulttype (in:instr*) 'end' id? - * 'if' I:label rt:resulttype (in:instr*) 'else' id? (in2:intr*) 'end' id? - * - * plaininst :: 'unreachable' - * 'nop' - * 'br' l:labelidx - * 'br_if' l:labelidx - * 'br_table' l*:vec(labelidx) ln:labelidx - * 'return' - * 'call' x:funcidx - * 'call_indirect' x, I:typeuse - * - * WAST: - * - * instr: - * <expr> - * <op> - * block <name>? <block_sig> <instr>* end <name>? - * loop <name>? <block_sig> <instr>* end <name>? - * if <name>? <block_sig> <instr>* end <name>? - * if <name>? <block_sig> <instr>* else <name>? <instr>* end <name>? - * - * expr: - * ( <op> ) - * ( <op> <expr>+ ) - * ( block <name>? <block_sig> <instr>* ) - * ( loop <name>? <block_sig> <instr>* ) - * ( if <name>? <block_sig> ( then <instr>* ) ( else <instr>* )? ) - * ( if <name>? <block_sig> <expr>+ ( then <instr>* ) ( else <instr>* )? ) - * - * op: - * unreachable - * nop - * br <var> - * br_if <var> - * br_table <var>+ - * return - * call <var> - * call_indirect <func_sig> - * drop - * select - * get_local <var> - * set_local <var> - * tee_local <var> - * get_global <var> - * set_global <var> - * <type>.load((8|16|32)_<sign>)? <offset>? <align>? - * <type>.store(8|16|32)? <offset>? <align>? - * current_memory - * grow_memory - * <type>.const <value> - * <type>.<unop> - * <type>.<binop> - * <type>.<testop> - * <type>.<relop> - * <type>.<cvtop>/<type> - * - * func_type: ( type <var> )? <param>* <result>* - */ - - - function parseFuncInstr() { - var startLoc = getStartLoc(); - maybeIgnoreComment(); - /** - * A simple instruction - */ - - if (token.type === _tokenizer.tokens.name || token.type === _tokenizer.tokens.valtype) { - var _name2 = token.value; - var object; - eatToken(); - - if (token.type === _tokenizer.tokens.dot) { - object = _name2; - eatToken(); - - if (token.type !== _tokenizer.tokens.name) { - throw new TypeError("Unknown token: " + token.type + ", name expected"); - } - - _name2 = token.value; - eatToken(); - } - - if (token.type === _tokenizer.tokens.closeParen) { - var _endLoc = token.loc.end; - - if (typeof object === "undefined") { - return t.withLoc(t.instruction(_name2), _endLoc, startLoc); - } else { - return t.withLoc(t.objectInstruction(_name2, object, []), _endLoc, startLoc); - } - } - - var signature = t.signatureForOpcode(object || "", _name2); - - var _parseFuncInstrArgume = parseFuncInstrArguments(signature), - _args = _parseFuncInstrArgume.args, - _namedArgs = _parseFuncInstrArgume.namedArgs; - - var endLoc = token.loc.end; - - if (typeof object === "undefined") { - return t.withLoc(t.instruction(_name2, _args, _namedArgs), endLoc, startLoc); - } else { - return t.withLoc(t.objectInstruction(_name2, object, _args, _namedArgs), endLoc, startLoc); - } - } else if (isKeyword(token, _tokenizer.keywords.loop)) { - /** - * Else a instruction with a keyword (loop or block) - */ - eatToken(); // keyword - - return parseLoop(); - } else if (isKeyword(token, _tokenizer.keywords.block)) { - eatToken(); // keyword - - return parseBlock(); - } else if (isKeyword(token, _tokenizer.keywords.call_indirect)) { - eatToken(); // keyword - - return parseCallIndirect(); - } else if (isKeyword(token, _tokenizer.keywords.call)) { - eatToken(); // keyword - - var index; - - if (token.type === _tokenizer.tokens.identifier) { - index = identifierFromToken(token); - eatToken(); - } else if (token.type === _tokenizer.tokens.number) { - index = t.indexLiteral(token.value); - eatToken(); - } - - var instrArgs = []; // Nested instruction - - while (token.type === _tokenizer.tokens.openParen) { - eatToken(); - instrArgs.push(parseFuncInstr()); - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - if (typeof index === "undefined") { - throw new Error("Missing argument in call instruciton"); - } - - if (instrArgs.length > 0) { - return t.callInstruction(index, instrArgs); - } else { - return t.callInstruction(index); - } - } else if (isKeyword(token, _tokenizer.keywords.if)) { - eatToken(); // Keyword - - return parseIf(); - } else if (isKeyword(token, _tokenizer.keywords.module) && hasPlugin("wast")) { - eatToken(); // In WAST you can have a module as an instruction's argument - // we will cast it into a instruction to not break the flow - // $FlowIgnore - - var module = parseModule(); - return module; - } else { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected instruction in function body" + ", given " + tokenToString(token)); - }(); - } - } - /* - * Parses a function - * - * WAT: - * - * functype :: ( 'func' t1:vec(param) t2:vec(result) ) - * param :: ( 'param' id? t:valtype ) - * result :: ( 'result' t:valtype ) - * - * WAST: - * - * func :: ( func <name>? <func_sig> <local>* <instr>* ) - * ( func <name>? ( export <string> ) <...> ) - * ( func <name>? ( import <string> <string> ) <func_sig> ) - * func_sig :: ( type <var> )? <param>* <result>* - * param :: ( param <type>* ) | ( param <name> <type> ) - * result :: ( result <type>* ) - * local :: ( local <type>* ) | ( local <name> <type> ) - * - */ - - - function parseFunc() { - var fnName = t.identifier(getUniqueName("func")); - var typeRef; - var fnBody = []; - var fnParams = []; - var fnResult = []; // name - - if (token.type === _tokenizer.tokens.identifier) { - fnName = identifierFromToken(token); - eatToken(); - } else { - fnName = t.withRaw(fnName, ""); // preserve anonymous - } - - maybeIgnoreComment(); - - while (token.type === _tokenizer.tokens.openParen || token.type === _tokenizer.tokens.name || token.type === _tokenizer.tokens.valtype) { - // Instructions without parens - if (token.type === _tokenizer.tokens.name || token.type === _tokenizer.tokens.valtype) { - fnBody.push(parseFuncInstr()); - continue; - } - - eatToken(); - - if (lookaheadAndCheck(_tokenizer.keywords.param) === true) { - eatToken(); - fnParams.push.apply(fnParams, _toConsumableArray(parseFuncParam())); - } else if (lookaheadAndCheck(_tokenizer.keywords.result) === true) { - eatToken(); - fnResult.push.apply(fnResult, _toConsumableArray(parseFuncResult())); - } else if (lookaheadAndCheck(_tokenizer.keywords.export) === true) { - eatToken(); - parseFuncExport(fnName); - } else if (lookaheadAndCheck(_tokenizer.keywords.type) === true) { - eatToken(); - typeRef = parseTypeReference(); - } else if (lookaheadAndCheck(_tokenizer.tokens.name) === true || lookaheadAndCheck(_tokenizer.tokens.valtype) === true || token.type === "keyword" // is any keyword - ) { - // Instruction - fnBody.push(parseFuncInstr()); - } else { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected token in func body" + ", given " + tokenToString(token)); - }(); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - return t.func(fnName, typeRef !== undefined ? typeRef : t.signature(fnParams, fnResult), fnBody); - } - /** - * Parses shorthand export in func - * - * export :: ( export <string> ) - */ - - - function parseFuncExport(funcId) { - if (token.type !== _tokenizer.tokens.string) { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Function export expected a string" + ", given " + tokenToString(token)); - }(); - } - - var name = token.value; - eatToken(); - /** - * Func export shorthand, we trait it as a syntaxic sugar. - * A export ModuleField will be added later. - * - * We give the anonymous function a generated name and export it. - */ - - var id = t.identifier(funcId.value); - state.registredExportedElements.push({ - exportType: "Func", - name: name, - id: id - }); - } - /** - * Parses a type instruction - * - * WAST: - * - * typedef: ( type <name>? ( func <param>* <result>* ) ) - */ - - - function parseType() { - var id; - var params = []; - var result = []; - - if (token.type === _tokenizer.tokens.identifier) { - id = identifierFromToken(token); - eatToken(); - } - - if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.func)) { - eatToken(); // ( - - eatToken(); // func - - if (token.type === _tokenizer.tokens.closeParen) { - eatToken(); // function with an empty signature, we can abort here - - return t.typeInstruction(id, t.signature([], [])); - } - - if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.param)) { - eatToken(); // ( - - eatToken(); // param - - params = parseFuncParam(); - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.result)) { - eatToken(); // ( - - eatToken(); // result - - result = parseFuncResult(); - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - return t.typeInstruction(id, t.signature(params, result)); - } - /** - * Parses a function result - * - * WAST: - * - * result :: ( result <type>* ) - */ - - - function parseFuncResult() { - var results = []; - - while (token.type !== _tokenizer.tokens.closeParen) { - if (token.type !== _tokenizer.tokens.valtype) { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unexpected token in func result" + ", given " + tokenToString(token)); - }(); - } - - var valtype = token.value; - eatToken(); - results.push(valtype); - } - - return results; - } - /** - * Parses a type reference - * - */ - - - function parseTypeReference() { - var ref; - - if (token.type === _tokenizer.tokens.identifier) { - ref = identifierFromToken(token); - eatToken(); - } else if (token.type === _tokenizer.tokens.number) { - ref = t.numberLiteralFromRaw(token.value); - eatToken(); - } - - return ref; - } - /** - * Parses a global instruction - * - * WAST: - * - * global: ( global <name>? <global_sig> <instr>* ) - * ( global <name>? ( export <string> ) <...> ) - * ( global <name>? ( import <string> <string> ) <global_sig> ) - * - * global_sig: <type> | ( mut <type> ) - * - */ - - - function parseGlobal() { - var name = t.identifier(getUniqueName("global")); - var type; // Keep informations in case of a shorthand import - - var importing = null; - maybeIgnoreComment(); - - if (token.type === _tokenizer.tokens.identifier) { - name = identifierFromToken(token); - eatToken(); - } else { - name = t.withRaw(name, ""); // preserve anonymous - } - /** - * maybe export - */ - - - if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.export)) { - eatToken(); // ( - - eatToken(); // export - - var exportName = token.value; - eatTokenOfType(_tokenizer.tokens.string); - state.registredExportedElements.push({ - exportType: "Global", - name: exportName, - id: name - }); - eatTokenOfType(_tokenizer.tokens.closeParen); - } - /** - * maybe import - */ - - - if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.import)) { - eatToken(); // ( - - eatToken(); // import - - var moduleName = token.value; - eatTokenOfType(_tokenizer.tokens.string); - var _name3 = token.value; - eatTokenOfType(_tokenizer.tokens.string); - importing = { - module: moduleName, - name: _name3, - descr: undefined - }; - eatTokenOfType(_tokenizer.tokens.closeParen); - } - /** - * global_sig - */ - - - if (token.type === _tokenizer.tokens.valtype) { - type = t.globalType(token.value, "const"); - eatToken(); - } else if (token.type === _tokenizer.tokens.openParen) { - eatToken(); // ( - - if (isKeyword(token, _tokenizer.keywords.mut) === false) { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unsupported global type, expected mut" + ", given " + tokenToString(token)); - }(); - } - - eatToken(); // mut - - type = t.globalType(token.value, "var"); - eatToken(); - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - if (type === undefined) { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Could not determine global type" + ", given " + tokenToString(token)); - }(); - } - - maybeIgnoreComment(); - var init = []; - - if (importing != null) { - importing.descr = type; - init.push(t.moduleImport(importing.module, importing.name, importing.descr)); - } - /** - * instr* - */ - - - while (token.type === _tokenizer.tokens.openParen) { - eatToken(); - init.push(parseFuncInstr()); - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - return t.global(type, init, name); - } - /** - * Parses a function param - * - * WAST: - * - * param :: ( param <type>* ) | ( param <name> <type> ) - */ - - - function parseFuncParam() { - var params = []; - var id; - var valtype; - - if (token.type === _tokenizer.tokens.identifier) { - id = token.value; - eatToken(); - } - - if (token.type === _tokenizer.tokens.valtype) { - valtype = token.value; - eatToken(); - params.push({ - id: id, - valtype: valtype - }); - /** - * Shorthand notation for multiple anonymous parameters - * @see https://webassembly.github.io/spec/core/text/types.html#function-types - * @see https://github.com/xtuc/webassemblyjs/issues/6 - */ - - if (id === undefined) { - while (token.type === _tokenizer.tokens.valtype) { - valtype = token.value; - eatToken(); - params.push({ - id: undefined, - valtype: valtype - }); - } - } - } else {// ignore - } - - return params; - } - /** - * Parses an element segments instruction - * - * WAST: - * - * elem: ( elem <var>? (offset <instr>* ) <var>* ) - * ( elem <var>? <expr> <var>* ) - * - * var: <nat> | <name> - */ - - - function parseElem() { - var tableIndex = t.indexLiteral(0); - var offset = []; - var funcs = []; - - if (token.type === _tokenizer.tokens.identifier) { - tableIndex = identifierFromToken(token); - eatToken(); - } - - if (token.type === _tokenizer.tokens.number) { - tableIndex = t.indexLiteral(token.value); - eatToken(); - } - - while (token.type !== _tokenizer.tokens.closeParen) { - if (lookaheadAndCheck(_tokenizer.tokens.openParen, _tokenizer.keywords.offset)) { - eatToken(); // ( - - eatToken(); // offset - - while (token.type !== _tokenizer.tokens.closeParen) { - eatTokenOfType(_tokenizer.tokens.openParen); - offset.push(parseFuncInstr()); - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - eatTokenOfType(_tokenizer.tokens.closeParen); - } else if (token.type === _tokenizer.tokens.identifier) { - funcs.push(t.identifier(token.value)); - eatToken(); - } else if (token.type === _tokenizer.tokens.number) { - funcs.push(t.indexLiteral(token.value)); - eatToken(); - } else if (token.type === _tokenizer.tokens.openParen) { - eatToken(); // ( - - offset.push(parseFuncInstr()); - eatTokenOfType(_tokenizer.tokens.closeParen); - } else { - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unsupported token in elem" + ", given " + tokenToString(token)); - }(); - } - } - - return t.elem(tableIndex, offset, funcs); - } - /** - * Parses the start instruction in a module - * - * WAST: - * - * start: ( start <var> ) - * var: <nat> | <name> - * - * WAT: - * start ::= ‘(’ ‘start’ x:funcidx ‘)’ - */ - - - function parseStart() { - if (token.type === _tokenizer.tokens.identifier) { - var index = identifierFromToken(token); - eatToken(); - return t.start(index); - } - - if (token.type === _tokenizer.tokens.number) { - var _index2 = t.indexLiteral(token.value); - - eatToken(); - return t.start(_index2); - } - - throw new Error("Unknown start, token: " + tokenToString(token)); - } - - if (token.type === _tokenizer.tokens.openParen) { - eatToken(); - var startLoc = getStartLoc(); - - if (isKeyword(token, _tokenizer.keywords.export)) { - eatToken(); - var node = parseExport(); - - var _endLoc2 = getEndLoc(); - - return t.withLoc(node, _endLoc2, startLoc); - } - - if (isKeyword(token, _tokenizer.keywords.loop)) { - eatToken(); - - var _node = parseLoop(); - - var _endLoc3 = getEndLoc(); - - return t.withLoc(_node, _endLoc3, startLoc); - } - - if (isKeyword(token, _tokenizer.keywords.func)) { - eatToken(); - - var _node2 = parseFunc(); - - var _endLoc4 = getEndLoc(); - - maybeIgnoreComment(); - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.withLoc(_node2, _endLoc4, startLoc); - } - - if (isKeyword(token, _tokenizer.keywords.module)) { - eatToken(); - - var _node3 = parseModule(); - - var _endLoc5 = getEndLoc(); - - return t.withLoc(_node3, _endLoc5, startLoc); - } - - if (isKeyword(token, _tokenizer.keywords.import)) { - eatToken(); - - var _node4 = parseImport(); - - var _endLoc6 = getEndLoc(); - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.withLoc(_node4, _endLoc6, startLoc); - } - - if (isKeyword(token, _tokenizer.keywords.block)) { - eatToken(); - - var _node5 = parseBlock(); - - var _endLoc7 = getEndLoc(); - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.withLoc(_node5, _endLoc7, startLoc); - } - - if (isKeyword(token, _tokenizer.keywords.memory)) { - eatToken(); - - var _node6 = parseMemory(); - - var _endLoc8 = getEndLoc(); - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.withLoc(_node6, _endLoc8, startLoc); - } - - if (isKeyword(token, _tokenizer.keywords.data)) { - eatToken(); - - var _node7 = parseData(); - - var _endLoc9 = getEndLoc(); - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.withLoc(_node7, _endLoc9, startLoc); - } - - if (isKeyword(token, _tokenizer.keywords.table)) { - eatToken(); - - var _node8 = parseTable(); - - var _endLoc10 = getEndLoc(); - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.withLoc(_node8, _endLoc10, startLoc); - } - - if (isKeyword(token, _tokenizer.keywords.global)) { - eatToken(); - - var _node9 = parseGlobal(); - - var _endLoc11 = getEndLoc(); - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.withLoc(_node9, _endLoc11, startLoc); - } - - if (isKeyword(token, _tokenizer.keywords.type)) { - eatToken(); - - var _node10 = parseType(); - - var _endLoc12 = getEndLoc(); - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.withLoc(_node10, _endLoc12, startLoc); - } - - if (isKeyword(token, _tokenizer.keywords.start)) { - eatToken(); - - var _node11 = parseStart(); - - var _endLoc13 = getEndLoc(); - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.withLoc(_node11, _endLoc13, startLoc); - } - - if (isKeyword(token, _tokenizer.keywords.elem)) { - eatToken(); - - var _node12 = parseElem(); - - var _endLoc14 = getEndLoc(); - - eatTokenOfType(_tokenizer.tokens.closeParen); - return t.withLoc(_node12, _endLoc14, startLoc); - } - - var instruction = parseFuncInstr(); - var endLoc = getEndLoc(); - maybeIgnoreComment(); - - if (_typeof(instruction) === "object") { - if (typeof token !== "undefined") { - eatTokenOfType(_tokenizer.tokens.closeParen); - } - - return t.withLoc(instruction, endLoc, startLoc); - } - } - - if (token.type === _tokenizer.tokens.comment) { - var _startLoc = getStartLoc(); - - var builder = token.opts.type === "leading" ? t.leadingComment : t.blockComment; - - var _node13 = builder(token.value); - - eatToken(); // comment - - var _endLoc15 = getEndLoc(); - - return t.withLoc(_node13, _endLoc15, _startLoc); - } - - throw function () { - return new Error("\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, token.loc) + "\n" + "Unknown token" + ", given " + tokenToString(token)); - }(); - } - - var body = []; - - while (current < tokensList.length) { - body.push(walk()); - } - - return t.program(body); -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wast-parser/lib/index.js b/node_modules/@webassemblyjs/wast-parser/lib/index.js deleted file mode 100644 index 1567e05..0000000 --- a/node_modules/@webassemblyjs/wast-parser/lib/index.js +++ /dev/null @@ -1,35 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -var _exportNames = { - parse: true -}; -exports.parse = parse; - -var parser = _interopRequireWildcard(require("./grammar")); - -var _tokenizer = require("./tokenizer"); - -var _numberLiterals = require("./number-literals"); - -Object.keys(_numberLiterals).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function get() { - return _numberLiterals[key]; - } - }); -}); - -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 parse(source) { - var tokens = (0, _tokenizer.tokenize)(source); // We pass the source here to show code frames - - var ast = parser.parse(tokens, source); - return ast; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wast-parser/lib/number-literals.js b/node_modules/@webassemblyjs/wast-parser/lib/number-literals.js deleted file mode 100644 index fea08f9..0000000 --- a/node_modules/@webassemblyjs/wast-parser/lib/number-literals.js +++ /dev/null @@ -1,116 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.parse32F = parse32F; -exports.parse64F = parse64F; -exports.parse32I = parse32I; -exports.parseU32 = parseU32; -exports.parse64I = parse64I; -exports.isInfLiteral = isInfLiteral; -exports.isNanLiteral = isNanLiteral; - -var _long = _interopRequireDefault(require("@xtuc/long")); - -var _floatingPointHexParser = _interopRequireDefault(require("@webassemblyjs/floating-point-hex-parser")); - -var _helperApiError = require("@webassemblyjs/helper-api-error"); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function parse32F(sourceString) { - if (isHexLiteral(sourceString)) { - return (0, _floatingPointHexParser.default)(sourceString); - } - - if (isInfLiteral(sourceString)) { - return sourceString[0] === "-" ? -1 : 1; - } - - if (isNanLiteral(sourceString)) { - return (sourceString[0] === "-" ? -1 : 1) * (sourceString.includes(":") ? parseInt(sourceString.substring(sourceString.indexOf(":") + 1), 16) : 0x400000); - } - - return parseFloat(sourceString); -} - -function parse64F(sourceString) { - if (isHexLiteral(sourceString)) { - return (0, _floatingPointHexParser.default)(sourceString); - } - - if (isInfLiteral(sourceString)) { - return sourceString[0] === "-" ? -1 : 1; - } - - if (isNanLiteral(sourceString)) { - return (sourceString[0] === "-" ? -1 : 1) * (sourceString.includes(":") ? parseInt(sourceString.substring(sourceString.indexOf(":") + 1), 16) : 0x8000000000000); - } - - if (isHexLiteral(sourceString)) { - return (0, _floatingPointHexParser.default)(sourceString); - } - - return parseFloat(sourceString); -} - -function parse32I(sourceString) { - var value = 0; - - if (isHexLiteral(sourceString)) { - value = ~~parseInt(sourceString, 16); - } else if (isDecimalExponentLiteral(sourceString)) { - throw new Error("This number literal format is yet to be implemented."); - } else { - value = parseInt(sourceString, 10); - } - - return value; -} - -function parseU32(sourceString) { - var value = parse32I(sourceString); - - if (value < 0) { - throw new _helperApiError.CompileError("Illegal value for u32: " + sourceString); - } - - return value; -} - -function parse64I(sourceString) { - var long; - - if (isHexLiteral(sourceString)) { - long = _long.default.fromString(sourceString, false, 16); - } else if (isDecimalExponentLiteral(sourceString)) { - throw new Error("This number literal format is yet to be implemented."); - } else { - long = _long.default.fromString(sourceString); - } - - return { - high: long.high, - low: long.low - }; -} - -var NAN_WORD = /^\+?-?nan/; -var INF_WORD = /^\+?-?inf/; - -function isInfLiteral(sourceString) { - return INF_WORD.test(sourceString.toLowerCase()); -} - -function isNanLiteral(sourceString) { - return NAN_WORD.test(sourceString.toLowerCase()); -} - -function isDecimalExponentLiteral(sourceString) { - return !isHexLiteral(sourceString) && sourceString.toUpperCase().includes("E"); -} - -function isHexLiteral(sourceString) { - return sourceString.substring(0, 2).toUpperCase() === "0X" || sourceString.substring(0, 3).toUpperCase() === "-0X"; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wast-parser/lib/string-literals.js b/node_modules/@webassemblyjs/wast-parser/lib/string-literals.js deleted file mode 100644 index db1ff75..0000000 --- a/node_modules/@webassemblyjs/wast-parser/lib/string-literals.js +++ /dev/null @@ -1,94 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.parseString = parseString; -// string literal characters cannot contain control codes -var CONTROL_CODES = [0, // null -7, // bell -8, // backspace -9, // horizontal -10, // line feed -11, // vertical tab -12, // form feed -13, // carriage return -26, // Control-Z -27, // escape -127 // delete -]; // escaped sequences can either be a two character hex value, or one of the -// following single character codes - -function decodeControlCharacter(char) { - switch (char) { - case "t": - return 0x09; - - case "n": - return 0x0a; - - case "r": - return 0x0d; - - case '"': - return 0x22; - - case "′": - return 0x27; - - case "\\": - return 0x5c; - } - - return -1; -} - -var ESCAPE_CHAR = 92; // backslash - -var QUOTE_CHAR = 34; // backslash -// parse string as per the spec: -// https://webassembly.github.io/spec/core/multipage/text/values.html#text-string - -function parseString(value) { - var byteArray = []; - var index = 0; - - while (index < value.length) { - var charCode = value.charCodeAt(index); - - if (CONTROL_CODES.indexOf(charCode) !== -1) { - throw new Error("ASCII control characters are not permitted within string literals"); - } - - if (charCode === QUOTE_CHAR) { - throw new Error("quotes are not permitted within string literals"); - } - - if (charCode === ESCAPE_CHAR) { - var firstChar = value.substr(index + 1, 1); - var decodedControlChar = decodeControlCharacter(firstChar); - - if (decodedControlChar !== -1) { - // single character escaped values, e.g. \r - byteArray.push(decodedControlChar); - index += 2; - } else { - // hex escaped values, e.g. \2a - var hexValue = value.substr(index + 1, 2); - - if (!/^[0-9A-F]{2}$/i.test(hexValue)) { - throw new Error("invalid character encoding"); - } - - byteArray.push(parseInt(hexValue, 16)); - index += 3; - } - } else { - // ASCII encoded values - byteArray.push(charCode); - index++; - } - } - - return byteArray; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wast-parser/lib/tokenizer.js b/node_modules/@webassemblyjs/wast-parser/lib/tokenizer.js deleted file mode 100644 index bb6f78f..0000000 --- a/node_modules/@webassemblyjs/wast-parser/lib/tokenizer.js +++ /dev/null @@ -1,447 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.tokenize = tokenize; -exports.tokens = exports.keywords = void 0; - -var _helperFsm = require("@webassemblyjs/helper-fsm"); - -var _helperCodeFrame = require("@webassemblyjs/helper-code-frame"); - -// eslint-disable-next-line -function getCodeFrame(source, line, column) { - var loc = { - start: { - line: line, - column: column - } - }; - return "\n" + (0, _helperCodeFrame.codeFrameFromSource)(source, loc) + "\n"; -} - -var WHITESPACE = /\s/; -var PARENS = /\(|\)/; -var LETTERS = /[a-z0-9_/]/i; -var idchar = /[a-z0-9!#$%&*+./:<=>?@\\[\]^_`|~-]/i; -var valtypes = ["i32", "i64", "f32", "f64"]; -var NUMBERS = /[0-9|.|_]/; -var NUMBER_KEYWORDS = /nan|inf/; - -function isNewLine(char) { - return char.charCodeAt(0) === 10 || char.charCodeAt(0) === 13; -} - -function Token(type, value, start, end) { - var opts = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; - var token = { - type: type, - value: value, - loc: { - start: start, - end: end - } - }; - - if (Object.keys(opts).length > 0) { - // $FlowIgnore - token["opts"] = opts; - } - - return token; -} - -var tokenTypes = { - openParen: "openParen", - closeParen: "closeParen", - number: "number", - string: "string", - name: "name", - identifier: "identifier", - valtype: "valtype", - dot: "dot", - comment: "comment", - equal: "equal", - keyword: "keyword" -}; -var keywords = { - module: "module", - func: "func", - param: "param", - result: "result", - export: "export", - loop: "loop", - block: "block", - if: "if", - then: "then", - else: "else", - call: "call", - call_indirect: "call_indirect", - import: "import", - memory: "memory", - table: "table", - global: "global", - anyfunc: "anyfunc", - mut: "mut", - data: "data", - type: "type", - elem: "elem", - start: "start", - offset: "offset" -}; -exports.keywords = keywords; -var NUMERIC_SEPARATOR = "_"; -/** - * Build the FSM for number literals - */ - -var numberLiteralFSM = new _helperFsm.FSM({ - START: [(0, _helperFsm.makeTransition)(/-|\+/, "AFTER_SIGN"), (0, _helperFsm.makeTransition)(/nan:0x/, "NAN_HEX", { - n: 6 - }), (0, _helperFsm.makeTransition)(/nan|inf/, "STOP", { - n: 3 - }), (0, _helperFsm.makeTransition)(/0x/, "HEX", { - n: 2 - }), (0, _helperFsm.makeTransition)(/[0-9]/, "DEC"), (0, _helperFsm.makeTransition)(/\./, "DEC_FRAC")], - AFTER_SIGN: [(0, _helperFsm.makeTransition)(/nan:0x/, "NAN_HEX", { - n: 6 - }), (0, _helperFsm.makeTransition)(/nan|inf/, "STOP", { - n: 3 - }), (0, _helperFsm.makeTransition)(/0x/, "HEX", { - n: 2 - }), (0, _helperFsm.makeTransition)(/[0-9]/, "DEC"), (0, _helperFsm.makeTransition)(/\./, "DEC_FRAC")], - DEC_FRAC: [(0, _helperFsm.makeTransition)(/[0-9]/, "DEC_FRAC", { - allowedSeparator: NUMERIC_SEPARATOR - }), (0, _helperFsm.makeTransition)(/e|E/, "DEC_SIGNED_EXP")], - DEC: [(0, _helperFsm.makeTransition)(/[0-9]/, "DEC", { - allowedSeparator: NUMERIC_SEPARATOR - }), (0, _helperFsm.makeTransition)(/\./, "DEC_FRAC"), (0, _helperFsm.makeTransition)(/e|E/, "DEC_SIGNED_EXP")], - DEC_SIGNED_EXP: [(0, _helperFsm.makeTransition)(/\+|-/, "DEC_EXP"), (0, _helperFsm.makeTransition)(/[0-9]/, "DEC_EXP")], - DEC_EXP: [(0, _helperFsm.makeTransition)(/[0-9]/, "DEC_EXP", { - allowedSeparator: NUMERIC_SEPARATOR - })], - HEX: [(0, _helperFsm.makeTransition)(/[0-9|A-F|a-f]/, "HEX", { - allowedSeparator: NUMERIC_SEPARATOR - }), (0, _helperFsm.makeTransition)(/\./, "HEX_FRAC"), (0, _helperFsm.makeTransition)(/p|P/, "HEX_SIGNED_EXP")], - HEX_FRAC: [(0, _helperFsm.makeTransition)(/[0-9|A-F|a-f]/, "HEX_FRAC", { - allowedSeparator: NUMERIC_SEPARATOR - }), (0, _helperFsm.makeTransition)(/p|P|/, "HEX_SIGNED_EXP")], - HEX_SIGNED_EXP: [(0, _helperFsm.makeTransition)(/[0-9|+|-]/, "HEX_EXP")], - HEX_EXP: [(0, _helperFsm.makeTransition)(/[0-9]/, "HEX_EXP", { - allowedSeparator: NUMERIC_SEPARATOR - })], - NAN_HEX: [(0, _helperFsm.makeTransition)(/[0-9|A-F|a-f]/, "NAN_HEX", { - allowedSeparator: NUMERIC_SEPARATOR - })], - STOP: [] -}, "START", "STOP"); - -function tokenize(input) { - var current = 0; - var char = input[current]; // Used by SourceLocation - - var column = 1; - var line = 1; - var tokens = []; - /** - * Creates a pushToken function for a given type - */ - - function pushToken(type) { - return function (v) { - var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var startColumn = opts.startColumn || column - String(v).length; - delete opts.startColumn; - var endColumn = opts.endColumn || startColumn + String(v).length - 1; - delete opts.endColumn; - var start = { - line: line, - column: startColumn - }; - var end = { - line: line, - column: endColumn - }; - tokens.push(Token(type, v, start, end, opts)); - }; - } - /** - * Functions to save newly encountered tokens - */ - - - var pushCloseParenToken = pushToken(tokenTypes.closeParen); - var pushOpenParenToken = pushToken(tokenTypes.openParen); - var pushNumberToken = pushToken(tokenTypes.number); - var pushValtypeToken = pushToken(tokenTypes.valtype); - var pushNameToken = pushToken(tokenTypes.name); - var pushIdentifierToken = pushToken(tokenTypes.identifier); - var pushKeywordToken = pushToken(tokenTypes.keyword); - var pushDotToken = pushToken(tokenTypes.dot); - var pushStringToken = pushToken(tokenTypes.string); - var pushCommentToken = pushToken(tokenTypes.comment); - var pushEqualToken = pushToken(tokenTypes.equal); - /** - * Can be used to look at the next character(s). - * - * The default behavior `lookahead()` simply returns the next character without consuming it. - * Letters are always returned in lowercase. - * - * @param {number} length How many characters to query. Default = 1 - * @param {number} offset How many characters to skip forward from current one. Default = 1 - * - */ - - function lookahead() { - var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; - var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; - return input.substring(current + offset, current + offset + length).toLowerCase(); - } - /** - * Advances the cursor in the input by a certain amount - * - * @param {number} amount How many characters to consume. Default = 1 - */ - - - function eatCharacter() { - var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; - column += amount; - current += amount; - char = input[current]; - } - - while (current < input.length) { - // ;; - if (char === ";" && lookahead() === ";") { - var startColumn = column; - eatCharacter(2); - var text = ""; - - while (!isNewLine(char)) { - text += char; - eatCharacter(); - - if (char === undefined) { - break; - } - } - - var endColumn = column; - pushCommentToken(text, { - type: "leading", - startColumn: startColumn, - endColumn: endColumn - }); - continue; - } // (; - - - if (char === "(" && lookahead() === ";") { - var _startColumn = column; - eatCharacter(2); - var _text = ""; // ;) - - while (true) { - char = input[current]; - - if (char === ";" && lookahead() === ")") { - eatCharacter(2); - break; - } - - _text += char; - eatCharacter(); - - if (isNewLine(char)) { - line++; - column = 0; - } - } - - var _endColumn = column; - pushCommentToken(_text, { - type: "block", - startColumn: _startColumn, - endColumn: _endColumn - }); - continue; - } - - if (char === "(") { - pushOpenParenToken(char); - eatCharacter(); - continue; - } - - if (char === "=") { - pushEqualToken(char); - eatCharacter(); - continue; - } - - if (char === ")") { - pushCloseParenToken(char); - eatCharacter(); - continue; - } - - if (isNewLine(char)) { - line++; - eatCharacter(); - column = 0; - continue; - } - - if (WHITESPACE.test(char)) { - eatCharacter(); - continue; - } - - if (char === "$") { - var _startColumn2 = column; - eatCharacter(); - var value = ""; - - while (idchar.test(char)) { - value += char; - eatCharacter(); - } - - var _endColumn2 = column; - pushIdentifierToken(value, { - startColumn: _startColumn2, - endColumn: _endColumn2 - }); - continue; - } - - if (NUMBERS.test(char) || NUMBER_KEYWORDS.test(lookahead(3, 0)) || char === "-" || char === "+") { - var _startColumn3 = column; - - var _value = numberLiteralFSM.run(input.slice(current)); - - if (_value === "") { - throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char)); - } - - pushNumberToken(_value, { - startColumn: _startColumn3 - }); - eatCharacter(_value.length); - - if (char && !PARENS.test(char) && !WHITESPACE.test(char)) { - throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char)); - } - - continue; - } - - if (char === '"') { - var _startColumn4 = column; - var _value2 = ""; - eatCharacter(); // " - - while (char !== '"') { - if (isNewLine(char)) { - throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char)); - } - - _value2 += char; - eatCharacter(); // char - } - - eatCharacter(); // " - - var _endColumn3 = column; - pushStringToken(_value2, { - startColumn: _startColumn4, - endColumn: _endColumn3 - }); - continue; - } - - if (LETTERS.test(char)) { - var _value3 = ""; - var _startColumn5 = column; - - while (char && LETTERS.test(char)) { - _value3 += char; - eatCharacter(); - } - /* - * Handle MemberAccess - */ - - - if (char === ".") { - var dotStartColumn = column; - - if (valtypes.indexOf(_value3) !== -1) { - pushValtypeToken(_value3, { - startColumn: _startColumn5 - }); - } else { - pushNameToken(_value3); - } - - eatCharacter(); - _value3 = ""; - var nameStartColumn = column; - - while (LETTERS.test(char)) { - _value3 += char; - eatCharacter(); - } - - pushDotToken(".", { - startColumn: dotStartColumn - }); - pushNameToken(_value3, { - startColumn: nameStartColumn - }); - continue; - } - /* - * Handle keywords - */ - // $FlowIgnore - - - if (typeof keywords[_value3] === "string") { - pushKeywordToken(_value3, { - startColumn: _startColumn5 - }); - continue; - } - /* - * Handle types - */ - - - if (valtypes.indexOf(_value3) !== -1) { - pushValtypeToken(_value3, { - startColumn: _startColumn5 - }); - continue; - } - /* - * Handle literals - */ - - - pushNameToken(_value3, { - startColumn: _startColumn5 - }); - continue; - } - - throw new Error(getCodeFrame(input, line, column) + "Unexpected character " + JSON.stringify(char)); - } - - return tokens; -} - -var tokens = tokenTypes; -exports.tokens = tokens;
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wast-parser/package.json b/node_modules/@webassemblyjs/wast-parser/package.json deleted file mode 100644 index 40a54de..0000000 --- a/node_modules/@webassemblyjs/wast-parser/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "_from": "@webassemblyjs/wast-parser@1.9.0", - "_id": "@webassemblyjs/wast-parser@1.9.0", - "_inBundle": false, - "_integrity": "sha512-qsqSAP3QQ3LyZjNC/0jBJ/ToSxfYJ8kYyuiGvtn/8MK89VrNEfwj7BPQzJVHi0jGTRK2dGdJ5PRqhtjzoww+bw==", - "_location": "/@webassemblyjs/wast-parser", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/wast-parser@1.9.0", - "name": "@webassemblyjs/wast-parser", - "escapedName": "@webassemblyjs%2fwast-parser", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/ast", - "/@webassemblyjs/wast-printer" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/wast-parser/-/wast-parser-1.9.0.tgz", - "_shasum": "3031115d79ac5bd261556cecc3fa90a3ef451914", - "_spec": "@webassemblyjs/wast-parser@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/ast", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "dependencies": { - "@webassemblyjs/ast": "1.9.0", - "@webassemblyjs/floating-point-hex-parser": "1.9.0", - "@webassemblyjs/helper-api-error": "1.9.0", - "@webassemblyjs/helper-code-frame": "1.9.0", - "@webassemblyjs/helper-fsm": "1.9.0", - "@xtuc/long": "4.2.2" - }, - "deprecated": false, - "description": "WebAssembly text format parser", - "devDependencies": { - "@webassemblyjs/helper-test-framework": "1.9.0", - "mamacro": "^0.0.7" - }, - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "keywords": [ - "webassembly", - "javascript", - "ast", - "parser", - "wat", - "wast" - ], - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/wast-parser", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "scripts": { - "test": "mocha" - }, - "version": "1.9.0" -} diff --git a/node_modules/@webassemblyjs/wast-printer/LICENSE b/node_modules/@webassemblyjs/wast-printer/LICENSE deleted file mode 100644 index 87e7e1f..0000000 --- a/node_modules/@webassemblyjs/wast-printer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Sven Sauleau <sven@sauleau.com> - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/node_modules/@webassemblyjs/wast-printer/README.md b/node_modules/@webassemblyjs/wast-printer/README.md deleted file mode 100644 index ed4cd4e..0000000 --- a/node_modules/@webassemblyjs/wast-printer/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# @webassemblyjs/wast-parser - -> WebAssembly text format printer - -## Installation - -```sh -yarn add @webassemblyjs/wast-printer -``` - -## Usage - -```js -import { print } from "@webassemblyjs/wast-printer" - -console.log(print(ast)); -``` diff --git a/node_modules/@webassemblyjs/wast-printer/esm/index.js b/node_modules/@webassemblyjs/wast-printer/esm/index.js deleted file mode 100644 index 398e86f..0000000 --- a/node_modules/@webassemblyjs/wast-printer/esm/index.js +++ /dev/null @@ -1,900 +0,0 @@ -function _typeof(obj) { 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); } - -function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - -function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } } - -import { isAnonymous, isInstruction } from "@webassemblyjs/ast"; -import Long from "@xtuc/long"; -var compact = false; -var space = " "; - -var quote = function quote(str) { - return "\"".concat(str, "\""); -}; - -function indent(nb) { - return Array(nb).fill(space + space).join(""); -} // TODO(sven): allow arbitrary ast nodes - - -export function print(n) { - if (n.type === "Program") { - return printProgram(n, 0); - } else { - throw new Error("Unsupported node in print of type: " + String(n.type)); - } -} - -function printProgram(n, depth) { - return n.body.reduce(function (acc, child) { - if (child.type === "Module") { - acc += printModule(child, depth + 1); - } - - if (child.type === "Func") { - acc += printFunc(child, depth + 1); - } - - if (child.type === "BlockComment") { - acc += printBlockComment(child); - } - - if (child.type === "LeadingComment") { - acc += printLeadingComment(child); - } - - if (compact === false) { - acc += "\n"; - } - - return acc; - }, ""); -} - -function printTypeInstruction(n) { - var out = ""; - out += "("; - out += "type"; - out += space; - - if (n.id != null) { - out += printIndex(n.id); - out += space; - } - - out += "("; - out += "func"; - n.functype.params.forEach(function (param) { - out += space; - out += "("; - out += "param"; - out += space; - out += printFuncParam(param); - out += ")"; - }); - n.functype.results.forEach(function (result) { - out += space; - out += "("; - out += "result"; - out += space; - out += result; - out += ")"; - }); - out += ")"; // func - - out += ")"; - return out; -} - -function printModule(n, depth) { - var out = "("; - out += "module"; - - if (typeof n.id === "string") { - out += space; - out += n.id; - } - - if (compact === false) { - out += "\n"; - } else { - out += space; - } - - n.fields.forEach(function (field) { - if (compact === false) { - out += indent(depth); - } - - switch (field.type) { - case "Func": - { - out += printFunc(field, depth + 1); - break; - } - - case "TypeInstruction": - { - out += printTypeInstruction(field); - break; - } - - case "Table": - { - out += printTable(field); - break; - } - - case "Global": - { - out += printGlobal(field, depth + 1); - break; - } - - case "ModuleExport": - { - out += printModuleExport(field); - break; - } - - case "ModuleImport": - { - out += printModuleImport(field); - break; - } - - case "Memory": - { - out += printMemory(field); - break; - } - - case "BlockComment": - { - out += printBlockComment(field); - break; - } - - case "LeadingComment": - { - out += printLeadingComment(field); - break; - } - - case "Start": - { - out += printStart(field); - break; - } - - case "Elem": - { - out += printElem(field, depth); - break; - } - - case "Data": - { - out += printData(field, depth); - break; - } - - default: - throw new Error("Unsupported node in printModule: " + String(field.type)); - } - - if (compact === false) { - out += "\n"; - } - }); - out += ")"; - return out; -} - -function printData(n, depth) { - var out = ""; - out += "("; - out += "data"; - out += space; - out += printIndex(n.memoryIndex); - out += space; - out += printInstruction(n.offset, depth); - out += space; - out += '"'; - n.init.values.forEach(function (byte) { - // Avoid non-displayable characters - if (byte <= 31 || byte == 34 || byte == 92 || byte >= 127) { - out += "\\"; - out += ("00" + byte.toString(16)).substr(-2); - } else if (byte > 255) { - throw new Error("Unsupported byte in data segment: " + byte); - } else { - out += String.fromCharCode(byte); - } - }); - out += '"'; - out += ")"; - return out; -} - -function printElem(n, depth) { - var out = ""; - out += "("; - out += "elem"; - out += space; - out += printIndex(n.table); - - var _n$offset = _slicedToArray(n.offset, 1), - firstOffset = _n$offset[0]; - - out += space; - out += "("; - out += "offset"; - out += space; - out += printInstruction(firstOffset, depth); - out += ")"; - n.funcs.forEach(function (func) { - out += space; - out += printIndex(func); - }); - out += ")"; - return out; -} - -function printStart(n) { - var out = ""; - out += "("; - out += "start"; - out += space; - out += printIndex(n.index); - out += ")"; - return out; -} - -function printLeadingComment(n) { - // Don't print leading comments in compact mode - if (compact === true) { - return ""; - } - - var out = ""; - out += ";;"; - out += n.value; - out += "\n"; - return out; -} - -function printBlockComment(n) { - // Don't print block comments in compact mode - if (compact === true) { - return ""; - } - - var out = ""; - out += "(;"; - out += n.value; - out += ";)"; - out += "\n"; - return out; -} - -function printSignature(n) { - var out = ""; - n.params.forEach(function (param) { - out += space; - out += "("; - out += "param"; - out += space; - out += printFuncParam(param); - out += ")"; - }); - n.results.forEach(function (result) { - out += space; - out += "("; - out += "result"; - out += space; - out += result; - out += ")"; - }); - return out; -} - -function printModuleImportDescr(n) { - var out = ""; - - if (n.type === "FuncImportDescr") { - out += "("; - out += "func"; - - if (isAnonymous(n.id) === false) { - out += space; - out += printIdentifier(n.id); - } - - out += printSignature(n.signature); - out += ")"; - } - - if (n.type === "GlobalType") { - out += "("; - out += "global"; - out += space; - out += printGlobalType(n); - out += ")"; - } - - if (n.type === "Table") { - out += printTable(n); - } - - return out; -} - -function printModuleImport(n) { - var out = ""; - out += "("; - out += "import"; - out += space; - out += quote(n.module); - out += space; - out += quote(n.name); - out += space; - out += printModuleImportDescr(n.descr); - out += ")"; - return out; -} - -function printGlobalType(n) { - var out = ""; - - if (n.mutability === "var") { - out += "("; - out += "mut"; - out += space; - out += n.valtype; - out += ")"; - } else { - out += n.valtype; - } - - return out; -} - -function printGlobal(n, depth) { - var out = ""; - out += "("; - out += "global"; - out += space; - - if (n.name != null && isAnonymous(n.name) === false) { - out += printIdentifier(n.name); - out += space; - } - - out += printGlobalType(n.globalType); - out += space; - n.init.forEach(function (i) { - out += printInstruction(i, depth + 1); - }); - out += ")"; - return out; -} - -function printTable(n) { - var out = ""; - out += "("; - out += "table"; - out += space; - - if (n.name != null && isAnonymous(n.name) === false) { - out += printIdentifier(n.name); - out += space; - } - - out += printLimit(n.limits); - out += space; - out += n.elementType; - out += ")"; - return out; -} - -function printFuncParam(n) { - var out = ""; - - if (typeof n.id === "string") { - out += "$" + n.id; - out += space; - } - - out += n.valtype; - return out; -} - -function printFunc(n, depth) { - var out = ""; - out += "("; - out += "func"; - - if (n.name != null) { - if (n.name.type === "Identifier" && isAnonymous(n.name) === false) { - out += space; - out += printIdentifier(n.name); - } - } - - if (n.signature.type === "Signature") { - out += printSignature(n.signature); - } else { - var index = n.signature; - out += space; - out += "("; - out += "type"; - out += space; - out += printIndex(index); - out += ")"; - } - - if (n.body.length > 0) { - // func is empty since we ignore the default end instruction - if (n.body.length === 1 && n.body[0].id === "end") { - out += ")"; - return out; - } - - if (compact === false) { - out += "\n"; - } - - n.body.forEach(function (i) { - if (i.id !== "end") { - out += indent(depth); - out += printInstruction(i, depth); - - if (compact === false) { - out += "\n"; - } - } - }); - out += indent(depth - 1) + ")"; - } else { - out += ")"; - } - - return out; -} - -function printInstruction(n, depth) { - switch (n.type) { - case "Instr": - // $FlowIgnore - return printGenericInstruction(n, depth + 1); - - case "BlockInstruction": - // $FlowIgnore - return printBlockInstruction(n, depth + 1); - - case "IfInstruction": - // $FlowIgnore - return printIfInstruction(n, depth + 1); - - case "CallInstruction": - // $FlowIgnore - return printCallInstruction(n, depth + 1); - - case "CallIndirectInstruction": - // $FlowIgnore - return printCallIndirectIntruction(n, depth + 1); - - case "LoopInstruction": - // $FlowIgnore - return printLoopInstruction(n, depth + 1); - - default: - throw new Error("Unsupported instruction: " + JSON.stringify(n.type)); - } -} - -function printCallIndirectIntruction(n, depth) { - var out = ""; - out += "("; - out += "call_indirect"; - - if (n.signature.type === "Signature") { - out += printSignature(n.signature); - } else if (n.signature.type === "Identifier") { - out += space; - out += "("; - out += "type"; - out += space; - out += printIdentifier(n.signature); - out += ")"; - } else { - throw new Error("CallIndirectInstruction: unsupported signature " + JSON.stringify(n.signature.type)); - } - - out += space; - - if (n.intrs != null) { - // $FlowIgnore - n.intrs.forEach(function (i, index) { - // $FlowIgnore - out += printInstruction(i, depth + 1); // $FlowIgnore - - if (index !== n.intrs.length - 1) { - out += space; - } - }); - } - - out += ")"; - return out; -} - -function printLoopInstruction(n, depth) { - var out = ""; - out += "("; - out += "loop"; - - if (n.label != null && isAnonymous(n.label) === false) { - out += space; - out += printIdentifier(n.label); - } - - if (typeof n.resulttype === "string") { - out += space; - out += "("; - out += "result"; - out += space; - out += n.resulttype; - out += ")"; - } - - if (n.instr.length > 0) { - n.instr.forEach(function (e) { - if (compact === false) { - out += "\n"; - } - - out += indent(depth); - out += printInstruction(e, depth + 1); - }); - - if (compact === false) { - out += "\n"; - out += indent(depth - 1); - } - } - - out += ")"; - return out; -} - -function printCallInstruction(n, depth) { - var out = ""; - out += "("; - out += "call"; - out += space; - out += printIndex(n.index); - - if (_typeof(n.instrArgs) === "object") { - // $FlowIgnore - n.instrArgs.forEach(function (arg) { - out += space; - out += printFuncInstructionArg(arg, depth + 1); - }); - } - - out += ")"; - return out; -} - -function printIfInstruction(n, depth) { - var out = ""; - out += "("; - out += "if"; - - if (n.testLabel != null && isAnonymous(n.testLabel) === false) { - out += space; - out += printIdentifier(n.testLabel); - } - - if (typeof n.result === "string") { - out += space; - out += "("; - out += "result"; - out += space; - out += n.result; - out += ")"; - } - - if (n.test.length > 0) { - out += space; - n.test.forEach(function (i) { - out += printInstruction(i, depth + 1); - }); - } - - if (n.consequent.length > 0) { - if (compact === false) { - out += "\n"; - } - - out += indent(depth); - out += "("; - out += "then"; - depth++; - n.consequent.forEach(function (i) { - if (compact === false) { - out += "\n"; - } - - out += indent(depth); - out += printInstruction(i, depth + 1); - }); - depth--; - - if (compact === false) { - out += "\n"; - out += indent(depth); - } - - out += ")"; - } else { - if (compact === false) { - out += "\n"; - out += indent(depth); - } - - out += "("; - out += "then"; - out += ")"; - } - - if (n.alternate.length > 0) { - if (compact === false) { - out += "\n"; - } - - out += indent(depth); - out += "("; - out += "else"; - depth++; - n.alternate.forEach(function (i) { - if (compact === false) { - out += "\n"; - } - - out += indent(depth); - out += printInstruction(i, depth + 1); - }); - depth--; - - if (compact === false) { - out += "\n"; - out += indent(depth); - } - - out += ")"; - } else { - if (compact === false) { - out += "\n"; - out += indent(depth); - } - - out += "("; - out += "else"; - out += ")"; - } - - if (compact === false) { - out += "\n"; - out += indent(depth - 1); - } - - out += ")"; - return out; -} - -function printBlockInstruction(n, depth) { - var out = ""; - out += "("; - out += "block"; - - if (n.label != null && isAnonymous(n.label) === false) { - out += space; - out += printIdentifier(n.label); - } - - if (typeof n.result === "string") { - out += space; - out += "("; - out += "result"; - out += space; - out += n.result; - out += ")"; - } - - if (n.instr.length > 0) { - n.instr.forEach(function (i) { - if (compact === false) { - out += "\n"; - } - - out += indent(depth); - out += printInstruction(i, depth + 1); - }); - - if (compact === false) { - out += "\n"; - } - - out += indent(depth - 1); - out += ")"; - } else { - out += ")"; - } - - return out; -} - -function printGenericInstruction(n, depth) { - var out = ""; - out += "("; - - if (typeof n.object === "string") { - out += n.object; - out += "."; - } - - out += n.id; - n.args.forEach(function (arg) { - out += space; - out += printFuncInstructionArg(arg, depth + 1); - }); - out += ")"; - return out; -} - -function printLongNumberLiteral(n) { - if (typeof n.raw === "string") { - return n.raw; - } - - var _n$value = n.value, - low = _n$value.low, - high = _n$value.high; - var v = new Long(low, high); - return v.toString(); -} - -function printFloatLiteral(n) { - if (typeof n.raw === "string") { - return n.raw; - } - - return String(n.value); -} - -function printFuncInstructionArg(n, depth) { - var out = ""; - - if (n.type === "NumberLiteral") { - out += printNumberLiteral(n); - } - - if (n.type === "LongNumberLiteral") { - out += printLongNumberLiteral(n); - } - - if (n.type === "Identifier" && isAnonymous(n) === false) { - out += printIdentifier(n); - } - - if (n.type === "ValtypeLiteral") { - out += n.name; - } - - if (n.type === "FloatLiteral") { - out += printFloatLiteral(n); - } - - if (isInstruction(n)) { - out += printInstruction(n, depth + 1); - } - - return out; -} - -function printNumberLiteral(n) { - if (typeof n.raw === "string") { - return n.raw; - } - - return String(n.value); -} - -function printModuleExport(n) { - var out = ""; - out += "("; - out += "export"; - out += space; - out += quote(n.name); - - if (n.descr.exportType === "Func") { - out += space; - out += "("; - out += "func"; - out += space; - out += printIndex(n.descr.id); - out += ")"; - } else if (n.descr.exportType === "Global") { - out += space; - out += "("; - out += "global"; - out += space; - out += printIndex(n.descr.id); - out += ")"; - } else if (n.descr.exportType === "Memory" || n.descr.exportType === "Mem") { - out += space; - out += "("; - out += "memory"; - out += space; - out += printIndex(n.descr.id); - out += ")"; - } else if (n.descr.exportType === "Table") { - out += space; - out += "("; - out += "table"; - out += space; - out += printIndex(n.descr.id); - out += ")"; - } else { - throw new Error("printModuleExport: unknown type: " + n.descr.exportType); - } - - out += ")"; - return out; -} - -function printIdentifier(n) { - return "$" + n.value; -} - -function printIndex(n) { - if (n.type === "Identifier") { - return printIdentifier(n); - } else if (n.type === "NumberLiteral") { - return printNumberLiteral(n); - } else { - throw new Error("Unsupported index: " + n.type); - } -} - -function printMemory(n) { - var out = ""; - out += "("; - out += "memory"; - - if (n.id != null) { - out += space; - out += printIndex(n.id); - out += space; - } - - out += printLimit(n.limits); - out += ")"; - return out; -} - -function printLimit(n) { - var out = ""; - out += n.min + ""; - - if (n.max != null) { - out += space; - out += String(n.max); - } - - return out; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wast-printer/lib/index.js b/node_modules/@webassemblyjs/wast-printer/lib/index.js deleted file mode 100644 index 03be8ca..0000000 --- a/node_modules/@webassemblyjs/wast-printer/lib/index.js +++ /dev/null @@ -1,911 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.print = print; - -var _ast = require("@webassemblyjs/ast"); - -var _long = _interopRequireDefault(require("@xtuc/long")); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function _typeof(obj) { 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); } - -function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } - -function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } } - -var compact = false; -var space = " "; - -var quote = function quote(str) { - return "\"".concat(str, "\""); -}; - -function indent(nb) { - return Array(nb).fill(space + space).join(""); -} // TODO(sven): allow arbitrary ast nodes - - -function print(n) { - if (n.type === "Program") { - return printProgram(n, 0); - } else { - throw new Error("Unsupported node in print of type: " + String(n.type)); - } -} - -function printProgram(n, depth) { - return n.body.reduce(function (acc, child) { - if (child.type === "Module") { - acc += printModule(child, depth + 1); - } - - if (child.type === "Func") { - acc += printFunc(child, depth + 1); - } - - if (child.type === "BlockComment") { - acc += printBlockComment(child); - } - - if (child.type === "LeadingComment") { - acc += printLeadingComment(child); - } - - if (compact === false) { - acc += "\n"; - } - - return acc; - }, ""); -} - -function printTypeInstruction(n) { - var out = ""; - out += "("; - out += "type"; - out += space; - - if (n.id != null) { - out += printIndex(n.id); - out += space; - } - - out += "("; - out += "func"; - n.functype.params.forEach(function (param) { - out += space; - out += "("; - out += "param"; - out += space; - out += printFuncParam(param); - out += ")"; - }); - n.functype.results.forEach(function (result) { - out += space; - out += "("; - out += "result"; - out += space; - out += result; - out += ")"; - }); - out += ")"; // func - - out += ")"; - return out; -} - -function printModule(n, depth) { - var out = "("; - out += "module"; - - if (typeof n.id === "string") { - out += space; - out += n.id; - } - - if (compact === false) { - out += "\n"; - } else { - out += space; - } - - n.fields.forEach(function (field) { - if (compact === false) { - out += indent(depth); - } - - switch (field.type) { - case "Func": - { - out += printFunc(field, depth + 1); - break; - } - - case "TypeInstruction": - { - out += printTypeInstruction(field); - break; - } - - case "Table": - { - out += printTable(field); - break; - } - - case "Global": - { - out += printGlobal(field, depth + 1); - break; - } - - case "ModuleExport": - { - out += printModuleExport(field); - break; - } - - case "ModuleImport": - { - out += printModuleImport(field); - break; - } - - case "Memory": - { - out += printMemory(field); - break; - } - - case "BlockComment": - { - out += printBlockComment(field); - break; - } - - case "LeadingComment": - { - out += printLeadingComment(field); - break; - } - - case "Start": - { - out += printStart(field); - break; - } - - case "Elem": - { - out += printElem(field, depth); - break; - } - - case "Data": - { - out += printData(field, depth); - break; - } - - default: - throw new Error("Unsupported node in printModule: " + String(field.type)); - } - - if (compact === false) { - out += "\n"; - } - }); - out += ")"; - return out; -} - -function printData(n, depth) { - var out = ""; - out += "("; - out += "data"; - out += space; - out += printIndex(n.memoryIndex); - out += space; - out += printInstruction(n.offset, depth); - out += space; - out += '"'; - n.init.values.forEach(function (byte) { - // Avoid non-displayable characters - if (byte <= 31 || byte == 34 || byte == 92 || byte >= 127) { - out += "\\"; - out += ("00" + byte.toString(16)).substr(-2); - } else if (byte > 255) { - throw new Error("Unsupported byte in data segment: " + byte); - } else { - out += String.fromCharCode(byte); - } - }); - out += '"'; - out += ")"; - return out; -} - -function printElem(n, depth) { - var out = ""; - out += "("; - out += "elem"; - out += space; - out += printIndex(n.table); - - var _n$offset = _slicedToArray(n.offset, 1), - firstOffset = _n$offset[0]; - - out += space; - out += "("; - out += "offset"; - out += space; - out += printInstruction(firstOffset, depth); - out += ")"; - n.funcs.forEach(function (func) { - out += space; - out += printIndex(func); - }); - out += ")"; - return out; -} - -function printStart(n) { - var out = ""; - out += "("; - out += "start"; - out += space; - out += printIndex(n.index); - out += ")"; - return out; -} - -function printLeadingComment(n) { - // Don't print leading comments in compact mode - if (compact === true) { - return ""; - } - - var out = ""; - out += ";;"; - out += n.value; - out += "\n"; - return out; -} - -function printBlockComment(n) { - // Don't print block comments in compact mode - if (compact === true) { - return ""; - } - - var out = ""; - out += "(;"; - out += n.value; - out += ";)"; - out += "\n"; - return out; -} - -function printSignature(n) { - var out = ""; - n.params.forEach(function (param) { - out += space; - out += "("; - out += "param"; - out += space; - out += printFuncParam(param); - out += ")"; - }); - n.results.forEach(function (result) { - out += space; - out += "("; - out += "result"; - out += space; - out += result; - out += ")"; - }); - return out; -} - -function printModuleImportDescr(n) { - var out = ""; - - if (n.type === "FuncImportDescr") { - out += "("; - out += "func"; - - if ((0, _ast.isAnonymous)(n.id) === false) { - out += space; - out += printIdentifier(n.id); - } - - out += printSignature(n.signature); - out += ")"; - } - - if (n.type === "GlobalType") { - out += "("; - out += "global"; - out += space; - out += printGlobalType(n); - out += ")"; - } - - if (n.type === "Table") { - out += printTable(n); - } - - return out; -} - -function printModuleImport(n) { - var out = ""; - out += "("; - out += "import"; - out += space; - out += quote(n.module); - out += space; - out += quote(n.name); - out += space; - out += printModuleImportDescr(n.descr); - out += ")"; - return out; -} - -function printGlobalType(n) { - var out = ""; - - if (n.mutability === "var") { - out += "("; - out += "mut"; - out += space; - out += n.valtype; - out += ")"; - } else { - out += n.valtype; - } - - return out; -} - -function printGlobal(n, depth) { - var out = ""; - out += "("; - out += "global"; - out += space; - - if (n.name != null && (0, _ast.isAnonymous)(n.name) === false) { - out += printIdentifier(n.name); - out += space; - } - - out += printGlobalType(n.globalType); - out += space; - n.init.forEach(function (i) { - out += printInstruction(i, depth + 1); - }); - out += ")"; - return out; -} - -function printTable(n) { - var out = ""; - out += "("; - out += "table"; - out += space; - - if (n.name != null && (0, _ast.isAnonymous)(n.name) === false) { - out += printIdentifier(n.name); - out += space; - } - - out += printLimit(n.limits); - out += space; - out += n.elementType; - out += ")"; - return out; -} - -function printFuncParam(n) { - var out = ""; - - if (typeof n.id === "string") { - out += "$" + n.id; - out += space; - } - - out += n.valtype; - return out; -} - -function printFunc(n, depth) { - var out = ""; - out += "("; - out += "func"; - - if (n.name != null) { - if (n.name.type === "Identifier" && (0, _ast.isAnonymous)(n.name) === false) { - out += space; - out += printIdentifier(n.name); - } - } - - if (n.signature.type === "Signature") { - out += printSignature(n.signature); - } else { - var index = n.signature; - out += space; - out += "("; - out += "type"; - out += space; - out += printIndex(index); - out += ")"; - } - - if (n.body.length > 0) { - // func is empty since we ignore the default end instruction - if (n.body.length === 1 && n.body[0].id === "end") { - out += ")"; - return out; - } - - if (compact === false) { - out += "\n"; - } - - n.body.forEach(function (i) { - if (i.id !== "end") { - out += indent(depth); - out += printInstruction(i, depth); - - if (compact === false) { - out += "\n"; - } - } - }); - out += indent(depth - 1) + ")"; - } else { - out += ")"; - } - - return out; -} - -function printInstruction(n, depth) { - switch (n.type) { - case "Instr": - // $FlowIgnore - return printGenericInstruction(n, depth + 1); - - case "BlockInstruction": - // $FlowIgnore - return printBlockInstruction(n, depth + 1); - - case "IfInstruction": - // $FlowIgnore - return printIfInstruction(n, depth + 1); - - case "CallInstruction": - // $FlowIgnore - return printCallInstruction(n, depth + 1); - - case "CallIndirectInstruction": - // $FlowIgnore - return printCallIndirectIntruction(n, depth + 1); - - case "LoopInstruction": - // $FlowIgnore - return printLoopInstruction(n, depth + 1); - - default: - throw new Error("Unsupported instruction: " + JSON.stringify(n.type)); - } -} - -function printCallIndirectIntruction(n, depth) { - var out = ""; - out += "("; - out += "call_indirect"; - - if (n.signature.type === "Signature") { - out += printSignature(n.signature); - } else if (n.signature.type === "Identifier") { - out += space; - out += "("; - out += "type"; - out += space; - out += printIdentifier(n.signature); - out += ")"; - } else { - throw new Error("CallIndirectInstruction: unsupported signature " + JSON.stringify(n.signature.type)); - } - - out += space; - - if (n.intrs != null) { - // $FlowIgnore - n.intrs.forEach(function (i, index) { - // $FlowIgnore - out += printInstruction(i, depth + 1); // $FlowIgnore - - if (index !== n.intrs.length - 1) { - out += space; - } - }); - } - - out += ")"; - return out; -} - -function printLoopInstruction(n, depth) { - var out = ""; - out += "("; - out += "loop"; - - if (n.label != null && (0, _ast.isAnonymous)(n.label) === false) { - out += space; - out += printIdentifier(n.label); - } - - if (typeof n.resulttype === "string") { - out += space; - out += "("; - out += "result"; - out += space; - out += n.resulttype; - out += ")"; - } - - if (n.instr.length > 0) { - n.instr.forEach(function (e) { - if (compact === false) { - out += "\n"; - } - - out += indent(depth); - out += printInstruction(e, depth + 1); - }); - - if (compact === false) { - out += "\n"; - out += indent(depth - 1); - } - } - - out += ")"; - return out; -} - -function printCallInstruction(n, depth) { - var out = ""; - out += "("; - out += "call"; - out += space; - out += printIndex(n.index); - - if (_typeof(n.instrArgs) === "object") { - // $FlowIgnore - n.instrArgs.forEach(function (arg) { - out += space; - out += printFuncInstructionArg(arg, depth + 1); - }); - } - - out += ")"; - return out; -} - -function printIfInstruction(n, depth) { - var out = ""; - out += "("; - out += "if"; - - if (n.testLabel != null && (0, _ast.isAnonymous)(n.testLabel) === false) { - out += space; - out += printIdentifier(n.testLabel); - } - - if (typeof n.result === "string") { - out += space; - out += "("; - out += "result"; - out += space; - out += n.result; - out += ")"; - } - - if (n.test.length > 0) { - out += space; - n.test.forEach(function (i) { - out += printInstruction(i, depth + 1); - }); - } - - if (n.consequent.length > 0) { - if (compact === false) { - out += "\n"; - } - - out += indent(depth); - out += "("; - out += "then"; - depth++; - n.consequent.forEach(function (i) { - if (compact === false) { - out += "\n"; - } - - out += indent(depth); - out += printInstruction(i, depth + 1); - }); - depth--; - - if (compact === false) { - out += "\n"; - out += indent(depth); - } - - out += ")"; - } else { - if (compact === false) { - out += "\n"; - out += indent(depth); - } - - out += "("; - out += "then"; - out += ")"; - } - - if (n.alternate.length > 0) { - if (compact === false) { - out += "\n"; - } - - out += indent(depth); - out += "("; - out += "else"; - depth++; - n.alternate.forEach(function (i) { - if (compact === false) { - out += "\n"; - } - - out += indent(depth); - out += printInstruction(i, depth + 1); - }); - depth--; - - if (compact === false) { - out += "\n"; - out += indent(depth); - } - - out += ")"; - } else { - if (compact === false) { - out += "\n"; - out += indent(depth); - } - - out += "("; - out += "else"; - out += ")"; - } - - if (compact === false) { - out += "\n"; - out += indent(depth - 1); - } - - out += ")"; - return out; -} - -function printBlockInstruction(n, depth) { - var out = ""; - out += "("; - out += "block"; - - if (n.label != null && (0, _ast.isAnonymous)(n.label) === false) { - out += space; - out += printIdentifier(n.label); - } - - if (typeof n.result === "string") { - out += space; - out += "("; - out += "result"; - out += space; - out += n.result; - out += ")"; - } - - if (n.instr.length > 0) { - n.instr.forEach(function (i) { - if (compact === false) { - out += "\n"; - } - - out += indent(depth); - out += printInstruction(i, depth + 1); - }); - - if (compact === false) { - out += "\n"; - } - - out += indent(depth - 1); - out += ")"; - } else { - out += ")"; - } - - return out; -} - -function printGenericInstruction(n, depth) { - var out = ""; - out += "("; - - if (typeof n.object === "string") { - out += n.object; - out += "."; - } - - out += n.id; - n.args.forEach(function (arg) { - out += space; - out += printFuncInstructionArg(arg, depth + 1); - }); - out += ")"; - return out; -} - -function printLongNumberLiteral(n) { - if (typeof n.raw === "string") { - return n.raw; - } - - var _n$value = n.value, - low = _n$value.low, - high = _n$value.high; - var v = new _long.default(low, high); - return v.toString(); -} - -function printFloatLiteral(n) { - if (typeof n.raw === "string") { - return n.raw; - } - - return String(n.value); -} - -function printFuncInstructionArg(n, depth) { - var out = ""; - - if (n.type === "NumberLiteral") { - out += printNumberLiteral(n); - } - - if (n.type === "LongNumberLiteral") { - out += printLongNumberLiteral(n); - } - - if (n.type === "Identifier" && (0, _ast.isAnonymous)(n) === false) { - out += printIdentifier(n); - } - - if (n.type === "ValtypeLiteral") { - out += n.name; - } - - if (n.type === "FloatLiteral") { - out += printFloatLiteral(n); - } - - if ((0, _ast.isInstruction)(n)) { - out += printInstruction(n, depth + 1); - } - - return out; -} - -function printNumberLiteral(n) { - if (typeof n.raw === "string") { - return n.raw; - } - - return String(n.value); -} - -function printModuleExport(n) { - var out = ""; - out += "("; - out += "export"; - out += space; - out += quote(n.name); - - if (n.descr.exportType === "Func") { - out += space; - out += "("; - out += "func"; - out += space; - out += printIndex(n.descr.id); - out += ")"; - } else if (n.descr.exportType === "Global") { - out += space; - out += "("; - out += "global"; - out += space; - out += printIndex(n.descr.id); - out += ")"; - } else if (n.descr.exportType === "Memory" || n.descr.exportType === "Mem") { - out += space; - out += "("; - out += "memory"; - out += space; - out += printIndex(n.descr.id); - out += ")"; - } else if (n.descr.exportType === "Table") { - out += space; - out += "("; - out += "table"; - out += space; - out += printIndex(n.descr.id); - out += ")"; - } else { - throw new Error("printModuleExport: unknown type: " + n.descr.exportType); - } - - out += ")"; - return out; -} - -function printIdentifier(n) { - return "$" + n.value; -} - -function printIndex(n) { - if (n.type === "Identifier") { - return printIdentifier(n); - } else if (n.type === "NumberLiteral") { - return printNumberLiteral(n); - } else { - throw new Error("Unsupported index: " + n.type); - } -} - -function printMemory(n) { - var out = ""; - out += "("; - out += "memory"; - - if (n.id != null) { - out += space; - out += printIndex(n.id); - out += space; - } - - out += printLimit(n.limits); - out += ")"; - return out; -} - -function printLimit(n) { - var out = ""; - out += n.min + ""; - - if (n.max != null) { - out += space; - out += String(n.max); - } - - return out; -}
\ No newline at end of file diff --git a/node_modules/@webassemblyjs/wast-printer/package.json b/node_modules/@webassemblyjs/wast-printer/package.json deleted file mode 100644 index 68195dd..0000000 --- a/node_modules/@webassemblyjs/wast-printer/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "_from": "@webassemblyjs/wast-printer@1.9.0", - "_id": "@webassemblyjs/wast-printer@1.9.0", - "_inBundle": false, - "_integrity": "sha512-2J0nE95rHXHyQ24cWjMKJ1tqB/ds8z/cyeOZxJhcb+rW+SQASVjuznUSmdz5GpVJTzU8JkhYut0D3siFDD6wsA==", - "_location": "/@webassemblyjs/wast-printer", - "_phantomChildren": {}, - "_requested": { - "type": "version", - "registry": true, - "raw": "@webassemblyjs/wast-printer@1.9.0", - "name": "@webassemblyjs/wast-printer", - "escapedName": "@webassemblyjs%2fwast-printer", - "scope": "@webassemblyjs", - "rawSpec": "1.9.0", - "saveSpec": null, - "fetchSpec": "1.9.0" - }, - "_requiredBy": [ - "/@webassemblyjs/helper-code-frame", - "/@webassemblyjs/wasm-edit" - ], - "_resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.9.0.tgz", - "_shasum": "4935d54c85fef637b00ce9f52377451d00d47899", - "_spec": "@webassemblyjs/wast-printer@1.9.0", - "_where": "/home/pruss/Dev/3-minute-website/node_modules/@webassemblyjs/helper-code-frame", - "author": { - "name": "Sven Sauleau" - }, - "bugs": { - "url": "https://github.com/xtuc/webassemblyjs/issues" - }, - "bundleDependencies": false, - "dependencies": { - "@webassemblyjs/ast": "1.9.0", - "@webassemblyjs/wast-parser": "1.9.0", - "@xtuc/long": "4.2.2" - }, - "deprecated": false, - "description": "WebAssembly text format printer", - "devDependencies": { - "@webassemblyjs/helper-test-framework": "1.9.0" - }, - "gitHead": "0440b420888c1f7701eb9762ec657775506b87d8", - "homepage": "https://github.com/xtuc/webassemblyjs#readme", - "keywords": [ - "webassembly", - "javascript", - "ast", - "compiler", - "printer", - "wast" - ], - "license": "MIT", - "main": "lib/index.js", - "module": "esm/index.js", - "name": "@webassemblyjs/wast-printer", - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/xtuc/webassemblyjs.git" - }, - "scripts": { - "test": "mocha" - }, - "version": "1.9.0" -} |