| | |
| | | const enabledTypes = new WeakMap(); |
| | | |
| | | /** |
| | | * Returns the set of wasm loading backends that have already been enabled for |
| | | * the compiler. |
| | | * @param {Compiler} compiler compiler instance |
| | | * @returns {WasmLoadingTypes} enabled types |
| | | */ |
| | | const getEnabledTypes = (compiler) => { |
| | | let set = enabledTypes.get(compiler); |
| | | if (set === undefined) { |
| | | /** @type {WasmLoadingTypes} */ |
| | | set = new Set(); |
| | | enabledTypes.set(compiler, set); |
| | | } |
| | | return set; |
| | | }; |
| | | |
| | | /** |
| | | * Validates and enables named wasm loading backends by applying the plugin |
| | | * implementations that provide their runtime support. |
| | | */ |
| | | class EnableWasmLoadingPlugin { |
| | | /** |
| | | * Stores the wasm loading backend name that should be enabled for the |
| | | * compiler. |
| | | * @param {WasmLoadingType} type library type that should be available |
| | | */ |
| | | constructor(type) { |
| | | /** @type {WasmLoadingType} */ |
| | | this.type = type; |
| | | } |
| | | |
| | | /** |
| | | * Marks a custom or built-in wasm loading type as enabled for the compiler |
| | | * without applying additional built-in behavior. |
| | | * @param {Compiler} compiler the compiler instance |
| | | * @param {WasmLoadingType} type type of library |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Verifies that a wasm loading type has been enabled before code generation |
| | | * attempts to use it. |
| | | * @param {Compiler} compiler the compiler instance |
| | | * @param {WasmLoadingType} type type of library |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Apply the plugin |
| | | * Enables the requested wasm loading backend once and applies the |
| | | * environment-specific plugins that provide its parser, generator, and |
| | | * runtime support. |
| | | * @param {Compiler} compiler the compiler instance |
| | | * @returns {void} |
| | | */ |