在看了霸爷的
erlang的abstract code之后,自己动手实验了一下,效果如下:
[liufan@liufan abstract_code]$ erl -s hello -s erlang halt
Erlang R16B01 (erts-5.10.2) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
"hello world"
[liufan@liufan abstract_code]$ cat hello.erl
-module(hello).
-export([start/0]).
start() ->
io:format("~p~n", ["hello world"]).
[liufan@liufan abstract_code]$ erlc +debug_info hello.erl
[liufan@liufan abstract_code]$ erl
Erlang R16B01 (erts-5.10.2) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V5.10.2 (abort with ^G)
1> rp(beam_lib:chunks(hello, [abstract_code])).
{ok,{hello,
[{abstract_code,
{raw_abstract_v1,
[{attribute,1,file,{"hello.erl",1}},
{attribute,1,module,hello},
{attribute,3,export,[{start,0}]},
{function,5,start,0,
[{clause,5,[],[],
[{call,6,
{remote,6,{atom,6,io},{atom,6,format}},
[{string,6,"~p~n"},
{cons,6,
{string,6,"hello world"},
{nil,6}}]}]}]},
{eof,7}]}}]}}
ok
2>