Socket
Socket
Sign inDemoInstall

@webassemblyjs/ast

Package Overview
Dependencies
12
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.5.6 to 1.5.7

58

lib/definitions.js

@@ -13,2 +13,3 @@ var definitions = {};

doc: "A module consists of a sequence of sections (termed fields in the text format).",
unionType: ["Node"],
fields: {

@@ -30,2 +31,3 @@ id: {

defineType("ModuleMetadata", {
unionType: ["Node"],
fields: {

@@ -49,2 +51,3 @@ sections: {

defineType("ModuleNameMetadata", {
unionType: ["Node"],
fields: {

@@ -57,2 +60,3 @@ value: {

defineType("FunctionNameMetadata", {
unionType: ["Node"],
fields: {

@@ -68,2 +72,3 @@ value: {

defineType("LocalNameMetadata", {
unionType: ["Node"],
fields: {

@@ -82,2 +87,3 @@ value: {

defineType("BinaryModule", {
unionType: ["Node"],
fields: {

@@ -95,2 +101,3 @@ id: {

defineType("QuoteModule", {
unionType: ["Node"],
fields: {

@@ -108,2 +115,3 @@ id: {

defineType("SectionMetadata", {
unionType: ["Node"],
fields: {

@@ -130,3 +138,3 @@ section: {

defineType("LoopInstruction", {
unionType: ["Block", "Instruction"],
unionType: ["Node", "Block", "Instruction"],
fields: {

@@ -153,3 +161,3 @@ id: {

defineType("Instr", {
unionType: ["Expression", "Instruction"],
unionType: ["Node", "Expression", "Instruction"],
fields: {

@@ -174,3 +182,3 @@ id: {

defineType("IfInstruction", {
unionType: ["Instruction"],
unionType: ["Node", "Instruction"],
fields: {

@@ -209,3 +217,3 @@ id: {

defineType("StringLiteral", {
unionType: ["Expression"],
unionType: ["Node", "Expression"],
fields: {

@@ -218,3 +226,3 @@ value: {

defineType("NumberLiteral", {
unionType: ["NumericLiteral", "Expression"],
unionType: ["Node", "NumericLiteral", "Expression"],
fields: {

@@ -230,3 +238,3 @@ value: {

defineType("LongNumberLiteral", {
unionType: ["NumericLiteral", "Expression"],
unionType: ["Node", "NumericLiteral", "Expression"],
fields: {

@@ -242,3 +250,3 @@ value: {

defineType("FloatLiteral", {
unionType: ["NumericLiteral", "Expression"],
unionType: ["Node", "NumericLiteral", "Expression"],
fields: {

@@ -262,2 +270,3 @@ value: {

defineType("Elem", {
unionType: ["Node"],
fields: {

@@ -278,2 +287,3 @@ table: {

defineType("IndexInFuncSection", {
unionType: ["Node"],
fields: {

@@ -286,3 +296,3 @@ index: {

defineType("ValtypeLiteral", {
unionType: ["Expression"],
unionType: ["Node", "Expression"],
fields: {

@@ -295,3 +305,3 @@ name: {

defineType("TypeInstruction", {
unionType: ["Instruction"],
unionType: ["Node", "Instruction"],
fields: {

@@ -308,2 +318,3 @@ id: {

defineType("Start", {
unionType: ["Node"],
fields: {

@@ -316,3 +327,3 @@ index: {

defineType("GlobalType", {
unionType: ["ImportDescr"],
unionType: ["Node", "ImportDescr"],
fields: {

@@ -328,2 +339,3 @@ valtype: {

defineType("LeadingComment", {
unionType: ["Node"],
fields: {

@@ -336,2 +348,3 @@ value: {

defineType("BlockComment", {
unionType: ["Node"],
fields: {

@@ -344,2 +357,3 @@ value: {

defineType("Data", {
unionType: ["Node"],
fields: {

@@ -358,2 +372,3 @@ memoryIndex: {

defineType("Global", {
unionType: ["Node"],
fields: {

@@ -374,3 +389,3 @@ globalType: {

defineType("Table", {
unionType: ["ImportDescr"],
unionType: ["Node", "ImportDescr"],
fields: {

@@ -395,3 +410,3 @@ elementType: {

defineType("Memory", {
unionType: ["ImportDescr"],
unionType: ["Node", "ImportDescr"],
fields: {

@@ -408,3 +423,3 @@ limits: {

defineType("FuncImportDescr", {
unionType: ["ImportDescr"],
unionType: ["Node", "ImportDescr"],
fields: {

@@ -420,2 +435,3 @@ id: {

defineType("ModuleImport", {
unionType: ["Node"],
fields: {

@@ -434,2 +450,3 @@ module: {

defineType("ModuleExportDescr", {
unionType: ["Node"],
fields: {

@@ -445,2 +462,3 @@ exportType: {

defineType("ModuleExport", {
unionType: ["Node"],
fields: {

@@ -456,2 +474,3 @@ name: {

defineType("Limit", {
unionType: ["Node"],
fields: {

@@ -468,2 +487,3 @@ min: {

defineType("Signature", {
unionType: ["Node"],
fields: {

@@ -481,2 +501,3 @@ params: {

defineType("Program", {
unionType: ["Node"],
fields: {

@@ -490,3 +511,3 @@ body: {

defineType("Identifier", {
unionType: ["Expression"],
unionType: ["Node", "Expression"],
fields: {

@@ -503,3 +524,3 @@ value: {

defineType("BlockInstruction", {
unionType: ["Block", "Instruction"],
unionType: ["Node", "Block", "Instruction"],
fields: {

@@ -526,3 +547,3 @@ id: {

defineType("CallInstruction", {
unionType: ["Instruction"],
unionType: ["Node", "Instruction"],
fields: {

@@ -545,3 +566,3 @@ id: {

defineType("CallIndirectInstruction", {
unionType: ["Instruction"],
unionType: ["Node", "Instruction"],
fields: {

@@ -564,2 +585,3 @@ id: {

defineType("ByteArray", {
unionType: ["Node"],
fields: {

@@ -573,3 +595,3 @@ values: {

defineType("Func", {
unionType: ["Block"],
unionType: ["Node", "Block"],
fields: {

@@ -576,0 +598,0 @@ name: {

@@ -16,3 +16,2 @@ "use strict";

traverse: true,
traverseWithHooks: true,
signatures: true,

@@ -85,8 +84,2 @@ getSectionMetadata: true,

});
Object.defineProperty(exports, "traverseWithHooks", {
enumerable: true,
get: function get() {
return _traverse.traverseWithHooks;
}
});
Object.defineProperty(exports, "signatures", {

@@ -93,0 +86,0 @@ enumerable: true,

@@ -46,3 +46,3 @@ "use strict";

exports.func = func;
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.assertSectionMetadata = exports.assertQuoteModule = exports.assertBinaryModule = exports.assertLocalNameMetadata = exports.assertFunctionNameMetadata = exports.assertModuleNameMetadata = exports.assertModuleMetadata = exports.assertModule = exports.isImportDescr = exports.isNumericLiteral = exports.isExpression = exports.isInstruction = exports.isBlock = 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.isSectionMetadata = exports.isQuoteModule = exports.isBinaryModule = exports.isLocalNameMetadata = exports.isFunctionNameMetadata = exports.isModuleNameMetadata = exports.isModuleMetadata = exports.isModule = void 0;
exports.nodeAndUnionTypes = exports.unionTypesMap = 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.assertSectionMetadata = exports.assertQuoteModule = exports.assertBinaryModule = exports.assertLocalNameMetadata = exports.assertFunctionNameMetadata = exports.assertModuleNameMetadata = exports.assertModuleMetadata = exports.assertModule = exports.isImportDescr = exports.isNumericLiteral = exports.isExpression = exports.isInstruction = exports.isBlock = exports.isNode = 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.isSectionMetadata = exports.isQuoteModule = exports.isBinaryModule = exports.isLocalNameMetadata = exports.isFunctionNameMetadata = exports.isModuleNameMetadata = exports.isModuleMetadata = exports.isModule = void 0;

@@ -815,2 +815,8 @@ var _mamacro = require("mamacro");

var isNode = function isNode(node) {
return isModule(node) || isModuleMetadata(node) || isModuleNameMetadata(node) || isFunctionNameMetadata(node) || isLocalNameMetadata(node) || isBinaryModule(node) || isQuoteModule(node) || isSectionMetadata(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);
};
exports.isNode = isNode;
var isBlock = function isBlock(node) {

@@ -924,2 +930,47 @@ return isLoopInstruction(node) || isBlockInstruction(node) || isFunc(node);

var assertFunc = assertTypeOf("Func");
exports.assertFunc = assertFunc;
exports.assertFunc = assertFunc;
var unionTypesMap = {
Module: ["Node"],
ModuleMetadata: ["Node"],
ModuleNameMetadata: ["Node"],
FunctionNameMetadata: ["Node"],
LocalNameMetadata: ["Node"],
BinaryModule: ["Node"],
QuoteModule: ["Node"],
SectionMetadata: ["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"]
};
exports.unionTypesMap = unionTypesMap;
var nodeAndUnionTypes = ["Module", "ModuleMetadata", "ModuleNameMetadata", "FunctionNameMetadata", "LocalNameMetadata", "BinaryModule", "QuoteModule", "SectionMetadata", "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", "Node", "Block", "Instruction", "Expression", "NumericLiteral", "ImportDescr"];
exports.nodeAndUnionTypes = nodeAndUnionTypes;

@@ -7,6 +7,11 @@ "use strict";

exports.traverse = traverse;
exports.traverseWithHooks = traverseWithHooks;
var debug = require("debug")("webassemblyjs:ast:traverse");
var _debug = _interopRequireDefault(require("debug"));
var _nodes = require("./nodes");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var debug = (0, _debug.default)("webassemblyjs:ast:traverse");
function removeNodeInBody(node, fromNode) {

@@ -119,17 +124,13 @@ switch (fromNode.type) {

var noop = function noop() {};
function traverse(n, visitors) {
var before = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop;
var after = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : noop;
var parentPath = null;
walk(n, function (type, path) {
if (typeof visitors["Node"] === "function") {
visitors["Node"](path);
Object.keys(visitors).forEach(function (visitor) {
if (!_nodes.nodeAndUnionTypes.includes(visitor)) {
throw new Error("Unexpected visitor ".concat(visitor));
}
if (typeof visitors[type] === "function") {
visitors[type](path);
}
}, parentPath);
}
function traverseWithHooks(n, visitors, before, after) {
var parentPath = null;
});
walk(n, function (type, path) {

@@ -141,3 +142,17 @@ if (typeof visitors[type] === "function") {

}
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);
}
});
}, parentPath);
}
{
"name": "@webassemblyjs/ast",
"version": "1.5.6",
"version": "1.5.7",
"description": "AST utils for webassemblyjs",

@@ -14,5 +14,5 @@ "keywords": [

"dependencies": {
"@webassemblyjs/helper-module-context": "1.5.6",
"@webassemblyjs/helper-wasm-bytecode": "1.5.6",
"@webassemblyjs/wast-parser": "1.5.6",
"@webassemblyjs/helper-module-context": "1.5.7",
"@webassemblyjs/helper-wasm-bytecode": "1.5.7",
"@webassemblyjs/wast-parser": "1.5.7",
"debug": "^3.1.0",

@@ -29,3 +29,3 @@ "mamacro": "^0.0.3"

"devDependencies": {
"@webassemblyjs/helper-test-framework": "1.5.6",
"@webassemblyjs/helper-test-framework": "1.5.7",
"array.prototype.flatmap": "^1.2.1",

@@ -32,0 +32,0 @@ "dump-exports": "^0.1.0"

@@ -15,2 +15,4 @@ const definitions = require("../src/definitions");

const quote = value => `"${value}"`;
function params(fields) {

@@ -182,4 +184,26 @@ const optionalDefault = field => (field.default ? ` = ${field.default}` : "");

});
// 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();

@@ -22,6 +22,3 @@ const definitions = require("../src/definitions");

// generate the union Node type
stdout.write(`type Node = ${Object.keys(definitions).join("|")}\n\n`);
// generate other union types
// generate union types
const unionTypes = unique(

@@ -44,3 +41,3 @@ flatMap(mapProps(definitions).filter(d => d.unionType), d => d.unionType)

stdout.write(`type ${typeDef.name} = {
...${typeDef.extends || "BaseNode"},
...BaseNode,
type: "${typeDef.name}",

@@ -47,0 +44,0 @@ ${params(typeDef.fields)}

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc