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

Instance: add exports() helpers for all exportable members #601

Open
evacchi opened this issue Oct 24, 2024 · 0 comments
Open

Instance: add exports() helpers for all exportable members #601

evacchi opened this issue Oct 24, 2024 · 0 comments
Assignees

Comments

@evacchi
Copy link
Collaborator

evacchi commented Oct 24, 2024

Currently Instance only exposes export("name") for function. We should also export tables, globals, memory

Instead of polluting the class namespace with multiple exportGlobal, exportTable, etc. we propose to instead have an .exports() with multiple members, e.g. exports().function("name") etc.

This way we could also have exports().functionType("name") etc. since accessing each exported member type is also a real chore.

The strategy could be to have an inner non-static class as a member to Instance; non-static so that it can easily access the Instance members without having to pass them to its constructor; e.g.

class Instance {

    SomeField f;

   public class Exports() {
        Function function(String name) {
             // `f` is accessible here
        }
   }

}

We might keep Instance#export("name") available both for compatibility and because getting an exported function is a frequent operation.

@evacchi evacchi self-assigned this Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant