Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env:abort function stub for wasm's import in template for asinit script #670

Merged
merged 1 commit into from Jun 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions bin/asinit
Expand Up @@ -26,7 +26,6 @@ const rl = require("readline").createInterface({

const projectDir = path.resolve(process.argv[2]);
const compilerDir = path.join(__dirname, "..");
const compilerVersion = require(path.join(compilerDir, "package.json")).version;
const assemblyDir = path.join(projectDir, "assembly");
const tsconfigFile = path.join(assemblyDir, "tsconfig.json");
const tsconfigBase = path.relative(assemblyDir, path.join(compilerDir, "std", "assembly.json"));
Expand Down Expand Up @@ -245,7 +244,13 @@ function ensureIndexJs() {
fs.writeFileSync(indexFile, [
"const fs = require(\"fs\");",
"const compiled = new WebAssembly.Module(fs.readFileSync(__dirname + \"/build/optimized.wasm\"));",
"const imports = {};",
"const imports = {",
" env: {",
" abort(_msg, _file, line, column) {",
" console.error(\"abort called at index.ts:\" + line + \":\" + column);",
" }",
" }",
"};",
"Object.defineProperty(module, \"exports\", {",
" get: () => new WebAssembly.Instance(compiled, imports).exports",
"});",
Expand Down