Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@webassemblyjs/wast-printer

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webassemblyjs/wast-printer - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

138

lib/index.js

@@ -57,2 +57,37 @@ "use strict";

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.result.forEach(function (result) {
out += space;
out += "(";
out += "result";
out += space;
out += result;
out += ")";
});
out += ")"; // func
out += ")";
return out;
}
function printModule(n, depth) {

@@ -78,36 +113,65 @@ var out = "(";

if (field.type === "Func") {
out += printFunc(field, depth + 1);
}
switch (field.type) {
case "Func":
{
out += printFunc(field, depth + 1);
break;
}
if (field.type === "Table") {
out += printTable(field);
}
case "TypeInstruction":
{
out += printTypeInstruction(field);
break;
}
if (field.type === "Global") {
out += printGlobal(field, depth + 1);
}
case "Table":
{
out += printTable(field);
break;
}
if (field.type === "ModuleExport") {
out += printModuleExport(field);
}
case "Global":
{
out += printGlobal(field, depth + 1);
break;
}
if (field.type === "ModuleImport") {
out += printModuleImport(field);
}
case "ModuleExport":
{
out += printModuleExport(field);
break;
}
if (field.type === "Memory") {
out += printMemory(field);
}
case "ModuleImport":
{
out += printModuleImport(field);
break;
}
if (field.type === "BlockComment") {
out += printBlockComment(field);
}
case "Memory":
{
out += printMemory(field);
break;
}
if (field.type === "LeadingComment") {
out += printLeadingComment(field);
}
case "BlockComment":
{
out += printBlockComment(field);
break;
}
if (field.type === "Start") {
out += printStart(field);
case "LeadingComment":
{
out += printLeadingComment(field);
break;
}
case "Start":
{
out += printStart(field);
break;
}
default:
throw new Error("Unsupported node in printModule: " + String(field.type));
}

@@ -569,2 +633,6 @@

function printLongNumberLiteral(n) {
if (typeof n.raw === "string") {
return n.raw;
}
var _n$value = n.value,

@@ -577,2 +645,10 @@ low = _n$value.low,

function printFloatLiteral(n) {
if (typeof n.raw === "string") {
return n.raw;
}
return String(n.value);
}
function printFuncInstructionArg(n) {

@@ -597,2 +673,6 @@ var out = "";

if (n.type === "FloatLiteral") {
out += printFloatLiteral(n);
}
if (n.type === "Instr") {

@@ -606,3 +686,7 @@ out += printGenericInstruction(n);

function printNumberLiteral(n) {
return n.value + "";
if (typeof n.raw === "string") {
return n.raw;
}
return String(n.value);
}

@@ -609,0 +693,0 @@

4

package.json
{
"name": "@webassemblyjs/wast-printer",
"version": "1.2.1",
"version": "1.2.2",
"description": "WebAssembly text format printer",

@@ -20,3 +20,3 @@ "main": "lib/index.js",

"dependencies": {
"@webassemblyjs/wast-parser": "1.2.1",
"@webassemblyjs/wast-parser": "1.2.2",
"long": "^3.2.0"

@@ -23,0 +23,0 @@ },

@@ -48,2 +48,46 @@ // @flow

function printTypeInstruction(n: TypeInstruction): string {
let out = "";
out += "(";
out += "type";
out += space;
if (n.id != null) {
out += printIndex(n.id);
out += space;
}
out += "(";
out += "func";
n.functype.params.forEach(param => {
out += space;
out += "(";
out += "param";
out += space;
out += printFuncParam(param);
out += ")";
});
n.functype.result.forEach(result => {
out += space;
out += "(";
out += "result";
out += space;
out += result;
out += ")";
});
out += ")"; // func
out += ")";
return out;
}
function printModule(n: Module, depth: number): string {

@@ -69,36 +113,57 @@ let out = "(";

if (field.type === "Func") {
out += printFunc(field, depth + 1);
}
switch (field.type) {
case "Func": {
out += printFunc(field, depth + 1);
break;
}
if (field.type === "Table") {
out += printTable(field);
}
case "TypeInstruction": {
out += printTypeInstruction(field);
break;
}
if (field.type === "Global") {
out += printGlobal(field, depth + 1);
}
case "Table": {
out += printTable(field);
break;
}
if (field.type === "ModuleExport") {
out += printModuleExport(field);
}
case "Global": {
out += printGlobal(field, depth + 1);
break;
}
if (field.type === "ModuleImport") {
out += printModuleImport(field);
}
case "ModuleExport": {
out += printModuleExport(field);
break;
}
if (field.type === "Memory") {
out += printMemory(field);
}
case "ModuleImport": {
out += printModuleImport(field);
break;
}
if (field.type === "BlockComment") {
out += printBlockComment(field);
}
case "Memory": {
out += printMemory(field);
break;
}
if (field.type === "LeadingComment") {
out += printLeadingComment(field);
}
case "BlockComment": {
out += printBlockComment(field);
break;
}
if (field.type === "Start") {
out += printStart(field);
case "LeadingComment": {
out += printLeadingComment(field);
break;
}
case "Start": {
out += printStart(field);
break;
}
default:
throw new Error(
"Unsupported node in printModule: " + String(field.type)
);
}

@@ -623,2 +688,6 @@

function printLongNumberLiteral(n: LongNumberLiteral): string {
if (typeof n.raw === "string") {
return n.raw;
}
const { low, high } = n.value;

@@ -631,2 +700,10 @@

function printFloatLiteral(n: FloatLiteral): string {
if (typeof n.raw === "string") {
return n.raw;
}
return String(n.value);
}
function printFuncInstructionArg(n: Object): string {

@@ -651,2 +728,6 @@ let out = "";

if (n.type === "FloatLiteral") {
out += printFloatLiteral(n);
}
if (n.type === "Instr") {

@@ -660,3 +741,7 @@ out += printGenericInstruction(n);

function printNumberLiteral(n: NumberLiteral): string {
return n.value + "";
if (typeof n.raw === "string") {
return n.raw;
}
return String(n.value);
}

@@ -663,0 +748,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