This repository has been archived by the owner on Jul 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the linker backend actually produce the specified output shape.
In addition to emitting the `.wasm` and `.wat` files in the output directory, we now also emit emit the internal `__loader.js` file, and the public module specified by the `ModuleSet`, such as `main.js`. We embed the content of the loader as a constant string in the backend, so that it works both on the JVM and on JS. Eventually, we will probably generate it more dynamically from `backend.javascript.Trees` anyway, so this not really a big deal. This change requires to adapt the loading mechanism to force URL resolution against the base directory of the `loader.js` file, rather than the working directly. We do this thanks to `import.meta.url`, which is also available in browsers. As is, this change destroys the semantics of top-level exported `var`s. Mutations performed after the module initializers have completed will not be reflected in the exports of `main.js`. We will need to revisit this later on, with a technique similar to the one used by the JS backend. With these changes, our linker backend actually abides by the specification of a `LinkerBackend`, which means we will be able to directly use it from sbt.
- Loading branch information
Showing
6 changed files
with
76 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import { load } from "./loader.mjs"; | ||
import { test, field } from "./target/sample/main.mjs"; | ||
|
||
const moduleExports = await load("./target/sample/main.wasm"); | ||
console.log(moduleExports.field); | ||
const o = moduleExports.test(7); | ||
console.log(field); | ||
const o = test(7); | ||
console.log(o); | ||
console.log(moduleExports.field); | ||
console.log(field); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters