Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function printGlobal(n, depth) {
var out = "";
out += "(";
out += "global";
out += space;
if (n.name != null && isAnonymous(n.name) === false) {
out += printIdentifier(n.name);
out += space;
}
out += printGlobalType(n.globalType);
out += space;
n.init.forEach(function (i) {
out += printInstruction(i, depth + 1);
});
out += ")";
return out;
}
function printModuleImportDescr(n: ImportDescr): string {
let out = "";
if (n.type === "FuncImportDescr") {
out += "(";
out += "func";
if (isAnonymous(n.id) === false) {
out += space;
out += printIdentifier(n.id);
}
out += printSignature(n.signature);
out += ")";
}
if (n.type === "GlobalType") {
out += "(";
out += "global";
out += space;
out += printGlobalType(n);
out += ")";
function printLoopInstruction(n: LoopInstruction, depth: number): string {
let out = "";
out += "(";
out += "loop";
if (n.label != null && isAnonymous(n.label) === false) {
out += space;
out += printIdentifier(n.label);
}
if (typeof n.resulttype === "string") {
out += space;
out += "(";
out += "result";
out += space;
out += n.resulttype;
out += ")";
}
if (n.instr.length > 0) {
function printModuleImportDescr(n) {
var out = "";
if (n.type === "FuncImportDescr") {
out += "(";
out += "func";
if (isAnonymous(n.id) === false) {
out += space;
out += printIdentifier(n.id);
}
out += printSignature(n.signature);
out += ")";
}
if (n.type === "GlobalType") {
out += "(";
out += "global";
out += space;
out += printGlobalType(n);
out += ")";
}
function printFunc(n: Func, depth: number): string {
let out = "";
out += "(";
out += "func";
if (n.name != null) {
if (n.name.type === "Identifier" && isAnonymous(n.name) === false) {
out += space;
out += printIdentifier(n.name);
}
}
if (n.signature.type === "Signature") {
out += printSignature(n.signature);
} else {
const index = (n.signature: Index);
out += space;
out += "(";
out += "type";
out += space;
out += printIndex(index);
function printFunc(n: Func, depth: number): string {
let out = "";
out += "(";
out += "func";
if (n.name != null) {
if (n.name.type === "Identifier" && isAnonymous(n.name) === false) {
out += space;
out += printIdentifier(n.name);
}
}
if (n.signature.type === "Signature") {
out += printSignature(n.signature);
} else {
const index = (n.signature: Index);
out += space;
out += "(";
out += "type";
out += space;
out += printIndex(index);
function printGlobal(n, depth) {
var out = "";
out += "(";
out += "global";
out += space;
if (n.name != null && isAnonymous(n.name) === false) {
out += printIdentifier(n.name);
out += space;
}
out += printGlobalType(n.globalType);
out += space;
n.init.forEach(function (i) {
out += printInstruction(i, depth + 1);
});
out += ")";
return out;
}
function printFuncInstructionArg(n: Object, depth: number): string {
let out = "";
if (n.type === "NumberLiteral") {
out += printNumberLiteral(n);
}
if (n.type === "LongNumberLiteral") {
out += printLongNumberLiteral(n);
}
if (n.type === "Identifier" && isAnonymous(n) === false) {
out += printIdentifier(n);
}
if (n.type === "ValtypeLiteral") {
out += n.name;
}
if (n.type === "FloatLiteral") {
out += printFloatLiteral(n);
}
if (isInstruction(n)) {
out += printInstruction(n, depth + 1);
}
return out;
function printBlockInstruction(n: BlockInstruction, depth: number): string {
let out = "";
out += "(";
out += "block";
if (n.label != null && isAnonymous(n.label) === false) {
out += space;
out += printIdentifier(n.label);
}
if (n.instr.length > 0) {
n.instr.forEach(i => {
if (compact === false) {
out += "\n";
}
out += indent(depth);
out += printInstruction(i, depth + 1);
});
if (compact === false) {
out += "\n";
function printIfInstruction(n, depth) {
var out = "";
out += "(";
out += "if";
if (n.testLabel != null && isAnonymous(n.testLabel) === false) {
out += space;
out += printIdentifier(n.testLabel);
}
if (typeof n.result === "string") {
out += space;
out += "(";
out += "result";
out += space;
out += n.result;
out += ")";
}
if (n.test.length > 0) {
out += space;
n.test.forEach(function (i) {