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]);
};
funcBody.push(t.instruction("end"));
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]);
};
state.registredExportedElements.forEach(function (decl) {
moduleFields.push(t.moduleExport(decl.name, t.moduleExportDescr(decl.exportType, decl.id)));
});
state.registredExportedElements = [];
state.elementsInExportSection.forEach(function (moduleExport) {
/**
* 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));
}
});
dumpSep("end of program");
state.registredExportedElements.forEach(decl => {
moduleFields.push(
t.moduleExport(
decl.name,
t.moduleExportDescr(decl.exportType, decl.id)
)
);
});
function parseExport() {
if (token.type !== tokens.string) {
throw new Error("Expected string after export, got: " + token.type);
}
var name = token.value;
eatToken();
var moduleExportDescr = parseModuleExportDescr();
return t.moduleExport(name, moduleExportDescr);
}
function parseExport() {
if (token.type !== tokens.string) {
throw new Error("Expected string after export, got: " + token.type);
}
var name = token.value;
eatToken();
var moduleExportDescr = parseModuleExportDescr();
return t.moduleExport(name, moduleExportDescr);
}
state.elementsInExportSection.forEach(function (moduleExport) {
/**
* 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));
}
});
dumpSep("end of program");
state.elementsInExportSection.forEach(function (moduleExport) {
/**
* 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));
}
});
dumpSep("end of program");
state.elementsInExportSection.forEach(function (moduleExport) {
/**
* 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));
}
});
dumpSep("end of program");