Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createModuleInstanceFromAst(moduleNode, enableTypeChecking = false) {
const internalInstanceOptions = {
checkForI64InSignature: false,
returnStackLocal: true
};
const importObject = {
_internalInstanceOptions: internalInstanceOptions
};
if (enableTypeChecking === true) {
denormalizeTypeReferences(moduleNode);
const typeErrors = typeCheck(t.program([moduleNode]));
if (typeErrors.length > 0) {
const containsImmutableGlobalViolation = typeErrors.some(
x => x === "global is immutable"
);
if (containsImmutableGlobalViolation) {
throw new Error("global is immutable");
}
throw new Error("type mismatch");
}
}
const compiledModule = createCompiledModule(moduleNode);