Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Dart bindings via javascript transpilation/execution. #132

Open
modulovalue opened this issue Feb 7, 2023 · 0 comments
Open

Dart bindings via javascript transpilation/execution. #132

modulovalue opened this issue Feb 7, 2023 · 0 comments

Comments

@modulovalue
Copy link
Contributor

I think it is safe to assume that all languages that have javascript as a compilation target will eventually support targeting wasm as a compilation target as well.

As part of the compilation pipeline of languages that target wasm today, it seems to be common to also generate bindings written in javascript to the generated wasm code (e.g. see Rust).

It would be very hard to convince all the languages that target wasm to also write bindings for Dart. What if we take the javascript that those compilation pipelines produce, and extract the wasm bindings out of them, and generate Dart bindings ourselves?

The open question here is whether this approach would be feasible. I can see the following levels of difficulty:

  • AST-based: Is it possible to extract enough information about the wasm bindings from the raw AST of javascript-based bindings?
  • Resolved-AST-based: Is it possible to extract enough information about the wasm bindings from the CST that had some simple transformations (such as name resolution) applied to it?
  • Type-flow-based: Is it possible to extract enough information about the wasm bindings from some resolved AST that had some types inferred using more complicated type flow based approaches?
  • Runtime-mirroring: Is it possible to extract enough information about the wasm bindings by simply executing the javascript bindings and using the prototype based nature of javascript and/or some other methods that allow reflection to extract enough information to generate Dart bindings?

I don't have enough insight into javascript to evaluate the Runtime-mirroring approach yet, but that would probably be the simplest.

To investigate this approach we should probably first collect some autogenerated javascript bindings and see if there's a common pattern there that we can make use of.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant