Ive lost/deleted/whatever the .erl files for my project, can I somehow recreate it from the .beam files?
If the code was compiled with the debug_info flag, then the .beam file contains a ‘partially compiled’ representation of the source—basically the parse tree. Here is a simple module: -module(hw). -export([go/0]). go() when true -> “this is my function”. and the corresponding abstract code: 3> {ok, {hw, [{abstract_code, Abs}]}} = beam_lib:chunks(“hw.beam”, [abstract_code]), Abs. {raw_abstract_v1,[{attribute,1,file,{“./hw.erl”,1}}, {attribute,1,module,hw}, {attribute,2,export,[{go,0}]}, {function,4, go, 0, [{clause,4, [], [], [{string,5,”this is my function”}]}]}, {eof,6}]} Writing a decompiler which can turn the above example back to source is a fifteen minute job. Writing a decompiler which handles more complex Erlang code is more time consuming, but not much harder. The syntax_tools package from the jungerl can be used to do most of the hard work. If the abstract code is not present in the beam file, the problem gets much harder. It is possible to study the remaining information and