On 17/01/2008, <b class="gmail_sendername">Richard Carlsson</b> <<a href="mailto:firstname.lastname@example.org">email@example.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
This page has the most up-to-date Core Erlang specification,<br>and some info on how to compile to/from Core source code:<br><br> <a href="http://www.it.uu.se/research/group/hipe/cerl/">http://www.it.uu.se/research/group/hipe/cerl/
</a><br><br>The Core Erlang representation is an important intermediate<br>step for the BEAM compiler, and the HiPE compiler can generate<br>native code directly from Core Erlang as well as from BEAM.</blockquote><div><br>
Have missed those papers, they're quite readable. The only bit which is missing is a description of the binary/bitstring parts.<br><br>If you are going to compile to Core then you need the following files as help:<br>
<br><erlang>/lib/compiler-?.?/src/<br> core_parse.hrl<br> core_lint.erl<br> core_pp.erl<br><br>Core_parse.hrl contains the record definitions of the AST of Core and together with appendix C "Syntax tree representation" (in the 1-0-3 paper) give a description of how to build Core code in abstract form. Then it's just core_lint it to be sure and run it in to the back-end of the compiler to generate module. Works really well.
<br><br>The list of annotations are just annotations but some have special meaning, especially a first anno in the list of an integer which is taken to be the line number and used in core_lint error messages.<br></div><br>
</div>The best way to truly understand how it all fits together is to generate core code "c(foo,[report,to_core])" and stare at it a bit. Most becomes clear then.<br><br>Guards can be a little tricky.<br><br>One major benefit of compiling to core, apart from it being a nice little language, is that you get some significant optimisations done for you in the back-end. A major one is the pattern-matching compiler which works on core code. This is a Big Win and while not really hairy code can be tricky to get right.