View Source edb_expr (edb_core v0.5.0)

Support for creating dynamic Erlang expressions that can be executed on the context of a process stack-frame.

Summary

Functions

Takes an Erlang expression Expr, that can refer to any free-variable referred to in the free_vars field of Opts, and compiles.

Returns the function to call in order to evaluate a compiled expression.

Types

compile_error()

-type compile_error() :: erl_scan:error_info() | erl_parse:error_info() | erl_lint:error_info().

compile_opts()

-type compile_opts() ::
          #{free_vars := [binary()], start_line => pos_integer(), start_col => pos_integer()}.

compiled_expr()

-type compiled_expr() :: #{module := module(), entrypoint := atom(), code := binary()}.

source_code()

-type source_code() :: binary().

Functions

compile_expr(Expr, Opts)

-spec compile_expr(Expr, Opts) -> {ok, compiled_expr()} | {error, compile_error()}
                      when Expr :: source_code(), Opts :: compile_opts().

Takes an Erlang expression Expr, that can refer to any free-variable referred to in the free_vars field of Opts, and compiles.

Any error at compile or run-time, will refer to locations relative to start_line and start_col (both defaulting to 1 if missing).

compile_guard(GuardExpr, Opts)

-spec compile_guard(GuardExpr, Opts) -> {ok, compiled_expr()} | {error, compile_error()}
                       when GuardExpr :: source_code(), Opts :: compile_opts().

entrypoint(CompiledExpr)

-spec entrypoint(CompiledExpr) -> Entrypoint
                    when
                        CompiledExpr :: compiled_expr(),
                        Entrypoint :: fun((Vars :: edb:stack_frame_vars()) -> dynamic()).

Returns the function to call in order to evaluate a compiled expression.