Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
const importObject = {
_internalInstanceOptions: internalInstanceOptions
};
if (type === "text") {
const content = readFileSync(join(WASM_TEST_DIR, filename), "utf8");
// we need a module in order to be compiled
const ast = parse("(module " + content + ")");
// TODO(sven): pass fakeCompiler here?
const module = createCompiledModule(ast);
return new Instance(module, importObject);
} else if (type === "binary") {
// $FlowIgnore
const buff = readFileSync(join(WASM_TEST_DIR, filename), null);
const ast = decode(buff, decoderOpts);
const module = createCompiledModule(ast);
return new Instance(module, importObject);
} else {
throw new Error("unsupported module type: " + type);
}
}
function createModuleInstanceFromAst(moduleNode) {
const internalInstanceOptions = {
checkForI64InSignature: false
};
const importObject = {
_internalInstanceOptions: internalInstanceOptions
};
const module = createCompiledModule(moduleNode);
return new Instance(module, importObject);
}
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);
return new Instance(compiledModule, importObject);
}