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

Use post-lowering code? #76

Open
timholy opened this issue Jul 10, 2024 · 4 comments
Open

Use post-lowering code? #76

timholy opened this issue Jul 10, 2024 · 4 comments

Comments

@timholy
Copy link

timholy commented Jul 10, 2024

If ExplicitImports were to iterate over all the names in the package, and then for every item that is a method, ask for Base.uncompressed_ast, then you could tally all the GlobalRefs that appear in the lowered code. This would presumably make your scope resolution fully accurate.

JuliaInterpreter does lots of shenanigans with lowered code, including replacing all GlobalRefs with the actual object (to save the cost of scope-resolution at runtime). So its code might be a good reference if you need pointers.

@timholy
Copy link
Author

timholy commented Jul 11, 2024

Learning materials:

More specific code examples:

@ericphanson
Copy link
Owner

Thanks Tim, this is really helpful! I will give it a try.

@ericphanson
Copy link
Owner

Is there a way to get lowered top-level code in a module? I'm having trouble finding a way to do that, which would be nice since then we might be able to drop parsing altogether. (Though already using lowered code for methods would be a win).

@timholy
Copy link
Author

timholy commented Jul 11, 2024

You mean stuff that runs at module-definition time but doesn't result in a method signature? Great question, and AFAIK the answer is no. For that you do have to parse 😢.

You could probably call Meta.lower on it, though, if you want to use Julia's scoping to resolve the references.

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

2 participants