[erlang-questions] Abstract code in .beam files

José Valim <>
Mon Sep 21 14:46:21 CEST 2015


Robert, the .beam file is made of a bunch of chunks. The abstract code is
stored in a chunk named "Abst", where it is versioned and
term_to_binary'ed. Literally:

    erlang:term_to_binary({raw_abstract_v1, AST})

You can't/shouldn't store the core format here but you can create as many
chunks as you want in the BEAM file. We actually do this in Elixir to store
the documentation. At EUC, I talked to Björn Gustavsson about officially
supporting a core chunk. Here is what we agreed on to the best of my memory:

1. We will have a new chunk named "Core" (they are all four letters)

2. The core AST will be versioned as well (raw_core_v1) and
term_to_binary'ed, like this: erlang:term_to_binary({raw_core_v1, CoreAST})

I also talked to Kostis so dialyzer starts reading the core information
from it too.  Let me know if you go ahead with this so we can sync before I
eventually send a PR to OTP and dialyzer.




*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

On Mon, Sep 21, 2015 at 2:14 PM, Robert Virding <> wrote:

> When you compile a file with debug_info then the Erlang AST of the file is
> included in the .beam file. Does anyone know if the actual structure which
> is put in the file is checked for format? Can I put anything in there, for
> example the core code?
>
> Robert
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150921/769f92de/attachment.html>


More information about the erlang-questions mailing list