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 get_module_ast(path) method to the Library trait #1123

Merged
merged 2 commits into from
Oct 27, 2023

Conversation

Fumuran
Copy link
Contributor

@Fumuran Fumuran commented Oct 25, 2023

This PR adds a get_module_ast(path: LibraryPath) method to the Library trait.
This method returns an instance of ModuleAst stored in the Library at the provided LibraryPath.

@Fumuran Fumuran linked an issue Oct 25, 2023 that may be closed by this pull request
Comment on lines 45 to 46
/// Returns the AST of the module stored at the provided path.
fn get_module_ast(&self, path: &LibraryPath) -> Option<ModuleAst>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we return Option<&ModuleAst> from here? This way, we can avoid cloning modules (which may be a bit expensive).

Also, should we provide a default implementation of this method - i.e., something like:

self.modules()
    .iter()
    .find(|&module| module.path == *path)
    .map(|module| module.ast)

Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you! Before merging this PR could you check if this will break anything in Miden base? (I think it might as we have another library defined there). If so, then let's create a PR there with the fix and then we'll merge both one right after another.

@bobbinth bobbinth merged commit 702fdf0 into next Oct 27, 2023
15 checks passed
@bobbinth bobbinth deleted the andrew-add-get-module-to-library branch October 27, 2023 00:53
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

Successfully merging this pull request may close these issues.

Add get_module(path) method to the Library trait.
2 participants