2 Commits

Author SHA1 Message Date
Guy Bedford 9d0de858d4 Toolchain upgrade (#477) 2024-07-29 09:23:07 -07:00
Ivan Enderlin fa0832ed76 feat: Allow --instantiation to generate non-async code (#254)
* feat: Allow `--instantiation` to generate non-async code.

The goal of this patch is to allow `--instantiation` to generate non-
async code as discussed in
https://github.com/bytecodealliance/jco/issues/245.

First off, this patch updates the `--instantiation` option to receive
a string value instead of a being a switch. The possible values are
`async` (the default) or `sync`. The fact that `async` is the default
value ensures the backward compatibility.

Next, this patch updates the `TranspileOpts::instantiation` field to be
`Option<InstantiationMode>` instead of `bool`. `InstantiationMode` is a
enum with 2 variants: `Async` and `Sync`. The code is updated
accordingly.

Finally, the same patch adds non-async code during the bindgen pass.

Everything is done in one patch in order to be atomic.

Note: `function_bindgen.rs` is updated to improve an error message. It's
helpful when one needs to debug its code.

* test: Allow multiple test files per fixture.

This patch allows one fixture to be tested by multiple test files.

* test: Add the `strings.sync.ts` test.

* chore: Rename and simplify the `instantiate` signature.

`compileCore` becomes `getCoreModule`, and its function type
definition is now `(path: string)` instead of `(path: string, imports:
Record<string, any>)`.
2023-11-14 11:32:00 -08:00