@webassemblyjs/wast-printer
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -283,2 +283,23 @@ "use strict"; | ||
function printSignature(n) { | ||
var out = ""; | ||
n.params.forEach(function (param) { | ||
out += space; | ||
out += "("; | ||
out += "param"; | ||
out += space; | ||
out += printFuncParam(param); | ||
out += ")"; | ||
}); | ||
n.results.forEach(function (result) { | ||
out += space; | ||
out += "("; | ||
out += "result"; | ||
out += space; | ||
out += result; | ||
out += ")"; | ||
}); | ||
return out; | ||
} | ||
function printModuleImportDescr(n) { | ||
@@ -296,18 +317,3 @@ var out = ""; | ||
n.signature.params.forEach(function (param) { | ||
out += space; | ||
out += "("; | ||
out += "param"; | ||
out += space; | ||
out += printFuncParam(param); | ||
out += ")"; | ||
}); | ||
n.signature.results.forEach(function (result) { | ||
out += space; | ||
out += "("; | ||
out += "result"; | ||
out += space; | ||
out += result; | ||
out += ")"; | ||
}); | ||
out += printSignature(n.signature); | ||
out += ")"; | ||
@@ -424,19 +430,3 @@ } | ||
if (n.signature.type === "Signature") { | ||
var signature = n.signature; | ||
signature.params.forEach(function (param) { | ||
out += space; | ||
out += "("; | ||
out += "param"; | ||
out += space; | ||
out += printFuncParam(param); | ||
out += ")"; | ||
}); | ||
signature.results.forEach(function (result) { | ||
out += space; | ||
out += "("; | ||
out += "result"; | ||
out += space; | ||
out += result; | ||
out += ")"; | ||
}); | ||
out += printSignature(n.signature); | ||
} else { | ||
@@ -491,2 +481,6 @@ var index = n.signature; | ||
case "CallIndirectInstruction": | ||
// $FlowIgnore | ||
return printCallIndirectIntruction(n, depth + 1); | ||
case "LoopInstruction": | ||
@@ -501,2 +495,38 @@ // $FlowIgnore | ||
function printCallIndirectIntruction(n, depth) { | ||
var out = ""; | ||
out += "("; | ||
out += "call_indirect"; | ||
if (n.signature.type === "Signature") { | ||
out += printSignature(n.signature); | ||
} else if (n.signature.type === "Identifier") { | ||
out += space; | ||
out += "("; | ||
out += "type"; | ||
out += space; | ||
out += printIdentifier(n.signature); | ||
out += ")"; | ||
} else { | ||
throw new Error("CallIndirectInstruction: unsupported signature " + JSON.stringify(n.signature.type)); | ||
} | ||
out += space; | ||
if (n.intrs != null) { | ||
// $FlowIgnore | ||
n.intrs.forEach(function (i, index) { | ||
// $FlowIgnore | ||
out += printInstruction(i, depth + 1); // $FlowIgnore | ||
if (index !== n.intrs.length - 1) { | ||
out += space; | ||
} | ||
}); | ||
} | ||
out += ")"; | ||
return out; | ||
} | ||
function printLoopInstruction(n, depth) { | ||
@@ -503,0 +533,0 @@ var out = ""; |
{ | ||
"name": "@webassemblyjs/wast-printer", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "WebAssembly text format printer", | ||
@@ -20,8 +20,8 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@webassemblyjs/ast": "1.3.0", | ||
"@webassemblyjs/wast-parser": "1.3.0", | ||
"@webassemblyjs/ast": "1.3.1", | ||
"@webassemblyjs/wast-parser": "1.3.1", | ||
"long": "^3.2.0" | ||
}, | ||
"devDependencies": { | ||
"@webassemblyjs/helper-test-framework": "1.3.0" | ||
"@webassemblyjs/helper-test-framework": "1.3.1" | ||
}, | ||
@@ -28,0 +28,0 @@ "repository": { |
121
src/index.js
@@ -292,2 +292,28 @@ // @flow | ||
function printSignature(n: Signature): string { | ||
let out = ""; | ||
n.params.forEach(param => { | ||
out += space; | ||
out += "("; | ||
out += "param"; | ||
out += space; | ||
out += printFuncParam(param); | ||
out += ")"; | ||
}); | ||
n.results.forEach(result => { | ||
out += space; | ||
out += "("; | ||
out += "result"; | ||
out += space; | ||
out += result; | ||
out += ")"; | ||
}); | ||
return out; | ||
} | ||
function printModuleImportDescr(n: ImportDescr): string { | ||
@@ -305,22 +331,4 @@ let out = ""; | ||
n.signature.params.forEach(param => { | ||
out += space; | ||
out += "("; | ||
out += "param"; | ||
out += space; | ||
out += printSignature(n.signature); | ||
out += printFuncParam(param); | ||
out += ")"; | ||
}); | ||
n.signature.results.forEach(result => { | ||
out += space; | ||
out += "("; | ||
out += "result"; | ||
out += space; | ||
out += result; | ||
out += ")"; | ||
}); | ||
out += ")"; | ||
@@ -454,24 +462,3 @@ } | ||
if (n.signature.type === "Signature") { | ||
const signature = (n.signature: Signature); | ||
signature.params.forEach(param => { | ||
out += space; | ||
out += "("; | ||
out += "param"; | ||
out += space; | ||
out += printFuncParam(param); | ||
out += ")"; | ||
}); | ||
signature.results.forEach(result => { | ||
out += space; | ||
out += "("; | ||
out += "result"; | ||
out += space; | ||
out += result; | ||
out += ")"; | ||
}); | ||
out += printSignature(n.signature); | ||
} else { | ||
@@ -529,2 +516,6 @@ const index = (n.signature: Index); | ||
case "CallIndirectInstruction": | ||
// $FlowIgnore | ||
return printCallIndirectIntruction(n, depth + 1); | ||
case "LoopInstruction": | ||
@@ -539,2 +530,50 @@ // $FlowIgnore | ||
function printCallIndirectIntruction( | ||
n: CallIndirectInstruction, | ||
depth: number | ||
): string { | ||
let out = ""; | ||
out += "("; | ||
out += "call_indirect"; | ||
if (n.signature.type === "Signature") { | ||
out += printSignature(n.signature); | ||
} else if (n.signature.type === "Identifier") { | ||
out += space; | ||
out += "("; | ||
out += "type"; | ||
out += space; | ||
out += printIdentifier(n.signature); | ||
out += ")"; | ||
} else { | ||
throw new Error( | ||
"CallIndirectInstruction: unsupported signature " + | ||
JSON.stringify(n.signature.type) | ||
); | ||
} | ||
out += space; | ||
if (n.intrs != null) { | ||
// $FlowIgnore | ||
n.intrs.forEach((i, index) => { | ||
// $FlowIgnore | ||
out += printInstruction(i, depth + 1); | ||
// $FlowIgnore | ||
if (index !== n.intrs.length - 1) { | ||
out += space; | ||
} | ||
}); | ||
} | ||
out += ")"; | ||
return out; | ||
} | ||
function printLoopInstruction(n: LoopInstruction, depth: number): string { | ||
@@ -541,0 +580,0 @@ let out = ""; |
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
1410
32534
4
+ Added@webassemblyjs/ast@1.3.1(transitive)
+ Added@webassemblyjs/floating-point-hex-parser@1.3.1(transitive)
+ Added@webassemblyjs/helper-code-frame@1.3.1(transitive)
+ Added@webassemblyjs/helper-fsm@1.3.1(transitive)
+ Added@webassemblyjs/helper-wasm-bytecode@1.3.1(transitive)
+ Added@webassemblyjs/leb128@1.3.1(transitive)
+ Added@webassemblyjs/validation@1.3.1(transitive)
+ Added@webassemblyjs/wasm-parser@1.3.1(transitive)
+ Added@webassemblyjs/wast-parser@1.3.1(transitive)
+ Addedwebassemblyjs@1.3.1(transitive)
- Removed@webassemblyjs/ast@1.3.0(transitive)
- Removed@webassemblyjs/floating-point-hex-parser@1.3.0(transitive)
- Removed@webassemblyjs/helper-code-frame@1.3.0(transitive)
- Removed@webassemblyjs/helper-fsm@1.3.0(transitive)
- Removed@webassemblyjs/helper-wasm-bytecode@1.3.0(transitive)
- Removed@webassemblyjs/leb128@1.3.0(transitive)
- Removed@webassemblyjs/validation@1.3.0(transitive)
- Removed@webassemblyjs/wasm-parser@1.3.0(transitive)
- Removed@webassemblyjs/wast-parser@1.3.0(transitive)
- Removedwebassemblyjs@1.3.0(transitive)
Updated@webassemblyjs/ast@1.3.1