View Source ktn_code (katana_code v2.2.0)

Summary

Types

Should eventually become beam_lib:beam(), once that's exposed (https://github.com/erlang/otp/pull/7534)

Should eventually become erl_syntax:annotation_or_location(), once that's exposed (https://github.com/erlang/otp/pull/7535)

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.

Types

-type beam_lib_beam() :: file:filename() | binary().

Should eventually become beam_lib:beam(), once that's exposed (https://github.com/erlang/otp/pull/7534)

-type erl_parse_foo() ::
          {attribute,
           Pos :: erl_syntax_annotation_or_location(),
           Name :: erl_syntax:syntaxTree(),
           Args :: none | [erl_syntax:syntaxTree()]} |
          {macro,
           Pos :: erl_syntax_annotation_or_location(),
           Name :: erl_syntax:syntaxTree(),
           Args :: none | [erl_syntax:syntaxTree()]} |
          {atom, [{node, Node :: erl_syntax:syntaxTree()}], non_reversible_form}.
Link to this type

erl_syntax_annotation_or_location/0

View Source
-type erl_syntax_annotation_or_location() :: erl_anno:anno() | erl_anno:location().

Should eventually become erl_syntax:annotation_or_location(), once that's exposed (https://github.com/erlang/otp/pull/7535)

-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.

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().