[erlang-questions] how: Getting -export_type information at run time?

Vlad Dumitrescu vladdu55@REDACTED
Fri Apr 10 11:36:40 CEST 2015


On Fri, Apr 10, 2015 at 10:25 AM, Bengt Kleberg <bengt.kleberg@REDACTED>
wrote:

>  When I use beam_lib:chunks/2 I get tuples that are easy to identity as
> type information(*).
> When I turn the chunks into an abstract tree I do not understand how to
> find the type info any more. How should a fun for erl_syntax_lib:fold/3
> look, to identify the type information nodes?
>
>
I haven't used that myself, so I don't really know, but if you get tuples
that you can use directly, maybe you don't need to call fold.

/Vlad



>
> bengt
> (*)
>        [{attribute,64,type,
>         {option_name,
>          {type,64,union,
>           [{atom,64,use_stdio},
>            {atom,65,cd},
>            {atom,66,compressed},
>            {atom,67,packet},
>            {atom,68,env},
>            {atom,69,start_timeout},
>            {atom,70,call_timeout},
>            {atom,71,buffer_size}]},
>          []}},
> ...]
>
>
>
> On 04/10/2015 08:41 AM, Vlad Dumitrescu wrote:
>
> Hi Bengt,
>
>  You have to extract this information from beam_lib:chunks(BEAM,
> [abstract_code]) by means of erl_syntax_lib:fold/3 to keep only the
> typespecs. It would be nice to have a higher-level library that gives
> access to these internals.
>
>  regards,
> Vlad
>
>
> On Fri, Apr 10, 2015 at 8:23 AM, Bengt Kleberg <bengt.kleberg@REDACTED
> > wrote:
>
>> Greetings,
>>
>> How do I find type information at run time?
>>
>> A very nice Erlang module takes an options list. The options are -type
>> defined and -export_type'ed.
>> How do another module get that information during run time?
>>
>> I thought that it might be in very_nice:module_info(attributes), but no
>> luck.
>>
>>
>> bengt
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150410/f7ffddd9/attachment.htm>


More information about the erlang-questions mailing list