rvirding
How to get chunks generated by the Elixir compiler?
I need to be able to get the Erlang AST which the Elixir compiler generates. So my question is:
Is it possible to get the Elixir compiler to generate the abstract_code chunk? I see that it generates the debug_info chunk which does contain the abstract code but that is not in a form directly usable by other tools, like those in the :beam_lib module. Or maybe there is an Elixir tool which can do this for me?
Most Liked
josevalim
:beam_lib.chunk(mod, [:abstract_code]) will give you the Erlang version, even for Elixir, as there is a public contract those chunks are expected to fulfill: otp/lib/stdlib/src/beam_lib.erl at 3257c5c5850299669026b72f71e2b1eae74f1a50 · erlang/otp · GitHub
rvirding
Well, I have worked out how to get the chunks. Now I just need to work out how to get the generated Erlang code out from the :debug_info chunk. It seems like the function which does it, well maybe does it, is :elixir_erl which isn’t documented using docs.
rvirding
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex










