Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const funcResults = [];
// Code section
const funcSignature = t.signature(funcParams, funcResults);
const func = t.func(initFuncId, funcSignature, funcBody);
// Type section
const functype = t.typeInstruction(undefined, funcSignature);
// Func section
const funcindex = t.indexInFuncSection(nextTypeIndex);
// Export section
const moduleExport = t.moduleExport(
initFuncId.value,
t.moduleExportDescr("Func", nextFuncIndex)
);
return addWithAST(ast, bin, [func, moduleExport, funcindex, functype]);
};
const funcResults = [];
// Code section
const funcSignature = t.signature(funcParams, funcResults);
const func = t.func(initFuncId, funcSignature, funcBody);
// Type section
const functype = t.typeInstruction(undefined, funcSignature);
// Func section
const funcindex = t.indexInFuncSection(nextTypeIndex);
// Export section
const moduleExport = t.moduleExport(
initFuncId.value,
t.moduleExportDescr("Func", nextFuncIndex)
);
return addWithAST(ast, bin, [func, moduleExport, funcindex, functype]);
};
const funcResults = [];
// Code section
const funcSignature = t.signature(funcParams, funcResults);
const func = t.func(initFuncId, funcSignature, funcBody);
// Type section
const functype = t.typeInstruction(undefined, funcSignature);
// Func section
const funcindex = t.indexInFuncSection(nextTypeIndex);
// Export section
const moduleExport = t.moduleExport(
initFuncId.value,
t.moduleExportDescr("Func", nextFuncIndex)
);
return addWithAST(ast, bin, [func, moduleExport, funcindex, functype]);
};
(moduleExport: DecodedElementInExportSection) => {
/**
* If the export has no id, we won't be able to call it from the outside
* so we can omit it
*/
if (moduleExport.id != null) {
moduleFields.push(
t.withLoc(
t.moduleExport(
moduleExport.name,
t.moduleExportDescr(moduleExport.type, moduleExport.id)
),
moduleExport.endLoc,
moduleExport.startLoc
)
);
}
}
);
eatToken();
index = parseExportIndex(token);
}
eatToken();
}
if (type === "") {
throw new Error("Unknown export type");
}
if (index === undefined) {
throw new Error("Exported function must have a name");
}
var node = t.moduleExportDescr(type, index);
var endLoc = getEndLoc();
eatTokenOfType(tokens.closeParen);
return t.withLoc(node, endLoc, startLoc);
}
eatToken();
index = parseExportIndex(token);
}
eatToken();
}
if (type === "") {
throw new Error("Unknown export type");
}
if (index === undefined) {
throw new Error("Exported function must have a name");
}
const node = t.moduleExportDescr(type, index);
const endLoc = getEndLoc();
eatTokenOfType(tokens.closeParen);
return t.withLoc(node, endLoc, startLoc);
}
eatToken();
index = parseExportIndex(token);
}
eatToken();
}
if (type === "") {
throw new Error("Unknown export type");
}
if (index === undefined) {
throw new Error("Exported function must have a name");
}
var node = t.moduleExportDescr(type, index);
var endLoc = getEndLoc();
eatTokenOfType(tokens.closeParen);
return t.withLoc(node, endLoc, startLoc);
}