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.5 to 1.2.6

48

lib/index.js

@@ -18,3 +18,5 @@ "use strict";

exports.moduleExport = moduleExport;
exports.functionSignature = functionSignature;
exports.func = func;
exports.funcWithTypeRef = funcWithTypeRef;
exports.objectInstruction = objectInstruction;

@@ -47,3 +49,3 @@ exports.instruction = instruction;

exports.callIndirectInstruction = callIndirectInstruction;
exports.callIndirectInstructionIndex = callIndirectInstructionIndex;
exports.callIndirectInstructionWithTypeRef = callIndirectInstructionWithTypeRef;
exports.start = start;

@@ -238,5 +240,13 @@ exports.elem = elem;

function func(name, params, result, body) {
function functionSignature(params, results) {
return {
type: "Signature",
params: params,
results: results
};
}
function func(name, params, results, body) {
assert(_typeof(params) === "object" && typeof params.length !== "undefined");
assert(_typeof(result) === "object" && typeof result.length !== "undefined");
assert(_typeof(results) === "object" && typeof results.length !== "undefined");
assert(_typeof(body) === "object" && typeof body.length !== "undefined");

@@ -247,4 +257,3 @@ assert(typeof name !== "string");

name: name,
params: params,
result: result,
signature: functionSignature(params, results),
body: body

@@ -254,2 +263,13 @@ };

function funcWithTypeRef(name, typeRef, body) {
assert(_typeof(body) === "object" && typeof body.length !== "undefined");
assert(typeof name !== "string");
return {
type: "Func",
name: name,
signature: typeRef,
body: body
};
}
function objectInstruction(id, object) {

@@ -494,4 +514,3 @@ var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];

id: id,
params: params,
results: results
signature: functionSignature(params, results)
};

@@ -592,3 +611,3 @@ }

var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var results = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var id = arguments.length > 2 ? arguments[2] : undefined;

@@ -598,6 +617,3 @@ return {

id: id,
functype: {
params: params,
result: result
}
functype: functionSignature(params, results)
};

@@ -609,4 +625,3 @@ }

type: "CallIndirectInstruction",
params: params,
results: results,
signature: functionSignature(params, results),
intrs: intrs

@@ -616,6 +631,7 @@ };

function callIndirectInstructionIndex(index) {
function callIndirectInstructionWithTypeRef(typeRef, intrs) {
return {
type: "CallIndirectInstruction",
index: index
signature: typeRef,
intrs: intrs
};

@@ -622,0 +638,0 @@ }

@@ -118,3 +118,9 @@ "use strict";

var funcNode = funcPath.node;
var params = funcNode.params;
var signature = funcNode.signature;
if (signature.type !== "Signature") {
throw new Error("Function signatures must be denormalised before execution");
}
var params = signature.params;
(0, _index.traverse)(funcNode, {

@@ -121,0 +127,0 @@ Instr: function Instr(instrPath) {

{
"name": "@webassemblyjs/ast",
"version": "1.2.5",
"version": "1.2.6",
"description": "AST utils for webassemblyjs",

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

"dependencies": {
"@webassemblyjs/wast-parser": "1.2.5",
"webassemblyjs": "1.2.5"
"@webassemblyjs/wast-parser": "1.2.6",
"webassemblyjs": "1.2.6"
},

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

@@ -162,10 +162,21 @@ // @flow

export function functionSignature(
params: Array<FuncParam>,
results: Array<Valtype>
): Signature {
return {
type: "Signature",
params,
results
};
}
export function func(
name: ?Index,
params: Array<FuncParam>,
result: Array<Valtype>,
results: Array<Valtype>,
body: Array<Instruction>
): Func {
assert(typeof params === "object" && typeof params.length !== "undefined");
assert(typeof result === "object" && typeof result.length !== "undefined");
assert(typeof results === "object" && typeof results.length !== "undefined");
assert(typeof body === "object" && typeof body.length !== "undefined");

@@ -177,4 +188,3 @@ assert(typeof name !== "string");

name,
params,
result,
signature: functionSignature(params, results),
body

@@ -184,2 +194,18 @@ };

export function funcWithTypeRef(
name: ?Index,
typeRef: Index,
body: Array<Instruction>
): Func {
assert(typeof body === "object" && typeof body.length !== "undefined");
assert(typeof name !== "string");
return {
type: "Func",
name,
signature: typeRef,
body
};
}
export function objectInstruction(

@@ -458,4 +484,3 @@ id: string,

id,
params,
results
signature: functionSignature(params, results)
};

@@ -573,3 +598,3 @@ }

params: Array<FuncParam> = [],
result: Array<Valtype> = [],
results: Array<Valtype> = [],
id: ?Index

@@ -580,6 +605,3 @@ ): TypeInstruction {

id,
functype: {
params,
result
}
functype: functionSignature(params, results)
};

@@ -595,4 +617,3 @@ }

type: "CallIndirectInstruction",
params,
results,
signature: functionSignature(params, results),
intrs

@@ -602,8 +623,10 @@ };

export function callIndirectInstructionIndex(
index: Index
export function callIndirectInstructionWithTypeRef(
typeRef: Index,
intrs: Array<Expression>
): CallIndirectInstruction {
return {
type: "CallIndirectInstruction",
index
signature: typeRef,
intrs
};

@@ -610,0 +633,0 @@ }

@@ -65,4 +65,11 @@ // @flow

const funcNode = funcPath.node;
const { params } = funcNode;
const signature = funcNode.signature;
if (signature.type !== "Signature") {
throw new Error(
"Function signatures must be denormalised before execution"
);
}
const params = signature.params;
traverse(funcNode, {

@@ -69,0 +76,0 @@ Instr(instrPath: NodePath<GenericInstruction>) {

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