View Source ktn_code (katana_code v2.0.1)

Link to this section Summary

Functions

If the beam was not compiled with debug_info the code generated by this function will look really ugly
If the beam was not compiled with debug_info the code generated by this function will look really ugly
Like file:consult/1 but for strings and binaries.
Evaluates the erlang expression in the string provided.
Parses code in a string or binary format and returns the parse tree.

Link to this section Types

-type tree_node() ::
    #{type => tree_node_type(), attrs => map(), node_attrs => map(), content => [tree_node()]}.
-type tree_node_type() ::
    root | function | clause | match | tuple | atom | integer | float | string | char | binary |
    binary_element | var | call | remote | 'case' | case_expr | case_clauses | 'fun' | named_fun |
    query | 'try' | try_catch | try_case | try_after | 'if' | 'catch' | 'receive' |
    receive_after | receive_case | nil | cons | map | map_field_assoc | map_field_exact | lc |
    lc_expr | generate | bc | bc_expr | b_generate | op | record_field | record_index | block |
    module | export | import | compile | vsn | on_load | behaviour | behavior | callback |
    record | include | include_lib | define | undef | ifdef | ifndef | 'else' | endif | elif |
    error | warning | file | line | type | opaque | export_type | remote_type | ann_type |
    paren_type | any.

Link to this section Functions

-spec attr(term(), tree_node()) -> term() | undefined.
Link to this function

beam_to_erl(BeamPath, ErlPath)

View Source
-spec beam_to_erl(beam_lib:beam(), string()) -> ok.
If the beam was not compiled with debug_info the code generated by this function will look really ugly
Link to this function

beam_to_string(BeamPath)

View Source
-spec beam_to_string(beam_lib:beam()) -> {ok, string()} | {error, beam_lib, term()}.
If the beam was not compiled with debug_info the code generated by this function will look really ugly
-spec consult(string() | binary()) -> [term()].
Like file:consult/1 but for strings and binaries.
-spec content(tree_node()) -> [tree_node()].
-spec eval(string() | binary()) -> term().
Evaluates the erlang expression in the string provided.
-spec node_attr(term(), tree_node()) -> term() | undefined.
-spec parse_tree(string() | binary()) -> tree_node().
Parses code in a string or binary format and returns the parse tree.
-spec to_str(binary() | list() | atom() | integer()) -> string().
-spec type(tree_node()) -> atom().