aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@webassemblyjs/wasm-gen
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/@webassemblyjs/wasm-gen
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/@webassemblyjs/wasm-gen')
-rw-r--r--node_modules/@webassemblyjs/wasm-gen/LICENSE21
-rw-r--r--node_modules/@webassemblyjs/wasm-gen/esm/encoder/index.js303
-rw-r--r--node_modules/@webassemblyjs/wasm-gen/esm/index.js51
-rw-r--r--node_modules/@webassemblyjs/wasm-gen/lib/encoder/index.js359
-rw-r--r--node_modules/@webassemblyjs/wasm-gen/lib/index.js64
-rw-r--r--node_modules/@webassemblyjs/wasm-gen/package.json27
-rw-r--r--node_modules/@webassemblyjs/wasm-gen/webassemblyjs-wasm-gen-1.7.10.tgzbin0 -> 4187 bytes
7 files changed, 825 insertions, 0 deletions
diff --git a/node_modules/@webassemblyjs/wasm-gen/LICENSE b/node_modules/@webassemblyjs/wasm-gen/LICENSE
new file mode 100644
index 00000000..87e7e1ff
--- /dev/null
+++ b/node_modules/@webassemblyjs/wasm-gen/LICENSE
@@ -0,0 +1,21 @@
+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
new file mode 100644
index 00000000..d5dcda71
--- /dev/null
+++ b/node_modules/@webassemblyjs/wasm-gen/esm/encoder/index.js
@@ -0,0 +1,303 @@
+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));
+ });
+ out.push(0x0b); // end
+
+ 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
new file mode 100644
index 00000000..83bc19fa
--- /dev/null
+++ b/node_modules/@webassemblyjs/wasm-gen/esm/index.js
@@ -0,0 +1,51 @@
+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
new file mode 100644
index 00000000..4ec1fbbb
--- /dev/null
+++ b/node_modules/@webassemblyjs/wasm-gen/lib/encoder/index.js
@@ -0,0 +1,359 @@
+"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));
+ });
+ out.push(0x0b); // end
+
+ 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
new file mode 100644
index 00000000..f5095b1c
--- /dev/null
+++ b/node_modules/@webassemblyjs/wasm-gen/lib/index.js
@@ -0,0 +1,64 @@
+"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
new file mode 100644
index 00000000..e30344a7
--- /dev/null
+++ b/node_modules/@webassemblyjs/wasm-gen/package.json
@@ -0,0 +1,27 @@
+{
+ "name": "@webassemblyjs/wasm-gen",
+ "version": "1.7.11",
+ "description": "WebAssembly binary format printer",
+ "main": "lib/index.js",
+ "module": "esm/index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/xtuc/webassemblyjs.git"
+ },
+ "publishConfig": {
+ "access": "public"
+ },
+ "author": "Sven Sauleau",
+ "license": "MIT",
+ "dependencies": {
+ "@webassemblyjs/ast": "1.7.11",
+ "@webassemblyjs/helper-wasm-bytecode": "1.7.11",
+ "@webassemblyjs/ieee754": "1.7.11",
+ "@webassemblyjs/leb128": "1.7.11",
+ "@webassemblyjs/utf8": "1.7.11"
+ },
+ "gitHead": "4291990bfc4648bc6676091a955d12dc3c7e5909"
+}
diff --git a/node_modules/@webassemblyjs/wasm-gen/webassemblyjs-wasm-gen-1.7.10.tgz b/node_modules/@webassemblyjs/wasm-gen/webassemblyjs-wasm-gen-1.7.10.tgz
new file mode 100644
index 00000000..737bc8f2
--- /dev/null
+++ b/node_modules/@webassemblyjs/wasm-gen/webassemblyjs-wasm-gen-1.7.10.tgz
Binary files differ