Socket
Socket
Sign inDemoInstall

@webassemblyjs/ast

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webassemblyjs/ast - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

29

lib/index.js

@@ -7,2 +7,4 @@ "use strict";

exports.signature = signature;
exports.functionNameMetadata = functionNameMetadata;
exports.moduleMetadata = moduleMetadata;
exports.identifier = identifier;

@@ -124,2 +126,23 @@ exports.valtype = valtype;

function functionNameMetadata(value, index) {
return {
type: "FunctionNameMetadata",
value: value,
index: index
};
}
function moduleMetadata(sections, functionNames) {
var n = {
type: "ModuleMetadata",
sections: sections
};
if (functionNames.length) {
n.functionNames = functionNames;
}
return n;
}
function identifier(value) {

@@ -296,3 +319,8 @@ return {

var type = "NumberLiteral";
var original = rawValue; // Remove numeric separators _
if (typeof rawValue === "string") {
rawValue = rawValue.replace(/_/g, "");
}
if (typeof rawValue === "number") {

@@ -359,2 +387,3 @@ value = rawValue;

x.raw = String(original);
return x;

@@ -361,0 +390,0 @@ }

107

lib/traverse.js

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

case "SectionMetadata":
case "FunctionNameMetadata":
case "ModuleExport":

@@ -84,4 +85,9 @@ case "Data":

case "Elem":
case "FuncImportDescr":
case "GlobalType":
case "NumberLiteral":
case "ValtypeLiteral":
case "FloatLiteral":
case "StringLiteral":
case "QuoteModule":
case "LongNumberLiteral":

@@ -97,11 +103,30 @@ case "BinaryModule":

case "Module":
case "ModuleMetadata":
{
var _path2 = createPath(n, parentPath);
cb(n.type, _path2);
cb(n.type, createPath(n, _path2));
n.sections.forEach(function (x) {
return walk(x, cb, _path2);
});
if (typeof n.functionNames !== "undefined") {
// $FlowIgnore
n.functionNames.forEach(function (x) {
return walk(x, cb, _path2);
});
}
break;
}
case "Module":
{
var _path3 = createPath(n, parentPath);
cb(n.type, _path3);
if (typeof n.fields !== "undefined") {
n.fields.forEach(function (x) {
return walk(x, cb, _path2);
return walk(x, cb, _path3);
});

@@ -112,5 +137,3 @@ }

// $FlowIgnore
n.metadata.sections.forEach(function (x) {
return walk(x, cb, _path2);
});
walk(n.metadata, cb, _path3);
}

@@ -124,8 +147,8 @@

{
var _path3 = createPath(n, parentPath); // $FlowIgnore
var _path4 = createPath(n, parentPath); // $FlowIgnore
cb(n.type, _path3); // $FlowIgnore
cb(n.type, _path4); // $FlowIgnore
walk(n.index, cb, _path3);
walk(n.index, cb, _path4);
break;

@@ -136,10 +159,10 @@ }

{
var _path4 = createPath(n, parentPath); // $FlowIgnore
var _path5 = createPath(n, parentPath); // $FlowIgnore
cb(n.type, _path4);
cb(n.type, _path5);
if (n.index != null) {
// $FlowIgnore
walk(n.index, cb, _path4);
walk(n.index, cb, _path5);
}

@@ -153,3 +176,8 @@

cb(n.type, createPath(n, parentPath));
cb(n.descr.type, createPath(n.descr, parentPath));
if (n.descr != null) {
// $FlowIgnore
walk(n.descr, cb, createPath(n, parentPath));
}
break;

@@ -161,10 +189,17 @@ }

{
var _path5 = createPath(n, parentPath);
var _path6 = createPath(n, parentPath);
cb(n.type, _path5);
cb(n.type, _path6);
if (n.name != null) {
walk(n.name, cb, _path5);
walk(n.name, cb, _path6);
}
if (n.init != null) {
// $FlowIgnore
n.init.forEach(function (x) {
return walk(x, cb, _path6);
});
}
break;

@@ -175,8 +210,8 @@ }

{
var _path6 = createPath(n, parentPath);
var _path7 = createPath(n, parentPath);
cb(n.type, _path6);
cb(n.type, _path7);
if (n.id != null) {
walk(n.id, cb, _path6);
walk(n.id, cb, _path7);
}

@@ -189,20 +224,20 @@

{
var _path7 = createPath(n, parentPath); // $FlowIgnore
var _path8 = createPath(n, parentPath); // $FlowIgnore
cb(n.type, _path7); // $FlowIgnore
cb(n.type, _path8); // $FlowIgnore
n.test.forEach(function (x) {
return walk(x, cb, _path7);
return walk(x, cb, _path8);
}); // $FlowIgnore
n.consequent.forEach(function (x) {
return walk(x, cb, _path7);
return walk(x, cb, _path8);
}); // $FlowIgnore
n.alternate.forEach(function (x) {
return walk(x, cb, _path7);
return walk(x, cb, _path8);
}); // $FlowIgnore
walk(n.testLabel, cb, _path7);
walk(n.testLabel, cb, _path8);
break;

@@ -213,10 +248,10 @@ }

{
var _path8 = createPath(n, parentPath); // $FlowIgnore
var _path9 = createPath(n, parentPath); // $FlowIgnore
cb(n.type, _path8); // $FlowIgnore
cb(n.type, _path9); // $FlowIgnore
if (_typeof(n.args) === "object") {
n.args.forEach(function (x) {
return walk(x, cb, _path8);
return walk(x, cb, _path9);
});

@@ -231,10 +266,10 @@ }

{
var _path9 = createPath(n, parentPath); // $FlowIgnore
var _path10 = createPath(n, parentPath); // $FlowIgnore
cb(n.type, _path9);
cb(n.type, _path10);
if (n.label != null) {
// $FlowIgnore
walk(n.label, cb, _path9);
walk(n.label, cb, _path10);
} // $FlowIgnore

@@ -244,3 +279,3 @@

n.instr.forEach(function (x) {
return walk(x, cb, _path9);
return walk(x, cb, _path10);
});

@@ -252,11 +287,11 @@ break;

{
var _path10 = createPath(n, parentPath);
var _path11 = createPath(n, parentPath);
cb(n.type, _path10);
cb(n.type, _path11);
n.body.forEach(function (x) {
return walk(x, cb, _path10);
return walk(x, cb, _path11);
});
if (n.name != null) {
walk(n.name, cb, _path10);
walk(n.name, cb, _path11);
}

@@ -263,0 +298,0 @@

{
"name": "@webassemblyjs/ast",
"version": "1.2.1",
"version": "1.2.2",
"description": "AST utils for webassemblyjs",

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

"dependencies": {
"@webassemblyjs/wast-parser": "1.2.1",
"@webassemblyjs/wast-parser": "1.2.2",
"webassembly-floating-point-hex-parser": "0.1.2",
"webassemblyjs": "1.2.1"
"webassemblyjs": "1.2.2"
},

@@ -19,0 +19,0 @@ "repository": {

@@ -36,2 +36,28 @@ // @flow

export function functionNameMetadata(
value: string,
index: number
): FunctionNameMetadata {
return {
type: "FunctionNameMetadata",
value,
index
};
}
export function moduleMetadata(
sections: Array<SectionMetadata>,
functionNames: Array<FunctionNameMetadata>
): ModuleMetadata {
const n: ModuleMetadata = {
type: "ModuleMetadata",
sections
};
if (functionNames.length) {
n.functionNames = functionNames;
}
return n;
}
export function identifier(value: string): Identifier {

@@ -246,3 +272,9 @@ return {

let type = "NumberLiteral";
const original = rawValue;
// Remove numeric separators _
if (typeof rawValue === "string") {
rawValue = rawValue.replace(/_/g, "");
}
if (typeof rawValue === "number") {

@@ -300,2 +332,4 @@ value = rawValue;

x.raw = String(original);
return x;

@@ -302,0 +336,0 @@ }

@@ -70,2 +70,3 @@ // @flow

case "SectionMetadata":
case "FunctionNameMetadata":
case "ModuleExport":

@@ -75,4 +76,9 @@ case "Data":

case "Elem":
case "FuncImportDescr":
case "GlobalType":
case "NumberLiteral":
case "ValtypeLiteral":
case "FloatLiteral":
case "StringLiteral":
case "QuoteModule":
case "LongNumberLiteral":

@@ -84,3 +90,14 @@ case "BinaryModule":

cb(n.type, createPath(n, parentPath));
break;
}
case "ModuleMetadata": {
const path = createPath(n, parentPath);
cb(n.type, createPath(n, path));
n.sections.forEach(x => walk(x, cb, path));
if (typeof n.functionNames !== "undefined") {
// $FlowIgnore
n.functionNames.forEach(x => walk(x, cb, path));
}
break;

@@ -99,3 +116,3 @@ }

// $FlowIgnore
n.metadata.sections.forEach(x => walk(x, cb, path));
walk(n.metadata, cb, path);
}

@@ -134,3 +151,6 @@

cb(n.descr.type, createPath(n.descr, parentPath));
if (n.descr != null) {
// $FlowIgnore
walk(n.descr, cb, createPath(n, parentPath));
}

@@ -149,2 +169,7 @@ break;

if (n.init != null) {
// $FlowIgnore
n.init.forEach(x => walk(x, cb, path));
}
break;

@@ -151,0 +176,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc