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 and use a new compilation API #362

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

krtab
Copy link
Collaborator

@krtab krtab commented Jul 10, 2024

No description provided.

@zapashcanon
Copy link
Member

zapashcanon commented Jul 10, 2024

I would like to avoid having two different APIs but I like the direction this is going.

I think this is quite easily doable by making a few changes.

Adding a module Any (feel free to find a better name) to compile.mli which would have the following signature:

module Any : sig
  val until_typecheck : unsafe:bool -> (Text.modul, Binary.modul) Either.t -> (Text.modul, Binary.modul) Either.t Result.t

  val until_optimize : unsafe:bool -> optimize:bool -> (Text.modul, Binary.modul) Either.t ->

  ...


+end

Then, change the signature of Parse.guess_from_file from ((Text.modul, Text.script) Either.t, Binary.modul) Either.t Result.t to ((Text.modul, Binary.modul) Either.t, Text.script) Either.t Result.t (permutting Binary.modul and Text.script in order to be able to easily pipe the result of this function to the one defined before.

Add add_main_as_start everywhere it is needed (in Compile.{Text,Binary,Any}.*).

Then if you want to avoid piping the output of Parse.guess_from_file to Compile.Any.* many time, we could define:

Compile.File and Compile.Files with the same interface as Any but taking Fpath.t and Fpath.t list as input respectively instead of an (Text.modul, Binary.modul) Either.t.

Finally, we could also have a Compile.Extern_module module.

Edit: instead of using Either.t it may also be the time to start thinking about having a type like:

type module_kind =
  | Wat of Text.modul
  | Wast of Text.script
  | Wasm of Binary.modul
  | Ml of Extern_module (* I don't remember the name for this one *)

@zapashcanon
Copy link
Member

Also this is actually fixing #249

@zapashcanon zapashcanon mentioned this pull request Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants