ktn_code (katana_code v2.5.0)

View Source

Summary

Types

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

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

beam_lib_beam/0

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

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

tree_node/0

-type tree_node() ::
          #{type => tree_node_type(), attrs => map(), node_attrs => map(), content => [tree_node()]}.

tree_node_type/0

-type tree_node_type() :: atom().

Functions

attr(Key, Node)

-spec attr(term(), tree_node()) -> term() | undefined.

beam_to_erl(BeamPath, ErlPath)

-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

beam_to_string(BeamPath)

-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

consult(Source)

-spec consult(string() | binary()) -> [term()].

Like file:consult/1 but for strings and binaries.

content(Node)

-spec content(tree_node()) -> [tree_node()].

eval(Source)

-spec eval(string() | binary()) -> term().

Evaluates the Erlang expression in the string provided.

node_attr(Key, Node)

-spec node_attr(term(), tree_node()) -> term() | undefined.

parse_tree(Source)

-spec parse_tree(string() | binary()) -> tree_node().

Parses code in a string or binary format and returns the parse tree.

to_str(Arg)

-spec to_str(binary() | list() | atom() | integer()) -> string().

type(_)

-spec type(tree_node()) -> undefined | tree_node_type().