Created
June 3, 2013 23:26
-
-
Save sile/5702343 to your computer and use it in GitHub Desktop.
beamからのソースコードを取得する方法のメモ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% http://erlang.org/pipermail/erlang-questions/2006-January/018812.html | |
-module(abst_to_src). | |
-export([transform/2]). | |
transform(BeamFName, ErlFName) -> | |
case beam_lib:chunks(BeamFName, [abstract_code]) of | |
{ok, {_, [{abstract_code, {raw_abstract_v1,Forms}}]}} -> | |
Src = | |
erl_prettypr:format(erl_syntax:form_list(tl(Forms))), | |
{ok, Fd} = file:open(ErlFName, [write]), | |
io:fwrite(Fd, "~s~n", [Src]), | |
file:close(Fd); | |
Error -> | |
Error | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment