@webassemblyjs/wast-printer
Advanced tools
Comparing version 1.0.0 to 1.1.1
102
lib/index.js
@@ -12,3 +12,2 @@ "use strict"; | ||
/* eslint flowtype-errors/show-errors: warn */ | ||
var compact = false; | ||
@@ -44,7 +43,7 @@ var space = " "; | ||
if (child.type === "BlockComment") { | ||
acc += printBlockComment(child, depth + 1); | ||
acc += printBlockComment(child); | ||
} | ||
if (child.type === "LeadingComment") { | ||
acc += printLeadingComment(child, depth + 1); | ||
acc += printLeadingComment(child); | ||
} | ||
@@ -66,3 +65,3 @@ | ||
out += space; | ||
out += printIdentifier(n.id); | ||
out += n.id; | ||
} | ||
@@ -86,3 +85,3 @@ | ||
if (field.type === "Table") { | ||
out += printTable(field, depth + 1); | ||
out += printTable(field); | ||
} | ||
@@ -107,11 +106,11 @@ | ||
if (field.type === "BlockComment") { | ||
out += printBlockComment(field, depth + 1); | ||
out += printBlockComment(field); | ||
} | ||
if (field.type === "LeadingComment") { | ||
out += printLeadingComment(field, depth + 1); | ||
out += printLeadingComment(field); | ||
} | ||
if (field.type === "Start") { | ||
out += printStart(field, depth + 1); | ||
out += printStart(field); | ||
} | ||
@@ -127,5 +126,3 @@ | ||
function printStart(n | ||
/*, depth: number*/ | ||
) { | ||
function printStart(n) { | ||
var out = ""; | ||
@@ -140,5 +137,3 @@ out += "("; | ||
function printLeadingComment(n | ||
/*, depth: number*/ | ||
) { | ||
function printLeadingComment(n) { | ||
// Don't print leading comments in compact mode | ||
@@ -156,5 +151,3 @@ if (compact === true) { | ||
function printBlockComment(n | ||
/*, depth: number*/ | ||
) { | ||
function printBlockComment(n) { | ||
// Don't print block comments in compact mode | ||
@@ -173,3 +166,3 @@ if (compact === true) { | ||
function printModuleImportDescr(n, depth) { | ||
function printModuleImportDescr(n) { | ||
var out = ""; | ||
@@ -187,3 +180,3 @@ | ||
out += space; | ||
out += printFuncParam(param, depth); | ||
out += printFuncParam(param); | ||
out += ")"; | ||
@@ -206,3 +199,3 @@ }); | ||
out += space; | ||
out += printGlobalType(n, depth); | ||
out += printGlobalType(n); | ||
out += ")"; | ||
@@ -212,3 +205,3 @@ } | ||
if (n.type === "Table") { | ||
out += printTable(n, depth); | ||
out += printTable(n); | ||
} | ||
@@ -219,5 +212,3 @@ | ||
function printModuleImport(n | ||
/*, depth: number*/ | ||
) { | ||
function printModuleImport(n) { | ||
var out = ""; | ||
@@ -236,5 +227,3 @@ out += "("; | ||
function printGlobalType(n | ||
/*, depth: number*/ | ||
) { | ||
function printGlobalType(n) { | ||
var out = ""; | ||
@@ -255,5 +244,3 @@ | ||
function printGlobal(n | ||
/*, depth: number*/ | ||
) { | ||
function printGlobal(n, depth) { | ||
var out = ""; | ||
@@ -272,3 +259,3 @@ out += "("; | ||
n.init.forEach(function (i) { | ||
out += printInstruction(i); | ||
out += printInstruction(i, depth + 1); | ||
}); | ||
@@ -279,5 +266,3 @@ out += ")"; | ||
function printTable(n | ||
/*, depth: number*/ | ||
) { | ||
function printTable(n) { | ||
var out = ""; | ||
@@ -300,5 +285,3 @@ out += "("; | ||
function printFuncParam(n | ||
/*, depth: number*/ | ||
) { | ||
function printFuncParam(n) { | ||
var out = ""; | ||
@@ -332,3 +315,3 @@ | ||
out += space; | ||
out += printFuncParam(param, depth); | ||
out += printFuncParam(param); | ||
out += ")"; | ||
@@ -367,19 +350,26 @@ }); | ||
function printInstruction(n, depth) { | ||
var out = ""; | ||
switch (n.type) { | ||
case "Instr": | ||
// $FlowIgnore | ||
return printGenericInstruction(n); | ||
if (n.type === "Instr") { | ||
out += printGenericInstruction(n, depth + 1); | ||
} else if (n.type === "BlockInstruction") { | ||
out += printBlockInstruction(n, depth + 1); | ||
} else if (n.type === "IfInstruction") { | ||
out += printIfInstruction(n, depth + 1); | ||
} else if (n.type === "CallInstruction") { | ||
out += printCallInstruction(n, depth + 1); | ||
} else if (n.type === "LoopInstruction") { | ||
out += printLoopInstruction(n, depth + 1); | ||
} else { | ||
throw new Error("Unsupported instruction: " + n.type); | ||
case "BlockInstruction": | ||
// $FlowIgnore | ||
return printBlockInstruction(n, depth + 1); | ||
case "IfInstruction": | ||
// $FlowIgnore | ||
return printIfInstruction(n, depth + 1); | ||
case "CallInstruction": | ||
// $FlowIgnore | ||
return printCallInstruction(n, depth + 1); | ||
case "LoopInstruction": | ||
// $FlowIgnore | ||
return printLoopInstruction(n, depth + 1); | ||
default: | ||
throw new Error("Unsupported instruction: " + JSON.stringify(n.type)); | ||
} | ||
return out; | ||
} | ||
@@ -578,5 +568,3 @@ | ||
function printGenericInstruction(n | ||
/*, depth: number*/ | ||
) { | ||
function printGenericInstruction(n) { | ||
var out = ""; | ||
@@ -702,3 +690,3 @@ out += "("; | ||
out += space; | ||
out += n.max; | ||
out += String(n.max); | ||
} | ||
@@ -705,0 +693,0 @@ |
{ | ||
"name": "@webassemblyjs/wast-printer", | ||
"version": "1.0.0", | ||
"version": "1.1.1", | ||
"description": "WebAssembly text format printer", | ||
@@ -20,3 +20,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@webassemblyjs/wast-parser": "1.0.0", | ||
"@webassemblyjs/wast-parser": "1.1.1", | ||
"long": "^3.2.0" | ||
@@ -23,0 +23,0 @@ }, |
// @flow | ||
/* eslint flowtype-errors/show-errors: warn */ | ||
import Long from "long"; | ||
@@ -34,7 +33,7 @@ | ||
if (child.type === "BlockComment") { | ||
acc += printBlockComment(child, depth + 1); | ||
acc += printBlockComment(child); | ||
} | ||
if (child.type === "LeadingComment") { | ||
acc += printLeadingComment(child, depth + 1); | ||
acc += printLeadingComment(child); | ||
} | ||
@@ -56,3 +55,3 @@ | ||
out += space; | ||
out += printIdentifier(n.id); | ||
out += n.id; | ||
} | ||
@@ -76,3 +75,3 @@ | ||
if (field.type === "Table") { | ||
out += printTable(field, depth + 1); | ||
out += printTable(field); | ||
} | ||
@@ -97,11 +96,11 @@ | ||
if (field.type === "BlockComment") { | ||
out += printBlockComment(field, depth + 1); | ||
out += printBlockComment(field); | ||
} | ||
if (field.type === "LeadingComment") { | ||
out += printLeadingComment(field, depth + 1); | ||
out += printLeadingComment(field); | ||
} | ||
if (field.type === "Start") { | ||
out += printStart(field, depth + 1); | ||
out += printStart(field); | ||
} | ||
@@ -119,3 +118,3 @@ | ||
function printStart(n: Start /*, depth: number*/): string { | ||
function printStart(n: Start): string { | ||
let out = ""; | ||
@@ -132,3 +131,3 @@ | ||
function printLeadingComment(n: LeadingComment /*, depth: number*/): string { | ||
function printLeadingComment(n: LeadingComment): string { | ||
// Don't print leading comments in compact mode | ||
@@ -149,3 +148,3 @@ if (compact === true) { | ||
function printBlockComment(n: BlockComment /*, depth: number*/): string { | ||
function printBlockComment(n: BlockComment): string { | ||
// Don't print block comments in compact mode | ||
@@ -167,3 +166,3 @@ if (compact === true) { | ||
function printModuleImportDescr(n: ImportDescr, depth: number): string { | ||
function printModuleImportDescr(n: ImportDescr): string { | ||
let out = ""; | ||
@@ -184,3 +183,3 @@ | ||
out += printFuncParam(param, depth); | ||
out += printFuncParam(param); | ||
out += ")"; | ||
@@ -207,3 +206,3 @@ }); | ||
out += printGlobalType(n, depth); | ||
out += printGlobalType(n); | ||
out += ")"; | ||
@@ -213,3 +212,3 @@ } | ||
if (n.type === "Table") { | ||
out += printTable(n, depth); | ||
out += printTable(n); | ||
} | ||
@@ -220,3 +219,3 @@ | ||
function printModuleImport(n: ModuleImport /*, depth: number*/): string { | ||
function printModuleImport(n: ModuleImport): string { | ||
let out = ""; | ||
@@ -241,3 +240,3 @@ | ||
function printGlobalType(n: GlobalType /*, depth: number*/): string { | ||
function printGlobalType(n: GlobalType): string { | ||
let out = ""; | ||
@@ -258,3 +257,3 @@ | ||
function printGlobal(n: Global /*, depth: number*/): string { | ||
function printGlobal(n: Global, depth: number): string { | ||
let out = ""; | ||
@@ -276,3 +275,3 @@ | ||
n.init.forEach(i => { | ||
out += printInstruction(i); | ||
out += printInstruction(i, depth + 1); | ||
}); | ||
@@ -285,3 +284,3 @@ | ||
function printTable(n: Table /*, depth: number*/): string { | ||
function printTable(n: Table): string { | ||
let out = ""; | ||
@@ -308,3 +307,3 @@ | ||
function printFuncParam(n: FuncParam /*, depth: number*/): string { | ||
function printFuncParam(n: FuncParam): string { | ||
let out = ""; | ||
@@ -341,3 +340,3 @@ | ||
out += printFuncParam(param, depth); | ||
out += printFuncParam(param); | ||
@@ -381,19 +380,26 @@ out += ")"; | ||
function printInstruction(n: Instruction, depth: number): string { | ||
let out = ""; | ||
switch (n.type) { | ||
case "Instr": | ||
// $FlowIgnore | ||
return printGenericInstruction(n); | ||
if (n.type === "Instr") { | ||
out += printGenericInstruction(n, depth + 1); | ||
} else if (n.type === "BlockInstruction") { | ||
out += printBlockInstruction(n, depth + 1); | ||
} else if (n.type === "IfInstruction") { | ||
out += printIfInstruction(n, depth + 1); | ||
} else if (n.type === "CallInstruction") { | ||
out += printCallInstruction(n, depth + 1); | ||
} else if (n.type === "LoopInstruction") { | ||
out += printLoopInstruction(n, depth + 1); | ||
} else { | ||
throw new Error("Unsupported instruction: " + n.type); | ||
case "BlockInstruction": | ||
// $FlowIgnore | ||
return printBlockInstruction(n, depth + 1); | ||
case "IfInstruction": | ||
// $FlowIgnore | ||
return printIfInstruction(n, depth + 1); | ||
case "CallInstruction": | ||
// $FlowIgnore | ||
return printCallInstruction(n, depth + 1); | ||
case "LoopInstruction": | ||
// $FlowIgnore | ||
return printLoopInstruction(n, depth + 1); | ||
default: | ||
throw new Error("Unsupported instruction: " + JSON.stringify(n.type)); | ||
} | ||
return out; | ||
} | ||
@@ -611,5 +617,3 @@ | ||
function printGenericInstruction( | ||
n: GenericInstruction /*, depth: number*/ | ||
): string { | ||
function printGenericInstruction(n: GenericInstruction): string { | ||
let out = ""; | ||
@@ -747,3 +751,3 @@ | ||
out += space; | ||
out += n.max; | ||
out += String(n.max); | ||
} | ||
@@ -750,0 +754,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24300
1092
+ Added@webassemblyjs/ast@1.1.1(transitive)
+ Added@webassemblyjs/helper-leb128@1.1.1(transitive)
+ Added@webassemblyjs/helper-wasm-bytecode@1.1.1(transitive)
+ Added@webassemblyjs/wasm-parser@1.1.1(transitive)
+ Added@webassemblyjs/wast-parser@1.1.1(transitive)
+ Addedleb@0.3.0(transitive)
+ Addedwebassemblyjs@1.1.1(transitive)
- Removed@webassemblyjs/ast@1.0.0(transitive)
- Removed@webassemblyjs/wasm-parser@1.0.0(transitive)
- Removed@webassemblyjs/wast-parser@1.0.0(transitive)
- Removedwebassemblyjs@1.0.0(transitive)